Problem of rotating a 3ds model!

hi,everyone.



I want a 3ds model to rotate from Y axis. Firstly,I need to rotate the model 90 degrees from X axis to agree with the JME coordinate.



Node s = loadModel("jmetest/data/models/talennode.3DS");

Quaternion quad=new Quaternion();
quad.fromAngleAxis(FastMath.PI/2,new Vector3f(1,0,0));
s.setLocalRotation(quad);



then i make this model rotate from Y axis constantly.


protected void update(float interpolation)
{

Hi



Each time you call setLocalRotation, you are over writing the old rotation, not adding to it, so your original rotation only happened for 1 frame, then you changed it to the second one.



You either need to create a temprorary Matrix4f, load identity on it, then set(quaternion) on it, then get the local position of the object and multiply it by the temporary matrix, or, create a Node, attach your existing node to that, and attach the top node to your scene graph, do the first rotation on the top node, and the other rotations of the node you do now, that way both rotation will have an effect.



HTH



Endolf

you can also multiply the two Quaternions btw (no need to use a Matrix4f for it)

make sure you get the order right of course as it matters for quats

thanks. I mutiply the two Quaternions and it works well.



protected void update(float interpolation)
{
   
    if (interpolation < 1)
    {
          angle = angle + (interpolation * 1);
          if (angle > 360)
          {
   angle = 0;
          }
    }
    Quaternion quad=new Quaternion();
    quad.fromAngleAxis(FastMath.PI/2,new Vector3f(1,0,0));
      
    rotQuat.fromAngleAxis(angle, new Vector3f(0, 1, 0));
      
    rotQuat.multLocal(quad);      
   
    s.setLocalRotation(rotQuat);
}