I have two models, each stored in a separate VBO. What I want do is to link them so that rotating one rotates the other, while still leaving the other connected to the first model. What I do now is have three model matrices: one main one for the entire object, and one for each of the models so that they can be translated in relation to the main matrix. When I do this however, the two models disconnect if I rotate them. How would I link the two models so that they stay connected during rotation or translation?
Share
Usually you would do it like this:
Of course, if you change
firstModelMatrixorsecondModelMatrix, the two models might be rendered disconnected. But than, this is what you intent. If you want to stay them connected, only change themainMatrix.However, note that those matrix operations are deprecated. Nevertheless you should be able to get the trick from the code.
EDIT: Given that you have a head and a body. You want to rotate the head. Than its all about how your head-matrix is computed, it is particularly important in which order you apply the translation and rotation. I guess, right now you have something like this:
But what you need is this in order to keep the head on top of the body: