# Procedural Catmull-Rom waypoints: How to clamp camera speed?

This topic is 4126 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello, I’m writing a procedurally-generated camera fly-by sequence based on a set of generated waypoints. For the waypoint following I use the standard Catmull-Rom function equivalent to D3DXVec3CatmullRom() that takes the four input vectors and a scalar of t between 0 and 1. Since most of the waypoints are not evenly spaced I get varying camera movement speeds between different waypoints which is not what I want. So the question is: what is a good way to calculate t-increments in a way that would make the movement speed consistent across the Catmull-Rom path? I’ve looked into the variable key-frame method but it uses key-frame time, which I don’t know how to generate for the waypoints. All I have is the set of vectors for waypoints. Does anybody know of a good way to do this? Thanks in advance, -Iv

##### Share on other sites
Don't think there is a sure-fire mathematical way to do this.

Sub-Sample the spline, recording how far you travelled along the spline for each increment of (t). So you get a sort of look up table of distance <-> t (you calculate the distance maybe using an even more minute sampling method, kinda likea numerical intergration). Then you can LUT for a given distance the correct t value, using basic linear interpolation. You'll get some error I guess, it wont be perfect, but should be almost unnoticeable, if you sub-sample enough.

void BuildCatmullRomLUT(C_CatmullRomSpline* pSpline, float* LUT[2], int LUTSize){    LUT[0][0] = 0.0f;     LUT[0][1] = 0.0f;     float  t = 0.0f;    float dt = 1.0f / LUTSize;    for(int i = 1; i < LUTSize; i ++, t += dt)    {        // spline calculates the length of the portion between [t, t+dt],        // using 100 intervals for accuracy.         float delta = pSpline->EvaluateLength(t, t + dt, 100);        LUT[0] = LUT[i-1][0] + delta;        LUT[1] = LUT[i-1][1] + dt;     }}

##### Share on other sites
You would need to make the increments in arc-length and calculate t based on the current arc-length. See this paper

##### Share on other sites
Got it. Thanks for your help.

• 10
• 48
• 12
• 10
• 10
• ### Forum Statistics

• Total Topics
631381
• Total Posts
2999676
×