View Full Version : Moving a Model

04-03-2012, 09:21 PM
Hello, I'm brand new to OpenGL and I'm having trouble moving a model inside a scene.

void timerFunc(int value)
glutTimerFunc(300, timerFunc, ++value);

//translateMatrix is a math function that takes in the matrix plus x, y, and z coordinates
translateMatrixBy(myModel->modelMatrix, 5.0f, 0.0f, 0.0f);

//this is just some text to verify that this section is running
char notify[] = {'1','2','3'};



The timer function is getting called. I'm guessing that re-rendering the model isn't what I need to be doing, or that changing the model matrix doesn't actually re-call the shader in the rendering process... or that I'm just completely confused. Any assistance would be hugely appreciated.

04-04-2012, 03:52 AM
Every time you render 'MyModel' you are supposed to draw it at some world space location. I assume you have the 'MyModel->ModelMatrix' for that purpose. Therefore every frame, the model will be drawn at the correct location.
So, all that has to happen in the timer is a change to the MyModel->ModelMatrix - i.e. alter the translation part of the matrix (the last column) to the new X,Y,Z world space coordinates. No drawing is required.