Skip to main content
GameDev.net gamedev.net
🔒 Locked

Projectiles (moving an object)

Started by Scooter Jun 26, 2004 at 1:52 PM 2 replies 900+ views
Original Post
Scooter
Scooter
I'm trying to convert a game over from DirectX to OpenGL and I'm tring to fire a cannon ball from a cannon, the ball rotates along with the cannon but the code that normally launches the cannon ball (it's projectile motion) doesn't work the same. This was the code that got the respective velocities in DirectX: weapon.Xvel = -proj.power*(cosf(proj.Xrot)*cosf(proj.Yrot)); weapon.Yvel = -proj.power*sinf(proj.Yrot); weapon.Zvel = proj.power*(sinf(proj.Xrot)*cosf(proj.Yrot)); but now when I elevate the cannon the Y direction of the object changes.( ie the whole coordinate system rotates too, if -y was pointing down and I rotate 90 deg -y is now pointing right) How can I fire the projectile in OpenGL?
We are here just like this,It really doesn't matter why.The world is here like it is,'We could laugh we could cry.Is it good or is it bad,Wright or maybe wrong?There's no use of being sad,Without a purpose within a song.
C-Junkie
C-Junkie
if the "whoel coordinate system" rotates, then most likely you're trying to use these velocities (which are based on the identity coordinate system) after a glRotate call. Try putting a call to glLoadIdentity in someplace before you start glTranslating to the position of the projectile.

(assuming, of course, that the projectile's position is relative to the origin, not the cannon.)
MGB
MGB
OpenGL has -Z axis going into the screen, and IIRC directX has +Y into screen...
Scooter
Scooter
Yup, those things and I needed to change from radians to degrees. It works now.
We are here just like this,It really doesn't matter why.The world is here like it is,'We could laugh we could cry.Is it good or is it bad,Wright or maybe wrong?There's no use of being sad,Without a purpose within a song.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.