创建3d效果非常简单,如果你有正确的工具,创建复杂的3d动画效果并不困难。在这个例子中,骰子和动画是用3dmax来创建的。
为了取代计算一个mesh的运动,运动可以被预先创建并保存在mascot capsule v3的mtra文件里或jsr 184的m3g文件里。
在下面的例子中,创建了6个动画,每个动画都针对一个骰子面。

为确保每个抛出的骰子是不同的,z轴旋转是随机的
下面是动画的代码示例:
建立每个动作并存储帧的数量。
private final int []framelength = new int[] {80,65,70,80,55,75};
载入骰子模型。
dicefigure = new figure("/res/dice.mbac");
六个不同动画可以全被合并到一个文件而不必使用六个不同的动画文件
action[0] = new actiontable("/res/one.mtra");
action[1] = new actiontable("/res/two.mtra");
action[2] = new actiontable("/res/three.mtra");
action[3] = new actiontable("/res/four.mtra");
action[4] = new actiontable("/res/five.mtra");
action[5] = new actiontable("/res/six.mtra");
在游戏循环中要保持动画帧的不断更新。
if(diceoneframe < action[diceoneindex].getnumframes(0)){
diceoneframe += action[diceoneindex].getnumframes(0)/framelength[diceoneindex];
}
dicefigure.setposture(action[diceoneindex], 0, diceoneframe);
下载范例程序和源代码:
http://developer.sonyericsson.com/getdocument.do?docid=73634
原文地址:点击这里
闽公网安备 35060202000074号