M3G内坐标系作用范围的混淆

M3G坐标系的混淆
mesh.translate(0.0f, 0.0f, 5.0f);
transform.postTranslate(0.0f, 0.0f, 5.0f);
mesh.setTransform(transform)
有什么区别?
答案:第一个是以mesh的父坐标系为基准,沿着父坐标系的Z轴平移
而第二个是以物体局部坐标系的Z轴移动,如果这个局部的Z轴经过了旋转,那就会沿着新的局部Z轴进行平移。
 
附M3G其它一些translate和rotate的规则说明:
---------------------------------------------------------------------------------------
Transformable:
postRotate(float angle, float ax, float ay, float az)
translate(float tx, float ty, float tz)
 
Transform:
postRotate(float angle, float ax, float ay, float az)
postTranslate(float tx, float ty, float tz)
 
mesh.postRotate(3.0f, 1.0f, 0.0f, 0.0f);
When rotation is made directly on the transformable object the rotation will be made around the origo of the local co-ordinate system(局部坐标系的原点).
 
transform.postRotate(3.0f, 1.0f, 0.0f, 0.0f);
mesh.setTransform(transform);

When the rotation is made using the transform class the object will rotate around its center(物体中心:取决于建模是规定的中心点,不一定是局部坐标系的原点).
 
mesh.translate(0.0f, 0.0f, 5.0f);
When the object is moved using methods in the transformable class the object is moved in the co-ordinate system of the parent node(父节点坐标系).
 
transform.postTranslate(0.0f, 0.0f, 5.0f);
mesh.setTransform(transform)

When the object is moved using the transform class the object is moved in the local co-ordinate system(局部坐标系).
----------------------------updated 2007-01-18--------------------------------
比如,我的
Camera cam;
Group camGroup;
在loadCamera时,
cam.translate(0.0f, 5.0f, 10.0f);
camGroup.addChild(cam);
world.addChild(camGroup);
那么在对相机进行旋转时,就需要操作camGroup,如果操作cam,则会导致translate的叠加效应
在平移时
如果camGroup.translate,则会导致camGroup在它父结点坐标系,也就是world的轴方向进行平移
如果要在相机局部坐标系下进行平移,则需要
cam.translate
 
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值