Jeroen 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 pascalcode that implements CatmullRom splines. I like CRsplines over Bicubic and Betasplines 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; {CatmullRom 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;
Begin
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); End;
{Play with the constants in the calculation for different effects} For J:=0 To 99 Do Begin T:=0; 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; XC:=T1*CP[X,1+J]+T2*CP[X,2+J]+T3*CP[X,3+J]+T4*CP[X,4+J]; YC:=T1*CP[Y,1+J]+T2*CP[Y,2+J]+T3*CP[Y,3+J]+T4*CP[Y,4+J]; ZC:=T1*CP[Z,1+J]+T2*CP[Z,2+J]+T3*CP[Z,3+J]+T4*CP[Z,4+J]; {0xA000 is the start of VGA videomemory, for all you DOS :) } Mem[$A000:320*Round(YC)+Round(XC)]:=Round(ZC); T:=T+1/70; End; End;
ReadLn;
End.
>End of code
