Qbasicnews.com

Full Version: I almost have it with the rotation.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Along with the rotation, I got the ability to move the camera around, pitching and yawing up and down and moving in it's proper direction (with outrolling) just like if it was an FPS. Thats worth saving for if I wanted to make an FPS which I am not doing atm.

What I am trying to do is create a simple free flight simulator(probably descent style gameplay) using the camera. As in, the camera will turn left or right, pitch up and down and roll no matter what angle the camera is at.

The problems I am currently encountering is, when the camera looks up or down, it rolls. And then it's on the horizon, it turns. Same thing goes with rolling the camera. The rotation is somewhat fuberd up when I roll the camera and move it at the same time.

I am still a beginner at this rotation thing.. But I have gotten the use of the GL basics.

Anyways...

Heres the program(You need FreeBasic):
http://edice.arvixe.com/3dmvtest.bas

As for the controls:

Q, E to roll camera.
Left, Right to turn camera.
Up, Down to pitch camera.
W,S to move camera backwards or fowards.

I really don't have the time to solve this problem.

Yeah, I also included the wrapvalue and the MoveX,Y,Z with the angles function routes to make life a little easier.

Anyways, got to sleep.
Yeah, it's a comon problem called gimbal lock. The best solution I've found is to rotate the desired axis, and then compute the new perpendicular axis using the cross product. It would make a weird fps though. :lol:
Sounds cool. And... thanks for the hint.

I'll run a google search for it.
Quats. quats!!! Bleh. ;*)
j/k
Perhaps someone should write an issue about avoiding the gimble lock.

Which reminds me has anyone heard of SLERP?
Somebody needs to write a good tutorial on quaternion numbers and their use for 3D graphics. Preferably with some examples in FreeBASIC. Apparently gimbal-lock can be avoided using quaternion numbers.

I've tried to read a couple of articles about them before -- I feel I'm competant enough with complex numbers to understand most of it. The one thing I'm most unhappy about is how multiplication stops being commutative.

So if anybody would be willing to spend a little time writing a tutorial on quaternions (post in this forum maybe)... that would be hugely appreciated and I'm sure would be very useful to a lot of people here. Maybe post it as a new topic - "TUTORIAL: Coding with Quaternion Numbers".
Qwhats??? :lol:

j/k too! Big Grin

Anyway:
I think quaternions are too complicated for for basic rotations. Also, they do suffer from gimbal lock, if you use them the same way you do with euler angles. In my opinion, a much simpler solution is axis angle rotation, which doesn't suffer from gimbal lock, as long as you always rotate all three axes in the same order.


Ummm, like this...

If you rotate about the X axis(Direction Vector), then always compute the new Up vector, using the negative cross product of the Direction vector, and the Right vector.

If you rotate about the Y axis(Up vector), then always compute the new Right vector, using the cross product of the Direction vector, and the Up vector.

If you rotate about the Z axis(Right vector), then always compute the new Up vector the same way you did at the X axis.
Quote:Qwhats??? :lol:

j/k too! Big Grin

Anyway:
I think quaternions are too complicated for for basic rotations. Also, they do suffer from gimbal lock, if you use them the same way you do with euler angles. In my opinion, a much simpler solution is axis angle rotation, which doesn't suffer from gimbal lock, as long as you always rotate all three axes in the same order.


Ummm, like this...

If you rotate about the X axis(Direction Vector), then always compute the new Up vector, using the negative cross product of the Direction vector, and the Right vector.

If you rotate about the Y axis(Up vector), then always compute the new Right vector, using the cross product of the Direction vector, and the Up vector.

If you rotate about the Z axis(Right vector), then always compute the new Up vector the same way you did at the X axis.

True dat!!!

Shiftlynx : Matrix multiplication is also not commutative so...

I would bet most Quat users did not derive those rotations(me included) but it would not stop you from using quats effectively as long as you understand the basic concepts. But I unless I want to interpolate between rotations (SLERPS, etc), and the linecube demo in my site is a good candidate, I would use the axis-angle way. Quats cannot be visualized well because of it's spherical nature. I tried and got a lil headache trying. :*)
Someone should write a free flight sample demo where pitch, yaw and roll works correctly.

This hours of searching to try getting the problem fixed and understandable is getting into my RL time.
I made one that should be pretty easy to understand. Wink

http://forum.qbasicnews.com/viewtopic.ph...406#109406