Archived

This topic is now archived and is closed to further replies.

thedustbustr

camera following bezier curves

Recommended Posts

thedustbustr    191
I want to have my camera follow curves in scripted sequences. Currently, I''m using peicewize Bezier4 curves. I evenly increment mu (the distance between 0 and 1) like so:
mu += clock.DeltaTime / curveTime 
where curveTime is the amount of time to spend on this curve. I calculate mu each frame then calculate a point on the curve from mu. This causes the camera to start at rest (0 velocity) accelerate then decelerate to rest again for each set of four control points. I''ve looked into another curve generating formula (b-splines) but they seem to have the same problem. I read in Game Programming Gems that you can calculate the curve data for each set of curve points and save it to an array and then calculate the distance between each saved point, but this limits the resolution of the curve if you have a fast enough computer. Is there an alternative workaround to this solution? Maybe there is a problem with my code, I can post it if necessary. While I''m at it, how do you guys update the view vector relative to the position vector change? Thanks! Dustin

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
Nurbs are popular to get smooth camera movements.
If you connect a series of Bezier curves you will get problems cause the tangent vectors at the end of one curve and at the start of the next curve will only have the same direction and not the same length.

/__fold

Share this post


Link to post
Share on other sites
MrOreo    124
If you want to have the camera face along the splines path, you could get the position of the camera at the NEXT clock tick(or the previous clock tick.. it should be a trivial decision, depending on the value of delta mu), and the correct camera vector would be the vector created from the current position of the camera, and the next position.

A cheap little hack, and I don''t know how well it would look on low resolution curves....

/__fold is right about the normals though.. Creating a Nurbs evaluator is probably just a matter of spending a few minutes with google anyways.

-=|Mr.Oreo|=-
Code Monkey, Serpent Engine

Share this post


Link to post
Share on other sites
Wildfire    154
A nice idea might be to use two paths. One for the camera position, one for the camara to look at. Might give you a little more creative freedom.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
I''ve also built a pathed camera system and I had a lot of luck with Catmull Rom splines. They are mathematically equivalent to bezier curves, but they pass through all their control points. The good news is that you string a long sequence of them together and it behaves like you''d expect without you having to (for bezier curves) make sure your derivative control points line up at the endpoints of each segment.

So, very simple to use with good results (C1 continuity, curvature is interpolated between endpoints, so it''s not C2).

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
"Much uglier" is very subjective. Math says that B-Splines are smoother (having C2 continuity) true, but the problem is that they don''t interpolate any of their control points. This is no problem if you have a nice graphical tool that well let you plop down control points and tweak them until you get the curve you want. However, my system also needed to generate curves in real-time so B-Splines were not an option.

In truth, I found that curve smoothness is not as significant an aesthetic factor as the acceleration/deceleration equations that affect camera motion.

Share this post


Link to post
Share on other sites