okay, this is probably a simple problem and I’m obviously overlooking something trivial…
ALL I’m trying to do is to move my spaceship.
I can rotate left and right properly. However, when I try to use the up arrow for “thrusting”, my ship flies off in another direction…
Is it going oposite? That is if you press up it does down?
Originally posted by eyuzwa:
[b]okay, this is probably a simple problem and I’m obviously overlooking something trivial…
ALL I’m trying to do is to move my spaceship.
I can rotate left and right properly. However, when I try to use the up arrow for “thrusting”, my ship flies off in another direction…
Originally posted by eyuzwa:
[b]okay, this is probably a simple problem and I’m obviously overlooking something trivial…
ALL I’m trying to do is to move my spaceship.
I can rotate left and right properly. However, when I try to use the up arrow for “thrusting”, my ship flies off in another direction…
I don’t know much about opengl however there does seem to be a logical explaination for the problem. Are you sure that the math library you’re using uses rads for the cosine and sine. What I would try is just passing in the angle in degrees. The reason this seems logical is that 0 degrees is pointing up right? Therefore even if you rotate the ship 180 degrees that’s only going to convert to pie radians, right. However ship moving at 3 degrees would look like it is moving straight up. Hope this helps.
I don’t know if I was clear enough. I think (if of course the sine and cosine functions are in degrees) that your code should look like this:
vx = (FLOAT)sin(ship.rotation)
xy = (FLOAT)cos(ship.rotation)
If that doesn’t work it means that ship.rotation is either not in degrees or your math library doesn’t use degrees.
I would then go on to test the program further by outputing the value of ship.rotation somewhere on the screen so you can see what is happining (what the values are) while you rotate the ship.
Best of luck.
Originally posted by dmath1: I would then go on to test the program further by outputing the value of ship.rotation somewhere on the screen so you can see what is happining (what the values are) while you rotate the ship.
Best of luck.
If you have problems outputting to screen try the following code after calculating vy.
You are working out the vector position of the space craft, but which coordinate system is it relating to? If you ship always flies straight up, then it is referring to the origin, as opposed to the new coordinate system which needs to be created when you rotate your ship, do you see what I mean. Think about push/pop/modelview matrix/rotate/translate all work.
You are working out the vector position of the space craft, but which coordinate system is it relating to? If you ship always flies straight up, then it is referring to the origin, as opposed to the new coordinate system which needs to be created when you rotate your ship, do you see what I mean. Think about push/pop/modelview matrix/rotate/translate all work.
Gavin: Thanks for the suggestions…I was starting to come to that conclusion last night. sigh. After going through mounds of debug spew, the positional calculations looked ok, so perhaps this means an error within my OpenGL rendering code.