| 01-23-2007, 11:44 PM | #1 | ||||
I'm attempting to make a game in C++ using OpenGL where some sort of ship is moved through space. I'm trying to get 3D movement, so when I would press up the ship would tilt upward and keep heading at that particular angle. Everything appears to work fine, but after a second or so of holding down an arrow, the angles seem to mess up. I figure it's something wrong with the math I'm using, but I can't be sure. Here's the sections of code that I think are important: All the classes being used.
Function to draw the scene. 'ship' is a variable of type 'Ship'.
Function to handle Keys, and adjust angles of movement. Adjustment is set at 0.1 currently. 'keys' is a bool array that has values set to true when a key is pressed (handled in the window procedure)
And lastly, the main function (though I'm fairly sure the problem isn't with this).
If anyone has any ideas on what I did wrong, I would greatly appreciate some help. I'll also upload all the source files with the exe in a second. |
| 01-24-2007, 01:10 AM | #2 |
Go read about quaternions, linear algebra and euler angles. |
| 01-24-2007, 01:30 AM | #3 |
Any specific sites or places I should look at? I'm clueless about what quaternions and eular angles are. I'm also fairly sure I don't know too much about linear algebra either. (I'm currently taking Algebra 1, and have a fairly good grasp of it) |
| 01-24-2007, 03:48 AM | #4 |
This is my favorite site about quaternions: http://www.gamedev.net/reference/art...rticle1691.asp |
| 02-04-2007, 09:15 AM | #5 |
nonono you don't need quaternions >_> they are useful but you don't need them really... I suggest that you store the ship's rotation in matrices... they are good enough for full 3D rotations and don't suffer from problems Euler angles do (google for gimbal lock - probably this happens to you) |
