Quaternion rotation

A friend and I were messing around with jME and were rotating 2 cubes. We had different ideas on how we could do it, but got one way to work. The other didn’t and we aren’t sure why.

We have an array of the geometry we want to rotate. Below is a code snippet -

          Quaternion rotQuat = new Quaternion();
          Quaternion localQuat = null;
          float angle = 0;

          if (timer.getTimePerFrame() < 1) {
                angle = timer.getTimePerFrame() * 50;
               rotQuat.fromAngleAxis(angle*FastMath.DEG_TO_RAD, new Vector3f(1, 0, 0));

         for (int i = 0; i < spinList.size(); i++){

               TriMesh geom = (TriMesh)spinList.get(i);
               localQuat = geom.getLocalRotation();


Shouldn't this take the quat from the current object and add a small amount of rotation to it?

If we instead change 2 things: make the angle additive each time, ie angle += .... and then do a geom.setLocalRotation(rotQuat), it works. Of course, this means all the rotating objects are rotated at exactly the same angles, rather than whatever angles they started at.

Dr. A>

check out this thread: http://www.jmonkeyengine.com/jmeforum/viewtopic.php?t=1424

here is a snipped of a mouse drag method I wrote 5 minutes ago

Vector2f v=oldmousepos.subtract(mousepos);
Quaternion quat=chosen.getLocalRotation();
Quaternion q=new Quaternion();
q.fromAngles(new float[]{v.y,-v.x,0});

not very clean but I hope it helps