Getting back to previous coordinate for rotation

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

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.

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,