# 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.

## 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 on other sites
glTranslatef( 2*xx, 0.f, 2*zz );

or was that a typo?

##### Share on other sites
it was a typo, eheh, gonna edit it

##### 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:

glTranslatef(2,0,0);

Hope this works!

##### Share on other sites
erissian thats it :)
If i was gay, i would kiss you :)
many thanks

1. 1
Rutin
43
2. 2
3. 3
4. 4
5. 5

• 9
• 27
• 20
• 9
• 20
• ### Forum Statistics

• Total Topics
633398
• Total Posts
3011659
• ### Who's Online (See full list)

There are no registered users currently online

×