[ODE] Camera should be a body with zero mass?

Brent Burton brentb at io.com
Thu Jun 24 12:01:16 MST 2004


On Thu, 24 Jun 2004, James Arthur wrote:
> On Thu, 24 Jun 2004 10:36:26 -0400, andresch at cox.net <andresch at cox.net> wrote:
> >  ... I
> > want my camera to follow my character as it moves and rotates ...
> 
> The trick is to work out where the camera wants to be and where it
> wants to be pointing. For a third person game this will be a little
> bit behind the player, looking straight at the player. ...

A couple months back I wrote a simple trebuchet (catapult) simulation.
Once the projectile was launched and reached it's apogee, the viewpoint
would change to follow the projectile on its descent.

At each rendering step, the projectile body's position and velocity
are fetched, and the camera is placed behind the object (normalize
the vel vector, then scale it with a negative factor to get a general
location behind the object).  Some adjustment will be necessary for
the view/effect you want, but that's the idea.

This essentially forms a rigid, noninterfering link between the
projectile/player and camera.

Source and cygwin executable available at: 
http://www.io.com/~brentb/trebode.zip

(Actually, the source is a bit different than what I described
above.  The trebuchet source only launches the projectile a certain
direction, so a constant offset is used for camera position, while
the projectile's velocity determines the camera's view direction.
See follow_projectile() and its call to dsSetViewpoint().)

cheers,
-Brent




More information about the ODE mailing list