Jump to content
  • Advertisement
Sign in to follow this  
Bruno

shooting from camera position

This topic is 4677 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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!