Camera "flight" with POV
27-Apr-93 19:41:10
Sb: #20778-Camera "flight" with POV
Fm: Eric Barish 71501,1065
To: Mark Campbell 70673,1722
For direction, try LOOK_AT(SPLINE(T+1)) or
LOOK_AT(SPLINE(T+1)+SPLINE(T)-SPLINE(T-1)). I think the second one
will giver better results.
In order to vary the speed, you can calculate 100 times as many
spline points, and then increase T by SPEED/100 (and use int(T) in
all SPLINE statments). For a rollercoaster, SPEED = sqrt(H-Y).
Where Y = the hight of the camera, and H is some hight HIGHER than
the highest point on the ride. The higher H is, the faster the
ride. Hmmm, that ignores friction. For a rollercoaster with
friction, SPEED = sqrt(H*POW(F,T)-Y). Where F=friction (just under
1.0 , around 0.999 is reasonable). Note: If H is too low, and/or F
is too far below 1.0, you will get an error, SQRT(negative number).
If you use E=H*POW(F,T)-Y (or E=H-Y) and
SPEED=sqrt(abs(E))*sign(E)*sign(SPEED(T-1)), you won't get the
sqrt(negative) error, and the camera will run backwards if it can't
get over a hill (like a real roller coaster, and it you are using
friction, it will rock back and forth and come to a stop at the
bottom).
P.S. sign(X)= if (X<0) then return -1 else return 1
or sign(X)=X/abs(X) (You may want to test for X=0 first, and
return 1 if X=0, but if X ever equals 0, it means SPEED=0.)
P.P.S I can imagine cases where this might get stuck and act real
weird when it can't make it over a hill and tries to back up.
Hmmm… E=H*POW(F,T)-Y (or E=H-Y) and SPEED=sqrt(abs(E))*D should
work (start with D=1), but each frame test if sign(E) < 0, and if
it is then DON'T change T, but make D=-D. I just realized the
camera will turn around in all the examples where it goes
backwards. In the spline statements, if you change T+1 to T+D and
T-1 to T-D,
the camera won't turn around when you back up.
Ask if anything is confusing.
Read action !