Sign in to follow this  

shooting from camera position

This topic is 4337 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

Let me try to explain in the best english that i can what the problem is.., I have a camera setup in fps style mode, and i'm tryng to shoot a sphere from my camera position. Everything is working, and the sphere is being shot from the center of the screen to the horizon. Now i wanna make that the sphere shoots from the right of the screen to the horizont, instead of from the center of it. So before rendering it, i just make a little translation (2,0,0) so she indeed shoots from the right. However now, when i rotate the player the sphere is no longer shooting from where it should, her point of origin moves around while i rotate the camera, it goes from the right to the left and back to the right again as i make a full camera rotation. I think that while the camera is being rotated the new translated point of origin isn't. So, i did the following : float xx = sin(myCamera.heading); float zz = cos(myCamera.heading); glTranslatef(2*xx,0,2*zz); glTranslate(sphereX,sphereY,sphereZ); render_sphere(); But, still not working.., Any ideias on what could be wrong ? thanks, Bruno [Edited by - Bruno on January 29, 2006 7:21:52 AM]

Share this post


Link to post
Share on other sites
In what order are you performing your transformations?

In this case, you want to set your sphere's initial position, and then rotate it with your player. That means you have to translate first and rotate second.

Because transformations happen in the opposite order that you call them:

glRotatef(myCamera.heading,0,1,0);
glTranslatef(2,0,0);

Hope this works!

Share this post


Link to post
Share on other sites

This topic is 4337 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.

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