物體移動和旋轉

mesh.postRotate 物體繞物體座標系統的原點旋轉

transform.postRotate
mesh.setTransform(transform); 物體繞自己的中心旋轉
Transform.postRotate(float angle, float ax, float ay, float az):按給定角度繞穿過(0, 0, 0)和(ax, ay, az)的軸旋轉對象。角度爲正值,則表示若您順着正旋轉軸方向觀察,對象是按順時針旋轉的。例如,postRotate(30, 1, 0, 0) 將繞 x 軸將對象旋轉 30 度。

 

mesh.translate 物體在世界座標系統中平移

transform.postTranslate
mesh.setTransform(transform);物體在它的父節點座標系中平移//Group group :group.add(mesh);group爲父節點;World:world:world.add(mesh);world爲父節點

Mshort points[] = {
            0,0,0, 1,0,0, 0,1,0, 1,1,0, 1,0,0, 0,0,0, 1,1,0, 0,1,0,
         };
            int[] indices = {0,1,2,3,4,5,6,7};//每一個正方形的每個面要顯示出來,那個面的兩個三角帶均必須面對camera逆時針旋轉

 

1.mesh.postTranslate(x,y,z) //相對於世界座標再平移(x,y,z),這次的(x,y,z)會疊加上一次mesh.postTranslate(x',y',z') 那麼mesh距離世界座標原點將會是(x+x', y+y', z+z');
2.transform.postTranslate (x,y,z)
mesh.setTransform(transform);//假如上一次是 transform.postTranslate (x',y',z')
1.transform相同
那麼這次的(x,y,z)會加上上一次的(x',y',z'),mesh會距離物體座標系原點(x+x',y+y',z+z')

2.transform不同
那麼這次的(x,y,z)不會加上上一次的(x',y',z'),mesh會距離物體座標系原點(x,y,z)

postRotate的疊加原理和上面差不多

 

 

發佈了20 篇原創文章 · 獲贊 2 · 訪問量 2萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章