Sign in to follow this  
Agwan

Help, Writing camera system for Space Flight Sim

Recommended Posts

Agwan    122
Hello, I'm trying to write a spaceflight simulater, the problem is creating the camera system to do this.. .. unlike in normal first person cameras, if you look straight down and "Turn" (Mouse.X changes) then instead of turning on the spot you would simpily turn just like u would if facing directly forward. I'm reasonably sure i have to use Quaternions to fix the problem, but have been unable to find a working solution, after searching with google as much as humanly possible. so my question is this.. does anyone know of a working demo, i'm using c#.. or has anyone actualy gotten this to work? .. i do not intend to re-write a quaternion engine as it's included in directX .. thanks.. Agwan [Edited by - Agwan on March 20, 2007 4:04:23 AM]

Share this post


Link to post
Share on other sites
jyk    2094
Quote:
Original post by Agwan
Hello,

I'm trying to write a spaceflight simulater, the problem is creating the camera system to do this..

.. unlike in normal first person cameras, if you look straight down and "Turn" (Mouse.X changes) then instead of turning on the spot you would simpily turn just like u would if facing directly forward.

I'm reasonably sure i have to use Quaternions to fix the problem, but have been unable to find a working solution, after searching with google as much as humanly possible.

so my question is this.. does anyone know of a working demo, i'm using c#..
or has anyone actualy gotten this to work? .. i do not intend to re-write a quaternion engine as it's included in directX .. thanks..
No, you do not have to use quaternions.

This exact topic is currently under discussion here as well, so you might give that thread a read. I posted some links to example source code in the thread, but the code is in C++ so you'd have to adapt it.

However, given that you're using the DirectX math library, you already have all the tools you need at your disposal to do this easily. The key is to store the orientation as a matrix (or quaternion - your choice), and apply incremental local-axis rotations each frame or game tick to update the orientation. I don't know if DirectX has a matrix orthogonalization function, so you might want to go with quaternions just for convenience.

If you get stuck on any of the details, just post back here and I'm sure I or someone else will be able to help you.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this