View Full Version : Get Coordinates of Transformed Geometry

H.Stony

03-26-2005, 03:28 AM

Get Coordinates of Transformed Geometry?

Example:

glPushMatrix();

glRotatef(55,1.0,0.0,0.0);

glBegin(GL_POINTS);

glVertex3f(x,y,z);

glEnd();

glPopMatrix();

So how can I get the Coordinates of my rotated vertex? is this possible or do i have to calculate the position myself (would be very slow)?

thank you H.Stony

There are several other threads talking about that.

H.Stony

03-27-2005, 06:15 AM

sorry..i found nothing really useful

i found something about "feedback mode". are there tutorials on it?

thanks

pedrodx

03-29-2005, 01:49 AM

I'm not sure, but maybe if you multiply the coordinates of the vertex by the rotated modelview matrix...

H.Stony

03-29-2005, 08:54 AM

that was also my first idea: which are the elements in the matrix to multiplicate? the last row? ....but

i found a sgi example. in the example they use the feedback mode but i didn't find tutorials on it - only the example is hard to understand.

brinck

03-29-2005, 11:42 PM

First retrieve the current modelview matrix:

float mv[16];

glGetFloatv(GL_MODELVIEW_MATRIX, mv);

Then do the following to transform your vertex:

float xp = mv[0] * x + mv[4] * y + mv[8] * z + mv[12];

float yp = mv[1] * x + mv[5] * y + mv[9] * z + mv[13];

float zp = mv[2] * x + mv[6] * y + mv[10] * z + mv[14];

float wp = mv[3] * x + mv[7] * y + mv[11] * z + mv[15];

xp /= wp;

yp /= wp;

zp /= wp;

/A.B.

H.Stony

03-31-2005, 09:29 PM

thank you

Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.