Jump to content

  • Log In with Google      Sign In   
  • Create Account

Best approach for a classic 3D space shooter camera


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 Sybalos   Members   -  Reputation: 214

Like
0Likes
Like

Posted 03 April 2012 - 06:37 AM

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!

Sponsor:

#2 EJH   Members   -  Reputation: 314

Like
0Likes
Like

Posted 03 April 2012 - 02:07 PM

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.

#3 medevilenemy   Members   -  Reputation: 315

Like
0Likes
Like

Posted 03 April 2012 - 07:40 PM

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 Posted Image ) 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.

#4 Danisflying   Members   -  Reputation: 100

Like
0Likes
Like

Posted 05 April 2012 - 06:07 PM

The easiest way is to keep the camera still and move the objects towards the camera.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS