Skip to main content
GameDev.net gamedev.net
🔒 Locked

Pre Defined Camera Movement

Started by jonbell Nov 3, 2002 at 9:55 AM 6 replies 400+ views
Original Post
jonbell
jonbell
What are peoples thoughts on how to get the camera to move along a predefined route? An example of what i mean is in Mario 64 when you start a new game and the camera goes up round the castle under the bridge etc giving the player a good look at the area before they begin play. I thought that to do this i will predefine a number of key points where i want the camera to be then define the curves between each set of points (spline etc). Is this a good way to do this or are there other better techniques? Any thoughts at all regarding this would be appreciated.
LordDeath
LordDeath
One way to do it would be to lay down a spline for the camera, and a spline for the camera's target, and then just run them. Uniform bsplines take very little data and are really easy to program. All you need to export to the game side are the control vertices, and you can evaluate the spline in code. Small data, fast code, big win. Non uniform splines are a little harder and might not be worth the effort.

An even easier, but less efficient way to implement this would be to actually sample and export your camera's positions at say 24 FPS (or whatever you feel is apropriate), and linearly interpolate in between the frames.

Marc Hanson
Programmer on "Alter Echo"
Outrage Games - THQ

[edited by - LordDeath on November 3, 2002 12:03:29 PM]
jonbell
jonbell
Whats the differance between uniform and non uniform splines?

If i have say 20 positions that i want the camera to move through would i just need the list oif these 20 positions and then the control position to warp the spline and get the curves i want?
LordDeath
LordDeath
If you have a tool like Maya or 3DSMax where you can lay out splines visually, just lay out the splines so that it flies where you want to, and export the control vertices of the plines to your game. You can use the CV''s to evaluate the splines and get the positions of the camera/target at any parameter [0.0, 1.0]. If you are trying to do this by hand (or programmatically...) ugh, I don''t even want to think about that. Get yourself some kind of visual editor to do this. Or set it up in your level editor (whatever you are using).

The difference between uniform and nonuniform are many, and I''m not going to explain them all since there are a lot of resources out there that you can read which will do a better job, but the short version is that uniform are much simpler for the programmer to implement, and are less expensive. Nonuniform are more flexible for the designers to use. However, I don''t think the difference is worth dicking around with nonuniform splines. Even in most commercial game uses, uniform splines are good enough.

Marc Hanson
Programmer on "Alter Echo"
Outrage Games - THQ
S1CA
S1CA
Yep - I''d go with splines too. As well as the control point position I''d also store a tangent vector and interpolate that too - this allows the camera ''roll'' to be animated too.

--
Simon O''Connor
Programmer on "BattleBots"
Creative Asylum Limited
Also for THQ [codev with Warthog]
Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site
Sharky
Sharky
Yep - I agree that splines are the way to go. As a starting point take a look (search) for Catmull-Rom splines as these are very simple to implement and yield good results - especially for things like camera movements.

As an example you might define two paths that use these types of spline. The first path could be the camera position and the second path the camera look-at point. Do a little reading about their uses, too, as there are a few little details regarding their use that may or may not be beneficial to your particular situation...

Regards,
Sharky
jonbell
jonbell
Would A 3D Beizer Spline do the job? What other splines should i look at? Cheers
S1CA
S1CA
quote:
Original post by jonbell
Would A 3D Beizer Spline do the job? What other splines should i look at? Cheers



Yep Bezier would be ok. Alternatives to look at: Catmull-Rom and Hermite.

The best advice would be two experiment with each to see which gives you the most pleasing path for YOUR application.

Things to evaluate when comparing splines depending on your needs:

- Continuity: Your camera path will probably actually be made of multiple splines, continuity is how smoothly one transitions to the next.

- Whether points on the spline will ever touch a control point. If you need the camera to hit a particular point exactly during the path (e.g. a camera attached to a bird swooping into a nest), you''d prefer a spline type which passes through its points - some don''t.

- Convex Hull property: Some splines have shapes which enclose all their control points which describe the space the spline passes through. This can be handy in some circumstances for high level collision with the camera (i.e. seeing if an object may end up in the path of the camera).

- Velocity: You find positions along the spline by specifying a parameter (say t) ranging between 0 and 1. The speed at which the camera travels down the spline may vary with different types of spline.

--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com
Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.