glpushmatrix ()
gltranslate (shippos.x, shippos.y, shippos.z)
glrotate (shiprotation, 0, 1, 0);
glrotate (shipsroll, 1, 0, 0); //the ship tilts as it turns
Drawship (); //draw a 3d model in place
glpushmatrix ();
gltranslate (10.0f, 0.0f, 4.0f); //move to where the gun is on the ship body
//I need to find this point in world space
DrawGun (); //draw a gun
glpopmatrix ();
glpopmatrix();
Anyone know if there is a way for me to find this gun's position in world coordinates?
I can find it in a complicated way, but I am wondering if their is a simple way that I have overlooked?
Thanks for any help.
Finding a position
Hi.
Is there any way to find the world coordinates of an item which is being position through push and pop matrixes?
Here is my problem:
I have a ship, which is controllable by the player. The ship has a position (3 x floats), and is rotated around as required:
You need object transformation matrix and extract position from there. You either have to grab that matrix from opengl or build it yourself (I sugest this).
I don't suppose anyone would know a link to a tut on this subjext would they, or any relevant documents that would help.
I have not used object transformation matrix, and have no idea how to extract the position from it.
I have not used object transformation matrix, and have no idea how to extract the position from it.
Thanks for that.
I know how to to matrix sums, but what sums do I need to do to turn the matrix that is held for the objects translation and rotations into world coordinates.
And how do I do that using OPenGL.
I know how to to matrix sums, but what sums do I need to do to turn the matrix that is held for the objects translation and rotations into world coordinates.
And how do I do that using OPenGL.
You would actually use matrix multiplication, to get the world coordinates of something you would multiply the object's coordinates by the model's transformation matrix.
hope that helps
-Dan
hope that helps
-Dan
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement