shooting from camera position

Started by
3 comments, last by Bruno 18 years, 2 months ago
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]
Advertisement
glTranslatef( 2*xx, 0.f, 2*zz );


or was that a typo?
it was a typo, eheh, gonna edit it
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!
We''re sorry, but you don''t have the clearance to read this post. Please exit your browser at this time. (Code 23)
erissian thats it :)
If i was gay, i would kiss you :)
many thanks

This topic is closed to new replies.

Advertisement