Rotating object

I like to make a cube rotate around itself. I am sure I have seen this in one of the tests. Does anybody know which test does this?

tomcat

not sure I understand… how do you rotate around yourself? Do you mean 1 spinning cube? Or do you mean 2 cubes with one moving in orbit around the other?

I mean one spining cube (rotating around itself). I need a couple of movements one is rotation around itself, the other is moving up and down.

tomcat

Rotating is just adjusting the LocalRotation of the object over time. I.e. in the update phase of the app. There are plenty of examples of rotating boxes in the tests and demos. The color box test would probably be the easiest to look at (very little going on in that one).

thx, looked atthe example. it seems all I have to do is identify the axis of rotation and start rotating round it a few degrees (create a quarternion first) each frame. Is this right?

tomcat

you can’t. The pivot point is always the centre of that object (i.e a local translation of 0,0,0 on that object). Its because of the way the scenegraph works and the children/parent relationship causes this constraint.



I wanted this feature a long time ago, but what i wanted it for had always had a better solution to the problem than setting a pivot point.



DP

Thanks DarkProphet,



I did the scene rotation as follows:



My scene graph looks like:


            rootNode
                |
            pivotNode
                |
     +


+
+
     |          |         |
nodesNode  planesNode  axesNode



Then compute your virtual origin coordinates (point you want to rotate the scene around) and move all nodes under pivotNode in the opposite direction.
Finally, turn on rotation of pivotNode and you've got it!