|
@@ -108,16 +108,22 @@ begin
|
|
m.W.W := 1; //}
|
|
m.W.W := 1; //}
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+//----------------------------------------------------
|
|
|
|
+
|
|
procedure ODERToGLSceneMatrix(var m: TGLMatrix; R: PdMatrix3; pos: PdVector3);
|
|
procedure ODERToGLSceneMatrix(var m: TGLMatrix; R: PdMatrix3; pos: PdVector3);
|
|
begin
|
|
begin
|
|
ODERToGLSceneMatrix(m, TdMatrix3_As3x4(R^), pos^);
|
|
ODERToGLSceneMatrix(m, TdMatrix3_As3x4(R^), pos^);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+//----------------------------------------------------
|
|
|
|
+
|
|
procedure ODERToGLSceneMatrix(var m: TGLMatrix; R: TdMatrix3; pos: TdVector3);
|
|
procedure ODERToGLSceneMatrix(var m: TGLMatrix; R: TdMatrix3; pos: TdVector3);
|
|
begin
|
|
begin
|
|
ODERToGLSceneMatrix(m, TdMatrix3_As3x4(R), pos);
|
|
ODERToGLSceneMatrix(m, TdMatrix3_As3x4(R), pos);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+//----------------------------------------------------
|
|
|
|
+
|
|
procedure DrawBox(Sides: TdVector3);
|
|
procedure DrawBox(Sides: TdVector3);
|
|
var
|
|
var
|
|
lx, ly, lz: single;
|
|
lx, ly, lz: single;
|
|
@@ -163,6 +169,8 @@ begin
|
|
gl.End_();
|
|
gl.End_();
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+//----------------------------------------------------
|
|
|
|
+
|
|
function GLSceneMatrixToODER(m: TGLMatrix): TdMatrix3;
|
|
function GLSceneMatrixToODER(m: TGLMatrix): TdMatrix3;
|
|
begin
|
|
begin
|
|
TransposeMatrix(m);
|
|
TransposeMatrix(m);
|
|
@@ -177,11 +185,15 @@ begin
|
|
Result[10] := m.Z.Z;
|
|
Result[10] := m.Z.Z;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+//----------------------------------------------------
|
|
|
|
+
|
|
procedure dsDrawBox(pos: PdVector3; R: PdMatrix3; Sides: TdVector3);
|
|
procedure dsDrawBox(pos: PdVector3; R: PdMatrix3; Sides: TdVector3);
|
|
begin
|
|
begin
|
|
dsDrawBox(pos^, r^, Sides);
|
|
dsDrawBox(pos^, r^, Sides);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+//----------------------------------------------------
|
|
|
|
+
|
|
procedure dsDrawBox(pos: TdVector3; R: TdMatrix3; Sides: TdVector3);
|
|
procedure dsDrawBox(pos: TdVector3; R: TdMatrix3; Sides: TdVector3);
|
|
begin
|
|
begin
|
|
setTransform(pos, R);
|
|
setTransform(pos, R);
|
|
@@ -215,6 +227,8 @@ end;
|
|
|
|
|
|
(*$WARNINGS OFF*)
|
|
(*$WARNINGS OFF*)
|
|
|
|
|
|
|
|
+//----------------------------------------------------
|
|
|
|
+
|
|
function ConvertdVector3ToVector3f(R: TdVector3): TVector3f;
|
|
function ConvertdVector3ToVector3f(R: TdVector3): TVector3f;
|
|
begin
|
|
begin
|
|
result.X := R[0];
|
|
result.X := R[0];
|
|
@@ -222,6 +236,8 @@ begin
|
|
result.Z := R[2];
|
|
result.Z := R[2];
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+//----------------------------------------------------
|
|
|
|
+
|
|
function ConvertdVector3ToVector3f(R: PdVector3): TVector3f;
|
|
function ConvertdVector3ToVector3f(R: PdVector3): TVector3f;
|
|
begin
|
|
begin
|
|
result.X := R[0];
|
|
result.X := R[0];
|
|
@@ -229,6 +245,8 @@ begin
|
|
result.Z := R[2];
|
|
result.Z := R[2];
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+//----------------------------------------------------
|
|
|
|
+
|
|
function ConvertdVector3ToVector4f(R: TdVector3): TVector4f; overload;
|
|
function ConvertdVector3ToVector4f(R: TdVector3): TVector4f; overload;
|
|
begin
|
|
begin
|
|
result.X := R[0];
|
|
result.X := R[0];
|
|
@@ -237,6 +255,8 @@ begin
|
|
result.W := 0;
|
|
result.W := 0;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+//----------------------------------------------------
|
|
|
|
+
|
|
function ConvertdVector3ToVector4f(R: PdVector3): TVector4f; overload;
|
|
function ConvertdVector3ToVector4f(R: PdVector3): TVector4f; overload;
|
|
begin
|
|
begin
|
|
result.X := R[0];
|
|
result.X := R[0];
|
|
@@ -245,6 +265,8 @@ begin
|
|
result.W := 0;
|
|
result.W := 0;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+//----------------------------------------------------
|
|
|
|
+
|
|
function ConvertdVector3ToAffineVector(R: PdVector3): TAffineVector; overload;
|
|
function ConvertdVector3ToAffineVector(R: PdVector3): TAffineVector; overload;
|
|
begin
|
|
begin
|
|
result.X := R[0];
|
|
result.X := R[0];
|
|
@@ -252,6 +274,8 @@ begin
|
|
result.Z := R[2];
|
|
result.Z := R[2];
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+//----------------------------------------------------
|
|
|
|
+
|
|
function ConvertdVector3ToAffineVector(R: TdVector3): TAffineVector; overload;
|
|
function ConvertdVector3ToAffineVector(R: TdVector3): TAffineVector; overload;
|
|
begin
|
|
begin
|
|
result.X := R[0];
|
|
result.X := R[0];
|
|
@@ -259,6 +283,8 @@ begin
|
|
result.Z := R[2];
|
|
result.Z := R[2];
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+//----------------------------------------------------
|
|
|
|
+
|
|
function ConvertVector3fTodVector3(R: TVector3f): TdVector3;
|
|
function ConvertVector3fTodVector3(R: TVector3f): TdVector3;
|
|
begin
|
|
begin
|
|
result[0] := R.X;
|
|
result[0] := R.X;
|
|
@@ -266,6 +292,8 @@ begin
|
|
result[2] := R.Z;
|
|
result[2] := R.Z;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+//----------------------------------------------------
|
|
|
|
+
|
|
function ConvertVector3fToPdVector3(R: TVector3f): PdVector3;
|
|
function ConvertVector3fToPdVector3(R: TVector3f): PdVector3;
|
|
begin
|
|
begin
|
|
result[0] := R.X;
|
|
result[0] := R.X;
|
|
@@ -273,6 +301,8 @@ begin
|
|
result[2] := R.Z;
|
|
result[2] := R.Z;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+//----------------------------------------------------
|
|
|
|
+
|
|
function ConvertVector4fTodVector3(R: TVector4f): TdVector3;
|
|
function ConvertVector4fTodVector3(R: TVector4f): TdVector3;
|
|
begin
|
|
begin
|
|
result[0] := R.X;
|
|
result[0] := R.X;
|
|
@@ -281,6 +311,8 @@ begin
|
|
result[3] := 0;
|
|
result[3] := 0;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+//----------------------------------------------------
|
|
|
|
+
|
|
function ConvertVector4fToPdVector3(R: TVector4f): PdVector3;
|
|
function ConvertVector4fToPdVector3(R: TVector4f): PdVector3;
|
|
begin
|
|
begin
|
|
result[0] := R.X;
|
|
result[0] := R.X;
|
|
@@ -296,12 +328,16 @@ begin
|
|
result := ConvertdVector3ToVector3f(dBodyGetPosition(Body));
|
|
result := ConvertdVector3ToVector3f(dBodyGetPosition(Body));
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+//----------------------------------------------------
|
|
|
|
+
|
|
procedure PositionSceneObjectForGeom(Geom: PdxGeom);
|
|
procedure PositionSceneObjectForGeom(Geom: PdxGeom);
|
|
begin
|
|
begin
|
|
if Assigned(Geom.Data) then
|
|
if Assigned(Geom.Data) then
|
|
PositionSceneObject(TGLBaseSceneObject(Geom.Data), Geom);
|
|
PositionSceneObject(TGLBaseSceneObject(Geom.Data), Geom);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+//----------------------------------------------------
|
|
|
|
+
|
|
function GLMatrixFromGeom(Geom: PdxGeom): TGLMatrix;
|
|
function GLMatrixFromGeom(Geom: PdxGeom): TGLMatrix;
|
|
var
|
|
var
|
|
pos, Pos2: PdVector3;
|
|
pos, Pos2: PdVector3;
|
|
@@ -344,6 +380,8 @@ begin
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+//----------------------------------------------------
|
|
|
|
+
|
|
function GLDirectionFromGeom(Geom: PdxGeom): TGLVector;
|
|
function GLDirectionFromGeom(Geom: PdxGeom): TGLVector;
|
|
var
|
|
var
|
|
m: TGLMatrix;
|
|
m: TGLMatrix;
|
|
@@ -353,6 +391,8 @@ begin
|
|
result := VectorNormalize(m.Z);
|
|
result := VectorNormalize(m.Z);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+//----------------------------------------------------
|
|
|
|
+
|
|
procedure PositionSceneObject(GLBaseSceneObject: TGLBaseSceneObject; Geom: PdxGeom);
|
|
procedure PositionSceneObject(GLBaseSceneObject: TGLBaseSceneObject; Geom: PdxGeom);
|
|
var
|
|
var
|
|
Scale: TAffineVector;
|
|
Scale: TAffineVector;
|
|
@@ -373,6 +413,8 @@ begin
|
|
Cube.CubeDepth := Sides[2]; // 2
|
|
Cube.CubeDepth := Sides[2]; // 2
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+//----------------------------------------------------
|
|
|
|
+
|
|
procedure CopyPosFromGeomToGL(Geom: PdxGeom; GLBaseSceneObject: TGLBaseSceneObject);
|
|
procedure CopyPosFromGeomToGL(Geom: PdxGeom; GLBaseSceneObject: TGLBaseSceneObject);
|
|
var
|
|
var
|
|
v: TGLVector;
|
|
v: TGLVector;
|
|
@@ -405,6 +447,8 @@ begin
|
|
dGeomSetRotation(Geom, R^);
|
|
dGeomSetRotation(Geom, R^);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+//----------------------------------------------------
|
|
|
|
+
|
|
function CreateGeomFromCube(Cube: TGLCube; Space: PdxSpace): PdxGeom;
|
|
function CreateGeomFromCube(Cube: TGLCube; Space: PdxSpace): PdxGeom;
|
|
var
|
|
var
|
|
Geom: PdxGeom;
|
|
Geom: PdxGeom;
|
|
@@ -414,6 +458,8 @@ begin
|
|
result := Geom;
|
|
result := Geom;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+//----------------------------------------------------
|
|
|
|
+
|
|
function CreateBodyFromCube(var Geom: PdxGeom; Cube: TGLCube; World: PdxWorld; Space: PdxSpace): PdxBody;
|
|
function CreateBodyFromCube(var Geom: PdxGeom; Cube: TGLCube; World: PdxWorld; Space: PdxSpace): PdxBody;
|
|
var
|
|
var
|
|
Body: PdxBody;
|
|
Body: PdxBody;
|
|
@@ -429,6 +475,8 @@ begin
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+//----------------------------------------------------
|
|
|
|
+
|
|
function CreateTriMeshFromBaseMesh(
|
|
function CreateTriMeshFromBaseMesh(
|
|
GLBaseMesh: TGLBaseMesh;
|
|
GLBaseMesh: TGLBaseMesh;
|
|
Space: PdxSpace;
|
|
Space: PdxSpace;
|
|
@@ -507,6 +555,8 @@ begin
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+//----------------------------------------------------
|
|
|
|
+
|
|
procedure CopyBodyFromCube(Body: PdxBody; var Geom: PdxGeom; Cube: TGLCube;
|
|
procedure CopyBodyFromCube(Body: PdxBody; var Geom: PdxGeom; Cube: TGLCube;
|
|
Space: PdxSpace);
|
|
Space: PdxSpace);
|
|
var
|
|
var
|
|
@@ -525,6 +575,8 @@ begin
|
|
Geom.data := Cube;
|
|
Geom.data := Cube;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+//----------------------------------------------------
|
|
|
|
+
|
|
function dBodyToBodyDistance(Body1, Body2: PdxBody): TdReal;
|
|
function dBodyToBodyDistance(Body1, Body2: PdxBody): TdReal;
|
|
begin
|
|
begin
|
|
result := dVector3Length(Vector3SUB(Body1.posr.pos, Body2.posr.pos));
|
|
result := dVector3Length(Vector3SUB(Body1.posr.pos, Body2.posr.pos));
|
|
@@ -549,6 +601,8 @@ begin
|
|
PositionSceneObject(TGLBaseSceneObject(GeomList[i].data), GeomList[i]);
|
|
PositionSceneObject(TGLBaseSceneObject(GeomList[i].data), GeomList[i]);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+//----------------------------------------------------
|
|
|
|
+
|
|
function CreateODEPlaneFromGLPlane(Plane: TGLPlane; Space: PdxSpace): PdxGeom;
|
|
function CreateODEPlaneFromGLPlane(Plane: TGLPlane; Space: PdxSpace): PdxGeom;
|
|
var
|
|
var
|
|
Pos, Direction: TGLVector;
|
|
Pos, Direction: TGLVector;
|