Best approach for a classic 3D space shooter camera

Started by
2 comments, last by Danisflying 12 years ago
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!
Advertisement
I assume you mean 3rd person camera. The XNA chase camera sample is pretty good.

http://create.msdn.com/en-US/education/catalog/sample/chasecamera

It implements a configurable mass-spring system, which is a pretty common method.
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 biggrin.png ) 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.
There was a saying we had in college: Those who walk into the engineering building are never quite the same when they walk out.
The easiest way is to keep the camera still and move the objects towards the camera.

This topic is closed to new replies.

Advertisement