I have a model loaded in OpenGL that I want to rotate about a specific point. Right now, when I rotate the model (a beam) about Y, it rotates about a point located at the center of the beam.
I really want it to rotate about a point at the end of the beam. AFAIK, I cannot use glTranslatef followed by glRotatef because the point of rotation must be fixed in space.
The only solution I can come up with so far is to add a point at the desired point of rotation, and then rotate the beam in the point’s coordinate system.
Is this the right idea? Any suggestions would be great.
I’m now realizing that it was a huge mistake to make assumptions and write code to implement the behavior I’m looking for, without fully understanding how OpenGL works.
I’m taking a step back and would just like to confirm that I am thinking about things correctly.
Basically, I have 3 links, a, b, and c. a and b are pinned, and b and c are pinned. If I rotate b, then c should follow, as in (2). If I then rotate a, then b and c should follow, as in (3). If I rotate c, then a and b should keep their current orientation, as in (3).
In general, it almost looks like the algorithm is – do whatever transformation the link’s parent did, followed by its own transformation.
(3) shows two ways of thinking side-by-side. The one on the left (with a faint X through it) is what I believe is incorrect thinking. The one on the right is correct.
(4) shows the transformations that I think should be applied to c to get the desired effect.
Can anyone please glance at the PDF and let me know if I’m on the right track? Thanks!
EDIT – Can anyone also add input about how pushing and popping the modelview matrix could affect things? I think than in my example, the same modelview matrix would be used
i just that a snap look of your pdf, one thing that you should remember, a is only depends on rotA, b depends on rotA and rotB, and c depends on rotA, rotB, and rotC.
in step(2) even though it’s only b that moving, you can’t only use rotB in your formula, but you have to include rotA as well.
Yeah, I spoke with my friend that knows OpenGL pretty well, and I think I now know how to approach the problem. I’m going to start rewriting the code today to deal with the linked models, and hopefully I’ll come up with something suitable. Thank you for your help!