Jump to content
  • Advertisement
Sign in to follow this  
ade-the-heat

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.

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

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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
glLoadidentity
//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 this post


Link to post
Share on other sites
Quote:

glPushMatrix
glLoadidentity
//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


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
glLoadidentity
//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();
glLoadIdentity();
write a sphere at this new point to check if my method
is correct.
glPopMatrix();

glPopMatrix

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!