M3G坐标系的混淆
mesh.translate(0.0f, 0.0f, 5.0f);
与
transform.postTranslate(0.0f, 0.0f, 5.0f);
mesh.setTransform(transform)
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)
- 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)
- 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(局部坐标系的原点).
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.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(父节点坐标系).
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(局部坐标系).
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