Jump to content
  • Advertisement
Sign in to follow this  
hury

Get coordinates

This topic is 3641 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, i draw 3 triangles, which are my mousepointer:
Quote:
void Cursor::draw() { glLoadIdentity(); glTranslatef(x , y, z); glRotatef(-120, 0, 1, 0); glRotatef(-25, 1, 0, 0); glRotatef(cursorRotator, 0, 0, 1); glScalef(0.1f, 0.1f, 0.1f); glEnable(GL_BLEND); glEnable (GL_SMOOTH); glBegin(GL_TRIANGLES); // Fange an Dreiecke zu zeichnen glColor3f(0, 0.5f, 0); glVertex3f(0, 0 , 0); glColor3f(0, 0.5f, 0.5f); glVertex3f(0, 1 , -2); glColor3f(0, 0.5f, 1); glVertex3f(1, 0 , -2); glColor3f(0.5f, 0, 0); glVertex3f(0, 0 , 0); glColor3f(0.5f, 0.5f, 0); glVertex3f(0, -1, -2); glColor3f(0.5f, 1, 0); glVertex3f(1, 0 ,-2); glColor3f(0, 0, 0.5f); glVertex3f(0, 0, 0); glColor3f(0, 0.5f, 0.5f); glVertex3f(-1, 0, -2); glColor3f(0, 1, 0.5f); glVertex3f(0, -1, -2); glColor3f(0.5f, 0, 0); glVertex3f(0, 0 , 0); glColor3f(0.5f, 0.5f, 0); glVertex3f(-1, 0 , -2); glColor3f(0.5f, 1, 0); glVertex3f(0, 1 , -2); glEnd(); }
How is it possible to get the (real) x, y, z Coordinates, after my triangles has been rotated with glRotatef(-120, 0, 1, 0); and glRotatef(-25, 1, 0, 0); ? Best regards Alex

Share this post


Link to post
Share on other sites
Advertisement
Solved it that way:

GLdouble modelMatrix[16];
GLdouble projMatrix[16];
GLint viewport[4];

glGetDoublev(GL_MODELVIEW_MATRIX, modelMatrix);
glGetDoublev(GL_PROJECTION_MATRIX, projMatrix);
glGetIntegerv(GL_VIEWPORT, viewport);

GLdouble xi ,yi ,zi ;
GLdouble ix ,iy ,iz ;
gluProject(xPointer, yPointer, zPointer, modelMatrix, projMatrix, viewport, &xi, &yi, &zi);
gluProject(ico.getIconVector().at(x)->getX(), ico.getIconVector().at(x)->getY(), ico.getIconVector().at(x)->getZ(), modelMatrix, projMatrix, viewport, &ix, &iy, &iz);
cout << "Pointer Xi: " << xi << "\n";
cout << "Icon Xi: " << ix << "\n";

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!