精通Micro3D v3基础技术[7]

[入库:2006年2月23日] [更新:2007年3月24日]

本文简介:

旋转3D模型与例3中的缩放模型是用的同样的技术。你创建一个AffineTrans对象来控制你的旋转数据,并把它的矩阵添加到模型的主AffineTrans里。

// Rotation value
public final static int SPIN_X_PLUS = 100; // Increase or decrease value of the rotation around X axis
public final static int SPIN_Y_PLUS = 100; // Increase or decrease value of the rotation around Y axis
private static int spinX = 0; // X axis rotation value
private static int spinY = 0; // Y axis rotation value

...
kc = getGameAction(kc);
switch (kc) {
case Canvas.UP: // roll up
  setSpinX(-SPIN_X_PLUS);
  break;
 case Canvas.DOWN: // roll down
  setSpinX(SPIN_X_PLUS);
  break;
case Canvas.LEFT: // roll left
  setSpinY(-SPIN_Y_PLUS);
  break;
 case Canvas.RIGHT: // roll right
  setSpinY(SPIN_Y_PLUS);
  break;
 default:
  break;
}

...
AffineTrans rotTrans = new AffineTrans();
//X roll
rotTrans.setIdentity();
rotTrans.setRotationX(spinX);
affineTrans.mul(rotTrans);

//Y roll
rotTrans.setIdentity();
rotTrans setRotationY(spinY);
affineTrans.mul(rotTrans);

7 模型中的动画效果

本文关键:精通Micro3D v3基础技术
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top