Jump to content
xisto Community
Sign in to follow this  
switch

Opengl Matrix Translation Issues having trouble with my 3D game.

Recommended Posts

hey

i'm making a game, and just went to implement collision detection when i found that it would be incredibly difficult because of a shortcut i added to work around a problem. now i'm going back to fix that problem, but i'm running out of ideas.

i'm trying to do this... (in c++)

xPos = (whatever); //the x and z coordinates of the object.zPos = (whatever);rotation = (whatever); //the rotation of the object in degrees.glPushMatrix();    glTranslatef(xPos, 0, yPos);    glRotatef(rotation);    renderObject();glPopMatrix();

and draw an object at xPos,0,yPos with a rotation of 'rotation'.

instead, the object appears at xPos, 0, -yPos. the problem can be fixed by putting doing this for the translation:
glTranslatef(xPos, 0, yPos);
and until now this is what i was doing, but it makes things like collision detection and camera work much more complicated later on.

does anyone have any ideas on why this would be occuring and/or how to fix it?

thanks, muchly appreciated.

Share this post


Link to post
Share on other sites

ok sorry that post was riddled with problems. zPos (in the second line of the first block of code) should be yPos, and the second block of code should read

glTranslatef(xPos, 0, -yPos);

ok thanks sorry about that.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.