Sign in to follow this  
Sybalos

Best approach for a classic 3D space shooter camera

Recommended Posts

Hi all!

I was wondering what would be the best approach for a simple classic 3D space shooter smooth camera movement. Games like Freelancer, DarkHorizon, SpaceForce have such a smooth camera movement controlled with the mouse. What would be the step to achieve that kind of result ? Any idea will be appreciate!
I also want to understand the math behind it. I'm using c++ and directx.

Thanks!

Share this post


Link to post
Share on other sites
I assume you mean 3rd person camera. The XNA chase camera sample is pretty good.

[url="http://create.msdn.com/en-US/education/catalog/sample/chasecamera"]http://create.msdn.com/en-US/education/catalog/sample/chasecamera[/url]

It implements a configurable mass-spring system, which is a pretty common method.

Share this post


Link to post
Share on other sites
If you do a forum search, you'll probably find a couple dozen threads on such camera setups. Really, there are two separate logical components that go into this... One is a 6DoF (6 Degree of Freedom, aka Vertical, Horizontal, Lateral, Pitch, Yaw, Roll in no particular order [img]http://public.gamedev.net//public/style_emoticons/default/biggrin.png[/img] ) camera and the other is an appropriate control scheme. I suppose there's sort of a third, depending on how you think about it, which is how the camera tracks the player... Obviously with a first person setup you don't generally even render the player character (except perhaps a HUD, but thats separate) and the camera is effectively where the player is. A third person setup (more like freelancer) locks the camera in a certain position relative to the player and sometimes provides control to deviate from that lock (so you can look behind you or whatever). A basic 6DoF camera isn't nightmarishly complicated. There are a couple different ways to go about it, just be careful to avoid the dreaded gimbal lock (luckily, typical approaches like those using matrices are immune to this particular problem).

As for control scheme: A typical modern mouse provides a relatively convenient way to control two axes (pitch with forward-back and probably yaw with left-right). The third axis is usually bound either to the mouse wheel (windows, for instance, provides easily detectable messages for mouse wheel movement) or perhaps a couple of keyboard keys like z and x. From here, the absolute simplest (well, I think) of "smoothing" motion is to set up a good movement rate lock so that the amount of rotation (and translation) is specified not by frame but by timestep. You then use a measurement of elapsed time to figure out the time difference between frames and therefore the appropriate fraction of movement to apply. More elaborate setups improve this by making movement more or less immune to variations in framerate and/or by locking framerate to be a constant. I'm by no means an expert, but there are plenty of discussions of this in historical forum threads.

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