# Scene graph rotation problems

This topic is 4824 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I have a simple scene graph in which I have nodes that correspond to lights, geometries, transformations, and sounds. When I have a geometry node and I add it as a child to a transformation node (which simply contains a matrix which I pass to glMultMatrixf) and then apply a rotation to the transformation node around some axis the goemetry rotates around the global axis when I want it to rotate locally . How would I go about modifying how I'm rotating so that I can rotate the abject around its current position? Here is a piece of the input code which does the translation and rotation for a transformation node.
	switch(key) {
case GLUT_KEY_LEFT:
playerTrans- >matRotate(playerTrans->transMatrix, 0.0, 0.1, 0.0);
rOarTrans- >matRotate(rOarTrans->transMatrix, 1.0, 0.0, 0.0);

break;

case GLUT_KEY_RIGHT:
playerTrans- >matRotate(playerTrans->transMatrix, 0.0, -0.1, 0.0);
lOarTrans- >matRotate(lOarTrans->transMatrix, 1.0, 0.0, 0.0);

break;

case GLUT_KEY_UP:
playerTrans- >Translate(playerTrans->transMatrix, 0.0, 0.0, incr+0.1);

break;

case GLUT_KEY_DOWN:

playerTrans- >Translate(playerTrans->transMatrix, 0.0, 0.0, incr-0.1);

break;

default: break;
}



##### Share on other sites
Jon,

Saw your rather old post with no replies and thought I would try to help in case you haven't fixed the problem yet. You need to have a distinct rotation matrix for each of the local objects to be transformed. Local object verts should be defined relative to the origin, and moved into world space after applying the rotation. Then, apply the global transformations to put objects into camera space.

##### Share on other sites
Your transform class can keep 3 different matrices: a translation matrix (T), a rotation matrix (R) and a scaling matrix (S). During the render phase, just multiply the matrices in order T*R*S, glMultMatrix on the result and you'll get the desired effect.

Tom

1. 1
2. 2
3. 3
Rutin
22
4. 4
frob
17
5. 5

• 33
• 13
• 12
• 10
• 12
• ### Forum Statistics

• Total Topics
632573
• Total Posts
3007144

×