unit ant_camera;

{$MODE FPC}
{$MODESWITCH AUTODEREF}
{$MODESWITCH DEFAULTPARAMETERS}
{$MODESWITCH OUT}
{$MODESWITCH RESULT}

interface

uses
  {$I deng_app_units.inc},
  dvector3f,
  dmatrix4f;

type
PCamera = ^TCamera;
TCamera = object
private
  FFOV: Single;
  FViewer, FTarget, FUp: TVec3f;

public
  Projection: TMat4f;
  View: TMat4f;
  // Model: TMat4f;

  procedure Init;
  procedure Done;

  procedure SetFOV(FOV: Single);
  procedure LookAt(const Viewer, Target, Up: TVec3f);

  procedure Setup(FrameFactor: Single);
end;

implementation

procedure TCamera.Init;
begin
  FViewer := Vec3f(0, -10.0, 10.0);
  FTarget := Vec3f(0, 0, 0);
  FUp := Vec3f(0, 0, 1.0);
  FFOV := 90;
end;

procedure TCamera.Done;
begin
end;

procedure TCamera.SetFOV(FOV: Single);
begin
end;

procedure TCamera.LookAt(const Viewer, Target, Up: TVec3f);
begin
  FViewer := Viewer;
  FTarget := Target;
  FUp := Up;
end;

procedure TCamera.Setup(FrameFactor: Single);
begin
  Eng.Draw.Start3D(FFOV);
  Eng.Draw.LookAt(FViewer, FTarget, FUp);
  Eng.Draw.GetModelViewMatrix(View);
  Eng.Draw.GetProjectionMatrix(Projection);
end;

end.
