Quote Originally Posted by savage
I consciously kept the var keyword in there so that it is clear that the Object will be changed. Maybe I should explicitly define it as an out parameter, but I am unsure if FreePascal supports that keyword.
out is the same as var except the value going in is ignored. const, var and out are only mostly useful when dealing with record types. For objects they have no real benefit.

[pascal]
// these are used for moving and changing camera orientation
// through the MoveTo/LookTo methods
initPosition, finalPosition : TVector;
initLookAt, finalLookAt : TVector;[/pascal]
These vectors are never used.

[pascal] LookAtVelocity : TVector; // velocity for looking at objects
LookAtAcceleration : TVector; // acceleration for looking at objects[/pascal]
LookAtVelocity is referenced, but never created. LookAtAcceleration is never used.

[pascal] procedure UpdateLookAt;
procedure UpdateMoveTo;[/pascal]
How are these methods called if they are in the protected section?

[pascal] procedure LookAt( aX : TScalar; aY : TScalar; aZ : TScalar ); overload;
procedure LookAt( aLook : TVector ); overload;
procedure MoveTo( aX : TScalar; aY : TScalar; aZ : TScalar ); overload;
procedure MoveTo( aPosition : TVector ); overload;[/pascal]
I would provide a LookAt method that functions like most other LookAt functions where you provide the eye, target and up vectors.

[pascal] // right rotation along y-axis (yaw)
procedure RotateYaw( aRadians : TScalar );
procedure RotatePitch( aRadians : TScalar );
procedure RotateRoll( aRadians : TScalar );
end;[/pascal]
How about a Rotate(aAngle: TVector) where each element of the vector is the angle in one axis? That is quite common. Instead of (x, y, z), it is (pitch, yaw, roll).

[pascal]destructor TCamera.Destroy;
begin
if CameraPosition <> nil then
CameraPosition.Free;
if CameraLookAt <> nil then
CameraLookAt.Free;

if CameraForward <> nil then
CameraForward.Free;
if CameraUp <> nil then
CameraUp.Free;
if CameraRight <> nil then
CameraRight.Free;

if CameraVelocity <> nil then
CameraVelocity.Free;
if CameraAcceleration <> nil then
CameraAcceleration.Free;

if CalcVector <> nil then
CalcVector.Free;
inherited;
end;[/pascal]
You can call Free on a nil object with no ill effect. No need to check for nil before calling Free.

The Sine and Cosine operations should probably be a look-up table to speed things up, if you are so inclined .
The difference is not that great these days with these operations implemented in the FPU. If you do want it to be faster, call SinCos instead of calling Sin and Cos separately.