View Full Version : Getting back to previous coordinate for rotation

02-06-2005, 02:24 PM
Im very new to opengl so im very sorry if this question is to basic.

Say i have a crane which has to 4 joints in it.

(note pretend _____3____ is just above ___4____ in the above diagram, could get it located right)

Now i have joings 1, 2 and 3 working great. Staying within there ranges. Ive gltranslated to get ____4_____ to its correct alignment with 3. But the problem is joint 4 which controls ______4________ is now rotation about the end of _____3________ which is no good.

How can i get both joints 3 and 4 to rotate at the end of _________2_________? Ive got joint 3 for ________3________ perfect at the end of _________2_______.

Sorry if its unclear, i tried to make it as simple as possible

thanks for any help,

Basically looking on how to get the point of rotation moved back to the end of _________2_________(here).

thanks again

02-06-2005, 04:15 PM
I'm not sure I understood your description. Sections _3_ and _4_ are both attached to the same rigid endpoint but should be able to rotate independently, right?

I think you can solve your problem with glPushMatrix and glPopMatrix. PushMatrix duplicates your current transformation matrix, so that you can "undo" later changes with PopMatrix.

//do transforms for joint 1

//do transforms for joint 2

//remember the transformation matrix as it is now

//do transforms for joint 3

//restore the matrix to what it was at the time of PushMatrix

//do transforms for joint 4
As the names suggest, PushMatrix and PopMatrix are stack operations. The usual rules apply:
1)Know the maximum depth of your stack
2)Use Push and Pop only in matched pairs.

02-06-2005, 04:59 PM
Yeah thats exactly it,

So pop takes me back one step? So then all i would really need to do is pop twice.

Also would you mind if i pm'd you about a unrelated german DHL question? I see your from germany and i have a quick question. I dont speak german so im in kinda a pickle.

thanks again for your help,