getting positon of an object

hi
i’m woundering are there any functions in opengl to get the coordinates of a object in 3D or do you just have to make a funtion that does this,

would a structure that gets the current and previous coordinate of a object work but updating it (this is for a game).

thanks

You can use the selection buffer to find what object you have clicked on, nehe.gamedev.net has a tutor on it.

But you also can just track each object with a variable as to its location, since you have to place the object’s in your scene yourself anyway.

example:
// Define object location
typedef struct object_3D
{
GLfloat x1, y1 ,z1; // location current
GLfloat x2, y2 ,z2; // direction of travel
int rx,ry,rz; // Rotation of object
};

Originally posted by darkquest:
[b]hi
i’m woundering are there any functions in opengl to get the coordinates of a object in 3D or do you just have to make a funtion that does this,

would a structure that gets the current and previous coordinate of a object work but updating it (this is for a game).

thanks[/b]

[This message has been edited by nexusone (edited 12-28-2003).]

a function like you requested cannot exist as OpenGL does not know objects. You only draw primitives, and OpenGL uses matrices to calculate the coordinates that have do be drawn. So a function like that is completely impossible.

Maybe you should start learning some OpenGL basics first?

Jan

Games update the position of objects and tell OpenGL where the objects are, not the other way around.

OpenGL draws stuff and that is all, do draw moving stuff typically software must be written to track and move the viewing position and objects in the scene.

u could use gluUnproject (pg 151 : red book)