> if i had several primitives and i clicked one of them, the rotation point shouldl be from the centre point of that
> primitive and all the other primitives move in relation to this.
ok lets see, if i understand correctly:
Object A -> trans 1, 0, 0
Object B -> trans 0, 1, 0
now you click Object A and it is rotated around its local center.
what should Object B do now? the same rotation around Object A's center or the same rotation around its own center?
the latter one is:
// render object A
glPushMatrix();
glTranslatef( 1.0, 0.0, 0.0 );
// apply the rotation from mouse-movement, rotate around Object A's center
glRotatef( .. here comes the rotation from the mouse-movement
.. render Object A ..
glPopMatrix();
// render object B
glPushMatrix();
glTranslatef( 0.0, 1.0, 0.0 );
// apply the rotation from mouse-movement
glRotatef( .. here comes the SAME rotation from the mouse-movement
.. render Object B ..
glPopMatrix();
just make sure, you apply the same rotation (from mouse-movement) after each object's translation-call ..
ike
Main Topics
Browse All Topics





by: ikeworkPosted on 2007-09-27 at 13:03:47ID: 19974327
hi vishalchavda,
you have to apply the transformations in the opposite order:
// first translate it
glTranslatef( 1.0, 0.0, 0.0 );
// now rotate it, it rotates around its local-center
glRotatef( 30.0, 0.0, 1.0, 0.0 );
// render your object ...
hope it helps,
ike