Dies ist der Fehlercode ..Constant Objekt kann nicht als var-Parameter übergeben werden
multresult := mult(mult(temp, quatview), conjugate(temp));
Voll Verfahren
procedure TForm2.RotateCamera(var angle: Single; x: Single; y: Single; z: Single);
var
temp, QuatView, multResult : TQuaternion;
begin
temp.x := x * sin(Angle/2);
temp.y := y * sin(Angle/2);
temp.z := z * sin(Angle/2);
temp.w := cos(Angle/2);
quatview.x := camera1.Position.x;
quatview.y := camera1.Position.y;
quatview.z := camera1.Position.z;
quatview.w := 0;
multresult := mult(mult(temp, quatview), conjugate(temp));
camera1.Position.x := multresult.x;
camera1.Position.y := multresult.y;
camera1.Position.z := multresult.z;
end;
mult Funktion
function TForm2.mult(var A: TQuaternion; B: TQuaternion) :TQuaternion;
var
c : TQuaternion;
begin
C.x := A.w*B.x + A.x*B.w + A.y*B.z - A.z*B.y;
C.y := A.w*B.y - A.x*B.z + A.y*B.w + A.z*B.x;
C.z := A.w*B.z + A.x*B.y - A.y*B.x + A.z*B.w;
C.w := A.w*B.w - A.x*B.x - A.y*B.y - A.z*B.z;
result := C;
End;
und Konjugat
function TForm2.conjugate(var quat:TQuaternion) :TQuaternion;
begin
quat.x := -quat.x;
quat.y := -quat.y;
quat.z := -quat.z;
result := quat;
end;
und bei Bedarf TQuaternion
type
TQuaternion = class
x: single;
y: single;
z: single;
w: single;
end;
eine Ahnung, warum ich diesen Fehler und wie man es beheben?
Danke, guter Rat. Während ich versuchen werde, das wieder zu verwenden ... ab jetzt muss ich herausfinden, wie man das mit der Feuerwaffe-Kamera benutzt .. wie FMX hat Position (x, y, z) und rotateposition (x, y, z) Während alle Beispiele, die ich finden könnte, benutze opengls Aussehen (Positionx, y, z, Ansichtx, y, z, upx, y, z) so arbeiten, all dies herauszufinden. –