Sphere rotation around y axis

Hi,



Can anybody indicate how to make a sphere to endlessly rotate around its y axis (probably using quartenions)? Assume that i have created a sphere  and attached it to my scene node. I have found a relative example in the tutorial section but it envolved rotating a lightsource around a sphere.



Thanx



L.

just multiply the rotation by another quaternion.



      rotQ = new Quaternion();
      rotQ.fromAngleAxis(0.01f, Vector3f.UNIT_Y);

   protected void simpleUpdate() {
      sphere.getLocalRotation().multLocal(rotQ);
   }



make sure to surf through the wiki, there are tons of invaluable informations who will get you started :)

Thanks for the reply.



I have searched in the wiki indeed and found some very usefull insight about rotations. However, i have the following question: When rotating an object using the method indicated in the previous reply, we simply rotate the spatial around its origin (0,0,0). What if i want to rotate the shape around some axis in respect to its centre?



In my example, i have created a planet (shpere) and applied the earth's texture on it. However, the earth's poles appear incorrectly aligned (noth pole appears in the face of the spatial). So, in order to display it correctly, i guess that i have to rotate the object around its x axis by 90 degrees, in respect to its centre (so the north pole appears on the north). Then i can apply the rotation around its y axis on every update in order to make the planet rotate around its axis.



Please, correct me if i got something wrong here.



Regards



L.

you could do the following:

  • create the sphere and apply the texture to it
  • rotate the sphere 90 degree so that i its correctly set up.
  • create a new node and attach the sphere to the node, attach the new node to the rootNode
  • now rotate the node instead of the sphere in the update method

I've managed to do that and works ok. The only problem now is when i translate the planet in order to push back a bit (0, 0, -40). There, i have problems since the planet seems to be revolving not around it's own axis, rather than the original centre. If i don't translate the spatial then averything work as expected.

if you translate the sphere, and rotate the node, the sphere will orbit around the nodes center like a moon.

if you translate the node, and rotate the node, the node will rotate around its own axis.