当前位置: 代码迷 >> J2ME >> 关于m3g得动画和一些坐标有关问题
  详细解决方案

关于m3g得动画和一些坐标有关问题

热度:9905   发布时间:2013-02-25 21:37:07.0
关于m3g得动画和一些坐标问题
1.我在程序里面调用m3g   的动画时world.animate(startTime)   ,
mesh.translate(),
mesh.setTranslation(),
这些都会失效,正确的说应该是移动以后又被拽回来,是不是动画里面包含了坐标的信息,所以每次都会被从新拉回阿,还是怎么了。我在用3DMAX里看到一些动画的关键点过滤器,里面可以过滤掉位置,但是导出以后好像还是不行~~
我本来想做一个一个人在走路的动画(原地的)然后通过mesh.translate()达到视觉上走路的效果,如果不行,不知道有没有别的什么方法可以实现?还是说我的方法是可行的,但是在哪里出了错误?

2.world里面都是3维的,如果我知道其中2点的位置,然后要去查询某个mesh的上下底面的坐标(也就是在mesh表面的第3点),不知道是否可以获得?   如何获得。
如果我要做一个人在不平坦的路面上走动,那么是不是还有别的方法可以检测出路面颠簸不平?

很诚心的求教,希望有人可以帮我~~

------解决方案--------------------------------------------------------
1,如果你的模型里面已经做好了两脚交替前进的动画,那就播放这个动画
关于动画播放,不可以只是一个简单的animate, 你需要控制动画播放的起始时间以及循环次数等等,这些是基础问题,查些资料应该可以解决
2。
我现在用的欧拉角来存储每一个对象(比如一个group,里面可能有多个mesh,但旋转的话是统一旋转的)的旋转,所以得到角度很容易~~
mesh.getOrientation(angleAxis) 可以得到四元数形式表示的旋转信息
getOrientation 得到的数据的意义
http://blog.csdn.net/xueyong1203/archive/2007/01/05/1474454.aspx

获得mesh的顶点,可以
void transformPoints(Transform t, VertexBuffer vb, float[] out)
{
// Make a copy of the given Transform so that we can restore
// its original contents at the end.

Transform tmp = new Transform(t);

// Retrieve the vertex coordinate array and its associated
// scale and bias. In real applications, the float array
// and the temporary Transform object should both be class
// variables to avoid garbage collection.

float[] scaleBias = new float[4];
VertexArray points = vb.getPositions(scaleBias);

// Note the order of constructing the transformation matrix.
// The coordinates must be scaled first, then biased:
// v ' = T S v

t.postTranslate(scaleBias[1], scaleBias[2], scaleBias[3]);
t.postScale(scaleBias[0], scaleBias[0], scaleBias[0]);
t.transform(points, out, true);

// Restore the original Transform.

t.set(tmp);
}

  相关解决方案