PDA

View Full Version : How I can detect each object my mouse click.



amstel
01-25-2002, 09:10 PM
I draw my 3D-Object by use these command

//////////////////////////////////////////////////
//class declaration
class CMyObject
{
double x,y,z;
......................
public:
void Draw();
}
/////////////////////////////////////////////////
//Object declaration
CMyObject* MyShape;
////////////////////////////////////////////////
// Draw all objects
for(i=0;i<N;i++)
MyShape[i].Draw();
////////////////////////////////////////////////
void CMyObject: http://www.opengl.org/discussion_boards/ubb/biggrin.gifraw()
{
glBegin(GL_POLYGON);
glVertext(x1,y1,z1);
glVertext(x2,y2,z2);
............................
glEnd();
}
///////////////////////////////////////////////
How I can detect each object by mouse clicked? In addition,my objects can be free rotated.So the plane may be contained x-z or y-z coordinate(not x-y). When I move mouse onto drawing area, I want to know the x,y and z coordinate .

Thanks,
amstel.

Leyder Dylan
01-28-2002, 09:19 AM
Hi,

Use this tut (the last one of the page) for your program :
http://www.gametutorials.com/Tutorials/OpenGL/OpenGL_Pg2.htm