Not logged in, Join Here! or Log In Below:  
News Articles Search    

 Home / 3D Theory & Graphics / Spline paths Account Manager
Archive Notice: This thread is old and no longer active. It is here for reference purposes. This thread was created on an older version of the flipcode forums, before the site closed in 2005. Please keep that in mind as you view this thread, as many of the topics and opinions may be outdated.

March 11, 1999, 03:10 PM

Hi everybody,

I found a message in one of these forums asking about better control over the position
of the camera using spline paths (Like in the opening movie for Unreal). Somehow, I can't
find it anymore. But anyway, to everybody interested, here's a short piece of pascal-code that
implements Catmull-Rom splines. I like CR-splines over Bicubic and Beta-splines because CD-
splines _always_ pass through the control points, unlike others.
If you have any questions, I'd like to hear them (I undoubdedly will :-)

BTW: Kurt, if you think this message is too long, just say so, and I won't do it again :-)

>-------Start of code

Uses Crt;
{Catmull-Rom interpolation spline}

Type Dims=(X,Y,Z);

Var CP : Array[Dims,1..100] Of Integer;
XC,YC,ZC : Real;
I,J,K : Integer;
T : Real;
T1,T2,T3,T4 : Real;
C : Real;


Asm mov ax,$13; int $10 end;

For I:=1 To 100 Do Begin
CP[X,I]:=Random(320); CP[Y,I]:=Random(200); CP[Z,I]:=Random(255);

{Play with the constants in the calculation for different effects}
For J:=0 To 99 Do Begin
For I:=0 To 69 Do Begin
T1:=T*T*T*-0.5 +T*T*1.0 +T*-0.5 +0;
T2:=T*T*T*1.5 +T*T*-2.5 +T*0 +1;
T3:=T*T*T*-1.5 +T*T*2.0 +T*0.5 +0;
T4:=T*T*T*0.5 +T*T*-0.5 +T*0 +0;
{0xA000 is the start of VGA video-memory, for all you DOS :-) }



>-------End of code

This thread contains 1 message.
Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.