Traveling Through a 3D Scene
- Games like Doom and Quake work by moving the camera through a scene
- The code shown here moves the camera through a scene
- First you get the orientation of the camera, then you set its velocity along that vector
- If the user wants to look to his left or right, use the SetRotation routine
CODE:
procedure TSteerShip.Steer(Key: Integer);
var
direction, up: D3DVECTOR;
begin
FCamera.GetOrientation(FScene, direction, up);
case (Key) of
VK_UP: FCamera.SetVelocity(FScene, direction.x, direction.y, direction.z, False);
VK_DOWN: FCamera.SetVelocity(FScene, -direction.x, -direction.y, -direction.z, False);
VK_RIGHT: FCamera.SetRotation(FScene, 0.0, 1.0, 0.0, 0.1);
VK_LEFT: FCamera.SetRotation(FScene, 0.0, 1.0, 0.0, -0.1);
end;
end;