# vector transformation problem

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

## Recommended Posts

I draw the wings on my airplane like this: Basically, it's a whole bunch of transformations to get to the places to draw the items (I've cut loads of to make it easier to read) ===================================== glTranslatef(xPos, yPos, zPos); glRotatef(pitch, 1.0, 0.0, 0.0); etc //draw cylinder part of airplane (not shown for brevity) //now go to where wing is supposed to be glTranslatef(AIRPLANE_RADIUS, 0.0, AIRPLANE_TAILFIN_LENGTH); glScalef(TAILFIN_LENGTH, TAILFIN_LENGTH,TAILFIN_LENGTH); //draw the wing (simplified) glBegin(GL_TRIANGLES); //POINT ONE - GET MODEL MATRIX HERE ??? glVertex3f(0.0f, 0.0f, 0.0f); //FIRST POINT ON WING glVertex3f(1.0f, 0.0f, 0.0f); glVertex3f(1.0f, 1.0f, 0.0f); glEnd(); ===================================== Now, I assume that if I want to know the precise vector of the first point on the wing I can simply multiply the vector at the first point on the wing (ie (0.0f, 0.0f, 0.0f) ) with the model matrix at POINT ONE ?? I do that - then in order to check I've got it right I draw a big fat sphere at that point by glPushMatrix glLoadIdentity(); glTranslatef(values from model matrix multiply); //draw big sphere here !!! glPopMatrix(); Of course the sphere isn't there !! So what am I doing wrong ??? If I can overcome this problem then I'm nearly finished. cheers Ade

##### Share on other sites
anyone have any ideas ?!

cheers

##### Share on other sites
I don't see any problem with the idea. Where do you place the glGet* call to get the matrix. I'm asking because I see that the comment //GET MODEL MATRIX HERE is between a glBegin/glEnd pair, which is illegal. Get the modelmatrix right before glBegin.

##### Share on other sites
I missed a bit out - the matrix model isn't obtained within a Begin and End section.
also, I simplified the code here to make it easier to understand.

What I actually have done in order to obtain the new vertices is to:

glPushMatrix
//repeat all the transformations I did on the airplane
//to get to the drawing the wing part

get the modelmatrix
multiply the vector (0.0, 0.0, 0.0) with this.
write a sphere at this new point to check if my method
is correct.
glPopMatrix

Obviously the sphere doesn't come out even though I made it enormous !

cheers

##### Share on other sites
Quote:
 glPushMatrixglLoadidentity//repeat all the transformations I did on the airplane//to get to the drawing the wing partget the modelmatrixmultiply the vector (0.0, 0.0, 0.0) with this.write a sphere at this new point to check if my methodis correct.glPopMatrix

According to those, you manually multiply the vector(0,0,0) with modelmatrix, and then draw the sphere, which gets translated AGAIN with the same modelview matrix. The correct would be:

glPushMatrix
//repeat all the transformations I did on the airplane
//to get to the drawing the wing part
get the modelmatrix
multiply the vector (0.0, 0.0, 0.0) with this.

glPushMatrix();
write a sphere at this new point to check if my method
is correct.
glPopMatrix();

glPopMatrix

• 32
• 12
• 10
• 9
• 9
• ### Forum Statistics

• Total Topics
631352
• Total Posts
2999483
×