I'm wondering what the best way is to store the positions of objects in a 3D scene. In my case, the scenes are actually levels of a game.
Each Scene has:
- It's own projection matrix.
- A list of models to render
Each Model has:
- The vertex list
- A GLSL program to render itself
- A texture
- A "model" matrix
I'm using GLES 2. So there is no glPushMatrix, glPopMatrix, glTranslate, etc. They aren't available. Instead, I have my own functions which operate on my own Matrix objects.
1) Setup the projection matrix (using an orthographic matrix)
_math_matrix_ortho(&this->ProjectionMatrix, 0.0, 1.0, 0.0, (float)height / (float)width, -1.0f, 1.0f);
2) Load each model
3) Scale each model to make them the right side in proportion to one another. The scaling function adjusts the Model's "model" matrix.
model->modelMatrix.Scale(0.25, 0.25, 0.25);
4) Move each model into place
model->modelMatrix.Translate(2.0, 0.0, 0.0);
7) Render each model
What seems odd to me right off: Is it appropriate to be translating the Model's matrix in order to position the models?
Should I store the model ID along with rotation, scale and translation factors in a file somewhere?