PDA

View Full Version : function to find coordinates



dadec
05-01-2009, 09:05 AM
Hi

I'm trying to rotate a 3D wire cone and to find the coordinates of the tip once rotation has been applied. Is there any function to do this automatically?

Thanks in advance! :)

dadec
05-01-2009, 09:25 AM
apologies, i meant that rotation has been applied and i want to be able to track the coordinates of the tip of the cone if thats possible?

todayman
05-02-2009, 06:37 AM
If you're using the modelview matrix provided by OpenGL, you should query that and then multiply the matrix by the initial coordinates of the tip of the cone. I don't think there's a function to do this automatically, but it's not particularly difficult.

dadec
05-04-2009, 11:08 AM
sorry i'm really new to this, heres a section my code:

glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix();

glTranslatef(0.0, 0.0, 0.0);
glRotatef(0.0, 0.0, 0.0, 0.0);
glPushMatrix();
glutWireCube(1.0);

glPopMatrix();


glTranslatef(0.0, 1.0, 0.0);
glRotatef((GLfloat) segment[5], 0.0, 0.0, 1.0);

glPushMatrix();
glutWireSphere(0.5, 10, 10);


glPopMatrix();
glGetFloatv(GL_MODELVIEW_MATRIX, currentPos[6]);


it is my understanding that glGetFloatv(GL_MODEL_MATRIX, matrix) saves the current coordinates to matrix[12], matrix[13], and matrix[14]. is this not so? if it is not, how do i get the coordinates from the modelview matrix?