I would like to know how to solve my problem.
Translated and Rotated I use OpenGL, and I’m doing a 3D game.
My character has to move on a 3D terrain.
Let me explain my problem:
I start from the beginning until now all is well.
I realize a translation and rotation.
Either the frame 1.
The rotation should be about itself.
[b]Then the frame 2:
And that is my problem![/b]
The character still all right.
Once completed this rotation I’d like to make a translation but in the sense of rotation.
Here’s a little diagram explaining:
I don’t understand exactly what you mean…
But it’s a difference if you use
- glTranslate before glRotate or
- glRotate before glTranslate
Yes i know that.
My question is:
How to make a translation followed by rotation of the object
on itself and then resume moving toward the new direction.
This is not an openGL question but a programming question. Here’s some pseudo code
else if (frame==2)
Note that assumes that you keep accumulating the MODELVIEW matrix.
Or you could just note that in the second frame the rotation is 0.
direction is (0,dy,0)
else if (frame==2)
direction is (dx,0,0)
ok thank but i can have 600 frames, it’s more complexe than you said.
I find the solution:
We must make calculations and save the matrix and the matrix
reuse each time.
Thank you again
I have a another question on the matrix.
When you have an array of size 16 for the womb.
What are the boxes containing the position x, y, z.
And what are the other boxes?
Reading here may help you see how the 16 element matrix is composed. Pay particular note of the section “Model-View Matrix (GL_MODELVIEW)”
Ok I ask you this question because now my character moves in a 3d world and I want to follow the camera.
Thank for the link, now i understand the matrix!
Do you have a another link for another methods for the camera without lookat with matrix of character ?
I find gluLookAt is good for what I do … sorry No I don’t have any other references that do not use gluLookAt.
Ok i seek technics as it:
double x = Mesh.objectTransformationMatrix - Mesh.objectTransformationMatrix;
double y = Mesh.objectTransformationMatrix - Mesh.objectTransformationMatrix;
double z = Mesh.objectTransformationMatrix - Mesh.objectTransformationMatrix;
// eyeCenter == eyeDir
Glu.gluLookAt(Mesh.objectTransformationMatrix, //eye X
Mesh.objectTransformationMatrix, //eye Y
Mesh.objectTransformationMatrix, //eye Z
x, //center X
y, //center Y
z, //center Z
0.0f, // upvect X
Math.Sin(Mesh.objectTransformationMatrix), // upvect Y
0.0f); // upvect Z
But this code don’t work…