Commit 88b0293e authored by Martok's avatar Martok

[glcCamera] Add LookAt

parent 5ac0a0f3
......@@ -88,6 +88,7 @@ type
procedure Tilt(const aAngle: Single);
procedure Turn(const aAngle: Single);
procedure Roll(const aAngle: Single);
procedure LookAt(const aEye, aCenter, aUp: TgluVector3f);
procedure Activate;
function GetRay(const aPos: TgluVector2f): TgluRayf;
......@@ -326,6 +327,23 @@ begin
fPosition := gluMatrixMult(gluMatrixRotate(gluVector3f(0,0,1), aAngle), fPosition);
end;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure TglcCamera.LookAt(const aEye, aCenter, aUp: TgluVector3f);
var
f, up, s, u: TgluVector3f;
M: TgluMatrix4f;
begin
f:= gluVectorNormalize(aCenter - aEye);
up:= gluVectorNormalize(aUp);
s:= gluVectorNormalize(f >< up);
u:= s >< f;
M[0]:= gluVector4f(s[0], u[0], -f[0], 0.0);
M[1]:= gluVector4f(s[1], u[1], -f[1], 0.0);
M[2]:= gluVector4f(s[2], u[2], -f[2], 0.0);
M[3]:= gluVector4f( 0, 0, 0, 1.0);
fPosition := gluMatrixMult(M, gluMatrixTranslate(-1*aEye));
end;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure TglcCamera.Activate;
begin
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment