newbie help with rotations
i was hoping someone could help me with the push and pop matrix functions. if i have 2 cubes and i want to rotate and move them differently do i have to use these functions?
hm.. you want 2 cubes to rotate in diferent directions?
about push/pop : those function store/load curent matrix to/from stack. I hope you know what stack is. Anyways, you store the postion, then do some translation/rotation/scaling/... and when calling pop you resotre matrix to the state it was before pushing it to stack...
ok.. so here is some code..
...
// cube 1
glPushMatrix(); // store matrix
glTranslate(...) // translate to postion of first cube
glRotate(angle1,..) // rotate first cube for angle1
DrawCube();
glPopMatrix() // load matrix stored with push
// cube 2
glPushMatrix(); // store matrix
glTranslate(...) // translate to postion of second cube
glRotate(angle2,..) // rotate second cube for angle2
DrawCube();
glPopMatrix() // load matrix stored with push
...
hope this helps...
There are more worlds than the one that you hold in your hand...
about push/pop : those function store/load curent matrix to/from stack. I hope you know what stack is. Anyways, you store the postion, then do some translation/rotation/scaling/... and when calling pop you resotre matrix to the state it was before pushing it to stack...
ok.. so here is some code..
...
// cube 1
glPushMatrix(); // store matrix
glTranslate(...) // translate to postion of first cube
glRotate(angle1,..) // rotate first cube for angle1
DrawCube();
glPopMatrix() // load matrix stored with push
// cube 2
glPushMatrix(); // store matrix
glTranslate(...) // translate to postion of second cube
glRotate(angle2,..) // rotate second cube for angle2
DrawCube();
glPopMatrix() // load matrix stored with push
...
hope this helps...
There are more worlds than the one that you hold in your hand...
You should never let your fears become the boundaries of your dreams.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement