Browse Source

TMatrix from GLS.VectorGeometry renamed to TGLMatrix to be able use TMatrix from System.Math.Vectors without conflicts of names

GLScene 4 years ago
parent
commit
0bfd0aba28
89 changed files with 811 additions and 768 deletions
  1. 5 5
      AdvDemos/CPP/Quake3Demo/Unit1.cpp
  2. 2 2
      AdvDemos/CPP/Quake3Demo/Unit1.h
  3. 6 6
      AdvDemos/Delphi/Forest/Unit1.pas
  4. 3 3
      AdvDemos/Delphi/Quake3Demo/Unit1.pas
  5. 2 2
      Demos/CPP/collisions/BoxSphere/Unit1.cpp
  6. 1 1
      Demos/CPP/collisions/BoxSphere/Unit1.h
  7. 1 1
      Demos/CPP/glslshaders/Ocean/Unit1.cpp
  8. 1 1
      Demos/CPP/graph/projection/Unit1.cpp
  9. 1 1
      Demos/CPP/interface/camera/Unit1.cpp
  10. 1 1
      Demos/CPP/meshes/actorms3d/Unit1.cpp
  11. 2 2
      Demos/CPP/meshes/tiles/Unit1.h
  12. 3 3
      Demos/CPP/physics/NewtonDensity/Unit1.cpp
  13. 5 5
      Demos/CPP/specialsFX/ShadowmappingFBO/Unit1.h
  14. 3 3
      Demos/Delphi/collisions/BoxSphereFm.pas
  15. 1 1
      Demos/Delphi/graph/ProjectionFm.pas
  16. 1 1
      Demos/Delphi/interface/CameraFm.pas
  17. 10 10
      Demos/Delphi/meshes/Actorms3dFm.pas
  18. 1 1
      Demos/Delphi/physics/NewtonDensityFm.pas
  19. 5 5
      Demos/Delphi/specialsFX/ShadowFBOFm.pas
  20. 1 1
      Packages/GLScene_Cg_RT.dproj
  21. 1 1
      Packages/GLScene_Physics_RT.dproj
  22. 1 1
      Packages/GLScene_RT.dproj
  23. 1 1
      Packages/GLScene_Sounds_RT.dproj
  24. 3 3
      Source/DWS.OpenGL.pas
  25. 7 7
      Source/DWS.Scene.pas
  26. 25 25
      Source/DWS.VectorGeometry.pas
  27. 4 4
      Source/Formats.GL2.pas
  28. 5 5
      Source/Formats.X.pas
  29. 1 1
      Source/GLS.AnimatedSprite.pas
  30. 2 2
      Source/GLS.CameraController.pas
  31. 1 1
      Source/GLS.Canvas.pas
  32. 4 4
      Source/GLS.Collision.pas
  33. 5 5
      Source/GLS.Context.pas
  34. 1 1
      Source/GLS.EllipseCollision.pas
  35. 1 1
      Source/GLS.ExplosionFx.pas
  36. 9 9
      Source/GLS.File3DS.pas
  37. 6 6
      Source/GLS.File3DSSceneObjects.pas
  38. 2 2
      Source/GLS.FileASE.pas
  39. 2 2
      Source/GLS.FileB3D.pas
  40. 2 2
      Source/GLS.FileMD5.pas
  41. 1 1
      Source/GLS.FileMS3D.pas
  42. 1 1
      Source/GLS.FileOBJ.pas
  43. 3 2
      Source/GLS.FileQ3MD3.pas
  44. 2 2
      Source/GLS.FileVRML.pas
  45. 1 1
      Source/GLS.FileX.pas
  46. 2 2
      Source/GLS.FireFX.pas
  47. 1 1
      Source/GLS.GeomObjects.pas
  48. 10 10
      Source/GLS.GeometryBB.pas
  49. 7 7
      Source/GLS.Gizmo.pas
  50. 7 7
      Source/GLS.GizmoEx.pas
  51. 5 5
      Source/GLS.Imposter.pas
  52. 1 1
      Source/GLS.LensFlare.pas
  53. 1 1
      Source/GLS.LinePFX.pas
  54. 5 5
      Source/GLS.Material.pas
  55. 5 5
      Source/GLS.MaterialEx.pas
  56. 2 2
      Source/GLS.Mirror.pas
  57. 1 1
      Source/GLS.Objects.pas
  58. 5 5
      Source/GLS.Octree.pas
  59. 3 3
      Source/GLS.ParticleFX.pas
  60. 35 35
      Source/GLS.PipelineTransformation.pas
  61. 2 2
      Source/GLS.ProjectedTextures.pas
  62. 5 5
      Source/GLS.ProxyObjects.pas
  63. 155 123
      Source/GLS.Ragdoll.pas
  64. 1 0
      Source/GLS.RenderContextInfo.pas
  65. 50 50
      Source/GLS.Scene.pas
  66. 2 2
      Source/GLS.ShadowPlane.pas
  67. 2 2
      Source/GLS.ShadowVolume.pas
  68. 1 1
      Source/GLS.SpaceText.pas
  69. 1 1
      Source/GLS.Spline.pas
  70. 2 2
      Source/GLS.State.pas
  71. 7 7
      Source/GLS.Texture.pas
  72. 1 1
      Source/GLS.ThorFX.pas
  73. 8 8
      Source/GLS.Tree.pas
  74. 32 32
      Source/GLS.VectorFileObjects.pas
  75. 126 128
      Source/GLS.VectorGeometry.pas
  76. 4 4
      Source/GLS.VectorLists.pas
  77. 1 1
      Source/GLS.VectorTypes.pas
  78. 2 2
      Source/GLS.VectorTypesExt.pas
  79. 2 2
      Source/GLSL.ProjectedTextures.pas
  80. 4 4
      Source/GLSL.TextureShaders.pas
  81. 16 16
      Source/Physics.NGDManager.pas
  82. 5 5
      Source/Physics.NGDRagdoll.pas
  83. 30 30
      Source/Physics.ODEManager.pas
  84. 95 86
      Source/Physics.ODERagdoll.pas
  85. 3 2
      Source/Physics.ODESkeletonColliders.pas
  86. 12 12
      Source/Physics.ODEUtils.pas
  87. 3 3
      Source/Physics.SPIInertias.pas
  88. 2 2
      Source/Physics.SPIJoints.pas
  89. 1 0
      Source/Sounds.OpenAL.pas

+ 5 - 5
AdvDemos/CPP/Quake3Demo/Unit1.cpp

@@ -51,10 +51,10 @@ void __fastcall TForm1::FormCreate(TObject *Sender) {
 }
 }
 
 
 // ---------------------------------------------------------------------------
 // ---------------------------------------------------------------------------
-Glvectorgeometry::TMatrix __fastcall TForm1::InterpolateMatrix
-	(Glvectorgeometry::TMatrix m1, Glvectorgeometry::TMatrix m2, float delta) {
+Glvectorgeometry::TGLMatrix __fastcall TForm1::InterpolateMatrix
+	(Glvectorgeometry::TGLMatrix m1, Glvectorgeometry::TGLMatrix m2, float delta) {
 	int i, j;
 	int i, j;
-	Glvectorgeometry::TMatrix mat;
+	Glvectorgeometry::TGLMatrix mat;
 	// This is used for interpolating between 2 matrices. The result
 	// This is used for interpolating between 2 matrices. The result
 	// is used to reposition the model parts each frame.
 	// is used to reposition the model parts each frame.
 	//
 	//
@@ -140,8 +140,8 @@ void __fastcall TForm1::ComboBox2Change(TObject *Sender) {
 // ---------------------------------------------------------------------------
 // ---------------------------------------------------------------------------
 void __fastcall TForm1::GLCadencer1Progress(TObject *Sender,
 void __fastcall TForm1::GLCadencer1Progress(TObject *Sender,
 	const double deltaTime, const double newTime) {
 	const double deltaTime, const double newTime) {
-	Glvectorgeometry::TMatrix m1;
-	Glvectorgeometry::TMatrix m2;
+	Glvectorgeometry::TGLMatrix m1;
+	Glvectorgeometry::TGLMatrix m2;
 
 
 	// Set the transform for the torso
 	// Set the transform for the torso
 	m1 = LegsTags->GetTransform("tag_torso", Legs->CurrentFrame);
 	m1 = LegsTags->GetTransform("tag_torso", Legs->CurrentFrame);

+ 2 - 2
AdvDemos/CPP/Quake3Demo/Unit1.h

@@ -84,8 +84,8 @@ private:	// User declarations
 	TMD3TagList *TorsoTags;
 	TMD3TagList *TorsoTags;
 	TMD3TagList *WeaponTags;
 	TMD3TagList *WeaponTags;
 	void __fastcall BuildModel();
 	void __fastcall BuildModel();
-	Glvectorgeometry::TMatrix __fastcall InterpolateMatrix(
-	       Glvectorgeometry::TMatrix m1, Glvectorgeometry::TMatrix m2, Single Delta);
+	Glvectorgeometry::TGLMatrix __fastcall InterpolateMatrix(
+	       Glvectorgeometry::TGLMatrix m1, Glvectorgeometry::TGLMatrix m2, Single Delta);
 public:		// User declarations
 public:		// User declarations
 	__fastcall TForm1(TComponent* Owner);
 	__fastcall TForm1(TComponent* Owner);
 };
 };

+ 6 - 6
AdvDemos/Delphi/Forest/Unit1.pas

@@ -115,7 +115,7 @@ type
     lmp: TPoint;
     lmp: TPoint;
     camPitch, camTurn, camTime, curPitch, curTurn: Single;
     camPitch, camTurn, camTime, curPitch, curTurn: Single;
 
 
-    function GetTextureReflectionMatrix: TMatrix;
+    function GetTextureReflectionMatrix: TGLMatrix;
   public
   public
      
      
     TestTree: TGLTree;
     TestTree: TGLTree;
@@ -418,7 +418,7 @@ procedure TForm1.DOTreesRender(Sender: TObject;
 var
 var
   i: Integer;
   i: Integer;
   particle: TGLParticle;
   particle: TGLParticle;
-  TreeModelMatrix: TMatrix;
+  TreeModelMatrix: TGLMatrix;
 begin
 begin
   rci.GLStates.Disable(stBlend);
   rci.GLStates.Disable(stBlend);
   for i := 0 to nearTrees.Count - 1 do
   for i := 0 to nearTrees.Count - 1 do
@@ -504,7 +504,7 @@ procedure TForm1.DOInitializeReflectionRender(Sender: TObject;
   var rci: TGLRenderContextInfo);
   var rci: TGLRenderContextInfo);
 var
 var
   w, h: Integer;
   w, h: Integer;
-  refMat: TMatrix;
+  refMat: TGLMatrix;
   cameraPosBackup, cameraDirectionBackup: TGLVector;
   cameraPosBackup, cameraDirectionBackup: TGLVector;
   frustumBackup: TFrustum;
   frustumBackup: TFrustum;
   clipPlane: TDoubleHmgPlane;
   clipPlane: TDoubleHmgPlane;
@@ -607,7 +607,7 @@ const
   cWaveSpeed = 0.02;
   cWaveSpeed = 0.02;
   cSinScale = 0.02;
   cSinScale = 0.02;
 var
 var
-  tex0Matrix, tex1Matrix: TMatrix;
+  tex0Matrix, tex1Matrix: TGLMatrix;
   tWave: Single;
   tWave: Single;
   pos: TAffineVector;
   pos: TAffineVector;
   tex: TTexPoint;
   tex: TTexPoint;
@@ -743,9 +743,9 @@ end;
 // SetupReflectionMatrix
 // SetupReflectionMatrix
 //
 //
 
 
-function TForm1.GetTextureReflectionMatrix: TMatrix;
+function TForm1.GetTextureReflectionMatrix: TGLMatrix;
 const
 const
-  cBaseMat: TMatrix =
+  cBaseMat: TGLMatrix =
   (V:((X:0.5; Y:0;   Z:0; W:0),
   (V:((X:0.5; Y:0;   Z:0; W:0),
       (X:0;   Y:0.5; Z:0; W:0),
       (X:0;   Y:0.5; Z:0; W:0),
       (X:0;   Y:0; Z:1; W:0),
       (X:0;   Y:0; Z:1; W:0),

+ 3 - 3
AdvDemos/Delphi/Quake3Demo/Unit1.pas

@@ -84,7 +84,7 @@ type
   public
   public
     LegsTags, TorsoTags, WeaponTags: TMD3TagList;
     LegsTags, TorsoTags, WeaponTags: TMD3TagList;
     procedure BuildModel;
     procedure BuildModel;
-    function InterpolateMatrix(m1, m2: TMatrix; delta: single): TMatrix;
+    function InterpolateMatrix(m1, m2: TGLMatrix; delta: single): TGLMatrix;
   end;
   end;
 
 
 var
 var
@@ -278,7 +278,7 @@ begin
   LoadQ3Anims(Torso.Animations, '.\model\animation.cfg', 'TORSO');
   LoadQ3Anims(Torso.Animations, '.\model\animation.cfg', 'TORSO');
 end;
 end;
 
 
-function TForm1.InterpolateMatrix(m1, m2: TMatrix; delta: single): TMatrix;
+function TForm1.InterpolateMatrix(m1, m2: TGLMatrix; delta: single): TGLMatrix;
 var
 var
   i, j: Integer;
   i, j: Integer;
 begin
 begin
@@ -293,7 +293,7 @@ end;
 procedure TForm1.GLCadencer1Progress(Sender: TObject;
 procedure TForm1.GLCadencer1Progress(Sender: TObject;
   const deltaTime, newTime: Double);
   const deltaTime, newTime: Double);
 var
 var
-  m1, m2: TMatrix;
+  m1, m2: TGLMatrix;
 begin
 begin
   // Set the transform for the torso
   // Set the transform for the torso
   m1 := LegsTags.GetTransform('tag_torso', Legs.CurrentFrame);
   m1 := LegsTags.GetTransform('tag_torso', Legs.CurrentFrame);

+ 2 - 2
Demos/CPP/collisions/BoxSphere/Unit1.cpp

@@ -44,10 +44,10 @@ void __fastcall TForm1::CheckBox04Click(TObject *Sender)
 //---------------------------------------------------------------------------
 //---------------------------------------------------------------------------
 
 
 // Generates random rotation for matrix. It remains a scale.
 // Generates random rotation for matrix. It remains a scale.
-Gls::Vectorgeometry::TMatrix RandomRotation(Gls::Vectorgeometry::TMatrix const &aMatrix)
+Gls::Vectorgeometry::TGLMatrix RandomRotation(Gls::Vectorgeometry::TGLMatrix const &aMatrix)
 {
 {
   TAffineVector aScale;
   TAffineVector aScale;
-  Gls::Vectorgeometry::TMatrix mat;
+  Gls::Vectorgeometry::TGLMatrix mat;
   int I;
   int I;
 
 
   // Save scale.
   // Save scale.

+ 1 - 1
Demos/CPP/collisions/BoxSphere/Unit1.h

@@ -83,7 +83,7 @@ __published:	// IDE-managed Components
 private:	// User declarations
 private:	// User declarations
 	int mdx, mdy;
 	int mdx, mdy;
 	TAffineVector intersPoint, ResNormal, BoxScale, SpherePos;
 	TAffineVector intersPoint, ResNormal, BoxScale, SpherePos;
-	Gls::Vectorgeometry::TMatrix BoxMatrix;
+	Gls::Vectorgeometry::TGLMatrix BoxMatrix;
 	float SphereRadius;
 	float SphereRadius;
 public:		// User declarations
 public:		// User declarations
 	__fastcall TForm1(TComponent* Owner);
 	__fastcall TForm1(TComponent* Owner);

+ 1 - 1
Demos/CPP/glslshaders/Ocean/Unit1.cpp

@@ -93,7 +93,7 @@ void __fastcall TForm1::DOInitializeRender(TObject *Sender, TGLRenderContextInfo
 void __fastcall TForm1::GLUserShader1DoApply(TObject *Sender, TGLRenderContextInfo &rci)
 void __fastcall TForm1::GLUserShader1DoApply(TObject *Sender, TGLRenderContextInfo &rci)
 
 
 {
 {
-  TVector camPos;
+  TGLVector camPos;
 
 
   programObject = new TGLProgramHandle();
   programObject = new TGLProgramHandle();
   programObject->UseProgramObject();
   programObject->UseProgramObject();

+ 1 - 1
Demos/CPP/graph/projection/Unit1.cpp

@@ -39,7 +39,7 @@ void __fastcall TForm1::DirectOpenGLRender(TObject *Sender, TGLRenderContextInfo
 
 
 {
 {
    int i;
    int i;
-   Gls::Vectorgeometry::TMatrix mat;
+   Gls::Vectorgeometry::TGLMatrix mat;
    TGLVector p, pProj;
    TGLVector p, pProj;
    TGLVector planePoint, planeNormal;
    TGLVector planePoint, planeNormal;
    THmgPlane plane;
    THmgPlane plane;

+ 1 - 1
Demos/CPP/interface/camera/Unit1.cpp

@@ -57,7 +57,7 @@ void __fastcall TForm1::RadioGroup2Click(TObject *Sender)
 void __fastcall TForm1::GLCamera1CustomPerspective(const TRectangle &viewport, int width,
 void __fastcall TForm1::GLCamera1CustomPerspective(const TRectangle &viewport, int width,
           int height, int DPI, float &viewPortRadius)
           int height, int DPI, float &viewPortRadius)
 {
 {
-  Gls::Vectorgeometry::TMatrix Mat;
+  Gls::Vectorgeometry::TGLMatrix Mat;
 
 
   Mat =  CreatePerspectiveMatrix(GLCamera1->GetFieldOfView(Width)/4,
   Mat =  CreatePerspectiveMatrix(GLCamera1->GetFieldOfView(Width)/4,
 	Width / Height, GLCamera1->NearPlaneBias, GLCamera1->DepthOfView);
 	Width / Height, GLCamera1->NearPlaneBias, GLCamera1->DepthOfView);

+ 1 - 1
Demos/CPP/meshes/actorms3d/Unit1.cpp

@@ -50,7 +50,7 @@ int mdx, mdy;
 Gls::Vectorgeometry::TMatrix4f FBiasMatrix;
 Gls::Vectorgeometry::TMatrix4f FBiasMatrix;
 Gls::Vectorgeometry::TMatrix4f FLightModelViewMatrix;
 Gls::Vectorgeometry::TMatrix4f FLightModelViewMatrix;
 Gls::Vectorgeometry::TMatrix4f FLightProjMatrix;
 Gls::Vectorgeometry::TMatrix4f FLightProjMatrix;
-Gls::VectorGeometry::TMatrix FInvCameraMatrix;
+Gls::VectorGeometry::TGLMatrix FInvCameraMatrix;
 Gls::Vectorgeometry::TMatrix4f FEyeToLightMatrix;
 Gls::Vectorgeometry::TMatrix4f FEyeToLightMatrix;
 
 
 Gls::Vectorgeometry::TMatrix4f FLightModelViewMatrix2;
 Gls::Vectorgeometry::TMatrix4f FLightModelViewMatrix2;

+ 2 - 2
Demos/CPP/meshes/tiles/Unit1.h

@@ -47,8 +47,8 @@ __published:	// IDE-managed Components
 private:	// User declarations
 private:	// User declarations
 	int mx, my;
 	int mx, my;
 	int tileX, tileY;
 	int tileX, tileY;
-	TVector* mip;
-	TVector* translateOffset;
+	TGLVector* mip;
+	TGLVector* translateOffset;
 	bool translating;
 	bool translating;
 public:		// User declarations
 public:		// User declarations
 	__fastcall TForm1(TComponent* Owner);
 	__fastcall TForm1(TComponent* Owner);

+ 3 - 3
Demos/CPP/physics/NewtonDensity/Unit1.cpp

@@ -29,14 +29,14 @@ TForm1 *Form1;
 int __cdecl BuoyancyPlaneCallback(const int collisionID, void *context,
 int __cdecl BuoyancyPlaneCallback(const int collisionID, void *context,
   const PNGDFloat globalSpaceMatrix, PNGDFloat globalSpacePlane)
   const PNGDFloat globalSpaceMatrix, PNGDFloat globalSpacePlane)
 {
 {
-  Gls::Vectorgeometry::TMatrix *BodyMatrix;
+  Gls::Vectorgeometry::TGLMatrix *BodyMatrix;
   TGLVector PlaneEquation;
   TGLVector PlaneEquation;
-  Gls::Vectorgeometry::PVector pv;
+  Gls::Vectorgeometry::PGLVector pv;
   TForm1 *MyForm;
   TForm1 *MyForm;
 
 
   // Get the matrix of the actual body
   // Get the matrix of the actual body
 
 
-  BodyMatrix = (PMatrix) globalSpaceMatrix;
+  BodyMatrix = (PGLMatrix) globalSpaceMatrix;
   MyForm = (TForm1 *) context;
   MyForm = (TForm1 *) context;
 
 
   // this is the 4-value vector that represents the plane equation for
   // this is the 4-value vector that represents the plane equation for

+ 5 - 5
Demos/CPP/specialsFX/ShadowmappingFBO/Unit1.h

@@ -61,11 +61,11 @@ __published:	// IDE-managed Components
 	void __fastcall PrepareShadowMappingRender(TObject *Sender, TGLRenderContextInfo &rci);
 	void __fastcall PrepareShadowMappingRender(TObject *Sender, TGLRenderContextInfo &rci);
 
 
 private:	// User declarations
 private:	// User declarations
-	TMatrix FBiasMatrix;
-	TMatrix FLightModelViewMatrix;
-	TMatrix FLightProjMatrix;
-	TMatrix FInvCameraMatrix;
-	TMatrix FEyeToLightMatrix;
+	TGLMatrix FBiasMatrix;
+	TGLMatrix FLightModelViewMatrix;
+	TGLMatrix FLightProjMatrix;
+	TGLMatrix FInvCameraMatrix;
+	TGLMatrix FEyeToLightMatrix;
 public:		// User declarations
 public:		// User declarations
 	__fastcall TForm1(TComponent* Owner);
 	__fastcall TForm1(TComponent* Owner);
 };
 };

+ 3 - 3
Demos/Delphi/collisions/BoxSphereFm.pas

@@ -94,12 +94,12 @@ type
   private
   private
     mdx, mdy: Integer;
     mdx, mdy: Integer;
     intersPoint, ResNormal, BoxScale, SpherePos: TAffineVector;
     intersPoint, ResNormal, BoxScale, SpherePos: TAffineVector;
-    BoxMatrix: TMatrix;
+    BoxMatrix: TGLMatrix;
     SphereRadius: Single;
     SphereRadius: Single;
   end;
   end;
 
 
 // Generates random rotation for matrix. It remains a scale.
 // Generates random rotation for matrix. It remains a scale.
-function RandomRotation(const aMatrix: TMatrix): TMatrix;
+function RandomRotation(const aMatrix: TGLMatrix): TGLMatrix;
 
 
 var
 var
   FormBoxSphere: TFormBoxSphere;
   FormBoxSphere: TFormBoxSphere;
@@ -195,7 +195,7 @@ begin
 end;
 end;
 
 
 // Generates random rotation for matrix. It remains a scale.
 // Generates random rotation for matrix. It remains a scale.
-function RandomRotation(const aMatrix: TMatrix): TMatrix;
+function RandomRotation(const aMatrix: TGLMatrix): TGLMatrix;
 var
 var
   aScale: TAffineVector;
   aScale: TAffineVector;
   I:      Integer;
   I:      Integer;

+ 1 - 1
Demos/Delphi/graph/ProjectionFm.pas

@@ -73,7 +73,7 @@ end;
 procedure TFormProjection.DirectOpenGLRender(Sender: TObject; var rci: TGLRenderContextInfo);
 procedure TFormProjection.DirectOpenGLRender(Sender: TObject; var rci: TGLRenderContextInfo);
 var
 var
   i: Integer;
   i: Integer;
-  mat: TMatrix;
+  mat: TGLMatrix;
   p, pProj: TGLVector;
   p, pProj: TGLVector;
   planePoint, planeNormal: TGLVector;
   planePoint, planeNormal: TGLVector;
   plane: THmgPlane;
   plane: THmgPlane;

+ 1 - 1
Demos/Delphi/interface/CameraFm.pas

@@ -152,7 +152,7 @@ end;
 procedure TFormCamera.GLCamera1CustomPerspective(const viewport: TRectangle;
 procedure TFormCamera.GLCamera1CustomPerspective(const viewport: TRectangle;
   width, height, DPI: Integer; var viewPortRadius: Single);
   width, height, DPI: Integer; var viewPortRadius: Single);
 var
 var
-  Mat: TMatrix;
+  Mat: TGLMatrix;
 begin
 begin
   Mat :=  CreatePerspectiveMatrix(GLCamera1.GetFieldOfView(Width)/4,
   Mat :=  CreatePerspectiveMatrix(GLCamera1.GetFieldOfView(Width)/4,
     Width / Height, GLCamera1.NearPlaneBias, GLCamera1.DepthOfView);
     Width / Height, GLCamera1.NearPlaneBias, GLCamera1.DepthOfView);

+ 10 - 10
Demos/Delphi/meshes/Actorms3dFm.pas

@@ -107,16 +107,16 @@ var
   mdx: Integer;
   mdx: Integer;
   mdy: integer;
   mdy: integer;
 
 
-  FBiasMatrix: TMatrix;
-  FLightModelViewMatrix: TMatrix;
-  FLightProjMatrix: TMatrix;
-  FInvCameraMatrix: TMatrix;
-  FEyeToLightMatrix: TMatrix;
-
-  FLightModelViewMatrix2: TMatrix;
-  FLightProjMatrix2: TMatrix;
-  FInvCameraMatrix2: TMatrix;
-  FEyeToLightMatrix2: TMatrix;
+  FBiasMatrix: TGLMatrix;
+  FLightModelViewMatrix: TGLMatrix;
+  FLightProjMatrix: TGLMatrix;
+  FInvCameraMatrix: TGLMatrix;
+  FEyeToLightMatrix: TGLMatrix;
+
+  FLightModelViewMatrix2: TGLMatrix;
+  FLightProjMatrix2: TGLMatrix;
+  FInvCameraMatrix2: TGLMatrix;
+  FEyeToLightMatrix2: TGLMatrix;
 
 
 implementation
 implementation
 
 

+ 1 - 1
Demos/Delphi/physics/NewtonDensityFm.pas

@@ -82,7 +82,7 @@ function BuoyancyPlaneCallback(const collisionID: Integer; context: Pointer;
   const globalSpaceMatrix: PNGDFloat; globalSpacePlane: PNGDFloat): Integer;
   const globalSpaceMatrix: PNGDFloat; globalSpacePlane: PNGDFloat): Integer;
   cdecl;
   cdecl;
 var
 var
-  BodyMatrix: TMatrix;
+  BodyMatrix: TGLMatrix;
   PlaneEquation: TGLVector;
   PlaneEquation: TGLVector;
   pv: PGLVector;
   pv: PGLVector;
   MyForm: TFormNewtonDensity;
   MyForm: TFormNewtonDensity;

+ 5 - 5
Demos/Delphi/specialsFX/ShadowFBOFm.pas

@@ -82,11 +82,11 @@ type
   private
   private
      
      
 
 
-    FBiasMatrix: TMatrix;
-    FLightModelViewMatrix: TMatrix;
-    FLightProjMatrix: TMatrix;
-    FInvCameraMatrix: TMatrix;
-    FEyeToLightMatrix: TMatrix;
+    FBiasMatrix: TGLMatrix;
+    FLightModelViewMatrix: TGLMatrix;
+    FLightProjMatrix: TGLMatrix;
+    FInvCameraMatrix: TGLMatrix;
+    FEyeToLightMatrix: TGLMatrix;
   public
   public
      
      
   end;
   end;

+ 1 - 1
Packages/GLScene_Cg_RT.dproj

@@ -8,7 +8,7 @@
         <AppType>Package</AppType>
         <AppType>Package</AppType>
         <FrameworkType>VCL</FrameworkType>
         <FrameworkType>VCL</FrameworkType>
         <ProjectVersion>19.0</ProjectVersion>
         <ProjectVersion>19.0</ProjectVersion>
-        <Platform Condition="'$(Platform)'==''">Win32</Platform>
+        <Platform Condition="'$(Platform)'==''">Win64</Platform>
     </PropertyGroup>
     </PropertyGroup>
     <PropertyGroup Condition="'$(Config)'=='Base' or '$(Base)'!=''">
     <PropertyGroup Condition="'$(Config)'=='Base' or '$(Base)'!=''">
         <Base>true</Base>
         <Base>true</Base>

+ 1 - 1
Packages/GLScene_Physics_RT.dproj

@@ -8,7 +8,7 @@
         <AppType>Package</AppType>
         <AppType>Package</AppType>
         <FrameworkType>VCL</FrameworkType>
         <FrameworkType>VCL</FrameworkType>
         <ProjectVersion>19.0</ProjectVersion>
         <ProjectVersion>19.0</ProjectVersion>
-        <Platform Condition="'$(Platform)'==''">Win32</Platform>
+        <Platform Condition="'$(Platform)'==''">Win64</Platform>
     </PropertyGroup>
     </PropertyGroup>
     <PropertyGroup Condition="'$(Config)'=='Base' or '$(Base)'!=''">
     <PropertyGroup Condition="'$(Config)'=='Base' or '$(Base)'!=''">
         <Base>true</Base>
         <Base>true</Base>

+ 1 - 1
Packages/GLScene_RT.dproj

@@ -8,7 +8,7 @@
         <AppType>Package</AppType>
         <AppType>Package</AppType>
         <FrameworkType>VCL</FrameworkType>
         <FrameworkType>VCL</FrameworkType>
         <ProjectVersion>19.0</ProjectVersion>
         <ProjectVersion>19.0</ProjectVersion>
-        <Platform Condition="'$(Platform)'==''">Win64</Platform>
+        <Platform Condition="'$(Platform)'==''">Win32</Platform>
     </PropertyGroup>
     </PropertyGroup>
     <PropertyGroup Condition="'$(Config)'=='Base' or '$(Base)'!=''">
     <PropertyGroup Condition="'$(Config)'=='Base' or '$(Base)'!=''">
         <Base>true</Base>
         <Base>true</Base>

+ 1 - 1
Packages/GLScene_Sounds_RT.dproj

@@ -8,7 +8,7 @@
         <AppType>Package</AppType>
         <AppType>Package</AppType>
         <FrameworkType>VCL</FrameworkType>
         <FrameworkType>VCL</FrameworkType>
         <ProjectVersion>19.0</ProjectVersion>
         <ProjectVersion>19.0</ProjectVersion>
-        <Platform Condition="'$(Platform)'==''">Win32</Platform>
+        <Platform Condition="'$(Platform)'==''">Win64</Platform>
     </PropertyGroup>
     </PropertyGroup>
     <PropertyGroup Condition="'$(Config)'=='Base' or '$(Base)'!=''">
     <PropertyGroup Condition="'$(Config)'=='Base' or '$(Base)'!=''">
         <Base>true</Base>
         <Base>true</Base>

+ 3 - 3
Source/DWS.OpenGL.pas

@@ -285,7 +285,7 @@ begin
   RegisterComponents('GLScene DWS', [TdwsOpenGLUnit]);
   RegisterComponents('GLScene DWS', [TdwsOpenGLUnit]);
 end;
 end;
 
 
-function GetMatrixFromInfo(Info : IInfo) : TMatrix;
+function GetMatrixFromInfo(Info : IInfo) : TGLMatrix;
 var
 var
   i : Integer;
   i : Integer;
 begin
 begin
@@ -1048,7 +1048,7 @@ begin
   TGLPushMatrix.Create(SymbolTable, 'glPushMatrix', [], '');
   TGLPushMatrix.Create(SymbolTable, 'glPushMatrix', [], '');
   TGLPopMatrix.Create(SymbolTable, 'glPopMatrix', [], '');
   TGLPopMatrix.Create(SymbolTable, 'glPopMatrix', [], '');
   TGLLoadIdentity.Create(SymbolTable, 'glLoadIdentity', [], '');
   TGLLoadIdentity.Create(SymbolTable, 'glLoadIdentity', [], '');
-  TGLLoadMatrixf.Create(SymbolTable, 'glLoadMatrixf', ['m', 'TMatrix'], '');
+  TGLLoadMatrixf.Create(SymbolTable, 'glLoadMatrixf', ['m', 'TGLMatrix'], '');
   TGLTranslatef.Create(SymbolTable, 'glTranslatef', ['x', 'Float', 'y', 'Float', 'z', 'Float'], '');
   TGLTranslatef.Create(SymbolTable, 'glTranslatef', ['x', 'Float', 'y', 'Float', 'z', 'Float'], '');
   TGLRotatef.Create(SymbolTable, 'glRotatef', ['angle', 'Float', 'x', 'Float', 'y', 'Float', 'z', 'Float'], '');
   TGLRotatef.Create(SymbolTable, 'glRotatef', ['angle', 'Float', 'x', 'Float', 'y', 'Float', 'z', 'Float'], '');
   TGLScalef.Create(SymbolTable, 'glScalef', ['x', 'Float', 'y', 'Float', 'z', 'Float'], '');
   TGLScalef.Create(SymbolTable, 'glScalef', ['x', 'Float', 'y', 'Float', 'z', 'Float'], '');
@@ -2111,7 +2111,7 @@ end;
 
 
 procedure TGLLoadMatrixf.Execute;
 procedure TGLLoadMatrixf.Execute;
 var
 var
-  m: TMatrix;
+  m: TGLMatrix;
 begin
 begin
   m := GetMatrixFromInfo(Info.Vars['m']);
   m := GetMatrixFromInfo(Info.Vars['m']);
   glLoadMatrixf(@m[0]);
   glLoadMatrixf(@m[0]);

+ 7 - 7
Source/DWS.Scene.pas

@@ -336,7 +336,7 @@ begin
     Info.Element([i]).Value := vec[i];
     Info.Element([i]).Value := vec[i];
 end;
 end;
 
 
-function GetMatrixFromInfo(Info: IInfo): TMatrix;
+function GetMatrixFromInfo(Info: IInfo): TGLMatrix;
 var
 var
   i: Integer;
   i: Integer;
 begin
 begin
@@ -346,7 +346,7 @@ begin
       .Value, Info.Element([i]).Element([3]).Value);
       .Value, Info.Element([i]).Element([3]).Value);
 end;
 end;
 
 
-procedure SetInfoFromMatrix(Info: IInfo; mat: TMatrix);
+procedure SetInfoFromMatrix(Info: IInfo; mat: TGLMatrix);
 var
 var
   i, j: Integer;
   i, j: Integer;
 begin
 begin
@@ -930,16 +930,16 @@ begin
       [], 'Boolean', ClassSym, SymbolTable);
       [], 'Boolean', ClassSym, SymbolTable);
   if not Assigned(ClassSym.Members.FindLocal('SetMatrix')) then
   if not Assigned(ClassSym.Members.FindLocal('SetMatrix')) then
     TGLBaseSceneObjectSetMatrixMethod.Create(mkProcedure, [], 0, 'SetMatrix',
     TGLBaseSceneObjectSetMatrixMethod.Create(mkProcedure, [], 0, 'SetMatrix',
-      ['Value', 'TMatrix'], '', ClassSym, SymbolTable);
+      ['Value', 'TGLMatrix'], '', ClassSym, SymbolTable);
   if not Assigned(ClassSym.Members.FindLocal('GetMatrix')) then
   if not Assigned(ClassSym.Members.FindLocal('GetMatrix')) then
     TGLBaseSceneObjectGetMatrixMethod.Create(mkFunction, [], 0, 'GetMatrix', [],
     TGLBaseSceneObjectGetMatrixMethod.Create(mkFunction, [], 0, 'GetMatrix', [],
-      'TMatrix', ClassSym, SymbolTable);
+      'TGLMatrix', ClassSym, SymbolTable);
   if not Assigned(ClassSym.Members.FindLocal('AbsoluteMatrix')) then
   if not Assigned(ClassSym.Members.FindLocal('AbsoluteMatrix')) then
     TGLBaseSceneObjectAbsoluteMatrixMethod.Create(mkFunction, [], 0,
     TGLBaseSceneObjectAbsoluteMatrixMethod.Create(mkFunction, [], 0,
-      'AbsoluteMatrix', [], 'TMatrix', ClassSym, SymbolTable);
+      'AbsoluteMatrix', [], 'TGLMatrix', ClassSym, SymbolTable);
   if not Assigned(ClassSym.Members.FindLocal('InvAbsoluteMatrix')) then
   if not Assigned(ClassSym.Members.FindLocal('InvAbsoluteMatrix')) then
     TGLBaseSceneObjectInvAbsoluteMatrixMethod.Create(mkFunction, [], 0,
     TGLBaseSceneObjectInvAbsoluteMatrixMethod.Create(mkFunction, [], 0,
-      'InvAbsoluteMatrix', [], 'TMatrix', ClassSym, SymbolTable);
+      'InvAbsoluteMatrix', [], 'TGLMatrix', ClassSym, SymbolTable);
   if not Assigned(ClassSym.Members.FindLocal('SetAbsolutePosition')) then
   if not Assigned(ClassSym.Members.FindLocal('SetAbsolutePosition')) then
     TGLBaseSceneObjectSetAbsolutePositionMethod.Create(mkProcedure, [], 0,
     TGLBaseSceneObjectSetAbsolutePositionMethod.Create(mkProcedure, [], 0,
       'SetAbsolutePosition', ['Value', 'TGLVector'], '', ClassSym, SymbolTable);
       'SetAbsolutePosition', ['Value', 'TGLVector'], '', ClassSym, SymbolTable);
@@ -1021,7 +1021,7 @@ begin
   // Properties
   // Properties
   AddPropertyToClass('Visible', 'Boolean', 'GetVisible', 'SetVisible', '',
   AddPropertyToClass('Visible', 'Boolean', 'GetVisible', 'SetVisible', '',
     False, ClassSym, SymbolTable);
     False, ClassSym, SymbolTable);
-  AddPropertyToClass('Matrix', 'TMatrix', 'GetMatrix', 'SetMatrix', '', False,
+  AddPropertyToClass('Matrix', 'TGLMatrix', 'GetMatrix', 'SetMatrix', '', False,
     ClassSym, SymbolTable);
     ClassSym, SymbolTable);
   AddPropertyToClass('AbsolutePosition', 'TGLVector', 'GetAbsolutePosition',
   AddPropertyToClass('AbsolutePosition', 'TGLVector', 'GetAbsolutePosition',
     'SetAbsolutePosition', '', False, ClassSym, SymbolTable);
     'SetAbsolutePosition', '', False, ClassSym, SymbolTable);

+ 25 - 25
Source/DWS.VectorGeometry.pas

@@ -159,7 +159,7 @@ begin
     Info.Element([i]).Value := vec[i];
     Info.Element([i]).Value := vec[i];
 end;
 end;
 
 
-function GetMatrixFromInfo(Info: IInfo): TMatrix;
+function GetMatrixFromInfo(Info: IInfo): TGLMatrix;
 var
 var
   i: Integer;
   i: Integer;
 begin
 begin
@@ -169,7 +169,7 @@ begin
       .Value, Info.Element([i]).Element([3]).Value);
       .Value, Info.Element([i]).Element([3]).Value);
 end;
 end;
 
 
-procedure SetInfoFromMatrix(Info: IInfo; mat: TMatrix);
+procedure SetInfoFromMatrix(Info: IInfo; mat: TGLMatrix);
 var
 var
   i, j: Integer;
   i, j: Integer;
 begin
 begin
@@ -187,7 +187,7 @@ begin
   // Array types
   // Array types
   SymbolTable.AddSymbol(TStaticArraySymbol.Create('TGLVector',
   SymbolTable.AddSymbol(TStaticArraySymbol.Create('TGLVector',
     FloatSymbol, 0, 3));
     FloatSymbol, 0, 3));
-  SymbolTable.AddSymbol(TStaticArraySymbol.Create('TMatrix',
+  SymbolTable.AddSymbol(TStaticArraySymbol.Create('TGLMatrix',
     SymbolTable.FindSymbol('TGLVector'), 0, 3));
     SymbolTable.FindSymbol('TGLVector'), 0, 3));
 
 
   // Vector functions
   // Vector functions
@@ -217,30 +217,30 @@ begin
   TVectorNormalizeFunction.Create(SymbolTable, 'VectorNormalize',
   TVectorNormalizeFunction.Create(SymbolTable, 'VectorNormalize',
     ['v', 'TGLVector'], 'TGLVector');
     ['v', 'TGLVector'], 'TGLVector');
   TVectorTransformFunction.Create(SymbolTable, 'VectorTransform',
   TVectorTransformFunction.Create(SymbolTable, 'VectorTransform',
-    ['v', 'TGLVector', 'm', 'TMatrix'], 'TGLVector');
+    ['v', 'TGLVector', 'm', 'TGLMatrix'], 'TGLVector');
 
 
   // Matrix function
   // Matrix function
   TInvertMatrixFunction.Create(SymbolTable, 'InvertMatrix',
   TInvertMatrixFunction.Create(SymbolTable, 'InvertMatrix',
-    ['@mat', 'TMatrix'], '');
+    ['@mat', 'TGLMatrix'], '');
   TTransposeMatrixFunction.Create(SymbolTable, 'TransposeMatrix',
   TTransposeMatrixFunction.Create(SymbolTable, 'TransposeMatrix',
-    ['@mat', 'TMatrix'], '');
+    ['@mat', 'TGLMatrix'], '');
   TMatrixMultiplyFunction.Create(SymbolTable, 'MatrixMultiply',
   TMatrixMultiplyFunction.Create(SymbolTable, 'MatrixMultiply',
-    ['m1', 'TMatrix', 'm2', 'TMatrix'], 'TMatrix');
+    ['m1', 'TGLMatrix', 'm2', 'TGLMatrix'], 'TGLMatrix');
   TCreateScaleMatrixFunction.Create(SymbolTable, 'CreateScaleMatrix',
   TCreateScaleMatrixFunction.Create(SymbolTable, 'CreateScaleMatrix',
-    ['v', 'TGLVector'], 'TMatrix');
+    ['v', 'TGLVector'], 'TGLMatrix');
   TCreateTranslationMatrixFunction.Create(SymbolTable,
   TCreateTranslationMatrixFunction.Create(SymbolTable,
-    'CreateTranslationMatrix', ['v', 'TGLVector'], 'TMatrix');
+    'CreateTranslationMatrix', ['v', 'TGLVector'], 'TGLMatrix');
   TCreateScaleAndTranslationMatrixFunction.Create(SymbolTable,
   TCreateScaleAndTranslationMatrixFunction.Create(SymbolTable,
     'CreateScaleAndTranslationMatrix', ['scale', 'TGLVector', 'offset',
     'CreateScaleAndTranslationMatrix', ['scale', 'TGLVector', 'offset',
-    'TGLVector'], 'TMatrix');
+    'TGLVector'], 'TGLMatrix');
   TCreateRotationMatrixXFunction.Create(SymbolTable, 'CreateRotationMatrixX',
   TCreateRotationMatrixXFunction.Create(SymbolTable, 'CreateRotationMatrixX',
-    ['angle', 'Float'], 'TMatrix');
+    ['angle', 'Float'], 'TGLMatrix');
   TCreateRotationMatrixYFunction.Create(SymbolTable, 'CreateRotationMatrixY',
   TCreateRotationMatrixYFunction.Create(SymbolTable, 'CreateRotationMatrixY',
-    ['angle', 'Float'], 'TMatrix');
+    ['angle', 'Float'], 'TGLMatrix');
   TCreateRotationMatrixZFunction.Create(SymbolTable, 'CreateRotationMatrixZ',
   TCreateRotationMatrixZFunction.Create(SymbolTable, 'CreateRotationMatrixZ',
-    ['angle', 'Float'], 'TMatrix');
+    ['angle', 'Float'], 'TGLMatrix');
   TCreateRotationMatrixFunction.Create(SymbolTable, 'CreateRotationMatrix',
   TCreateRotationMatrixFunction.Create(SymbolTable, 'CreateRotationMatrix',
-    ['anAxis', 'TGLVector', 'angle', 'Float'], 'TMatrix');
+    ['anAxis', 'TGLVector', 'angle', 'Float'], 'TGLMatrix');
 end;
 end;
 
 
 constructor TdwsVectorGeometryUnit.Create(AOwner: TComponent);
 constructor TdwsVectorGeometryUnit.Create(AOwner: TComponent);
@@ -368,7 +368,7 @@ end;
 procedure TVectorTransformFunction.Execute;
 procedure TVectorTransformFunction.Execute;
 var
 var
   v, vr: TGLVector;
   v, vr: TGLVector;
-  mat: TMatrix;
+  mat: TGLMatrix;
 begin
 begin
   v := GetVectorFromInfo(Info.Vars['v']);
   v := GetVectorFromInfo(Info.Vars['v']);
   mat := GetMatrixFromInfo(Info.Vars['mat']);
   mat := GetMatrixFromInfo(Info.Vars['mat']);
@@ -378,7 +378,7 @@ end;
 
 
 procedure TInvertMatrixFunction.Execute;
 procedure TInvertMatrixFunction.Execute;
 var
 var
-  mat: TMatrix;
+  mat: TGLMatrix;
 begin
 begin
   mat := GetMatrixFromInfo(Info.Vars['mat']);
   mat := GetMatrixFromInfo(Info.Vars['mat']);
   InvertMatrix(mat);
   InvertMatrix(mat);
@@ -387,7 +387,7 @@ end;
 
 
 procedure TTransposeMatrixFunction.Execute;
 procedure TTransposeMatrixFunction.Execute;
 var
 var
-  mat: TMatrix;
+  mat: TGLMatrix;
 begin
 begin
   mat := GetMatrixFromInfo(Info.Vars['mat']);
   mat := GetMatrixFromInfo(Info.Vars['mat']);
   TransposeMatrix(mat);
   TransposeMatrix(mat);
@@ -396,7 +396,7 @@ end;
 
 
 procedure TMatrixMultiplyFunction.Execute;
 procedure TMatrixMultiplyFunction.Execute;
 var
 var
-  m1, m2, mr: TMatrix;
+  m1, m2, mr: TGLMatrix;
 begin
 begin
   m1 := GetMatrixFromInfo(Info.Vars['m1']);
   m1 := GetMatrixFromInfo(Info.Vars['m1']);
   m2 := GetMatrixFromInfo(Info.Vars['m2']);
   m2 := GetMatrixFromInfo(Info.Vars['m2']);
@@ -407,7 +407,7 @@ end;
 procedure TCreateScaleMatrixFunction.Execute;
 procedure TCreateScaleMatrixFunction.Execute;
 var
 var
   v: TGLVector;
   v: TGLVector;
-  mr: TMatrix;
+  mr: TGLMatrix;
 begin
 begin
   v := GetVectorFromInfo(Info.Vars['v']);
   v := GetVectorFromInfo(Info.Vars['v']);
   mr := CreateScaleMatrix(v);
   mr := CreateScaleMatrix(v);
@@ -417,7 +417,7 @@ end;
 procedure TCreateTranslationMatrixFunction.Execute;
 procedure TCreateTranslationMatrixFunction.Execute;
 var
 var
   v: TGLVector;
   v: TGLVector;
-  mr: TMatrix;
+  mr: TGLMatrix;
 begin
 begin
   v := GetVectorFromInfo(Info.Vars['v']);
   v := GetVectorFromInfo(Info.Vars['v']);
   mr := CreateTranslationMatrix(v);
   mr := CreateTranslationMatrix(v);
@@ -427,7 +427,7 @@ end;
 procedure TCreateScaleAndTranslationMatrixFunction.Execute;
 procedure TCreateScaleAndTranslationMatrixFunction.Execute;
 var
 var
   scale, offset: TGLVector;
   scale, offset: TGLVector;
-  mr: TMatrix;
+  mr: TGLMatrix;
 begin
 begin
   scale := GetVectorFromInfo(Info.Vars['scale']);
   scale := GetVectorFromInfo(Info.Vars['scale']);
   offset := GetVectorFromInfo(Info.Vars['offset']);
   offset := GetVectorFromInfo(Info.Vars['offset']);
@@ -438,7 +438,7 @@ end;
 procedure TCreateRotationMatrixXFunction.Execute;
 procedure TCreateRotationMatrixXFunction.Execute;
 var
 var
   angle: Single;
   angle: Single;
-  mr: TMatrix;
+  mr: TGLMatrix;
 begin
 begin
   angle := Info['angle'];
   angle := Info['angle'];
   mr := CreateRotationMatrixX(angle);
   mr := CreateRotationMatrixX(angle);
@@ -448,7 +448,7 @@ end;
 procedure TCreateRotationMatrixYFunction.Execute;
 procedure TCreateRotationMatrixYFunction.Execute;
 var
 var
   angle: Single;
   angle: Single;
-  mr: TMatrix;
+  mr: TGLMatrix;
 begin
 begin
   angle := Info['angle'];
   angle := Info['angle'];
   mr := CreateRotationMatrixY(angle);
   mr := CreateRotationMatrixY(angle);
@@ -458,7 +458,7 @@ end;
 procedure TCreateRotationMatrixZFunction.Execute;
 procedure TCreateRotationMatrixZFunction.Execute;
 var
 var
   angle: Single;
   angle: Single;
-  mr: TMatrix;
+  mr: TGLMatrix;
 begin
 begin
   angle := Info['angle'];
   angle := Info['angle'];
   mr := CreateRotationMatrixZ(angle);
   mr := CreateRotationMatrixZ(angle);
@@ -469,7 +469,7 @@ procedure TCreateRotationMatrixFunction.Execute;
 var
 var
   angle: Single;
   angle: Single;
   anAxis: TGLVector;
   anAxis: TGLVector;
-  mr: TMatrix;
+  mr: TGLMatrix;
 begin
 begin
   anAxis := GetVectorFromInfo(Info.Vars['anAxis']);
   anAxis := GetVectorFromInfo(Info.Vars['anAxis']);
   angle := Info['angle'];
   angle := Info['angle'];

+ 4 - 4
Source/Formats.GL2.pas

@@ -129,7 +129,7 @@ type
     BoneIndices: array of integer;
     BoneIndices: array of integer;
     CompBonePool: array of TGLACompQuatBone;
     CompBonePool: array of TGLACompQuatBone;
     function GetCompressedMatrix(Frame, Bone: integer): TGLACompQuatBone;
     function GetCompressedMatrix(Frame, Bone: integer): TGLACompQuatBone;
-    function GetUnCompressedMatrix(Frame, Bone: integer): TMatrix;
+    function GetUnCompressedMatrix(Frame, Bone: integer): TGLMatrix;
     procedure LoadFromStream(aStream: TStream);
     procedure LoadFromStream(aStream: TStream);
   end;
   end;
 
 
@@ -139,7 +139,7 @@ function G2_GetVertBoneIndex(const vert: TGLMVertex;
 function G2_GetVertBoneWeight(const vert: TGLMVertex; iWeightNum: Cardinal;
 function G2_GetVertBoneWeight(const vert: TGLMVertex; iWeightNum: Cardinal;
   var fTotalWeight: single; const iNumWeights: Cardinal): single;
   var fTotalWeight: single; const iNumWeights: Cardinal): single;
 
 
-procedure MC_UnCompressQuat(var mat: TMatrix; const comp: TGLACompQuatBone);
+procedure MC_UnCompressQuat(var mat: TGLMatrix; const comp: TGLACompQuatBone);
 
 
 // ------------------------------------------------------------------
 // ------------------------------------------------------------------
 implementation
 implementation
@@ -198,7 +198,7 @@ end;
 // Adapted from matcomp.c
 // Adapted from matcomp.c
 // void MC_UnCompressQuat(float mat[3][4],const unsigned char * comp)
 // void MC_UnCompressQuat(float mat[3][4],const unsigned char * comp)
 
 
-procedure MC_UnCompressQuat(var mat: TMatrix; const comp: TGLACompQuatBone);
+procedure MC_UnCompressQuat(var mat: TGLMatrix; const comp: TGLACompQuatBone);
 begin
 begin
   mat := QuaternionToMatrix(QuaternionMake([comp[1] - 32726, comp[2] - 32726,
   mat := QuaternionToMatrix(QuaternionMake([comp[1] - 32726, comp[2] - 32726,
     comp[3] - 32726], comp[0] - 32726));
     comp[3] - 32726], comp[0] - 32726));
@@ -305,7 +305,7 @@ end;
 
 
 // GetUnCompressedMatrix
 // GetUnCompressedMatrix
 //
 //
-function TFileGLA.GetUnCompressedMatrix(Frame, Bone: integer): TMatrix;
+function TFileGLA.GetUnCompressedMatrix(Frame, Bone: integer): TGLMatrix;
 begin
 begin
   MC_UnCompressQuat(result, CompBonePool[BoneIndices[Frame * AnimHeader.numBones
   MC_UnCompressQuat(result, CompBonePool[BoneIndices[Frame * AnimHeader.numBones
     + Bone]]);
     + Bone]]);

+ 5 - 5
Source/Formats.X.pas

@@ -71,11 +71,11 @@ type
 
 
   TDXFrame = class(TDXNode)
   TDXFrame = class(TDXNode)
   private
   private
-    FMatrix: TMatrix;
+    FMatrix: TGLMatrix;
   public
   public
     constructor Create; override;
     constructor Create; override;
-    function GlobalMatrix: TMatrix;
-    property Matrix: TMatrix read FMatrix write FMatrix;
+    function GlobalMatrix: TGLMatrix;
+    property Matrix: TGLMatrix read FMatrix write FMatrix;
 
 
   end;
   end;
 
 
@@ -259,7 +259,7 @@ var
     Result := StrToFloatDef(str, 0);
     Result := StrToFloatDef(str, 0);
   end;
   end;
 
 
-  function ReadMatrix: TMatrix;
+  function ReadMatrix: TGLMatrix;
   var
   var
     i, j: Integer;
     i, j: Integer;
   begin
   begin
@@ -670,7 +670,7 @@ begin
   FMatrix := IdentityHMGMatrix;
   FMatrix := IdentityHMGMatrix;
 end;
 end;
 
 
-function TDXFrame.GlobalMatrix: TMatrix;
+function TDXFrame.GlobalMatrix: TGLMatrix;
 begin
 begin
   if Owner is TDXFrame then
   if Owner is TDXFrame then
     Result := MatrixMultiply(TDXFrame(Owner).GlobalMatrix, FMatrix)
     Result := MatrixMultiply(TDXFrame(Owner).GlobalMatrix, FMatrix)

+ 1 - 1
Source/GLS.AnimatedSprite.pas

@@ -673,7 +673,7 @@ procedure TGLAnimatedSprite.BuildList(var rci: TGLRenderContextInfo);
 var
 var
   vx, vy: TAffineVector;
   vx, vy: TAffineVector;
   w, h, temp: Single;
   w, h, temp: Single;
-  mat: TMatrix;
+  mat: TGLMatrix;
   u0, v0, u1, v1: Single;
   u0, v0, u1, v1: Single;
   x0, y0, x1, y1, TexWidth, TexHeight: Integer;
   x0, y0, x1, y1, TexWidth, TexHeight: Integer;
   Anim: TGLSpriteAnimation;
   Anim: TGLSpriteAnimation;

+ 2 - 2
Source/GLS.CameraController.pas

@@ -126,7 +126,7 @@ type
   private
   private
     FCutoffAngle: Single;
     FCutoffAngle: Single;
     FNeedToRecalculateZoom: boolean;
     FNeedToRecalculateZoom: boolean;
-    FShouldBeMatrix: TMatrix;
+    FShouldBeMatrix: TGLMatrix;
     FSmoothNavigator: TGLNavigatorSmoothChangeVector;
     FSmoothNavigator: TGLNavigatorSmoothChangeVector;
   public
   public
     constructor Create(const AJoblist: TGLCameraJobList); override;
     constructor Create(const AJoblist: TGLCameraJobList); override;
@@ -890,7 +890,7 @@ procedure TGLSmoothOrbitToPos.Step;
 var
 var
   lCurrentDistanceToTarget: Single;
   lCurrentDistanceToTarget: Single;
   lTargetPosition: TGLVector;
   lTargetPosition: TGLVector;
-  lCurrentMatrix: TMatrix;
+  lCurrentMatrix: TGLMatrix;
   lAngle: Single;
   lAngle: Single;
   lAbsTargetPosition: TGLVector;
   lAbsTargetPosition: TGLVector;
 
 

+ 1 - 1
Source/GLS.Canvas.pas

@@ -255,7 +255,7 @@ end;
 
 
 procedure TGLCanvas.InvertYAxis;
 procedure TGLCanvas.InvertYAxis;
 var
 var
-  mat: TMatrix;
+  mat: TGLMatrix;
 begin
 begin
   mat := IdentityHmgMatrix;
   mat := IdentityHmgMatrix;
   mat.Y.Y := -1;
   mat.Y.Y := -1;

+ 4 - 4
Source/GLS.Collision.pas

@@ -441,7 +441,7 @@ const
     (4, 5), (5, 6), (6, 7), (7, 4), (0, 4), (1, 5), (2, 6), (3, 7));
     (4, 5), (5, 6), (6, 7), (7, 4), (0, 4), (1, 5), (2, 6), (3, 7));
 var
 var
   pt1: array [0 .. 7] of TGLVector;
   pt1: array [0 .. 7] of TGLVector;
-  M: TMatrix;
+  M: TGLMatrix;
   i: Integer;
   i: Integer;
   aad: TGLVector;
   aad: TGLVector;
 begin
 begin
@@ -507,7 +507,7 @@ end;
 function FastCheckCubeVsFace(obj1, obj2: TGLBaseSceneObject): Boolean;
 function FastCheckCubeVsFace(obj1, obj2: TGLBaseSceneObject): Boolean;
 // var
 // var
 // triList : TAffineVectorList;
 // triList : TAffineVectorList;
-// m1to2, m2to1 : TMatrix;
+// m1to2, m2to1 : TGLMatrix;
 // i:integer;
 // i:integer;
 begin
 begin
   if (obj2 is TGLFreeForm) then
   if (obj2 is TGLFreeForm) then
@@ -544,7 +544,7 @@ var
   i: Integer;
   i: Integer;
   triList: TAffineVectorList;
   triList: TAffineVectorList;
   tri: PTriangle;
   tri: PTriangle;
-  m1to2, m2to1: TMatrix;
+  m1to2, m2to1: TGLMatrix;
   AABB2: TAABB;
   AABB2: TAABB;
 begin
 begin
   Result := false;
   Result := false;
@@ -600,7 +600,7 @@ end;
 function IntersectCubes(obj1, obj2: TGLBaseSceneObject): Boolean;
 function IntersectCubes(obj1, obj2: TGLBaseSceneObject): Boolean;
 var
 var
   aabb1, AABB2: TAABB;
   aabb1, AABB2: TAABB;
-  m1to2, m2to1: TMatrix;
+  m1to2, m2to1: TGLMatrix;
 begin
 begin
   // Calc AABBs
   // Calc AABBs
   aabb1 := obj1.AxisAlignedBoundingBoxUnscaled;
   aabb1 := obj1.AxisAlignedBoundingBoxUnscaled;

+ 5 - 5
Source/GLS.Context.pas

@@ -816,8 +816,8 @@ type
     procedure SetUniformMatrix2fv(const index: string; const val: TMatrix2f);
     procedure SetUniformMatrix2fv(const index: string; const val: TMatrix2f);
     function GetUniformMatrix3fv(const index: string): TMatrix3f;
     function GetUniformMatrix3fv(const index: string): TMatrix3f;
     procedure SetUniformMatrix3fv(const index: string; const val: TMatrix3f);
     procedure SetUniformMatrix3fv(const index: string; const val: TMatrix3f);
-    function GetUniformMatrix4fv(const index: string): TMatrix;
-    procedure SetUniformMatrix4fv(const index: string; const val: TMatrix);
+    function GetUniformMatrix4fv(const index: string): TGLMatrix;
+    procedure SetUniformMatrix4fv(const index: string; const val: TGLMatrix);
     function GetUniformTextureHandle(const Index: string; const TextureIndex: Integer; const TextureTarget: TGLTextureTarget)
     function GetUniformTextureHandle(const Index: string; const TextureIndex: Integer; const TextureTarget: TGLTextureTarget)
       : TGLuint;
       : TGLuint;
     procedure SetUniformTextureHandle(const Index: string; const TextureIndex: Integer; const TextureTarget: TGLTextureTarget;
     procedure SetUniformTextureHandle(const Index: string; const TextureIndex: Integer; const TextureTarget: TGLTextureTarget;
@@ -868,7 +868,7 @@ type
     property Uniform4f[const index: string]: TGLVector read GetUniform4f write SetUniform4f;
     property Uniform4f[const index: string]: TGLVector read GetUniform4f write SetUniform4f;
     property UniformMatrix2fv[const index: string]: TMatrix2f read GetUniformMatrix2fv write SetUniformMatrix2fv;
     property UniformMatrix2fv[const index: string]: TMatrix2f read GetUniformMatrix2fv write SetUniformMatrix2fv;
     property UniformMatrix3fv[const index: string]: TMatrix3f read GetUniformMatrix3fv write SetUniformMatrix3fv;
     property UniformMatrix3fv[const index: string]: TMatrix3f read GetUniformMatrix3fv write SetUniformMatrix3fv;
-    property UniformMatrix4fv[const index: string]: TMatrix read GetUniformMatrix4fv write SetUniformMatrix4fv;
+    property UniformMatrix4fv[const index: string]: TGLMatrix read GetUniformMatrix4fv write SetUniformMatrix4fv;
     property UniformTextureHandle[const index: string; const TextureIndex: Integer; const TextureTarget: TGLTextureTarget]
     property UniformTextureHandle[const index: string; const TextureIndex: Integer; const TextureTarget: TGLTextureTarget]
       : TGLuint read GetUniformTextureHandle write SetUniformTextureHandle;
       : TGLuint read GetUniformTextureHandle write SetUniformTextureHandle;
     property UniformBuffer[const index: string]: TGLUniformBufferHandle write SetUniformBuffer;
     property UniformBuffer[const index: string]: TGLUniformBufferHandle write SetUniformBuffer;
@@ -3256,12 +3256,12 @@ begin
   gl.UniformMatrix3fv(GetUniformLocation(index), 1, False, @val);
   gl.UniformMatrix3fv(GetUniformLocation(index), 1, False, @val);
 end;
 end;
 
 
-function TGLProgramHandle.GetUniformMatrix4fv(const index: string): TMatrix;
+function TGLProgramHandle.GetUniformMatrix4fv(const index: string): TGLMatrix;
 begin
 begin
   gl.GetUniformfv(GetHandle, GetUniformLocation(index), @Result);
   gl.GetUniformfv(GetHandle, GetUniformLocation(index), @Result);
 end;
 end;
 
 
-procedure TGLProgramHandle.SetUniformMatrix4fv(const index: string; const val: TMatrix);
+procedure TGLProgramHandle.SetUniformMatrix4fv(const index: string; const val: TGLMatrix);
 begin
 begin
   gl.UniformMatrix4fv(GetUniformLocation(index), 1, False, @val);
   gl.UniformMatrix4fv(GetUniformLocation(index), 1, False, @val);
 end;
 end;

+ 1 - 1
Source/GLS.EllipseCollision.pas

@@ -31,7 +31,7 @@ type
 
 
   // Object collision properties
   // Object collision properties
   TECObjectInfo = record
   TECObjectInfo = record
-    AbsoluteMatrix: TMatrix;
+    AbsoluteMatrix: TGLMatrix;
     Solid: Boolean;
     Solid: Boolean;
     IsDynamic: Boolean;
     IsDynamic: Boolean;
     ObjectID: Integer;
     ObjectID: Integer;

+ 1 - 1
Source/GLS.ExplosionFx.pas

@@ -220,7 +220,7 @@ procedure TGLBExplosionFX.Render(var rci : TGLRenderContextInfo);
 var
 var
   Face: integer;
   Face: integer;
   dir, p1, p2, p3: TAffineVector;
   dir, p1, p2, p3: TAffineVector;
-  mat: TMatrix;
+  mat: TGLMatrix;
 
 
 begin
 begin
   if not FEnabled then
   if not FEnabled then

+ 9 - 9
Source/GLS.File3DS.pas

@@ -39,7 +39,7 @@ type
 
 
   // A record that holds all the information that is used during 3ds animation.
   // A record that holds all the information that is used during 3ds animation.
   TGLFile3DSAnimationData = packed record
   TGLFile3DSAnimationData = packed record
-    ModelMatrix: TMatrix;
+    ModelMatrix: TGLMatrix;
     Color: TGLVector; // Omni Light.
     Color: TGLVector; // Omni Light.
     TargetPos: TAffineVector; // Spot Light.
     TargetPos: TAffineVector; // Spot Light.
     SpotLightCutOff: Single;
     SpotLightCutOff: Single;
@@ -56,7 +56,7 @@ type
   protected
   protected
     function InterpolateValue(const AValues: array of Single; const AFrame: real): Single; overload;
     function InterpolateValue(const AValues: array of Single; const AFrame: real): Single; overload;
     function InterpolateValue(const AValues: array of TAffineVector; const AFrame: real): TAffineVector; overload;
     function InterpolateValue(const AValues: array of TAffineVector; const AFrame: real): TAffineVector; overload;
-    function InterpolateValue(const AValues: array of TKFRotKey3DS; const AFrame: real): TMatrix; overload;
+    function InterpolateValue(const AValues: array of TKFRotKey3DS; const AFrame: real): TGLMatrix; overload;
   public
   public
     procedure LoadData(const ANumKeys: Integer; const Keys: PKeyHeaderList; const AData: Pointer); virtual;
     procedure LoadData(const ANumKeys: Integer; const Keys: PKeyHeaderList; const AData: Pointer); virtual;
     procedure Apply(var DataTransf: TGLFile3DSAnimationData; const AFrame: real); virtual; abstract;
     procedure Apply(var DataTransf: TGLFile3DSAnimationData; const AFrame: real); virtual; abstract;
@@ -350,11 +350,11 @@ begin
   Result.RealPart := v.W;
   Result.RealPart := v.W;
 end;
 end;
 
 
-function QuaternionToRotateMatrix(const Quaternion: TQuaternion): TMatrix;
+function QuaternionToRotateMatrix(const Quaternion: TQuaternion): TGLMatrix;
 var
 var
   wx, wy, wz, xx, yy, yz, xy, xz, zz, x2, y2, z2: Single;
   wx, wy, wz, xx, yy, yz, xy, xz, zz, x2, y2, z2: Single;
   quat: TGLVector;
   quat: TGLVector;
-  m: TMatrix;
+  m: TGLMatrix;
 begin
 begin
   quat := VectorMake(Quaternion.ImagPart);
   quat := VectorMake(Quaternion.ImagPart);
   quat.W := Quaternion.RealPart;
   quat.W := Quaternion.RealPart;
@@ -453,7 +453,7 @@ begin
   Result := VectorLerp(start, stop, w);
   Result := VectorLerp(start, stop, w);
 end;
 end;
 
 
-function TGLFile3DSAnimationKeys.InterpolateValue(const AValues: array of TKFRotKey3DS; const AFrame: real): TMatrix;
+function TGLFile3DSAnimationKeys.InterpolateValue(const AValues: array of TKFRotKey3DS; const AFrame: real): TGLMatrix;
 var
 var
   I: Integer;
   I: Integer;
   w: real;
   w: real;
@@ -1155,8 +1155,8 @@ var
   aScale: TGLFile3DSScaleAnimationKeys;
   aScale: TGLFile3DSScaleAnimationKeys;
   aRot: TGLFile3DSRotationAnimationKeys;
   aRot: TGLFile3DSRotationAnimationKeys;
   aPos: TGLFile3DSPositionAnimationKeys;
   aPos: TGLFile3DSPositionAnimationKeys;
-  Mat : TMatrix;
-  RotMat : TMatrix;
+  Mat : TGLMatrix;
+  RotMat : TGLMatrix;
   AffVect : TAffineVector;
   AffVect : TAffineVector;
 begin
 begin
   inherited;
   inherited;
@@ -1702,13 +1702,13 @@ var
 
 
 // ----------------------------------------------------------------------
 // ----------------------------------------------------------------------
 
 
-  function InvertMeshMatrix(Objects: TObjectList; const Name: string): TMatrix;
+  function InvertMeshMatrix(Objects: TObjectList; const Name: string): TGLMatrix;
   // constructs a 4x4 matrix from 3x4 local mesh matrix given by Name and
   // constructs a 4x4 matrix from 3x4 local mesh matrix given by Name and
   // inverts it so it can be used for the keyframer stuff
   // inverts it so it can be used for the keyframer stuff
   var
   var
     I, Index: Integer;
     I, Index: Integer;
     boolY: Boolean;
     boolY: Boolean;
-    m: TMatrix;
+    m: TGLMatrix;
     v4: TGLVector;
     v4: TGLVector;
     factor: Single;
     factor: Single;
   begin
   begin

+ 6 - 6
Source/GLS.File3DSSceneObjects.pas

@@ -70,7 +70,7 @@ type
 
 
   TGLFile3DSFreeForm = class(TGLFreeForm)
   TGLFile3DSFreeForm = class(TGLFreeForm)
   private
   private
-    FTransfMat, FScaleMat, ParentMatrix: TMatrix;
+    FTransfMat, FScaleMat, ParentMatrix: TGLMatrix;
 
 
     FS_Rot3DS: TGLCoordinates4;
     FS_Rot3DS: TGLCoordinates4;
     FRot3DS: TGLCoordinates4;
     FRot3DS: TGLCoordinates4;
@@ -80,7 +80,7 @@ type
   protected
   protected
     procedure DefineProperties(Filer: TFiler); override;
     procedure DefineProperties(Filer: TFiler); override;
   public
   public
-    FRefMat: TMatrix;
+    FRefMat: TGLMatrix;
     constructor Create(AOWner: TComponent); override;
     constructor Create(AOWner: TComponent); override;
     destructor Destroy; override;
     destructor Destroy; override;
     procedure BuildList(var rci: TGLRenderContextInfo); override;
     procedure BuildList(var rci: TGLRenderContextInfo); override;
@@ -117,11 +117,11 @@ begin
   Result.RealPart := v.W;
   Result.RealPart := v.W;
 end;
 end;
 
 
-function QuaternionToRotateMatrix(const Quaternion: TQuaternion): TMatrix;
+function QuaternionToRotateMatrix(const Quaternion: TQuaternion): TGLMatrix;
 var
 var
   wx, wy, wz, xx, yy, yz, xy, xz, zz, x2, y2, z2: Single;
   wx, wy, wz, xx, yy, yz, xy, xz, zz, x2, y2, z2: Single;
   quat: TGLVector;
   quat: TGLVector;
-  m: TMatrix;
+  m: TGLMatrix;
 begin
 begin
   quat := VectorMake(Quaternion.ImagPart);
   quat := VectorMake(Quaternion.ImagPart);
   quat.W := Quaternion.RealPart;
   quat.W := Quaternion.RealPart;
@@ -460,7 +460,7 @@ end;
 function TGLFile3DSFreeForm.AxisAlignedDimensionsUnscaled: TGLVector;
 function TGLFile3DSFreeForm.AxisAlignedDimensionsUnscaled: TGLVector;
 var
 var
   dMin, dMax: TAffineVector;
   dMin, dMax: TAffineVector;
-  mat: TMatrix;
+  mat: TGLMatrix;
 begin
 begin
   MeshObjects.GetExtents(dMin, dMax);
   MeshObjects.GetExtents(dMin, dMax);
   mat := ParentMatrix;
   mat := ParentMatrix;
@@ -479,7 +479,7 @@ end;
 function TGLFile3DSFreeForm.BarycenterAbsolutePosition: TGLVector;
 function TGLFile3DSFreeForm.BarycenterAbsolutePosition: TGLVector;
 var
 var
   dMin, dMax: TAffineVector;
   dMin, dMax: TAffineVector;
-  mat: TMatrix;
+  mat: TGLMatrix;
 begin
 begin
   MeshObjects.GetExtents(dMin, dMax);
   MeshObjects.GetExtents(dMin, dMax);
   mat := ParentMatrix;
   mat := ParentMatrix;

+ 2 - 2
Source/GLS.FileASE.pas

@@ -90,7 +90,7 @@ type
   private
   private
     FFaces: TGLASEFaceList;
     FFaces: TGLASEFaceList;
     FVertices: TAffineVectorList;
     FVertices: TAffineVectorList;
-    FMatrix: TMatrix;
+    FMatrix: TGLMatrix;
     FInheritedPosition: TAffineVector;
     FInheritedPosition: TAffineVector;
     FInheritedScale: TAffineVector;
     FInheritedScale: TAffineVector;
     FInheritedRotation: TAffineVector;
     FInheritedRotation: TAffineVector;
@@ -113,7 +113,7 @@ type
     property Vertices: TAffineVectorList read FVertices;
     property Vertices: TAffineVectorList read FVertices;
     property TextChannel[Channel: Integer]: TAffineVectorList read GetTextChannel;
     property TextChannel[Channel: Integer]: TAffineVectorList read GetTextChannel;
     property TextChannelsCount: Integer read FTexChannelsCount;
     property TextChannelsCount: Integer read FTexChannelsCount;
-    property Matrix: TMatrix read FMatrix;
+    property Matrix: TGLMatrix read FMatrix;
     property InheritedPosition: TAffineVector read FInheritedPosition;
     property InheritedPosition: TAffineVector read FInheritedPosition;
     property InheritedRotation: TAffineVector read FInheritedRotation;
     property InheritedRotation: TAffineVector read FInheritedRotation;
     property InheritedScale: TAffineVector read FInheritedScale;
     property InheritedScale: TAffineVector read FInheritedScale;

+ 2 - 2
Source/GLS.FileB3D.pas

@@ -56,11 +56,11 @@ var
   Vertex: PVertexData;
   Vertex: PVertexData;
   Triangles: PTRISChunk;
   Triangles: PTRISChunk;
   V, V1: TAffineVector;
   V, V1: TAffineVector;
-  Matrix: TMatrix;
+  Matrix: TGLMatrix;
   MatLib: TGLMaterialLibrary;
   MatLib: TGLMaterialLibrary;
   LightLib: TGLMaterialLibrary;
   LightLib: TGLMaterialLibrary;
   RotQuat: TQuaternion;
   RotQuat: TQuaternion;
-  RotMat: TMatrix;
+  RotMat: TGLMatrix;
 
 
   function GetOrAllocateMaterial(MaterialNum: Integer; AMat: TB3DMaterial;
   function GetOrAllocateMaterial(MaterialNum: Integer; AMat: TB3DMaterial;
     ATex: TB3DTexture; ALightmap: TB3DTexture): string;
     ATex: TB3DTexture; ALightmap: TB3DTexture): string;

+ 2 - 2
Source/GLS.FileMD5.pas

@@ -127,7 +127,7 @@ procedure TGLMD5VectorFile.LoadFromStream(aStream: TStream);
     bonename: String;
     bonename: String;
     pos: TAffineVector;
     pos: TAffineVector;
     quat: TQuaternion;
     quat: TQuaternion;
-    mat, rmat: TMatrix;
+    mat, rmat: TGLMatrix;
     ParentBoneID: Integer;
     ParentBoneID: Integer;
     bone, parentbone: TGLSkeletonBone;
     bone, parentbone: TGLSkeletonBone;
   begin
   begin
@@ -208,7 +208,7 @@ procedure TGLMD5VectorFile.LoadFromStream(aStream: TStream);
     VertexWeighted: TAffineVectorList;
     VertexWeighted: TAffineVectorList;
     blendedVert, transformedVert: TAffineVector;
     blendedVert, transformedVert: TAffineVector;
     i, j, k: Integer;
     i, j, k: Integer;
-    mat: TMatrix;
+    mat: TGLMatrix;
   begin
   begin
     VertexWeightID := TIntegerList.Create;
     VertexWeightID := TIntegerList.Create;
     VertexWeightCount := TIntegerList.Create;
     VertexWeightCount := TIntegerList.Create;

+ 1 - 1
Source/GLS.FileMS3D.pas

@@ -411,7 +411,7 @@ var
 
 
   function AddRotations(rot, baserot: TAffineVector): TAffineVector;
   function AddRotations(rot, baserot: TAffineVector): TAffineVector;
   var
   var
-    mat1, mat2, rmat: TMatrix;
+    mat1, mat2, rmat: TGLMatrix;
     s, c: Single;
     s, c: Single;
     Trans: TTransformations;
     Trans: TTransformations;
   begin
   begin

+ 1 - 1
Source/GLS.FileOBJ.pas

@@ -20,6 +20,7 @@ uses
   System.Classes,
   System.Classes,
   System.SysUtils,
   System.SysUtils,
 
 
+  GLS.VectorTypes,
   GLS.ApplicationFileIO,
   GLS.ApplicationFileIO,
   GLS.PersistentClasses,
   GLS.PersistentClasses,
   GLS.VectorGeometry,
   GLS.VectorGeometry,
@@ -100,7 +101,6 @@ implementation
 // ------------------------------------------------------------------
 // ------------------------------------------------------------------
 
 
 uses
 uses
-  GLS.VectorTypes,
   GLS.Strings,
   GLS.Strings,
   GLS.OpenGLTokens,
   GLS.OpenGLTokens,
   GLS.XOpenGL,
   GLS.XOpenGL,

+ 3 - 2
Source/GLS.FileQ3MD3.pas

@@ -11,6 +11,7 @@ uses
   System.Classes,
   System.Classes,
   System.SysUtils,
   System.SysUtils,
 
 
+  GLS.VectorTypes,
   GLS.VectorGeometry,
   GLS.VectorGeometry,
   GLS.VectorFileObjects,
   GLS.VectorFileObjects,
   GLS.VectorLists,
   GLS.VectorLists,
@@ -30,7 +31,7 @@ type
   public
   public
     procedure LoadFromFile(const FileName: String);
     procedure LoadFromFile(const FileName: String);
     procedure LoadFromStream(AStream: TStream);
     procedure LoadFromStream(AStream: TStream);
-    function GetTransform(const TagName: string; Frame: Integer): TMatrix;
+    function GetTransform(const TagName: string; Frame: Integer): TGLMatrix;
     property TagCount: Integer read FNumTags;
     property TagCount: Integer read FNumTags;
     property FrameCount: Integer read FNumFrames;
     property FrameCount: Integer read FNumFrames;
     property Tags[index: Integer]: TMD3Tag read GetTag;
     property Tags[index: Integer]: TMD3Tag read GetTag;
@@ -304,7 +305,7 @@ begin
 end;
 end;
 
 
 function TMD3TagList.GetTransform(const TagName: string;
 function TMD3TagList.GetTransform(const TagName: string;
-  Frame: Integer): TMatrix;
+  Frame: Integer): TGLMatrix;
 var
 var
   TagIdx, i, j: Integer;
   TagIdx, i, j: Integer;
   Tag: TMD3Tag;
   Tag: TMD3Tag;

+ 2 - 2
Source/GLS.FileVRML.pas

@@ -164,7 +164,7 @@ var
   mesh: TMeshObject;
   mesh: TMeshObject;
   uniqueMatID: Integer;
   uniqueMatID: Integer;
   currentMaterial: TGLLibMaterial;
   currentMaterial: TGLLibMaterial;
-  currentTransform: TMatrix;
+  currentTransform: TGLMatrix;
   creaseAngle: Single;
   creaseAngle: Single;
 
 
   function GetUniqueMaterialName: String;
   function GetUniqueMaterialName: String;
@@ -443,7 +443,7 @@ var
     fg: TFGVertexNormalTexIndexList;
     fg: TFGVertexNormalTexIndexList;
     face: TIntegerList;
     face: TIntegerList;
     tempLibMat: TGLLibMaterial;
     tempLibMat: TGLLibMaterial;
-    saveTransform, mat: TMatrix;
+    saveTransform, mat: TGLMatrix;
     saveMaterial: TGLLibMaterial;
     saveMaterial: TGLLibMaterial;
     axis: TAffineVector;
     axis: TAffineVector;
     angle: Single;
     angle: Single;

+ 1 - 1
Source/GLS.FileX.pas

@@ -47,7 +47,7 @@ var
   var
   var
     i, j, k, l, vertcount: integer;
     i, j, k, l, vertcount: integer;
     mo: TMeshObject;
     mo: TMeshObject;
-    mat: TMatrix;
+    mat: TGLMatrix;
     libmat: TGLLibMaterial;
     libmat: TGLLibMaterial;
     fg: TFGVertexNormalTexIndexList;
     fg: TFGVertexNormalTexIndexList;
     str: String;
     str: String;

+ 2 - 2
Source/GLS.FireFX.pas

@@ -79,7 +79,7 @@ type
     procedure Notification(AComponent: TComponent; Operation: TOperation); override;
     procedure Notification(AComponent: TComponent; Operation: TOperation); override;
     procedure CalcFire(deltaTime: Double; ParticleInterval, ParticleLife: Single;
     procedure CalcFire(deltaTime: Double; ParticleInterval, ParticleLife: Single;
       FireAlpha: Single);
       FireAlpha: Single);
-    procedure AffParticle3d(Color2: TColorVector; const mat: TMatrix);
+    procedure AffParticle3d(Color2: TColorVector; const mat: TGLMatrix);
   public
   public
     constructor Create(AOwner: TComponent); override;
     constructor Create(AOwner: TComponent); override;
     destructor Destroy; override;
     destructor Destroy; override;
@@ -526,7 +526,7 @@ begin
   end;
   end;
 end;
 end;
 
 
-procedure TGLFireFXManager.AffParticle3d(Color2: TColorVector; const mat: TMatrix);
+procedure TGLFireFXManager.AffParticle3d(Color2: TColorVector; const mat: TGLMatrix);
 var
 var
   vx, vy: TGLVector;
   vx, vy: TGLVector;
   i: Integer;
   i: Integer;

+ 1 - 1
Source/GLS.GeomObjects.pas

@@ -3585,7 +3585,7 @@ end;
 procedure TGLTeapot.DoRender(var ARci: TGLRenderContextInfo;
 procedure TGLTeapot.DoRender(var ARci: TGLRenderContextInfo;
   ARenderSelf, ARenderChildren: Boolean);
   ARenderSelf, ARenderChildren: Boolean);
 const
 const
-  M: TMatrix = (
+  M: TGLMatrix = (
   X:(X:0.150000005960464; Y:0; Z:0; W:0);
   X:(X:0.150000005960464; Y:0; Z:0; W:0);
   Y:(X:0; Y:-6.55670850946422e-09; Z:-0.150000005960464; W:0);
   Y:(X:0; Y:-6.55670850946422e-09; Z:-0.150000005960464; W:0);
   Z:(X:0; Y:0.150000005960464; Z:-6.55670850946422e-09; W:0);
   Z:(X:0; Y:0.150000005960464; Z:-6.55670850946422e-09; W:0);

+ 10 - 10
Source/GLS.GeometryBB.pas

@@ -77,8 +77,8 @@ procedure AddAABB(var Aabb: TAABB; const Aabb1: TAABB);
 procedure SetBB(var C: THmgBoundingBox; const V: TGLVector);
 procedure SetBB(var C: THmgBoundingBox; const V: TGLVector);
 procedure SetAABB(var Bb: TAABB; const V: TGLVector); inline;
 procedure SetAABB(var Bb: TAABB; const V: TGLVector); inline;
 
 
-procedure BBTransform(var C: THmgBoundingBox; const M: TMatrix);
-procedure AABBTransform(var Bb: TAABB; const M: TMatrix);
+procedure BBTransform(var C: THmgBoundingBox; const M: TGLMatrix);
+procedure AABBTransform(var Bb: TAABB; const M: TGLMatrix);
 procedure AABBScale(var Bb: TAABB; const V: TAffineVector);
 procedure AABBScale(var Bb: TAABB; const V: TAffineVector);
 
 
 function BBMinX(const C: THmgBoundingBox): Single;
 function BBMinX(const C: THmgBoundingBox): Single;
@@ -100,7 +100,7 @@ function BBToAABB(const ABB: THmgBoundingBox): TAABB;
 // Converts an AABB to its canonical BB. 
 // Converts an AABB to its canonical BB. 
 function AABBToBB(const AnAABB: TAABB): THmgBoundingBox; overload;
 function AABBToBB(const AnAABB: TAABB): THmgBoundingBox; overload;
 // Transforms an AABB to a BB. 
 // Transforms an AABB to a BB. 
-function AABBToBB(const AnAABB: TAABB; const M: TMatrix): THmgBoundingBox; overload;
+function AABBToBB(const AnAABB: TAABB; const M: TGLMatrix): THmgBoundingBox; overload;
 //  Adds delta to min and max of the AABB. 
 //  Adds delta to min and max of the AABB. 
 procedure OffsetAABB(var Aabb: TAABB; const Delta: TAffineVector); overload;
 procedure OffsetAABB(var Aabb: TAABB; const Delta: TAffineVector); overload;
 procedure OffsetAABB(var Aabb: TAABB; const Delta: TGLVector); overload;
 procedure OffsetAABB(var Aabb: TAABB; const Delta: TGLVector); overload;
@@ -111,7 +111,7 @@ procedure OffsetBB(var Bb: THmgBoundingBox; const Delta: TGLVector); overload;
 procedure OffsetBBPoint(var Bb: THmgBoundingBox; const Delta: TGLVector); overload;
 procedure OffsetBBPoint(var Bb: THmgBoundingBox; const Delta: TGLVector); overload;
 (* Determines if two AxisAlignedBoundingBoxes intersect.
 (* Determines if two AxisAlignedBoundingBoxes intersect.
   The matrices are the ones that convert one point to the other's AABB system *)
   The matrices are the ones that convert one point to the other's AABB system *)
-function IntersectAABBs(const Aabb1, Aabb2: TAABB; const M1To2, M2To1: TMatrix): Boolean; overload;
+function IntersectAABBs(const Aabb1, Aabb2: TAABB; const M1To2, M2To1: TGLMatrix): Boolean; overload;
 // Checks whether two Bounding boxes aligned with the world axes collide in the XY plane.
 // Checks whether two Bounding boxes aligned with the world axes collide in the XY plane.
 function IntersectAABBsAbsoluteXY(const Aabb1, Aabb2: TAABB): Boolean;
 function IntersectAABBsAbsoluteXY(const Aabb1, Aabb2: TAABB): Boolean;
 // Checks whether two Bounding boxes aligned with the world axes collide in the XZ plane.
 // Checks whether two Bounding boxes aligned with the world axes collide in the XZ plane.
@@ -180,7 +180,7 @@ function BSphereIntersectsBSphere(const MainBSphere, TestBSphere: TBSphere): Boo
 // Extend the clip rect to include given coordinate. 
 // Extend the clip rect to include given coordinate. 
 procedure IncludeInClipRect(var ClipRect: TClipRect; X, Y: Single);
 procedure IncludeInClipRect(var ClipRect: TClipRect; X, Y: Single);
 // Projects an AABB and determines the extent of its projection as a clip rect. 
 // Projects an AABB and determines the extent of its projection as a clip rect. 
-function AABBToClipRect(const Aabb: TAABB; const ModelViewProjection: TMatrix;
+function AABBToClipRect(const Aabb: TAABB; const ModelViewProjection: TGLMatrix;
   ViewportSizeX, ViewportSizeY: Integer): TClipRect;
   ViewportSizeX, ViewportSizeY: Integer): TClipRect;
 
 
 // Finds the intersection between a ray and an axis aligned bounding box. 
 // Finds the intersection between a ray and an axis aligned bounding box. 
@@ -301,7 +301,7 @@ begin
   Bb.Min.Z := -Bb.Max.Z;
   Bb.Min.Z := -Bb.Max.Z;
 end;
 end;
 
 
-procedure BBTransform(var C: THmgBoundingBox; const M: TMatrix);
+procedure BBTransform(var C: THmgBoundingBox; const M: TGLMatrix);
 var
 var
   I: Integer;
   I: Integer;
 begin
 begin
@@ -309,7 +309,7 @@ begin
     C.BBox[I] := VectorTransform(C.BBox[I], M);
     C.BBox[I] := VectorTransform(C.BBox[I], M);
 end;
 end;
 
 
-procedure AABBTransform(var Bb: TAABB; const M: TMatrix);
+procedure AABBTransform(var Bb: TAABB; const M: TGLMatrix);
 var
 var
   OldMin, OldMax: TAffineVector;
   OldMin, OldMax: TAffineVector;
 begin
 begin
@@ -492,7 +492,7 @@ begin
   end;
   end;
 end;
 end;
 
 
-function AABBToBB(const AnAABB: TAABB; const M: TMatrix): THmgBoundingBox;
+function AABBToBB(const AnAABB: TAABB; const M: TGLMatrix): THmgBoundingBox;
 begin
 begin
   Result := AABBToBB(AnAABB);
   Result := AABBToBB(AnAABB);
   BBTransform(Result, M);
   BBTransform(Result, M);
@@ -537,7 +537,7 @@ begin
 end;
 end;
 
 
 function IntersectAABBs(const Aabb1, Aabb2: TAABB;
 function IntersectAABBs(const Aabb1, Aabb2: TAABB;
-  const M1To2, M2To1: TMatrix): Boolean;
+  const M1To2, M2To1: TGLMatrix): Boolean;
 const
 const
   CWires: array [0 .. 11, 0 .. 1] of Integer // Points of the wire
   CWires: array [0 .. 11, 0 .. 1] of Integer // Points of the wire
     = ((0, 1), (1, 2), (2, 3), (3, 0), (4, 5), (5, 6), (6, 7), (7, 4), (0, 4),
     = ((0, 1), (1, 2), (2, 3), (3, 0), (4, 5), (5, 6), (6, 7), (7, 4), (0, 4),
@@ -1288,7 +1288,7 @@ begin
   end;
   end;
 end;
 end;
 
 
-function AABBToClipRect(const Aabb: TAABB; const ModelViewProjection: TMatrix;
+function AABBToClipRect(const Aabb: TAABB; const ModelViewProjection: TGLMatrix;
   ViewportSizeX, ViewportSizeY: Integer): TClipRect;
   ViewportSizeX, ViewportSizeY: Integer): TClipRect;
 var
 var
   I: Integer;
   I: Integer;

+ 7 - 7
Source/GLS.Gizmo.pas

@@ -86,11 +86,11 @@ type
     FOldLibMaterialName: string;
     FOldLibMaterialName: string;
     FOldAutoScaling: TGLCoordinates;
     FOldAutoScaling: TGLCoordinates;
     FEffectedObject: TGLCustomSceneObject;
     FEffectedObject: TGLCustomSceneObject;
-    FOldMatr: TMatrix;
-    FOldMatrix: TMatrix;
+    FOldMatr: TGLMatrix;
+    FOldMatrix: TGLMatrix;
     procedure SetEffectedObject(const Value: TGLCustomSceneObject);
     procedure SetEffectedObject(const Value: TGLCustomSceneObject);
     procedure SetOldAutoScaling(const Value: TGLCoordinates);
     procedure SetOldAutoScaling(const Value: TGLCoordinates);
-    procedure SetOldMatrix(const Value: TMatrix);
+    procedure SetOldMatrix(const Value: TGLMatrix);
   protected
   protected
     procedure DoUndo; virtual;
     procedure DoUndo; virtual;
     function GetParent: TGLGizmoUndoCollection;
     function GetParent: TGLGizmoUndoCollection;
@@ -102,7 +102,7 @@ type
       Operation: TOperation); virtual;
       Operation: TOperation); virtual;
     procedure AssignFromObject(const AObject: TGLCustomSceneObject);
     procedure AssignFromObject(const AObject: TGLCustomSceneObject);
     // TODO: create a special type for Matrix.
     // TODO: create a special type for Matrix.
-    property OldMatrix: TMatrix read FOldMatrix write SetOldMatrix;
+    property OldMatrix: TGLMatrix read FOldMatrix write SetOldMatrix;
   published
   published
     property EffectedObject: TGLCustomSceneObject read FEffectedObject
     property EffectedObject: TGLCustomSceneObject read FEffectedObject
       write SetEffectedObject;
       write SetEffectedObject;
@@ -317,7 +317,7 @@ implementation
 procedure RotateAroundArbitraryAxis(const AnObject: TGLBaseSceneObject;
 procedure RotateAroundArbitraryAxis(const AnObject: TGLBaseSceneObject;
   const Axis, Origin: TAffineVector; const Angle: Single);
   const Axis, Origin: TAffineVector; const Angle: Single);
 var
 var
-  M, M1, M2, M3: TMatrix;
+  M, M1, M2, M3: TGLMatrix;
 begin
 begin
   M1 := CreateTranslationMatrix(VectorNegate(Origin));
   M1 := CreateTranslationMatrix(VectorNegate(Origin));
   M2 := CreateRotationMatrix(Axis, Angle * PI / 180);
   M2 := CreateRotationMatrix(Axis, Angle * PI / 180);
@@ -1312,7 +1312,7 @@ var
   var
   var
     Vec1: TGLVector;
     Vec1: TGLVector;
     RotV: TAffineVector;
     RotV: TAffineVector;
-    Pmat: TMatrix;
+    Pmat: TGLMatrix;
 
 
   begin
   begin
     Vec1.X := 0;
     Vec1.X := 0;
@@ -1797,7 +1797,7 @@ begin
   FOldAutoScaling.Assign(Value);
   FOldAutoScaling.Assign(Value);
 end;
 end;
 
 
-procedure TGLGizmoUndoItem.SetOldMatrix(const Value: TMatrix);
+procedure TGLGizmoUndoItem.SetOldMatrix(const Value: TGLMatrix);
 begin
 begin
   FOldMatrix := Value;
   FOldMatrix := Value;
 end;
 end;

+ 7 - 7
Source/GLS.GizmoEx.pas

@@ -54,10 +54,10 @@ type
     FIndexOldObject: Integer;
     FIndexOldObject: Integer;
     FNameOldObject: string;
     FNameOldObject: string;
     FReturnObject: Boolean;
     FReturnObject: Boolean;
-    FOldMatrix: TMatrix;
+    FOldMatrix: TGLMatrix;
     FGizmoTmpRoot: TGLBaseSceneObject;
     FGizmoTmpRoot: TGLBaseSceneObject;
     procedure SetEffectedObject(const Value: TGLBaseSceneObject);
     procedure SetEffectedObject(const Value: TGLBaseSceneObject);
-    procedure SetOldMatrix(const Value: TMatrix);
+    procedure SetOldMatrix(const Value: TGLMatrix);
   protected
   protected
     procedure DoUndo;
     procedure DoUndo;
     function GetParent: TGLGizmoExObjectCollection;
     function GetParent: TGLGizmoExObjectCollection;
@@ -69,7 +69,7 @@ type
     procedure Notification(AComponent: TComponent; Operation: TOperation); virtual;
     procedure Notification(AComponent: TComponent; Operation: TOperation); virtual;
     procedure AssignFromObject(const AObject: TGLBaseSceneObject; AssignAndRemoveObj: Boolean = False);
     procedure AssignFromObject(const AObject: TGLBaseSceneObject; AssignAndRemoveObj: Boolean = False);
     // TODO: create a special type for Matrix.
     // TODO: create a special type for Matrix.
-    property OldMatrix: TMatrix read FOldMatrix write SetOldMatrix;
+    property OldMatrix: TGLMatrix read FOldMatrix write SetOldMatrix;
   published
   published
     property EffectedObject: TGLBaseSceneobject read FEffectedObject write SetEffectedObject;
     property EffectedObject: TGLBaseSceneobject read FEffectedObject write SetEffectedObject;
   end;
   end;
@@ -480,7 +480,7 @@ uses
 
 
 procedure RotateAroundArbitraryAxis(const anObject: TGLBaseSceneObject; const Axis, Origin: TAffineVector; const angle: Single);
 procedure RotateAroundArbitraryAxis(const anObject: TGLBaseSceneObject; const Axis, Origin: TAffineVector; const angle: Single);
 var
 var
-  M, M1, M2, M3: TMatrix;
+  M, M1, M2, M3: TGLMatrix;
 begin
 begin
   M1 := CreateTranslationMatrix(VectorNegate(Origin));
   M1 := CreateTranslationMatrix(VectorNegate(Origin));
   M2 := CreateRotationMatrix(Axis, Angle * PI / 180);
   M2 := CreateRotationMatrix(Axis, Angle * PI / 180);
@@ -2138,7 +2138,7 @@ procedure TGLGizmoEx.InternalRender(Sender: TObject; var rci: TGLRenderContextIn
   var
   var
     FLayout: TTextLayout;
     FLayout: TTextLayout;
     FAlignment: TAlignment;
     FAlignment: TAlignment;
-    wm:   TMatrix;
+    wm:   TGLMatrix;
     I, J: Integer;
     I, J: Integer;
   begin
   begin
     if not Assigned(FLabelFont) and (Text = '') then
     if not Assigned(FLabelFont) and (Text = '') then
@@ -3560,7 +3560,7 @@ var
   var
   var
     vec1: TGLVector;
     vec1: TGLVector;
     rotV: TAffineVector;
     rotV: TAffineVector;
-    pmat: TMatrix;
+    pmat: TGLMatrix;
     I:    Integer;
     I:    Integer;
     IncludeCh: Boolean;
     IncludeCh: Boolean;
     v:    TGLVector;
     v:    TGLVector;
@@ -4324,7 +4324,7 @@ begin
   FEffectedObject := Value;
   FEffectedObject := Value;
 end;
 end;
 
 
-procedure TGLGizmoExObjectItem.SetOldMatrix(const Value: TMatrix);
+procedure TGLGizmoExObjectItem.SetOldMatrix(const Value: TGLMatrix);
 begin
 begin
   FOldMatrix := Value;
   FOldMatrix := Value;
 end;
 end;

+ 5 - 5
Source/GLS.Imposter.pas

@@ -417,7 +417,7 @@ end;
 
 
 procedure TImposter.BeginRender(var rci: TGLRenderContextInfo);
 procedure TImposter.BeginRender(var rci: TGLRenderContextInfo);
 var
 var
-  mat: TMatrix;
+  mat: TGLMatrix;
   filter: Cardinal;
   filter: Cardinal;
   fx, fy, yOffset, cosAlpha, dynScale: Single;
   fx, fy, yOffset, cosAlpha, dynScale: Single;
 begin
 begin
@@ -1124,7 +1124,7 @@ var
   xDest, xSrc, yDest, ySrc: Integer;
   xDest, xSrc, yDest, ySrc: Integer;
   corona: TGLStaticImposterBuilderCorona;
   corona: TGLStaticImposterBuilderCorona;
   fx, fy, yOffset: Single;
   fx, fy, yOffset: Single;
-  LM: TMatrix;
+  LM: TGLMatrix;
 begin
 begin
   FTextureSize := ComputeOptimalTextureSize;
   FTextureSize := ComputeOptimalTextureSize;
   if (FTextureSize.X <= 0) and (FTextureSize.Y <= 0) then
   if (FTextureSize.X <= 0) and (FTextureSize.Y <= 0) then
@@ -1302,7 +1302,7 @@ procedure TGLDynamicImposterBuilder.DoRender(var rci : TGLRenderContextInfo;
 var
 var
   i, size, Left, Top, Width, Height : Integer;
   i, size, Left, Top, Width, Height : Integer;
   imposter : TGLImposter;
   imposter : TGLImposter;
-  mat, projection, modelview : TMatrix;
+  mat, projection, modelview : TGLMatrix;
   BackColor, pos, temp : TGLVector;
   BackColor, pos, temp : TGLVector;
   rad : Single;
   rad : Single;
   AABB : TAABB;
   AABB : TAABB;
@@ -1508,10 +1508,10 @@ begin
    Result:=NullHMGVector;
    Result:=NullHMGVector;
 end;
 end;
 
 
-function TGLImposter.CalcError(NewMatrix : TMatrix) : Single;
+function TGLImposter.CalcError(NewMatrix : TGLMatrix) : Single;
 var
 var
    i : Integer;
    i : Integer;
-   mat : TMatrix;
+   mat : TGLMatrix;
    err : Single;
    err : Single;
 begin
 begin
    err:=0;
    err:=0;

+ 1 - 1
Source/GLS.LensFlare.pas

@@ -461,7 +461,7 @@ var
   screenPos: TAffineVector;
   screenPos: TAffineVector;
   flareInViewPort, dynamicSize: Boolean;
   flareInViewPort, dynamicSize: Boolean;
   oldSeed: LongInt;
   oldSeed: LongInt;
-  projMatrix: TMatrix;
+  projMatrix: TGLMatrix;
   CurrentBuffer: TGLSceneBuffer;
   CurrentBuffer: TGLSceneBuffer;
 begin
 begin
   if (rci.drawState = dsPicking) then
   if (rci.drawState = dsPicking) then

+ 1 - 1
Source/GLS.LinePFX.pas

@@ -113,7 +113,7 @@ end;
 procedure TGLLinePFXManager.InitializeRendering(var rci: TGLRenderContextInfo);
 procedure TGLLinePFXManager.InitializeRendering(var rci: TGLRenderContextInfo);
 var
 var
   i: Integer;
   i: Integer;
-  matrix: TMatrix;
+  matrix: TGLMatrix;
 begin
 begin
   inherited;
   inherited;
   gl.GetFloatv(GL_MODELVIEW_MATRIX, @matrix);
   gl.GetFloatv(GL_MODELVIEW_MATRIX, @matrix);

+ 5 - 5
Source/GLS.Material.pas

@@ -460,7 +460,7 @@ type
     FTextureRotate: Single;
     FTextureRotate: Single;
     FTextureMatrixIsIdentity: Boolean;
     FTextureMatrixIsIdentity: Boolean;
     FTextureOverride: Boolean;
     FTextureOverride: Boolean;
-    FTextureMatrix: TMatrix;
+    FTextureMatrix: TGLMatrix;
     FTexture2Name: TGLLibMaterialName;
     FTexture2Name: TGLLibMaterialName;
     FShader: TGLShader;
     FShader: TGLShader;
     libMatTexture2: TGLLibMaterial; // internal cache
     libMatTexture2: TGLLibMaterial; // internal cache
@@ -469,7 +469,7 @@ type
     procedure SetMaterial(const val: TGLMaterial);
     procedure SetMaterial(const val: TGLMaterial);
     procedure SetTextureOffset(const val: TGLCoordinates);
     procedure SetTextureOffset(const val: TGLCoordinates);
     procedure SetTextureScale(const val: TGLCoordinates);
     procedure SetTextureScale(const val: TGLCoordinates);
-    procedure SetTextureMatrix(const Value: TMatrix);
+    procedure SetTextureMatrix(const Value: TGLMatrix);
     procedure SetTexture2Name(const val: TGLLibMaterialName);
     procedure SetTexture2Name(const val: TGLLibMaterialName);
     procedure SetShader(const val: TGLShader);
     procedure SetShader(const val: TGLShader);
     procedure SetTextureRotate(Value: Single);
     procedure SetTextureRotate(Value: Single);
@@ -487,7 +487,7 @@ type
     { Restore non-standard material states that were altered}
     { Restore non-standard material states that were altered}
     function UnApply(var ARci: TGLRenderContextInfo): Boolean; override;
     function UnApply(var ARci: TGLRenderContextInfo): Boolean; override;
     procedure NotifyUsersOfTexMapChange;
     procedure NotifyUsersOfTexMapChange;
-    property TextureMatrix: TMatrix read FTextureMatrix write SetTextureMatrix;
+    property TextureMatrix: TGLMatrix read FTextureMatrix write SetTextureMatrix;
     property TextureMatrixIsIdentity: boolean read FTextureMatrixIsIdentity;
     property TextureMatrixIsIdentity: boolean read FTextureMatrixIsIdentity;
     procedure NotifyTexMapChange(Sender: TObject);
     procedure NotifyTexMapChange(Sender: TObject);
     function Blended: Boolean; override;
     function Blended: Boolean; override;
@@ -1968,9 +1968,9 @@ begin
   CalculateTextureMatrix;
   CalculateTextureMatrix;
 end;
 end;
 
 
-procedure TGLLibMaterial.SetTextureMatrix(const Value: TMatrix);
+procedure TGLLibMaterial.SetTextureMatrix(const Value: TGLMatrix);
 begin
 begin
-  FTextureMatrixIsIdentity := CompareMem(@Value.V[0], @IdentityHmgMatrix.V[0], SizeOf(TMatrix));
+  FTextureMatrixIsIdentity := CompareMem(@Value.V[0], @IdentityHmgMatrix.V[0], SizeOf(TGLMatrix));
   FTextureMatrix := Value;
   FTextureMatrix := Value;
   FTextureOverride := True;
   FTextureOverride := True;
   NotifyUsers;
   NotifyUsers;

+ 5 - 5
Source/GLS.MaterialEx.pas

@@ -408,7 +408,7 @@ type
     FTextureRotate: Single;
     FTextureRotate: Single;
     FTextureMatrixIsIdentity: Boolean;
     FTextureMatrixIsIdentity: Boolean;
     FTextureOverride: Boolean;
     FTextureOverride: Boolean;
-    FTextureMatrix: TMatrix;
+    FTextureMatrix: TGLMatrix;
     FMappingMode: TGLTextureMappingMode;
     FMappingMode: TGLTextureMappingMode;
     FEnvColor: TGLColor;
     FEnvColor: TGLColor;
     FMapSCoordinates: TGLCoordinates4;
     FMapSCoordinates: TGLCoordinates4;
@@ -426,7 +426,7 @@ type
     function GetTextureScale: TGLCoordinates;
     function GetTextureScale: TGLCoordinates;
     procedure SetTextureScale(const AValue: TGLCoordinates);
     procedure SetTextureScale(const AValue: TGLCoordinates);
     function StoreTextureScale: Boolean;
     function StoreTextureScale: Boolean;
-    procedure SetTextureMatrix(const AValue: TMatrix);
+    procedure SetTextureMatrix(const AValue: TGLMatrix);
     procedure SetTextureRotate(AValue: Single);
     procedure SetTextureRotate(AValue: Single);
     function StoreTextureRotate: Boolean;
     function StoreTextureRotate: Boolean;
     procedure SetMappingMode(const AValue: TGLTextureMappingMode);
     procedure SetMappingMode(const AValue: TGLTextureMappingMode);
@@ -459,7 +459,7 @@ type
     function IsValid: Boolean;
     function IsValid: Boolean;
     procedure Apply(var ARci: TGLRenderContextInfo);
     procedure Apply(var ARci: TGLRenderContextInfo);
     procedure UnApply(var ARci: TGLRenderContextInfo);
     procedure UnApply(var ARci: TGLRenderContextInfo);
-    property TextureMatrix: TMatrix read FTextureMatrix write SetTextureMatrix;
+    property TextureMatrix: TGLMatrix read FTextureMatrix write SetTextureMatrix;
   published
   published
     property LibTextureName: TGLMaterialComponentName read GetLibTextureName
     property LibTextureName: TGLMaterialComponentName read GetLibTextureName
       write SetLibTextureName;
       write SetLibTextureName;
@@ -3903,10 +3903,10 @@ begin
   FSwizzling.Assign(AValue);
   FSwizzling.Assign(AValue);
 end;
 end;
 
 
-procedure TGLTextureProperties.SetTextureMatrix(const AValue: TMatrix);
+procedure TGLTextureProperties.SetTextureMatrix(const AValue: TGLMatrix);
 begin
 begin
   FTextureMatrixIsIdentity := CompareMem(@AValue.V[0], @IdentityHmgMatrix.V[0],
   FTextureMatrixIsIdentity := CompareMem(@AValue.V[0], @IdentityHmgMatrix.V[0],
-    SizeOf(TMatrix));
+    SizeOf(TGLMatrix));
   FTextureMatrix := AValue;
   FTextureMatrix := AValue;
   FTextureOverride := True;
   FTextureOverride := True;
   NotifyChange(Self);
   NotifyChange(Self);

+ 2 - 2
Source/GLS.Mirror.pas

@@ -139,7 +139,7 @@ procedure TGLMirror.DoRender(var ARci: TGLRenderContextInfo;
   ARenderSelf, ARenderChildren: Boolean);
   ARenderSelf, ARenderChildren: Boolean);
 var
 var
   oldProxySubObject: Boolean;
   oldProxySubObject: Boolean;
-  refMat, curMat, ModelMat: TMatrix;
+  refMat, curMat, ModelMat: TGLMatrix;
   clipPlane: TDoubleHmgPlane;
   clipPlane: TDoubleHmgPlane;
   bgColor: TColorVector;
   bgColor: TColorVector;
   cameraPosBackup, cameraDirectionBackup: TGLVector;
   cameraPosBackup, cameraDirectionBackup: TGLVector;
@@ -307,7 +307,7 @@ end;
 
 
 procedure TGLMirror.ClearZBufferArea(aBuffer: TGLSceneBuffer);
 procedure TGLMirror.ClearZBufferArea(aBuffer: TGLSceneBuffer);
 var
 var
-  worldMat: TMatrix;
+  worldMat: TGLMatrix;
   p: TAffineVector;
   p: TAffineVector;
 begin
 begin
   with aBuffer do
   with aBuffer do

+ 1 - 1
Source/GLS.Objects.pas

@@ -1303,7 +1303,7 @@ procedure TGLSprite.BuildList(var rci: TGLRenderContextInfo);
 var
 var
   vx, vy: TAffineVector;
   vx, vy: TAffineVector;
   W, h: Single;
   W, h: Single;
-  mat: TMatrix;
+  mat: TGLMatrix;
   u0, v0, u1, v1: Integer;
   u0, v0, u1, v1: Integer;
 begin
 begin
   if FAlphaChannel <> 1 then
   if FAlphaChannel <> 1 then

+ 5 - 5
Source/GLS.Octree.pas

@@ -118,9 +118,9 @@ type
       : TAffineVectorList;
       : TAffineVectorList;
     //  Returns all triangles in an arbitrarily placed cube
     //  Returns all triangles in an arbitrarily placed cube
     function GetTrianglesFromNodesIntersectingCube(const ObjAABB: TAABB;
     function GetTrianglesFromNodesIntersectingCube(const ObjAABB: TAABB;
-      const ObjToSelf, SelfToObj: TMatrix): TAffineVectorList;
+      const ObjToSelf, SelfToObj: TGLMatrix): TAffineVectorList;
     //  Checks if an AABB intersects a face on the octree
     //  Checks if an AABB intersects a face on the octree
-    function AABBIntersect(const AABB: TAABB; const M1to2, M2to1: TMatrix;
+    function AABBIntersect(const AABB: TAABB; const M1to2, M2to1: TGLMatrix;
       Triangles: TAffineVectorList = nil): Boolean;
       Triangles: TAffineVectorList = nil): Boolean;
     // function SphereIntersect(position:TAffineVector; radius:single);
     // function SphereIntersect(position:TAffineVector; radius:single);
   end;
   end;
@@ -1410,7 +1410,7 @@ begin
   end; // end for i nodes
   end; // end for i nodes
 end;
 end;
 
 
-function TGLOctree.AABBIntersect(const AABB: TAABB; const M1to2, M2to1: TMatrix;
+function TGLOctree.AABBIntersect(const AABB: TAABB; const M1to2, M2to1: TGLMatrix;
   Triangles: TAffineVectorList = nil): Boolean;
   Triangles: TAffineVectorList = nil): Boolean;
 var
 var
   TriList: TAffineVectorList;
   TriList: TAffineVectorList;
@@ -1512,10 +1512,10 @@ begin
 end;
 end;
 
 
 function TGLOctree.GetTrianglesFromNodesIntersectingCube(const ObjAABB: TAABB;
 function TGLOctree.GetTrianglesFromNodesIntersectingCube(const ObjAABB: TAABB;
-  const ObjToSelf, SelfToObj: TMatrix): TAffineVectorList;
+  const ObjToSelf, SelfToObj: TGLMatrix): TAffineVectorList;
 var
 var
   AABB1: TAABB;
   AABB1: TAABB;
-  M1To2, M2To1: TMatrix;
+  M1To2, M2To1: TGLMatrix;
 
 
   procedure HandleNode(Onode: POctreeNode);
   procedure HandleNode(Onode: POctreeNode);
   var
   var

+ 3 - 3
Source/GLS.ParticleFX.pas

@@ -2286,7 +2286,7 @@ procedure TGLLifeColoredPFXManager.RotateVertexBuf(buf: TAffineVectorList;
   lifeTime: Single; const axis: TAffineVector; offsetAngle: Single);
   lifeTime: Single; const axis: TAffineVector; offsetAngle: Single);
 var
 var
   rotateAngle: Single;
   rotateAngle: Single;
-  rotMatrix: TMatrix;
+  rotMatrix: TGLMatrix;
   diff: Single;
   diff: Single;
   lifeRotationApplied: Boolean;
   lifeRotationApplied: Boolean;
 begin
 begin
@@ -2421,7 +2421,7 @@ end;
 procedure TGLPolygonPFXManager.InitializeRendering(var rci: TGLRenderContextInfo);
 procedure TGLPolygonPFXManager.InitializeRendering(var rci: TGLRenderContextInfo);
 var
 var
   i: Integer;
   i: Integer;
-  matrix: TMatrix;
+  matrix: TGLMatrix;
   s, c: Single;
   s, c: Single;
 begin
 begin
   inherited;
   inherited;
@@ -2629,7 +2629,7 @@ end;
 procedure TGLBaseSpritePFXManager.InitializeRendering(var rci: TGLRenderContextInfo);
 procedure TGLBaseSpritePFXManager.InitializeRendering(var rci: TGLRenderContextInfo);
 var
 var
   i: Integer;
   i: Integer;
-  matrix: TMatrix;
+  matrix: TGLMatrix;
   s, c, w, h: Single;
   s, c, w, h: Single;
 begin
 begin
   inherited;
   inherited;

+ 35 - 35
Source/GLS.PipelineTransformation.pas

@@ -40,14 +40,14 @@ type
   PTransformationRec = ^TTransformationRec;
   PTransformationRec = ^TTransformationRec;
   TTransformationRec = record
   TTransformationRec = record
     FStates: TGLPipelineTransformationStates;
     FStates: TGLPipelineTransformationStates;
-    FModelMatrix: TMatrix;
-    FViewMatrix: TMatrix;
-    FProjectionMatrix: TMatrix;
-    FInvModelMatrix: TMatrix;
+    FModelMatrix: TGLMatrix;
+    FViewMatrix: TGLMatrix;
+    FProjectionMatrix: TGLMatrix;
+    FInvModelMatrix: TGLMatrix;
     FNormalModelMatrix: TAffineMatrix;
     FNormalModelMatrix: TAffineMatrix;
-    FModelViewMatrix: TMatrix;
-    FInvModelViewMatrix: TMatrix;
-    FViewProjectionMatrix: TMatrix;
+    FModelViewMatrix: TGLMatrix;
+    FInvModelViewMatrix: TGLMatrix;
+    FViewProjectionMatrix: TGLMatrix;
     FFrustum: TFrustum;
     FFrustum: TFrustum;
   end;
   end;
 
 
@@ -61,14 +61,14 @@ type
     FStack: array of TTransformationRec;
     FStack: array of TTransformationRec;
     FLoadMatricesEnabled: Boolean;
     FLoadMatricesEnabled: Boolean;
     FOnPush: TOnMatricesPush;
     FOnPush: TOnMatricesPush;
-    function GetModelMatrix: PMatrix; inline;
-    function GetViewMatrix: PMatrix; inline;
-    function GetProjectionMatrix: PMatrix; inline;
-    function GetModelViewMatrix: PMatrix; inline;
-    function GetInvModelViewMatrix: PMatrix; inline;
-    function GetInvModelMatrix: PMatrix; inline;
+    function GetModelMatrix: PGLMatrix; inline;
+    function GetViewMatrix: PGLMatrix; inline;
+    function GetProjectionMatrix: PGLMatrix; inline;
+    function GetModelViewMatrix: PGLMatrix; inline;
+    function GetInvModelViewMatrix: PGLMatrix; inline;
+    function GetInvModelMatrix: PGLMatrix; inline;
     function GetNormalModelMatrix: PAffineMatrix; inline;
     function GetNormalModelMatrix: PAffineMatrix; inline;
-    function GetViewProjectionMatrix: PMatrix; inline;
+    function GetViewProjectionMatrix: PGLMatrix; inline;
     function GetFrustum: TFrustum; inline;
     function GetFrustum: TFrustum; inline;
   protected
   protected
     procedure LoadModelViewMatrix; inline;
     procedure LoadModelViewMatrix; inline;
@@ -77,23 +77,23 @@ type
     property OnPush: TOnMatricesPush read FOnPush write FOnPush;
     property OnPush: TOnMatricesPush read FOnPush write FOnPush;
   public
   public
     constructor Create;
     constructor Create;
-    procedure SetModelMatrix(const AMatrix: TMatrix); inline;
-    procedure SetViewMatrix(const AMatrix: TMatrix); inline;
-    procedure SetProjectionMatrix(const AMatrix: TMatrix); inline;
+    procedure SetModelMatrix(const AMatrix: TGLMatrix); inline;
+    procedure SetViewMatrix(const AMatrix: TGLMatrix); inline;
+    procedure SetProjectionMatrix(const AMatrix: TGLMatrix); inline;
     procedure IdentityAll; inline;
     procedure IdentityAll; inline;
     procedure Push(AValue: PTransformationRec); overload;
     procedure Push(AValue: PTransformationRec); overload;
     procedure Push(); overload; inline;
     procedure Push(); overload; inline;
     procedure Pop;
     procedure Pop;
     procedure ReplaceFromStack;
     procedure ReplaceFromStack;
     function StackTop: TTransformationRec; inline;
     function StackTop: TTransformationRec; inline;
-    property ModelMatrix: PMatrix read GetModelMatrix;
-    property ViewMatrix: PMatrix read GetViewMatrix;
-    property ProjectionMatrix: PMatrix read GetProjectionMatrix;
-    property InvModelMatrix: PMatrix read GetInvModelMatrix;
-    property ModelViewMatrix: PMatrix read GetModelViewMatrix;
+    property ModelMatrix: PGLMatrix read GetModelMatrix;
+    property ViewMatrix: PGLMatrix read GetViewMatrix;
+    property ProjectionMatrix: PGLMatrix read GetProjectionMatrix;
+    property InvModelMatrix: PGLMatrix read GetInvModelMatrix;
+    property ModelViewMatrix: PGLMatrix read GetModelViewMatrix;
     property NormalModelMatrix: PAffineMatrix read GetNormalModelMatrix;
     property NormalModelMatrix: PAffineMatrix read GetNormalModelMatrix;
-    property InvModelViewMatrix: PMatrix read GetInvModelViewMatrix;
-    property ViewProjectionMatrix: PMatrix read GetViewProjectionMatrix;
+    property InvModelViewMatrix: PGLMatrix read GetInvModelViewMatrix;
+    property ViewProjectionMatrix: PGLMatrix read GetViewProjectionMatrix;
     property Frustum: TFrustum read GetFrustum;
     property Frustum: TFrustum read GetFrustum;
     property LoadMatricesEnabled: Boolean read FLoadMatricesEnabled write FLoadMatricesEnabled;
     property LoadMatricesEnabled: Boolean read FLoadMatricesEnabled write FLoadMatricesEnabled;
   end;
   end;
@@ -116,7 +116,7 @@ begin
   glMatrixMode(GL_MODELVIEW);
   glMatrixMode(GL_MODELVIEW);
 end;
 end;
 
 
-function TGLTransformation.GetModelViewMatrix: PMatrix;
+function TGLTransformation.GetModelViewMatrix: PGLMatrix;
 begin
 begin
   if trsModelViewChanged in FStack[FStackPos].FStates then
   if trsModelViewChanged in FStack[FStackPos].FStates then
   begin
   begin
@@ -232,22 +232,22 @@ begin
   end;
   end;
 end;
 end;
 
 
-function TGLTransformation.GetModelMatrix: PMatrix;
+function TGLTransformation.GetModelMatrix: PGLMatrix;
 begin
 begin
   Result := @FStack[FStackPos].FModelMatrix;
   Result := @FStack[FStackPos].FModelMatrix;
 end;
 end;
 
 
-function TGLTransformation.GetViewMatrix: PMatrix;
+function TGLTransformation.GetViewMatrix: PGLMatrix;
 begin
 begin
   Result := @FStack[FStackPos].FViewMatrix;
   Result := @FStack[FStackPos].FViewMatrix;
 end;
 end;
 
 
-function TGLTransformation.GetProjectionMatrix: PMatrix;
+function TGLTransformation.GetProjectionMatrix: PGLMatrix;
 begin
 begin
   Result := @FStack[FStackPos].FProjectionMatrix;
   Result := @FStack[FStackPos].FProjectionMatrix;
 end;
 end;
 
 
-procedure TGLTransformation.SetModelMatrix(const AMatrix: TMatrix);
+procedure TGLTransformation.SetModelMatrix(const AMatrix: TGLMatrix);
 begin
 begin
   FStack[FStackPos].FModelMatrix := AMatrix;
   FStack[FStackPos].FModelMatrix := AMatrix;
   FStack[FStackPos].FStates := FStack[FStackPos].FStates +
   FStack[FStackPos].FStates := FStack[FStackPos].FStates +
@@ -256,7 +256,7 @@ begin
     LoadModelViewMatrix;
     LoadModelViewMatrix;
 end;
 end;
 
 
-procedure TGLTransformation.SetViewMatrix(const AMatrix: TMatrix);
+procedure TGLTransformation.SetViewMatrix(const AMatrix: TGLMatrix);
 begin
 begin
   FStack[FStackPos].FViewMatrix:= AMatrix;
   FStack[FStackPos].FViewMatrix:= AMatrix;
   FStack[FStackPos].FStates := FStack[FStackPos].FStates +
   FStack[FStackPos].FStates := FStack[FStackPos].FStates +
@@ -270,7 +270,7 @@ begin
   Result := FStack[FStackPos];
   Result := FStack[FStackPos];
 end;
 end;
 
 
-procedure TGLTransformation.SetProjectionMatrix(const AMatrix: TMatrix);
+procedure TGLTransformation.SetProjectionMatrix(const AMatrix: TGLMatrix);
 begin
 begin
   FStack[FStackPos].FProjectionMatrix := AMatrix;
   FStack[FStackPos].FProjectionMatrix := AMatrix;
   FStack[FStackPos].FStates := FStack[FStackPos].FStates +
   FStack[FStackPos].FStates := FStack[FStackPos].FStates +
@@ -280,7 +280,7 @@ begin
 end;
 end;
 
 
 
 
-function TGLTransformation.GetInvModelViewMatrix: PMatrix;
+function TGLTransformation.GetInvModelViewMatrix: PGLMatrix;
 begin
 begin
   if trsInvModelViewChanged in FStack[FStackPos].FStates then
   if trsInvModelViewChanged in FStack[FStackPos].FStates then
   begin
   begin
@@ -291,7 +291,7 @@ begin
   Result := @FStack[FStackPos].FInvModelViewMatrix;
   Result := @FStack[FStackPos].FInvModelViewMatrix;
 end;
 end;
 
 
-function TGLTransformation.GetInvModelMatrix: PMatrix;
+function TGLTransformation.GetInvModelMatrix: PGLMatrix;
 begin
 begin
   if trsInvModelChanged in FStack[FStackPos].FStates then
   if trsInvModelChanged in FStack[FStackPos].FStates then
   begin
   begin
@@ -303,7 +303,7 @@ end;
 
 
 function TGLTransformation.GetNormalModelMatrix: PAffineMatrix;
 function TGLTransformation.GetNormalModelMatrix: PAffineMatrix;
 var
 var
-  M: TMatrix;
+  M: TGLMatrix;
 begin
 begin
   if trsNormalModelChanged in FStack[FStackPos].FStates then
   if trsNormalModelChanged in FStack[FStackPos].FStates then
   begin
   begin
@@ -315,7 +315,7 @@ begin
   Result := @FStack[FStackPos].FNormalModelMatrix;
   Result := @FStack[FStackPos].FNormalModelMatrix;
 end;
 end;
 
 
-function TGLTransformation.GetViewProjectionMatrix: PMatrix;
+function TGLTransformation.GetViewProjectionMatrix: PGLMatrix;
 begin
 begin
   if trsViewProjChanged in FStack[FStackPos].FStates then
   if trsViewProjChanged in FStack[FStackPos].FStates then
   begin
   begin

+ 2 - 2
Source/GLS.ProjectedTextures.pas

@@ -125,14 +125,14 @@ end;
 
 
 procedure TGLTextureEmitter.SetupTexMatrix(var ARci: TGLRenderContextInfo);
 procedure TGLTextureEmitter.SetupTexMatrix(var ARci: TGLRenderContextInfo);
 const
 const
-  cBaseMat: TMatrix =
+  cBaseMat: TGLMatrix =
       (V:((X:0.5; Y:0;   Z:0; W:0),
       (V:((X:0.5; Y:0;   Z:0; W:0),
           (X:0;   Y:0.5; Z:0; W:0),
           (X:0;   Y:0.5; Z:0; W:0),
           (X:0;   Y:0; Z:1; W:0),
           (X:0;   Y:0; Z:1; W:0),
           (X:0.5; Y:0.5; Z:0; W:1)));
           (X:0.5; Y:0.5; Z:0; W:1)));
 
 
 var
 var
-  PM: TMatrix;
+  PM: TGLMatrix;
 begin
 begin
   // Set the projector's "perspective" (i.e. the "spotlight cone"):.
   // Set the projector's "perspective" (i.e. the "spotlight cone"):.
   PM := MatrixMultiply(CreatePerspectiveMatrix(FFOVy, FAspect, 0.1, 1), cBaseMat);
   PM := MatrixMultiply(CreatePerspectiveMatrix(FFOVy, FAspect, 0.1, 1), cBaseMat);

+ 5 - 5
Source/GLS.ProxyObjects.pas

@@ -118,7 +118,7 @@ type
   // An object containing the bone matrix for TGLActorProxy.  
   // An object containing the bone matrix for TGLActorProxy.  
   TBoneMatrixObj = class
   TBoneMatrixObj = class
   public
   public
-    Matrix: TMatrix;
+    Matrix: TGLMatrix;
     BoneName: string;
     BoneName: string;
     BoneIndex: integer;
     BoneIndex: integer;
   end;
   end;
@@ -172,8 +172,8 @@ type
     property CurrentTime: TGLProgressTimes read FCurrentTime;
     property CurrentTime: TGLProgressTimes read FCurrentTime;
     (* Gets the Bones Matrix in the current animation frame.
     (* Gets the Bones Matrix in the current animation frame.
      (since the masterobject is shared between all proxies, each proxy will have it's bones matrices) *)
      (since the masterobject is shared between all proxies, each proxy will have it's bones matrices) *)
-    function BoneMatrix(BoneIndex: integer): TMatrix; overload;
-    function BoneMatrix(BoneName: string): TMatrix; overload;
+    function BoneMatrix(BoneIndex: integer): TGLMatrix; overload;
+    function BoneMatrix(BoneName: string): TGLMatrix; overload;
     procedure BoneMatricesClear;
     procedure BoneMatricesClear;
     // A standard version of the RayCastIntersect function. 
     // A standard version of the RayCastIntersect function. 
     function RayCastIntersect(const rayStart, rayVector: TGLVector;
     function RayCastIntersect(const rayStart, rayVector: TGLVector;
@@ -388,13 +388,13 @@ end;
 // ------------------ TGLActorProxy ------------------
 // ------------------ TGLActorProxy ------------------
 // ------------------
 // ------------------
 
 
-function TGLActorProxy.BoneMatrix(BoneIndex: integer): TMatrix;
+function TGLActorProxy.BoneMatrix(BoneIndex: integer): TGLMatrix;
 begin
 begin
   if BoneIndex < FBonesMatrices.count then
   if BoneIndex < FBonesMatrices.count then
     result := TBoneMatrixObj(FBonesMatrices.Objects[BoneIndex]).Matrix;
     result := TBoneMatrixObj(FBonesMatrices.Objects[BoneIndex]).Matrix;
 end;
 end;
 
 
-function TGLActorProxy.BoneMatrix(BoneName: string): TMatrix;
+function TGLActorProxy.BoneMatrix(BoneName: string): TGLMatrix;
 var
 var
   i: Integer;
   i: Integer;
 begin
 begin

+ 155 - 123
Source/GLS.Ragdoll.pas

@@ -1,7 +1,6 @@
 //
 //
 // The graphics rendering engine GLScene http://glscene.org
 // The graphics rendering engine GLScene http://glscene.org
 //
 //
-
 unit GLS.Ragdoll;
 unit GLS.Ragdoll;
 
 
 (* Base abstract ragdoll class. Should be extended to use any physics system. *)
 (* Base abstract ragdoll class. Should be extended to use any physics system. *)
@@ -12,8 +11,9 @@ interface
 
 
 uses
 uses
   GLS.Scene,
   GLS.Scene,
-  GLS.PersistentClasses, 
-  GLS.VectorGeometry, 
+  GLS.PersistentClasses,
+  GLS.VectorTypes,
+  GLS.VectorGeometry,
   GLS.VectorFileObjects,
   GLS.VectorFileObjects,
   GLS.VectorLists,
   GLS.VectorLists,
   GLS.Objects;
   GLS.Objects;
@@ -21,38 +21,41 @@ uses
 type
 type
   TGLRagdoll = class;
   TGLRagdoll = class;
   TGLRagdolBone = class;
   TGLRagdolBone = class;
-
   TGLRagdolJoint = class
   TGLRagdolJoint = class
   end;
   end;
 
 
-  TGLRagdolBoneList = class (TPersistentObjectList)
+  TGLRagdolBoneList = class(TPersistentObjectList)
   private
   private
-     FRagdoll : TGLRagdoll;
+    FRagdoll: TGLRagdoll;
   protected
   protected
-    function GetRagdollBone(Index: Integer) : TGLRagdolBone;
+    function GetRagdollBone(Index: Integer): TGLRagdolBone;
   public
   public
     constructor Create(Ragdoll: TGLRagdoll); reintroduce;
     constructor Create(Ragdoll: TGLRagdoll); reintroduce;
     destructor Destroy; override;
     destructor Destroy; override;
-    procedure WriteToFiler(writer : TVirtualWriter); override;
-    procedure ReadFromFiler(reader : TVirtualReader); override;
-    property Ragdoll : TGLRagdoll read FRagdoll;
-    property Items[Index: Integer] : TGLRagdolBone read GetRagdollBone; default;
-	end;
-	TGLRagdolBone = class (TGLRagdolBoneList)
+    procedure WriteToFiler(writer: TVirtualWriter); override;
+    procedure ReadFromFiler(reader: TVirtualReader); override;
+    property Ragdoll: TGLRagdoll read FRagdoll;
+    property Items[Index: Integer]: TGLRagdolBone read GetRagdollBone; default;
+  end;
+
+  TGLRagdolBone = class(TGLRagdolBoneList)
   private
   private
-    FOwner : TGLRagdolBoneList;
-    FName : String;
-    FBoneID : Integer; //Refering to TGLActor Bone
+    FOwner: TGLRagdolBoneList;
+    FName: String;
+    FBoneID: Integer; // Refering to TGLActor Bone
     FBoundMax: TAffineVector;
     FBoundMax: TAffineVector;
     FBoundMin: TAffineVector;
     FBoundMin: TAffineVector;
-    FBoundBoneDelta: TAffineVector; //Stores the diference from the bone.GlobalMatrix to the center of the bone's bounding box
+    FBoundBoneDelta: TAffineVector;
+    // Stores the diference from the bone.GlobalMatrix to the center of the bone's bounding box
     FOrigin: TAffineVector;
     FOrigin: TAffineVector;
     FSize: TAffineVector;
     FSize: TAffineVector;
-    FBoneMatrix: TMatrix;
+    FBoneMatrix: TGLMatrix;
     FJoint: TGLRagdolJoint;
     FJoint: TGLRagdolJoint;
-    FOriginalMatrix: TMatrix; //Stores the Bone.GlobalMatrix before the ragdoll start
-    FReferenceMatrix: TMatrix; //Stores the first bone matrix to be used as reference
-    FAnchor: TAffineVector; //The position of the joint
+    FOriginalMatrix: TGLMatrix;
+    // Stores the Bone.GlobalMatrix before the ragdoll start
+    FReferenceMatrix: TGLMatrix;
+    // Stores the first bone matrix to be used as reference
+    FAnchor: TAffineVector; // The position of the joint
     procedure CreateBoundingBox;
     procedure CreateBoundingBox;
     procedure SetAnchor(const Anchor: TAffineVector);
     procedure SetAnchor(const Anchor: TAffineVector);
     procedure AlignToSkeleton;
     procedure AlignToSkeleton;
@@ -62,60 +65,60 @@ type
     procedure UpdateChild;
     procedure UpdateChild;
     procedure StopChild;
     procedure StopChild;
   protected
   protected
-    function GetRagdollBone(Index: Integer) : TGLRagdolBone;
+    function GetRagdollBone(Index: Integer): TGLRagdolBone;
     procedure Start; virtual; abstract;
     procedure Start; virtual; abstract;
     procedure Align; virtual; abstract;
     procedure Align; virtual; abstract;
     procedure Update; virtual; abstract;
     procedure Update; virtual; abstract;
     procedure Stop; virtual; abstract;
     procedure Stop; virtual; abstract;
   public
   public
-    constructor CreateOwned(aOwner : TGLRagdolBoneList);
+    constructor CreateOwned(aOwner: TGLRagdolBoneList);
     constructor Create(Ragdoll: TGLRagdoll);
     constructor Create(Ragdoll: TGLRagdoll);
     destructor Destroy; override;
     destructor Destroy; override;
-    procedure WriteToFiler(writer : TVirtualWriter); override;
-    procedure ReadFromFiler(reader : TVirtualReader); override;
-    property Owner : TGLRagdolBoneList read FOwner;
-    property Name : String read FName write FName;
-    property BoneID : Integer read FBoneID write FBoneID;
-    property Origin : TAffineVector read FOrigin;
-    property Size : TAffineVector read FSize;
-    property BoneMatrix : TMatrix read FBoneMatrix;
-    property ReferenceMatrix : TMatrix read FReferenceMatrix;
-    property Anchor : TAffineVector read FAnchor;
-    property Joint : TGLRagdolJoint read FJoint write FJoint;
-    property Items[Index: Integer] : TGLRagdolBone read GetRagdollBone; default;
-	end;
+    procedure WriteToFiler(writer: TVirtualWriter); override;
+    procedure ReadFromFiler(reader: TVirtualReader); override;
+    property Owner: TGLRagdolBoneList read FOwner;
+    property Name: String read FName write FName;
+    property BoneID: Integer read FBoneID write FBoneID;
+    property Origin: TAffineVector read FOrigin;
+    property Size: TAffineVector read FSize;
+    property BoneMatrix: TGLMatrix read FBoneMatrix;
+    property ReferenceMatrix: TGLMatrix read FReferenceMatrix;
+    property Anchor: TAffineVector read FAnchor;
+    property Joint: TGLRagdolJoint read FJoint write FJoint;
+    property Items[Index: Integer]: TGLRagdolBone read GetRagdollBone; default;
+  end;
 
 
   TGLRagdoll = class(TPersistentObject)
   TGLRagdoll = class(TPersistentObject)
-	private
-    FOwner : TGLBaseMesh;
-    FRootBone : TGLRagdolBone;
+  private
+    FOwner: TGLBaseMesh;
+    FRootBone: TGLRagdolBone;
     FEnabled: Boolean;
     FEnabled: Boolean;
     FBuilt: Boolean;
     FBuilt: Boolean;
   public
   public
-    constructor Create(AOwner : TGLBaseMesh); reintroduce;
+    constructor Create(aOwner: TGLBaseMesh); reintroduce;
     destructor Destroy; override;
     destructor Destroy; override;
-    procedure WriteToFiler(writer : TVirtualWriter); override;
-    procedure ReadFromFiler(reader : TVirtualReader); override;
-    {Must be set before build the ragdoll }
+    procedure WriteToFiler(writer: TVirtualWriter); override;
+    procedure ReadFromFiler(reader: TVirtualReader); override;
+    // Must be set before build the ragdoll
     procedure SetRootBone(RootBone: TGLRagdolBone);
     procedure SetRootBone(RootBone: TGLRagdolBone);
-    {Create the bounding box and setup the ragdoll do be started later }
+    // Create the bounding box and setup the ragdoll do be started later
     procedure BuildRagdoll;
     procedure BuildRagdoll;
     procedure Start;
     procedure Start;
     procedure Update;
     procedure Update;
     procedure Stop;
     procedure Stop;
-    property Owner : TGLBaseMesh read FOwner;
-    property RootBone : TGLRagdolBone read FRootBone;
-    property Enabled : Boolean read FEnabled;
- end;
+    property Owner: TGLBaseMesh read FOwner;
+    property RootBone: TGLRagdolBone read FRootBone;
+    property Enabled: Boolean read FEnabled;
+  end;
 
 
-//------------------------------------------------------------------------	
+// ------------------------------------------------------------------------
 implementation
 implementation
-//------------------------------------------------------------------------	
+// ------------------------------------------------------------------------
 
 
-uses
-  GLS.VectorTypes;
 
 
-{ TGLRagdolBoneList }
+//--------------------------
+// TGLRagdolBoneList
+//--------------------------
 
 
 constructor TGLRagdolBoneList.Create(Ragdoll: TGLRagdoll);
 constructor TGLRagdolBoneList.Create(Ragdoll: TGLRagdoll);
 begin
 begin
@@ -124,30 +127,34 @@ begin
 end;
 end;
 
 
 destructor TGLRagdolBoneList.Destroy;
 destructor TGLRagdolBoneList.Destroy;
-var i: integer;
+var
+  i: Integer;
 begin
 begin
-  for i:=0 to Count-1 do Items[i].Destroy;
+  for i := 0 to Count - 1 do
+    Items[i].Destroy;
   inherited;
   inherited;
 end;
 end;
 
 
 function TGLRagdolBoneList.GetRagdollBone(Index: Integer): TGLRagdolBone;
 function TGLRagdolBoneList.GetRagdollBone(Index: Integer): TGLRagdolBone;
 begin
 begin
-  Result:=TGLRagdolBone(List^[Index]);
+  Result := TGLRagdolBone(List^[Index]);
 end;
 end;
 
 
 procedure TGLRagdolBoneList.ReadFromFiler(reader: TVirtualReader);
 procedure TGLRagdolBoneList.ReadFromFiler(reader: TVirtualReader);
 begin
 begin
   inherited;
   inherited;
-  //Not implemented
+  // Not implemented
 end;
 end;
 
 
 procedure TGLRagdolBoneList.WriteToFiler(writer: TVirtualWriter);
 procedure TGLRagdolBoneList.WriteToFiler(writer: TVirtualWriter);
 begin
 begin
   inherited;
   inherited;
-  //Not implemented
+  // Not implemented
 end;
 end;
 
 
-{ TGLRagdolBone }
+//----------------------------------
+// TGLRagdolBone
+//----------------------------------
 
 
 constructor TGLRagdolBone.Create(Ragdoll: TGLRagdoll);
 constructor TGLRagdolBone.Create(Ragdoll: TGLRagdoll);
 begin
 begin
@@ -157,54 +164,63 @@ end;
 procedure TGLRagdolBone.CreateBoundingBox;
 procedure TGLRagdolBone.CreateBoundingBox;
 var
 var
   bone: TGLSkeletonBone;
   bone: TGLSkeletonBone;
-  i, j: integer;
-  BoneVertices : TAffineVectorList;
-  BoneVertex, max,min: TAffineVector;
-  invMat, mat: TMatrix;
+  i, j: Integer;
+  BoneVertices: TAffineVectorList;
+  BoneVertex, max, min: TAffineVector;
+  invMat, mat: TGLMatrix;
 begin
 begin
   bone := Ragdoll.Owner.Skeleton.BoneByID(FBoneID);
   bone := Ragdoll.Owner.Skeleton.BoneByID(FBoneID);
 
 
-  //Get all vertices weighted to this bone
-  BoneVertices:=TAffineVectorList.Create;
-  for i:=0 to Ragdoll.Owner.MeshObjects.Count-1 do
-  with TGLSkeletonMeshObject(Ragdoll.Owner.MeshObjects[i]) do
-    for j:=0 to Vertices.Count-1 do
-      if bone.BoneID = VerticesBonesWeights[j][0].BoneID then
-        BoneVertices.FindOrAdd(Vertices[j]);
+  // Get all vertices weighted to this bone
+  BoneVertices := TAffineVectorList.Create;
+  for i := 0 to Ragdoll.Owner.MeshObjects.Count - 1 do
+    with TGLSkeletonMeshObject(Ragdoll.Owner.MeshObjects[i]) do
+      for j := 0 to Vertices.Count - 1 do
+        if bone.BoneID = VerticesBonesWeights[j][0].BoneID then
+          BoneVertices.FindOrAdd(Vertices[j]);
 
 
   invMat := bone.GlobalMatrix;
   invMat := bone.GlobalMatrix;
   InvertMatrix(invMat);
   InvertMatrix(invMat);
 
 
-  //For each vertex, get the max and min XYZ (Bounding box)
+  // For each vertex, get the max and min XYZ (Bounding box)
   if BoneVertices.Count > 0 then
   if BoneVertices.Count > 0 then
   begin
   begin
     BoneVertex := VectorTransform(BoneVertices[0], invMat);
     BoneVertex := VectorTransform(BoneVertices[0], invMat);
     max := BoneVertex;
     max := BoneVertex;
     min := BoneVertex;
     min := BoneVertex;
-    for i:=1 to BoneVertices.Count-1 do begin
+    for i := 1 to BoneVertices.Count - 1 do
+    begin
       BoneVertex := VectorTransform(BoneVertices[i], invMat);
       BoneVertex := VectorTransform(BoneVertices[i], invMat);
-      if (BoneVertex.X > max.X) then max.X := BoneVertex.X;
-      if (BoneVertex.Y > max.Y) then max.Y := BoneVertex.Y;
-      if (BoneVertex.Z > max.Z) then max.Z := BoneVertex.Z;
-
-      if (BoneVertex.X < min.X) then min.X := BoneVertex.X;
-      if (BoneVertex.Y < min.Y) then min.Y := BoneVertex.Y;
-      if (BoneVertex.Z < min.Z) then min.Z := BoneVertex.Z;
+      if (BoneVertex.X > max.X) then
+        max.X := BoneVertex.X;
+      if (BoneVertex.Y > max.Y) then
+        max.Y := BoneVertex.Y;
+      if (BoneVertex.Z > max.Z) then
+        max.Z := BoneVertex.Z;
+
+      if (BoneVertex.X < min.X) then
+        min.X := BoneVertex.X;
+      if (BoneVertex.Y < min.Y) then
+        min.Y := BoneVertex.Y;
+      if (BoneVertex.Z < min.Z) then
+        min.Z := BoneVertex.Z;
     end;
     end;
 
 
     FBoundMax := max;
     FBoundMax := max;
     FBoundMin := min;
     FBoundMin := min;
-    //Get the origin and subtract from the bone matrix
+    // Get the origin and subtract from the bone matrix
     FBoundBoneDelta := VectorScale(VectorAdd(FBoundMax, FBoundMin), 0.5);
     FBoundBoneDelta := VectorScale(VectorAdd(FBoundMax, FBoundMin), 0.5);
-  end else begin
+  end
+  else
+  begin
     FBoundMax := NullVector;
     FBoundMax := NullVector;
     FBoundMin := NullVector;
     FBoundMin := NullVector;
   end;
   end;
 
 
   AlignToSkeleton;
   AlignToSkeleton;
   FReferenceMatrix := FBoneMatrix;
   FReferenceMatrix := FBoneMatrix;
-  mat := MatrixMultiply(bone.GlobalMatrix,FRagdoll.Owner.AbsoluteMatrix);
-  //Set Joint position
+  mat := MatrixMultiply(bone.GlobalMatrix, FRagdoll.Owner.AbsoluteMatrix);
+  // Set Joint position
   SetAnchor(AffineVectorMake(mat.V[3]));
   SetAnchor(AffineVectorMake(mat.V[3]));
 
 
   BoneVertices.Free; // NEW1
   BoneVertices.Free; // NEW1
@@ -212,8 +228,8 @@ end;
 
 
 constructor TGLRagdolBone.CreateOwned(aOwner: TGLRagdolBoneList);
 constructor TGLRagdolBone.CreateOwned(aOwner: TGLRagdolBoneList);
 begin
 begin
-	Create(aOwner.Ragdoll);
-  FOwner:=aOwner;
+  Create(aOwner.Ragdoll);
+  FOwner := aOwner;
   aOwner.Add(Self);
   aOwner.Add(Self);
 end;
 end;
 
 
@@ -226,14 +242,14 @@ procedure TGLRagdolBone.AlignToSkeleton;
 var
 var
   o: TAffineVector;
   o: TAffineVector;
   bone: TGLSkeletonBone;
   bone: TGLSkeletonBone;
-  mat, posMat: TMatrix;
+  mat, posMat: TGLMatrix;
   noBounds: Boolean;
   noBounds: Boolean;
 begin
 begin
   bone := Ragdoll.Owner.Skeleton.BoneByID(FBoneID);
   bone := Ragdoll.Owner.Skeleton.BoneByID(FBoneID);
   noBounds := VectorIsNull(FBoundMax) and VectorIsNull(FBoundMin);
   noBounds := VectorIsNull(FBoundMax) and VectorIsNull(FBoundMin);
-  //Get the bone matrix relative to the Actor matrix
-  mat := MatrixMultiply(bone.GlobalMatrix,FRagdoll.Owner.AbsoluteMatrix);
-  //Set Rotation
+  // Get the bone matrix relative to the Actor matrix
+  mat := MatrixMultiply(bone.GlobalMatrix, FRagdoll.Owner.AbsoluteMatrix);
+  // Set Rotation
   FBoneMatrix := mat;
   FBoneMatrix := mat;
   NormalizeMatrix(FBoneMatrix);
   NormalizeMatrix(FBoneMatrix);
 
 
@@ -241,25 +257,27 @@ begin
   begin
   begin
     FOrigin := AffineVectorMake(mat.V[3]);
     FOrigin := AffineVectorMake(mat.V[3]);
     FSize := AffineVectorMake(0.1, 0.1, 0.1);
     FSize := AffineVectorMake(0.1, 0.1, 0.1);
-  end else begin
-    //Set Origin
+  end
+  else
+  begin
+    // Set Origin
     posMat := mat;
     posMat := mat;
     posMat.V[3] := NullHmgVector;
     posMat.V[3] := NullHmgVector;
     o := VectorTransform(FBoundBoneDelta, posMat);
     o := VectorTransform(FBoundBoneDelta, posMat);
     FOrigin := VectorAdd(AffineVectorMake(mat.V[3]), o);
     FOrigin := VectorAdd(AffineVectorMake(mat.V[3]), o);
-    //Set Size
-    FSize := VectorScale(VectorSubtract(FBoundMax, FBoundMin),0.9);
-    FSize.X := FSize.X*VectorLength(mat.V[0]);
-    FSize.Y := FSize.Y*VectorLength(mat.V[1]);
-    FSize.Z := FSize.Z*VectorLength(mat.V[2]);
+    // Set Size
+    FSize := VectorScale(VectorSubtract(FBoundMax, FBoundMin), 0.9);
+    FSize.X := FSize.X * VectorLength(mat.V[0]);
+    FSize.Y := FSize.Y * VectorLength(mat.V[1]);
+    FSize.Z := FSize.Z * VectorLength(mat.V[2]);
   end;
   end;
-  //Put the origin in the BoneMatrix
-  FBoneMatrix.V[3] := VectorMake(FOrigin,1);
+  // Put the origin in the BoneMatrix
+  FBoneMatrix.V[3] := VectorMake(FOrigin, 1);
 end;
 end;
 
 
 function TGLRagdolBone.GetRagdollBone(Index: Integer): TGLRagdolBone;
 function TGLRagdolBone.GetRagdollBone(Index: Integer): TGLRagdolBone;
 begin
 begin
-  Result:=TGLRagdolBone(List^[Index]);
+  Result := TGLRagdolBone(List^[Index]);
 end;
 end;
 
 
 procedure TGLRagdolBone.ReadFromFiler(reader: TVirtualReader);
 procedure TGLRagdolBone.ReadFromFiler(reader: TVirtualReader);
@@ -269,40 +287,47 @@ begin
 end;
 end;
 
 
 procedure TGLRagdolBone.StartChild;
 procedure TGLRagdolBone.StartChild;
-var i: integer;
+var
+  i: Integer;
 begin
 begin
   FOriginalMatrix := Ragdoll.Owner.Skeleton.BoneByID(FBoneID).GlobalMatrix;
   FOriginalMatrix := Ragdoll.Owner.Skeleton.BoneByID(FBoneID).GlobalMatrix;
   AlignToSkeleton;
   AlignToSkeleton;
   Start;
   Start;
-  for i := 0 to Count-1 do items[i].StartChild;
+  for i := 0 to Count - 1 do
+    Items[i].StartChild;
 end;
 end;
 
 
 procedure TGLRagdolBone.UpdateChild;
 procedure TGLRagdolBone.UpdateChild;
-var i: integer;
+var
+  i: Integer;
 begin
 begin
   Update;
   Update;
-  for i := 0 to Count-1 do items[i].UpdateChild;
+  for i := 0 to Count - 1 do
+    Items[i].UpdateChild;
 end;
 end;
 
 
 procedure TGLRagdolBone.WriteToFiler(writer: TVirtualWriter);
 procedure TGLRagdolBone.WriteToFiler(writer: TVirtualWriter);
 begin
 begin
   inherited;
   inherited;
-
 end;
 end;
 
 
 procedure TGLRagdolBone.StopChild;
 procedure TGLRagdolBone.StopChild;
-var i: integer;
+var
+  i: Integer;
 begin
 begin
   Stop;
   Stop;
   Ragdoll.Owner.Skeleton.BoneByID(FBoneID).SetGlobalMatrix(FOriginalMatrix);
   Ragdoll.Owner.Skeleton.BoneByID(FBoneID).SetGlobalMatrix(FOriginalMatrix);
-  for i := 0 to Count-1 do items[i].StopChild;
+  for i := 0 to Count - 1 do
+    Items[i].StopChild;
 end;
 end;
 
 
 procedure TGLRagdolBone.CreateBoundsChild;
 procedure TGLRagdolBone.CreateBoundsChild;
-var i: integer;
+var
+  i: Integer;
 begin
 begin
   CreateBoundingBox;
   CreateBoundingBox;
-  for i := 0 to Count-1 do items[i].CreateBoundsChild;
+  for i := 0 to Count - 1 do
+    Items[i].CreateBoundsChild;
 end;
 end;
 
 
 procedure TGLRagdolBone.SetAnchor(const Anchor: TAffineVector);
 procedure TGLRagdolBone.SetAnchor(const Anchor: TAffineVector);
@@ -311,25 +336,28 @@ begin
 end;
 end;
 
 
 procedure TGLRagdolBone.AlignChild;
 procedure TGLRagdolBone.AlignChild;
-var i: integer;
+var
+  i: Integer;
 begin
 begin
   Align;
   Align;
   Update;
   Update;
-  for i := 0 to Count-1 do items[i].AlignChild;
+  for i := 0 to Count - 1 do
+    Items[i].AlignChild;
 end;
 end;
 
 
 { TGLRagdoll }
 { TGLRagdoll }
 
 
-constructor TGLRagdoll.Create(AOwner : TGLBaseMesh);
+constructor TGLRagdoll.Create(aOwner: TGLBaseMesh);
 begin
 begin
-  FOwner := AOwner;
+  FOwner := aOwner;
   FEnabled := False;
   FEnabled := False;
   FBuilt := False;
   FBuilt := False;
 end;
 end;
 
 
 destructor TGLRagdoll.Destroy;
 destructor TGLRagdoll.Destroy;
 begin
 begin
-  if FEnabled then Stop;
+  if FEnabled then
+    Stop;
   inherited Destroy;
   inherited Destroy;
 end;
 end;
 
 
@@ -337,6 +365,7 @@ procedure TGLRagdoll.ReadFromFiler(reader: TVirtualReader);
 begin
 begin
   inherited;
   inherited;
 end;
 end;
+
 procedure TGLRagdoll.SetRootBone(RootBone: TGLRagdolBone);
 procedure TGLRagdoll.SetRootBone(RootBone: TGLRagdolBone);
 begin
 begin
   FRootBone := RootBone;
   FRootBone := RootBone;
@@ -345,13 +374,14 @@ end;
 procedure TGLRagdoll.Start;
 procedure TGLRagdoll.Start;
 begin
 begin
   Assert(FBuilt, 'First you need to build the ragdoll. BuildRagdoll;');
   Assert(FBuilt, 'First you need to build the ragdoll. BuildRagdoll;');
-  if (FEnabled) then Exit;
-  FEnabled:= True;
-  //First start the ragdoll in the reference position
+  if (FEnabled) then
+    Exit;
+  FEnabled := True;
+  // First start the ragdoll in the reference position
   RootBone.StartChild;
   RootBone.StartChild;
-  //Now align it to the animation
+  // Now align it to the animation
   RootBone.AlignChild;
   RootBone.AlignChild;
-  //Now it recalculate the vertices to use as reference
+  // Now it recalculate the vertices to use as reference
   FOwner.Skeleton.StartRagDoll;
   FOwner.Skeleton.StartRagDoll;
 end;
 end;
 
 
@@ -360,18 +390,19 @@ begin
   if FEnabled then
   if FEnabled then
   begin
   begin
     RootBone.UpdateChild;
     RootBone.UpdateChild;
-    FOwner.Skeleton.MorphMesh(true);
+    FOwner.Skeleton.MorphMesh(True);
   end;
   end;
 end;
 end;
 
 
 procedure TGLRagdoll.Stop;
 procedure TGLRagdoll.Stop;
 begin
 begin
-  if not FEnabled then Exit;
+  if not FEnabled then
+    Exit;
   FEnabled := False;
   FEnabled := False;
   RootBone.StopChild;
   RootBone.StopChild;
-  //Restore the old information
+  // Restore the old information
   FOwner.Skeleton.StopRagDoll;
   FOwner.Skeleton.StopRagDoll;
-  FOwner.Skeleton.MorphMesh(true);
+  FOwner.Skeleton.MorphMesh(True);
 end;
 end;
 
 
 procedure TGLRagdoll.WriteToFiler(writer: TVirtualWriter);
 procedure TGLRagdoll.WriteToFiler(writer: TVirtualWriter);
@@ -382,7 +413,8 @@ end;
 
 
 procedure TGLRagdoll.BuildRagdoll;
 procedure TGLRagdoll.BuildRagdoll;
 begin
 begin
-  Assert(RootBone <> nil, 'First you need to set the root bone. SetRootBone();');
+  Assert(RootBone <> nil,
+    'First you need to set the root bone. SetRootBone();');
   RootBone.CreateBoundsChild;
   RootBone.CreateBoundsChild;
   FBuilt := True;
   FBuilt := True;
 end;
 end;

+ 1 - 0
Source/GLS.RenderContextInfo.pas

@@ -11,6 +11,7 @@ interface
 
 
 uses
 uses
   GLS.PersistentClasses,
   GLS.PersistentClasses,
+  GLS.VectorTypes,
   GLS.VectorGeometry,
   GLS.VectorGeometry,
   GLS.State,
   GLS.State,
   GLS.PipelineTransformation,
   GLS.PipelineTransformation,

+ 50 - 50
Source/GLS.Scene.pas

@@ -157,8 +157,8 @@ type
      move and delete them). Using the regular TComponent methods is not encouraged *)
      move and delete them). Using the regular TComponent methods is not encouraged *)
   TGLBaseSceneObject = class(TGLCoordinatesUpdateAbleComponent)
   TGLBaseSceneObject = class(TGLCoordinatesUpdateAbleComponent)
   private
   private
-    FAbsoluteMatrix, FInvAbsoluteMatrix: TMatrix;
-    FLocalMatrix: TMatrix;
+    FAbsoluteMatrix, FInvAbsoluteMatrix: TGLMatrix;
+    FLocalMatrix: TGLMatrix;
     FObjectStyle: TGLObjectStyles;
     FObjectStyle: TGLObjectStyles;
     FListHandle: TGLListHandle; // created on 1st use
     FListHandle: TGLListHandle; // created on 1st use
     FPosition: TGLCoordinates;
     FPosition: TGLCoordinates;
@@ -200,7 +200,7 @@ type
     procedure SetIndex(aValue: Integer);
     procedure SetIndex(aValue: Integer);
     procedure SetDirection(AVector: TGLCoordinates);
     procedure SetDirection(AVector: TGLCoordinates);
     procedure SetUp(AVector: TGLCoordinates);
     procedure SetUp(AVector: TGLCoordinates);
-    function GetMatrix: PMatrix; inline;
+    function GetMatrix: PGLMatrix; inline;
     procedure SetPosition(APosition: TGLCoordinates);
     procedure SetPosition(APosition: TGLCoordinates);
     procedure SetPitchAngle(AValue: Single);
     procedure SetPitchAngle(AValue: Single);
     procedure SetRollAngle(AValue: Single);
     procedure SetRollAngle(AValue: Single);
@@ -221,11 +221,11 @@ type
     function GetAbsoluteScale: TGLVector;
     function GetAbsoluteScale: TGLVector;
     procedure SetAbsoluteAffineScale(const Value: TAffineVector);
     procedure SetAbsoluteAffineScale(const Value: TAffineVector);
     procedure SetAbsoluteScale(const Value: TGLVector);
     procedure SetAbsoluteScale(const Value: TGLVector);
-    function GetAbsoluteMatrix: TMatrix; inline;
-    procedure SetAbsoluteMatrix(const Value: TMatrix);
+    function GetAbsoluteMatrix: TGLMatrix; inline;
+    procedure SetAbsoluteMatrix(const Value: TGLMatrix);
     procedure SetBBChanges(const Value: TGLObjectBBChanges);
     procedure SetBBChanges(const Value: TGLObjectBBChanges);
-    function GetDirectAbsoluteMatrix: PMatrix;
-    function GetLocalMatrix: PMatrix; inline;
+    function GetDirectAbsoluteMatrix: PGLMatrix;
+    function GetLocalMatrix: PGLMatrix; inline;
   protected
   protected
     procedure Loaded; override;
     procedure Loaded; override;
     procedure SetScene(const Value: TGLScene); virtual;
     procedure SetScene(const Value: TGLScene); virtual;
@@ -286,34 +286,34 @@ type
     (* The local transformation (relative to parent).
     (* The local transformation (relative to parent).
        If you're *sure* the local matrix is up-to-date, you may use LocalMatrix
        If you're *sure* the local matrix is up-to-date, you may use LocalMatrix
        for quicker access. *)
        for quicker access. *)
-    procedure SetMatrix(const aValue: TMatrix); inline;
-    property Matrix: PMatrix read GetMatrix;
+    procedure SetMatrix(const aValue: TGLMatrix); inline;
+    property Matrix: PGLMatrix read GetMatrix;
     (* Holds the local transformation (relative to parent).
     (* Holds the local transformation (relative to parent).
        If you're not *sure* the local matrix is up-to-date, use Matrix property. *)
        If you're not *sure* the local matrix is up-to-date, use Matrix property. *)
-    property LocalMatrix: PMatrix read GetLocalMatrix;
+    property LocalMatrix: PGLMatrix read GetLocalMatrix;
     (* Forces the local matrix to the specified value.
     (* Forces the local matrix to the specified value.
        AbsoluteMatrix, InverseMatrix, etc. will honour that change, but
        AbsoluteMatrix, InverseMatrix, etc. will honour that change, but
        may become invalid if the specified matrix isn't orthonormal (can
        may become invalid if the specified matrix isn't orthonormal (can
        be used for specific rendering or projection effects).
        be used for specific rendering or projection effects).
        The local matrix will be reset by the next TransformationChanged,
        The local matrix will be reset by the next TransformationChanged,
        position or attitude change. *)
        position or attitude change. *)
-    procedure ForceLocalMatrix(const aMatrix: TMatrix); inline;
+    procedure ForceLocalMatrix(const aMatrix: TGLMatrix); inline;
     // See AbsoluteMatrix.
     // See AbsoluteMatrix.
-    function AbsoluteMatrixAsAddress: PMatrix;
+    function AbsoluteMatrixAsAddress: PGLMatrix;
     (* Holds the absolute transformation matrix.
     (* Holds the absolute transformation matrix.
        If you're not *sure* the absolute matrix is up-to-date,
        If you're not *sure* the absolute matrix is up-to-date,
        use the AbsoluteMatrix property, this one may be nil... *)
        use the AbsoluteMatrix property, this one may be nil... *)
-    property DirectAbsoluteMatrix: PMatrix read GetDirectAbsoluteMatrix;
+    property DirectAbsoluteMatrix: PGLMatrix read GetDirectAbsoluteMatrix;
     (* Calculates the object's absolute inverse matrix.
     (* Calculates the object's absolute inverse matrix.
        Multiplying an absolute coordinate with this matrix gives a local coordinate.
        Multiplying an absolute coordinate with this matrix gives a local coordinate.
        The current implem uses transposition(AbsoluteMatrix), which is true
        The current implem uses transposition(AbsoluteMatrix), which is true
        unless you're using some scaling... *)
        unless you're using some scaling... *)
-    function InvAbsoluteMatrix: TMatrix; inline;
+    function InvAbsoluteMatrix: TGLMatrix; inline;
     //See InvAbsoluteMatrix.
     //See InvAbsoluteMatrix.
-    function InvAbsoluteMatrixAsAddress: PMatrix;
+    function InvAbsoluteMatrixAsAddress: PGLMatrix;
     (* The object's absolute matrix by composing all local matrices.
     (* The object's absolute matrix by composing all local matrices.
        Multiplying a local coordinate with this matrix gives an absolute coordinate. *)
        Multiplying a local coordinate with this matrix gives an absolute coordinate. *)
-    property AbsoluteMatrix: TMatrix read GetAbsoluteMatrix write SetAbsoluteMatrix;
+    property AbsoluteMatrix: TGLMatrix read GetAbsoluteMatrix write SetAbsoluteMatrix;
     // Direction vector in absolute coordinates.
     // Direction vector in absolute coordinates.
     property AbsoluteDirection: TGLVector read GetAbsoluteDirection write SetAbsoluteDirection;
     property AbsoluteDirection: TGLVector read GetAbsoluteDirection write SetAbsoluteDirection;
     property AbsoluteAffineDirection: TAffineVector read GetAbsoluteAffineDirection write SetAbsoluteAffineDirection;
     property AbsoluteAffineDirection: TAffineVector read GetAbsoluteAffineDirection write SetAbsoluteAffineDirection;
@@ -1275,9 +1275,9 @@ type
     FRendering: Boolean;
     FRendering: Boolean;
     FRenderingContext: TGLContext;
     FRenderingContext: TGLContext;
     FAfterRenderEffects: TPersistentObjectList;
     FAfterRenderEffects: TPersistentObjectList;
-    FViewMatrixStack: array of TMatrix;
-    FProjectionMatrixStack: array of TMatrix;
-    FBaseProjectionMatrix: TMatrix;
+    FViewMatrixStack: array of TGLMatrix;
+    FProjectionMatrixStack: array of TGLMatrix;
+    FBaseProjectionMatrix: TGLMatrix;
     FCameraAbsolutePosition: TGLVector;
     FCameraAbsolutePosition: TGLVector;
     FViewPort: TRectangle;
     FViewPort: TRectangle;
     FSelector: TGLBaseSelectTechnique;
     FSelector: TGLBaseSelectTechnique;
@@ -1444,22 +1444,22 @@ type
     // Adjusts background alpha channel.
     // Adjusts background alpha channel.
     property BackgroundAlpha: Single read FBackgroundAlpha write SetBackgroundAlpha;
     property BackgroundAlpha: Single read FBackgroundAlpha write SetBackgroundAlpha;
     // Returns the projection matrix in use or used for the last rendering.
     // Returns the projection matrix in use or used for the last rendering.
-    function ProjectionMatrix: TMatrix; deprecated;
+    function ProjectionMatrix: TGLMatrix; deprecated;
     // Returns the view matrix in use or used for the last rendering.
     // Returns the view matrix in use or used for the last rendering.
-    function ViewMatrix: TMatrix; deprecated;
-    function ModelMatrix: TMatrix; deprecated;
+    function ViewMatrix: TGLMatrix; deprecated;
+    function ModelMatrix: TGLMatrix; deprecated;
     (* Returns the base projection matrix in use or used for the last rendering.
     (* Returns the base projection matrix in use or used for the last rendering.
        The "base" projection is (as of now) either identity or the pick
        The "base" projection is (as of now) either identity or the pick
        matrix, ie. it is the matrix on which the perspective or orthogonal
        matrix, ie. it is the matrix on which the perspective or orthogonal
        matrix gets applied. *)
        matrix gets applied. *)
-    property BaseProjectionMatrix: TMatrix read FBaseProjectionMatrix;
+    property BaseProjectionMatrix: TGLMatrix read FBaseProjectionMatrix;
     (* Back up current View matrix and replace it with newMatrix.
     (* Back up current View matrix and replace it with newMatrix.
        This method has no effect on the OpenGL matrix, only on the Buffer's
        This method has no effect on the OpenGL matrix, only on the Buffer's
        matrix, and is intended for special effects rendering. *)
        matrix, and is intended for special effects rendering. *)
-    procedure PushViewMatrix(const newMatrix: TMatrix); deprecated;
+    procedure PushViewMatrix(const newMatrix: TGLMatrix); deprecated;
     // Restore a View matrix previously pushed.
     // Restore a View matrix previously pushed.
     procedure PopViewMatrix; deprecated;
     procedure PopViewMatrix; deprecated;
-    procedure PushProjectionMatrix(const newMatrix: TMatrix); deprecated;
+    procedure PushProjectionMatrix(const newMatrix: TGLMatrix); deprecated;
     procedure PopProjectionMatrix;  deprecated;
     procedure PopProjectionMatrix;  deprecated;
     (* Converts a screen pixel coordinate into 3D coordinates for orthogonal projection.
     (* Converts a screen pixel coordinate into 3D coordinates for orthogonal projection.
        This function accepts standard canvas coordinates, with (0,0) being
        This function accepts standard canvas coordinates, with (0,0) being
@@ -2175,7 +2175,7 @@ begin
   Result := FChildren.Count;
   Result := FChildren.Count;
 end;
 end;
 
 
-function TGLBaseSceneObject.GetDirectAbsoluteMatrix: PMatrix;
+function TGLBaseSceneObject.GetDirectAbsoluteMatrix: PGLMatrix;
 begin
 begin
   Result := @FAbsoluteMatrix;
   Result := @FAbsoluteMatrix;
 end;
 end;
@@ -2255,7 +2255,7 @@ begin
   end;
   end;
 end;
 end;
 
 
-procedure TGLBaseSceneObject.ForceLocalMatrix(const aMatrix: TMatrix);
+procedure TGLBaseSceneObject.ForceLocalMatrix(const aMatrix: TGLMatrix);
 begin
 begin
   FLocalMatrix := aMatrix;
   FLocalMatrix := aMatrix;
   Exclude(FChanges, ocTransformation);
   Exclude(FChanges, ocTransformation);
@@ -2263,7 +2263,7 @@ begin
   Include(FChanges, ocInvAbsoluteMatrix);
   Include(FChanges, ocInvAbsoluteMatrix);
 end;
 end;
 
 
-function TGLBaseSceneObject.AbsoluteMatrixAsAddress: PMatrix;
+function TGLBaseSceneObject.AbsoluteMatrixAsAddress: PGLMatrix;
 begin
 begin
   if ocAbsoluteMatrix in FChanges then
   if ocAbsoluteMatrix in FChanges then
   begin
   begin
@@ -2281,12 +2281,12 @@ begin
   Result := @FAbsoluteMatrix;
   Result := @FAbsoluteMatrix;
 end;
 end;
 
 
-function TGLBaseSceneObject.InvAbsoluteMatrix: TMatrix;
+function TGLBaseSceneObject.InvAbsoluteMatrix: TGLMatrix;
 begin
 begin
   Result := InvAbsoluteMatrixAsAddress^;
   Result := InvAbsoluteMatrixAsAddress^;
 end;
 end;
 
 
-function TGLBaseSceneObject.InvAbsoluteMatrixAsAddress: PMatrix;
+function TGLBaseSceneObject.InvAbsoluteMatrixAsAddress: PGLMatrix;
 begin
 begin
   if ocInvAbsoluteMatrix in FChanges then
   if ocInvAbsoluteMatrix in FChanges then
   begin
   begin
@@ -2310,12 +2310,12 @@ begin
   Result := @FInvAbsoluteMatrix;
   Result := @FInvAbsoluteMatrix;
 end;
 end;
 
 
-function TGLBaseSceneObject.GetAbsoluteMatrix: TMatrix;
+function TGLBaseSceneObject.GetAbsoluteMatrix: TGLMatrix;
 begin
 begin
   Result := AbsoluteMatrixAsAddress^;
   Result := AbsoluteMatrixAsAddress^;
 end;
 end;
 
 
-procedure TGLBaseSceneObject.SetAbsoluteMatrix(const Value: TMatrix);
+procedure TGLBaseSceneObject.SetAbsoluteMatrix(const Value: TGLMatrix);
 begin
 begin
   if not MatrixEquals(Value, FAbsoluteMatrix) then
   if not MatrixEquals(Value, FAbsoluteMatrix) then
   begin
   begin
@@ -2852,7 +2852,7 @@ end;
 
 
 procedure TGLBaseSceneObject.ResetRotations;
 procedure TGLBaseSceneObject.ResetRotations;
 begin
 begin
-  FillChar(FLocalMatrix, SizeOf(TMatrix), 0);
+  FillChar(FLocalMatrix, SizeOf(TGLMatrix), 0);
   FLocalMatrix.X.X := Scale.DirectX;
   FLocalMatrix.X.X := Scale.DirectX;
   FLocalMatrix.Y.Y := Scale.DirectY;
   FLocalMatrix.Y.Y := Scale.DirectY;
   FLocalMatrix.Z.Z := Scale.DirectZ;
   FLocalMatrix.Z.Z := Scale.DirectZ;
@@ -2866,7 +2866,7 @@ end;
 
 
 procedure TGLBaseSceneObject.ResetAndPitchTurnRoll(const degX, degY, degZ: Single);
 procedure TGLBaseSceneObject.ResetAndPitchTurnRoll(const degX, degY, degZ: Single);
 var
 var
-  rotMatrix: TMatrix;
+  rotMatrix: TGLMatrix;
   V: TGLVector;
   V: TGLVector;
 begin
 begin
   ResetRotations;
   ResetRotations;
@@ -2903,7 +2903,7 @@ end;
 
 
 procedure TGLBaseSceneObject.RotateAbsolute(const rx, ry, rz: Single);
 procedure TGLBaseSceneObject.RotateAbsolute(const rx, ry, rz: Single);
 var
 var
-  resMat: TMatrix;
+  resMat: TGLMatrix;
   v: TAffineVector;
   v: TAffineVector;
 begin
 begin
   resMat := Matrix^;
   resMat := Matrix^;
@@ -2966,7 +2966,7 @@ end;
 procedure TGLBaseSceneObject.SetPitchAngle(AValue: Single);
 procedure TGLBaseSceneObject.SetPitchAngle(AValue: Single);
 var
 var
   diff: Single;
   diff: Single;
-  rotMatrix: TMatrix;
+  rotMatrix: TGLMatrix;
 begin
 begin
   if AValue <> FRotation.X then
   if AValue <> FRotation.X then
   begin
   begin
@@ -3024,7 +3024,7 @@ end;
 procedure TGLBaseSceneObject.SetRollAngle(AValue: Single);
 procedure TGLBaseSceneObject.SetRollAngle(AValue: Single);
 var
 var
   diff: Single;
   diff: Single;
-  rotMatrix: TMatrix;
+  rotMatrix: TGLMatrix;
 begin
 begin
   if AValue <> FRotation.Z then
   if AValue <> FRotation.Z then
   begin
   begin
@@ -3077,7 +3077,7 @@ end;
 procedure TGLBaseSceneObject.SetTurnAngle(AValue: Single);
 procedure TGLBaseSceneObject.SetTurnAngle(AValue: Single);
 var
 var
   diff: Single;
   diff: Single;
-  rotMatrix: TMatrix;
+  rotMatrix: TGLMatrix;
 begin
 begin
   if AValue <> FRotation.Y then
   if AValue <> FRotation.Y then
   begin
   begin
@@ -3188,7 +3188,7 @@ begin
     Result := -1;
     Result := -1;
 end;
 end;
 
 
-function TGLBaseSceneObject.GetLocalMatrix: PMatrix;
+function TGLBaseSceneObject.GetLocalMatrix: PGLMatrix;
 begin
 begin
   Result := @FLocalMatrix;
   Result := @FLocalMatrix;
 end;
 end;
@@ -3859,13 +3859,13 @@ begin
     FScene.NotifyChange(Self);
     FScene.NotifyChange(Self);
 end;
 end;
 
 
-function TGLBaseSceneObject.GetMatrix: PMatrix;
+function TGLBaseSceneObject.GetMatrix: PGLMatrix;
 begin
 begin
   RebuildMatrix;
   RebuildMatrix;
   Result := @FLocalMatrix;
   Result := @FLocalMatrix;
 end;
 end;
 
 
-procedure TGLBaseSceneObject.SetMatrix(const aValue: TMatrix);
+procedure TGLBaseSceneObject.SetMatrix(const aValue: TGLMatrix);
 begin
 begin
   FLocalMatrix := aValue;
   FLocalMatrix := aValue;
   FDirection.DirectVector := VectorNormalize(FLocalMatrix.Z);
   FDirection.DirectVector := VectorNormalize(FLocalMatrix.Z);
@@ -4459,7 +4459,7 @@ procedure TGLCamera.Apply;
 var
 var
   v, d, v2: TGLVector;
   v, d, v2: TGLVector;
   absPos: TGLVector;
   absPos: TGLVector;
-  LM, mat: TMatrix;
+  LM, mat: TGLMatrix;
 begin
 begin
   if Assigned(FDeferredApply) then
   if Assigned(FDeferredApply) then
     FDeferredApply(Self)
     FDeferredApply(Self)
@@ -4499,7 +4499,7 @@ var
   vLeft, vRight, vBottom, vTop, vFar: Single;
   vLeft, vRight, vBottom, vTop, vFar: Single;
   MaxDim, Ratio, f: Double;
   MaxDim, Ratio, f: Double;
   xmax, ymax: Double;
   xmax, ymax: Double;
-  mat: TMatrix;
+  mat: TGLMatrix;
 const
 const
   cEpsilon: Single = 1e-4;
   cEpsilon: Single = 1e-4;
 
 
@@ -4723,7 +4723,7 @@ end;
 procedure TGLCamera.RotateObject(obj: TGLBaseSceneObject; pitchDelta, turnDelta: Single;
 procedure TGLCamera.RotateObject(obj: TGLBaseSceneObject; pitchDelta, turnDelta: Single;
   rollDelta: Single = 0);
   rollDelta: Single = 0);
 var
 var
-  resMat: TMatrix;
+  resMat: TGLMatrix;
   vDir, vUp, vRight: TGLVector;
   vDir, vUp, vRight: TGLVector;
   v: TAffineVector;
   v: TAffineVector;
   position1: TGLVector;
   position1: TGLVector;
@@ -6806,7 +6806,7 @@ begin
   FFirstPerfCounter := 0;
   FFirstPerfCounter := 0;
 end;
 end;
 
 
-procedure TGLSceneBuffer.PushViewMatrix(const newMatrix: TMatrix);
+procedure TGLSceneBuffer.PushViewMatrix(const newMatrix: TGLMatrix);
 var
 var
   n: Integer;
   n: Integer;
 begin
 begin
@@ -6826,7 +6826,7 @@ begin
   SetLength(FViewMatrixStack, n);
   SetLength(FViewMatrixStack, n);
 end;
 end;
 
 
-procedure TGLSceneBuffer.PushProjectionMatrix(const newMatrix: TMatrix);
+procedure TGLSceneBuffer.PushProjectionMatrix(const newMatrix: TGLMatrix);
 var
 var
   n: Integer;
   n: Integer;
 begin
 begin
@@ -6851,12 +6851,12 @@ begin
   Result := RenderingContext.PipelineTransformation.ProjectionMatrix^;
   Result := RenderingContext.PipelineTransformation.ProjectionMatrix^;
 end;
 end;
 
 
-function TGLSceneBuffer.ViewMatrix: TMatrix;
+function TGLSceneBuffer.ViewMatrix: TGLMatrix;
 begin
 begin
   Result := RenderingContext.PipelineTransformation.ViewMatrix^;
   Result := RenderingContext.PipelineTransformation.ViewMatrix^;
 end;
 end;
 
 
-function TGLSceneBuffer.ModelMatrix: TMatrix;
+function TGLSceneBuffer.ModelMatrix: TGLMatrix;
 begin
 begin
   Result := RenderingContext.PipelineTransformation.ModelMatrix^;
   Result := RenderingContext.PipelineTransformation.ModelMatrix^;
 end;
 end;
@@ -7803,7 +7803,7 @@ procedure TGLNonVisualViewer.SetupCubeMapCamera(Sender: TObject);
 
 
 {
 {
 const
 const
-  cFaceMat: array[0..5] of TMatrix =
+  cFaceMat: array[0..5] of TGLMatrix =
   (
   (
     (X: (X:0; Y:0; Z:-1; W:0);
     (X: (X:0; Y:0; Z:-1; W:0);
      Y: (X:0; Y:-1; Z:0; W:0);
      Y: (X:0; Y:-1; Z:0; W:0);
@@ -7833,7 +7833,7 @@ const
 }
 }
 
 
 var
 var
-  TM: TMatrix;
+  TM: TGLMatrix;
 begin
 begin
   // Setup appropriate FOV
   // Setup appropriate FOV
   with CurrentGLContext.PipelineTransformation do
   with CurrentGLContext.PipelineTransformation do

+ 2 - 2
Source/GLS.ShadowPlane.pas

@@ -130,10 +130,10 @@ procedure TGLShadowPlane.DoRender(var ARci: TGLRenderContextInfo;
   ARenderSelf, ARenderChildren: Boolean);
   ARenderSelf, ARenderChildren: Boolean);
 var
 var
   oldProxySubObject, oldIgnoreMaterials: Boolean;
   oldProxySubObject, oldIgnoreMaterials: Boolean;
-  shadowMat: TMatrix;
+  shadowMat: TGLMatrix;
   sr, ds: TRect;
   sr, ds: TRect;
   CurrentBuffer: TGLSceneBuffer;
   CurrentBuffer: TGLSceneBuffer;
-  ModelMat: TMatrix;
+  ModelMat: TGLMatrix;
 begin
 begin
   if FRendering then
   if FRendering then
     Exit;
     Exit;

+ 2 - 2
Source/GLS.ShadowVolume.pas

@@ -363,7 +363,7 @@ end;
 function TGLShadowVolumeLight.SetupScissorRect(worldAABB: PAABB; var rci:
 function TGLShadowVolumeLight.SetupScissorRect(worldAABB: PAABB; var rci:
   TGLRenderContextInfo): Boolean;
   TGLRenderContextInfo): Boolean;
 var
 var
-  mvp: TMatrix;
+  mvp: TGLMatrix;
   ls: TGLLightSource;
   ls: TGLLightSource;
   aabb: TAABB;
   aabb: TAABB;
   clipRect: TClipRect;
   clipRect: TClipRect;
@@ -622,7 +622,7 @@ var
   silParams: TGLSilhouetteParameters;
   silParams: TGLSilhouetteParameters;
   worldAABB: TAABB;
   worldAABB: TAABB;
   pWorldAABB: PAABB;
   pWorldAABB: PAABB;
-  PM: TMatrix;
+  PM: TGLMatrix;
 begin
 begin
   if not Active then
   if not Active then
   begin
   begin

+ 1 - 1
Source/GLS.SpaceText.pas

@@ -1,7 +1,6 @@
 //
 //
 // The graphics rendering engine GLScene http://glscene.org
 // The graphics rendering engine GLScene http://glscene.org
 //
 //
-
 unit GLS.SpaceText;
 unit GLS.SpaceText;
 
 
 (*
 (*
@@ -31,6 +30,7 @@ uses
   VCL.Graphics,
   VCL.Graphics,
   VCL.Controls,
   VCL.Controls,
 
 
+  GLS.VectorTypes,
   GLS.OpenGLTokens,
   GLS.OpenGLTokens,
   GLS.Scene,
   GLS.Scene,
   GLS.Texture,
   GLS.Texture,

+ 1 - 1
Source/GLS.Spline.pas

@@ -1,7 +1,6 @@
 //
 //
 // The graphics rendering engine GLScene http://glscene.org
 // The graphics rendering engine GLScene http://glscene.org
 //
 //
-
 unit GLS.Spline;
 unit GLS.Spline;
 
 
 (* Cubic spline interpolation functions *)
 (* Cubic spline interpolation functions *)
@@ -9,6 +8,7 @@ unit GLS.Spline;
 interface
 interface
 
 
 uses
 uses
+  GLS.VectorTypes,
   GLS.VectorGeometry;
   GLS.VectorGeometry;
 
 
 {$I GLScene.inc}
 {$I GLScene.inc}

+ 2 - 2
Source/GLS.State.pas

@@ -893,7 +893,7 @@ type
     // Call display list
     // Call display list
     procedure CallList(list: Cardinal); inline;
     procedure CallList(list: Cardinal); inline;
     // Defines the OpenGL texture matrix. Assumed texture mode is GL_MODELVIEW.
     // Defines the OpenGL texture matrix. Assumed texture mode is GL_MODELVIEW.
-    procedure SetGLTextureMatrix(const matrix: TMatrix); inline;
+    procedure SetGLTextureMatrix(const matrix: TGLMatrix); inline;
     procedure ResetGLTextureMatrix; inline;
     procedure ResetGLTextureMatrix; inline;
     procedure ResetAllGLTextureMatrix; inline;
     procedure ResetAllGLTextureMatrix; inline;
     // note: needs to change to per draw-buffer
     // note: needs to change to per draw-buffer
@@ -2167,7 +2167,7 @@ begin
   end;
   end;
 end;
 end;
 
 
-procedure TGLStateCache.SetGLTextureMatrix(const matrix: TMatrix);
+procedure TGLStateCache.SetGLTextureMatrix(const matrix: TGLMatrix);
 begin
 begin
   { if FForwardContext then
   { if FForwardContext then
     exit; }
     exit; }

+ 7 - 7
Source/GLS.Texture.pas

@@ -471,12 +471,12 @@ type
     procedure Apply(var rci: TGLRenderContextInfo);
     procedure Apply(var rci: TGLRenderContextInfo);
     procedure UnApply(var rci: TGLRenderContextInfo);
     procedure UnApply(var rci: TGLRenderContextInfo);
     // Applies to TEXTURE1
     // Applies to TEXTURE1
-    procedure ApplyAsTexture2(var rci: TGLRenderContextInfo; textureMatrix: PMatrix = nil);
+    procedure ApplyAsTexture2(var rci: TGLRenderContextInfo; textureMatrix: PGLMatrix = nil);
     procedure UnApplyAsTexture2(var rci: TGLRenderContextInfo;
     procedure UnApplyAsTexture2(var rci: TGLRenderContextInfo;
       reloadIdentityTextureMatrix: boolean);
       reloadIdentityTextureMatrix: boolean);
     // N=1 for TEXTURE0, N=2 for TEXTURE1, etc.
     // N=1 for TEXTURE0, N=2 for TEXTURE1, etc.
     procedure ApplyAsTextureN(n: Integer; var rci: TGLRenderContextInfo;
     procedure ApplyAsTextureN(n: Integer; var rci: TGLRenderContextInfo;
-      textureMatrix: PMatrix = nil);
+      textureMatrix: PGLMatrix = nil);
     procedure UnApplyAsTextureN(n: Integer; var rci: TGLRenderContextInfo;
     procedure UnApplyAsTextureN(n: Integer; var rci: TGLRenderContextInfo;
       reloadIdentityTextureMatrix: boolean);
       reloadIdentityTextureMatrix: boolean);
     procedure Assign(Source: TPersistent); override;
     procedure Assign(Source: TPersistent); override;
@@ -616,7 +616,7 @@ type
     FTextureIndex: Integer;
     FTextureIndex: Integer;
     FTextureOffset, FTextureScale: TGLCoordinates;
     FTextureOffset, FTextureScale: TGLCoordinates;
     FTextureMatrixIsIdentity: Boolean;
     FTextureMatrixIsIdentity: Boolean;
-    FTextureMatrix: TMatrix;
+    FTextureMatrix: TGLMatrix;
     FApplied: Boolean;
     FApplied: Boolean;
     // Implementing IInterface
     // Implementing IInterface
     function QueryInterface(const IID: TGUID; out Obj): HResult; stdcall;
     function QueryInterface(const IID: TGUID; out Obj): HResult; stdcall;
@@ -2393,7 +2393,7 @@ procedure TGLTexture.Apply(var rci: TGLRenderContextInfo);
 
 
   procedure SetCubeMapTextureMatrix;
   procedure SetCubeMapTextureMatrix;
   var
   var
-    m, mm: TMatrix;
+    m, mm: TGLMatrix;
   begin
   begin
     // compute model view matrix for proper viewing
     // compute model view matrix for proper viewing
     case MappingMode of
     case MappingMode of
@@ -2487,7 +2487,7 @@ begin
 end;
 end;
 
 
 procedure TGLTexture.ApplyAsTexture2(var rci: TGLRenderContextInfo; textureMatrix:
 procedure TGLTexture.ApplyAsTexture2(var rci: TGLRenderContextInfo; textureMatrix:
-  PMatrix = nil);
+  PGLMatrix = nil);
 begin
 begin
   ApplyAsTextureN(2, rci, textureMatrix);
   ApplyAsTextureN(2, rci, textureMatrix);
 end;
 end;
@@ -2499,9 +2499,9 @@ begin
 end;
 end;
 
 
 procedure TGLTexture.ApplyAsTextureN(n: Integer; var rci: TGLRenderContextInfo;
 procedure TGLTexture.ApplyAsTextureN(n: Integer; var rci: TGLRenderContextInfo;
-  textureMatrix: PMatrix = nil);
+  textureMatrix: PGLMatrix = nil);
 var
 var
-  m: TMatrix;
+  m: TGLMatrix;
 begin
 begin
   if not Disabled then
   if not Disabled then
   begin
   begin

+ 1 - 1
Source/GLS.ThorFX.pas

@@ -468,7 +468,7 @@ var
   distList: TSingleList;
   distList: TSingleList;
   objList: TList;
   objList: TList;
   fp: PThorpoint;
   fp: PThorpoint;
-  mat: TMatrix;
+  mat: TGLMatrix;
 
 
   vx, vy: TGLVector;
   vx, vy: TGLVector;
   m: integer;
   m: integer;

+ 8 - 8
Source/GLS.Tree.pas

@@ -61,7 +61,7 @@ type
    constructor Create(AOwner: TGLTree);
    constructor Create(AOwner: TGLTree);
     destructor Destroy; override;
     destructor Destroy; override;
     procedure BuildList(var rci: TGLRenderContextInfo);
     procedure BuildList(var rci: TGLRenderContextInfo);
-    procedure AddNew(matrix: TMatrix);
+    procedure AddNew(matrix: TGLMatrix);
     procedure Clear;
     procedure Clear;
     property Owner: TGLTree read FOwner;
     property Owner: TGLTree read FOwner;
     property Count: Integer read FCount;
     property Count: Integer read FCount;
@@ -79,12 +79,12 @@ type
     FParent: TGLTreeBranch;
     FParent: TGLTreeBranch;
     FBranchID: Integer;
     FBranchID: Integer;
     FParentID: Integer;
     FParentID: Integer;
-    FMatrix: TMatrix;
+    FMatrix: TGLMatrix;
     FLower: TIntegerList;
     FLower: TIntegerList;
     FUpper: TIntegerList;
     FUpper: TIntegerList;
     FCentralLeader: Boolean;
     FCentralLeader: Boolean;
     procedure BuildBranch(branchNoise: TGLTreeBranchNoise;
     procedure BuildBranch(branchNoise: TGLTreeBranchNoise;
-      const matrix: TMatrix; TexCoordY, Twist: Single; Level: Integer);
+      const matrix: TGLMatrix; TexCoordY, Twist: Single; Level: Integer);
   public
   public
     constructor Create(AOwner: TGLTreeBranches; AParent: TGLTreeBranch);
     constructor Create(AOwner: TGLTreeBranches; AParent: TGLTreeBranch);
     destructor Destroy; override;
     destructor Destroy; override;
@@ -93,7 +93,7 @@ type
     property Center: TGLTreeBranch read FCenter;
     property Center: TGLTreeBranch read FCenter;
     property Right: TGLTreeBranch read FRight;
     property Right: TGLTreeBranch read FRight;
     property Parent: TGLTreeBranch read FParent;
     property Parent: TGLTreeBranch read FParent;
-    property matrix: TMatrix read FMatrix;
+    property matrix: TGLMatrix read FMatrix;
     property Lower: TIntegerList read FLower;
     property Lower: TIntegerList read FLower;
     property Upper: TIntegerList read FUpper;
     property Upper: TIntegerList read FUpper;
   end;
   end;
@@ -284,7 +284,7 @@ begin
   inherited;
   inherited;
 end;
 end;
 
 
-procedure TGLTreeLeaves.AddNew(matrix: TMatrix);
+procedure TGLTreeLeaves.AddNew(matrix: TGLMatrix);
 var
 var
   radius: Single;
   radius: Single;
   pos: TGLVector;
   pos: TGLVector;
@@ -400,7 +400,7 @@ begin
 end;
 end;
 
 
 procedure TGLTreeBranch.BuildBranch(branchNoise: TGLTreeBranchNoise;
 procedure TGLTreeBranch.BuildBranch(branchNoise: TGLTreeBranchNoise;
-  const matrix: TMatrix; TexCoordY, Twist: Single; Level: Integer);
+  const matrix: TGLMatrix; TexCoordY, Twist: Single; Level: Integer);
 var
 var
   i: Integer;
   i: Integer;
   Tree: TGLTree;
   Tree: TGLTree;
@@ -414,7 +414,7 @@ var
   LeftBranchNoise: TGLTreeBranchNoise;
   LeftBranchNoise: TGLTreeBranchNoise;
   CenterBranchNoise: TGLTreeBranchNoise;
   CenterBranchNoise: TGLTreeBranchNoise;
   RightBranchNoise: TGLTreeBranchNoise;
   RightBranchNoise: TGLTreeBranchNoise;
-  LeftMatrix, RightMatrix, CenterMatrix: TMatrix;
+  LeftMatrix, RightMatrix, CenterMatrix: TGLMatrix;
   central_leader: Boolean;
   central_leader: Boolean;
 begin
 begin
   Assert(Assigned(FOwner), 'Incorrect use of TGLTreeBranch');
   Assert(Assigned(FOwner), 'Incorrect use of TGLTreeBranch');
@@ -839,7 +839,7 @@ procedure TGLTree.BuildMesh(GLBaseMesh: TGLBaseMesh);
     Frame: TGLSkeletonFrame);
     Frame: TGLSkeletonFrame);
   var
   var
     trans: TTransformations;
     trans: TTransformations;
-    mat: TMatrix;
+    mat: TGLMatrix;
     rot, pos: TAffineVector;
     rot, pos: TAffineVector;
   begin
   begin
     bone.Name := 'Branch' + IntToStr(Branch.FBranchID);
     bone.Name := 'Branch' + IntToStr(Branch.FBranchID);

+ 32 - 32
Source/GLS.VectorFileObjects.pas

@@ -179,7 +179,7 @@ type
   private
   private
     FSkeleton: TGLSkeleton; // not persistent
     FSkeleton: TGLSkeleton; // not persistent
   protected
   protected
-    FGlobalMatrix: TMatrix;
+    FGlobalMatrix: TGLMatrix;
     function GetSkeletonBone(Index: Integer): TGLSkeletonBone;
     function GetSkeletonBone(Index: Integer): TGLSkeletonBone;
     procedure AfterObjectCreatedByReader(Sender: TObject); override;
     procedure AfterObjectCreatedByReader(Sender: TObject); override;
   public
   public
@@ -208,7 +208,7 @@ type
     procedure ReadFromFiler(reader: TVirtualReader); override;
     procedure ReadFromFiler(reader: TVirtualReader); override;
     // Render skeleton wireframe
     // Render skeleton wireframe
     procedure BuildList(var mrci: TGLRenderContextInfo); override;
     procedure BuildList(var mrci: TGLRenderContextInfo); override;
-    property GlobalMatrix: TMatrix read FGlobalMatrix write FGlobalMatrix;
+    property GlobalMatrix: TGLMatrix read FGlobalMatrix write FGlobalMatrix;
   end;
   end;
 
 
   (* A skeleton bone or node and its children.
   (* A skeleton bone or node and its children.
@@ -241,16 +241,16 @@ type
     function BoneByID(anID: Integer): TGLSkeletonBone; override;
     function BoneByID(anID: Integer): TGLSkeletonBone; override;
     function BoneByName(const aName: string): TGLSkeletonBone; override;
     function BoneByName(const aName: string): TGLSkeletonBone; override;
     // Set the bone's matrix. Becareful using this.
     // Set the bone's matrix. Becareful using this.
-    procedure SetGlobalMatrix(const Matrix: TMatrix); // Ragdoll
+    procedure SetGlobalMatrix(const Matrix: TGLMatrix); // Ragdoll
     // Set the bone's GlobalMatrix. Used for Ragdoll.
     // Set the bone's GlobalMatrix. Used for Ragdoll.
-    procedure SetGlobalMatrixForRagDoll(const RagDollMatrix: TMatrix); // Ragdoll
+    procedure SetGlobalMatrixForRagDoll(const RagDollMatrix: TGLMatrix); // Ragdoll
     (* Calculates the global matrix for the bone and its sub-bone.
     (* Calculates the global matrix for the bone and its sub-bone.
       Call this function directly only the RootBone. *)
       Call this function directly only the RootBone. *)
     procedure PrepareGlobalMatrices; override;
     procedure PrepareGlobalMatrices; override;
     (* Global Matrix for the bone in the current frame.
     (* Global Matrix for the bone in the current frame.
       Global matrices must be prepared by invoking PrepareGlobalMatrices
       Global matrices must be prepared by invoking PrepareGlobalMatrices
       on the root bone. *)
       on the root bone. *)
-    property GlobalMatrix: TMatrix read FGlobalMatrix;
+    property GlobalMatrix: TGLMatrix read FGlobalMatrix;
     // Free all sub bones and reset BoneID and Name.
     // Free all sub bones and reset BoneID and Name.
     procedure Clean; override;
     procedure Clean; override;
   end;
   end;
@@ -266,11 +266,11 @@ type
     FOwner: TGLSkeletonColliderList;
     FOwner: TGLSkeletonColliderList;
     FBone: TGLSkeletonBone;
     FBone: TGLSkeletonBone;
     FBoneID: Integer;
     FBoneID: Integer;
-    FLocalMatrix, FGlobalMatrix: TMatrix;
+    FLocalMatrix, FGlobalMatrix: TGLMatrix;
     FAutoUpdate: Boolean;
     FAutoUpdate: Boolean;
   protected
   protected
     procedure SetBone(const val: TGLSkeletonBone);
     procedure SetBone(const val: TGLSkeletonBone);
-    procedure SetLocalMatrix(const val: TMatrix);
+    procedure SetLocalMatrix(const val: TGLMatrix);
   public
   public
     constructor Create; override;
     constructor Create; override;
     constructor CreateOwned(AOwner: TGLSkeletonColliderList);
     constructor CreateOwned(AOwner: TGLSkeletonColliderList);
@@ -284,10 +284,10 @@ type
     // The bone that this collider associates with.
     // The bone that this collider associates with.
     property Bone: TGLSkeletonBone read FBone write SetBone;
     property Bone: TGLSkeletonBone read FBone write SetBone;
     // Offset and orientation of the collider in the associated bone's space.
     // Offset and orientation of the collider in the associated bone's space.
-    property LocalMatrix: TMatrix read FLocalMatrix write SetLocalMatrix;
+    property LocalMatrix: TGLMatrix read FLocalMatrix write SetLocalMatrix;
     (* Global offset and orientation of the collider.
     (* Global offset and orientation of the collider.
       This gets set in the AlignCollider method. *)
       This gets set in the AlignCollider method. *)
-    property GlobalMatrix: TMatrix read FGlobalMatrix;
+    property GlobalMatrix: TGLMatrix read FGlobalMatrix;
     property AutoUpdate: Boolean read FAutoUpdate write FAutoUpdate;
     property AutoUpdate: Boolean read FAutoUpdate write FAutoUpdate;
   end;
   end;
 
 
@@ -693,7 +693,7 @@ type
     property Owner: TGLFaceGroups read FOwner write FOwner;
     property Owner: TGLFaceGroups read FOwner write FOwner;
     property MaterialName: string read FMaterialName write FMaterialName;
     property MaterialName: string read FMaterialName write FMaterialName;
     property MaterialCache: TGLLibMaterial read FMaterialCache;
     property MaterialCache: TGLLibMaterial read FMaterialCache;
-    { Index of lightmap in the lightmap library. }
+    // Index of lightmap in the lightmap library.
     property LightMapIndex: Integer read FLightMapIndex write FLightMapIndex;
     property LightMapIndex: Integer read FLightMapIndex write FLightMapIndex;
   end;
   end;
 
 
@@ -840,7 +840,7 @@ type
     procedure SaveToStream(aStream: TStream); override;
     procedure SaveToStream(aStream: TStream); override;
   end;
   end;
 
 
-  // Base class for mesh objects. 
+  // Base class for mesh objects.
   TGLBaseMesh = class(TGLSceneObject)
   TGLBaseMesh = class(TGLSceneObject)
   private
   private
     FNormalsOrientation: TGLMeshNormalsOrientation;
     FNormalsOrientation: TGLMeshNormalsOrientation;
@@ -903,7 +903,7 @@ type
       rendering, reduced performance and/or invalid bounding box data
       rendering, reduced performance and/or invalid bounding box data
       (ie. invalid collision detection). Use with caution. *)
       (ie. invalid collision detection). Use with caution. *)
     procedure StructureChangedNoPrepare;
     procedure StructureChangedNoPrepare;
-    // BEWARE! Utterly inefficient implementation! 
+    // BEWARE! Utterly inefficient implementation!
     function RayCastIntersect(const rayStart, rayVector: TGLVector; intersectPoint: PGLVector = nil;
     function RayCastIntersect(const rayStart, rayVector: TGLVector; intersectPoint: PGLVector = nil;
 	  intersectNormal: PGLVector = nil): Boolean; override;
 	  intersectNormal: PGLVector = nil): Boolean; override;
     function GenerateSilhouette(const silhouetteParameters: TGLSilhouetteParameters): TGLSilhouette; override;
     function GenerateSilhouette(const silhouetteParameters: TGLSilhouetteParameters): TGLSilhouette; override;
@@ -964,10 +964,10 @@ type
       If you want to alter mesh data, use direct manipulation methods
       If you want to alter mesh data, use direct manipulation methods
       (on the TMeshObjects). *)
       (on the TMeshObjects). *)
     property AutoScaling: TGLCoordinates read FAutoScaling write FAutoScaling;
     property AutoScaling: TGLCoordinates read FAutoScaling write FAutoScaling;
-    { Material library where mesh materials will be stored/retrieved.
+    (* Material library where mesh materials will be stored/retrieved.
       If this property is not defined or if UseMeshMaterials is false,
       If this property is not defined or if UseMeshMaterials is false,
       only the FreeForm's material will be used (and the mesh's materials
       only the FreeForm's material will be used (and the mesh's materials
-      will be ignored. }
+      will be ignored. *)
     property MaterialLibrary: TGLMaterialLibrary read FMaterialLibrary write SetMaterialLibrary;
     property MaterialLibrary: TGLMaterialLibrary read FMaterialLibrary write SetMaterialLibrary;
     (* Defines wether materials declared in the vector file mesh are used.
     (* Defines wether materials declared in the vector file mesh are used.
       You must also define the MaterialLibrary property. *)
       You must also define the MaterialLibrary property. *)
@@ -981,10 +981,10 @@ type
       Implementation is up to the file loader class (ie. this property
       Implementation is up to the file loader class (ie. this property
       may be ignored by some loaders) *)
       may be ignored by some loaders) *)
     property IgnoreMissingTextures: Boolean read FIgnoreMissingTextures write FIgnoreMissingTextures default False;
     property IgnoreMissingTextures: Boolean read FIgnoreMissingTextures write FIgnoreMissingTextures default False;
-    // Normals orientation for owned mesh. 
+    // Normals orientation for owned mesh.
     property NormalsOrientation: TGLMeshNormalsOrientation read FNormalsOrientation
     property NormalsOrientation: TGLMeshNormalsOrientation read FNormalsOrientation
 	   write SetNormalsOrientation default mnoDefault;
 	   write SetNormalsOrientation default mnoDefault;
-    // Request rendering of skeleton bones over the mesh. 
+    // Request rendering of skeleton bones over the mesh.
     property OverlaySkeleton: Boolean read FOverlaySkeleton write SetOverlaySkeleton default False;
     property OverlaySkeleton: Boolean read FOverlaySkeleton write SetOverlaySkeleton default False;
   end;
   end;
 
 
@@ -1007,10 +1007,10 @@ type
     (* Returns true if Point is inside the free form - this will only work
     (* Returns true if Point is inside the free form - this will only work
       properly on closed meshes. Requires that Octree has been prepared. *)
       properly on closed meshes. Requires that Octree has been prepared. *)
     function OctreePointInMesh(const Point: TGLVector): Boolean;
     function OctreePointInMesh(const Point: TGLVector): Boolean;
-    function OctreeAABBIntersect(const AABB: TAABB; objMatrix, invObjMatrix: TMatrix;
+    function OctreeAABBIntersect(const AABB: TAABB; objMatrix, invObjMatrix: TGLMatrix;
       triangles: TAffineVectorList = nil): Boolean;
       triangles: TAffineVectorList = nil): Boolean;
     // TODO:  function OctreeSphereIntersect
     // TODO:  function OctreeSphereIntersect
-    // Octree support *experimental*. Use only if you understand what you're doing! 
+    // Octree support *experimental*. Use only if you understand what you're doing!
     property Octree: TGLOctree read FOctree;
     property Octree: TGLOctree read FOctree;
     procedure BuildOctree(TreeDepth: Integer = 3);
     procedure BuildOctree(TreeDepth: Integer = 3);
   published
   published
@@ -1870,7 +1870,7 @@ function TGLSkeletonFrame.LocalMatrixList: PMatrixArray;
 var
 var
   i: Integer;
   i: Integer;
   s, c: Single;
   s, c: Single;
-  mat, rmat: TMatrix;
+  mat, rmat: TGLMatrix;
   quat: TQuaternion;
   quat: TQuaternion;
 begin
 begin
   if not Assigned(FLocalMatrixList) then
   if not Assigned(FLocalMatrixList) then
@@ -1878,7 +1878,7 @@ begin
     case FTransformMode of
     case FTransformMode of
       sftRotation:
       sftRotation:
         begin
         begin
-          FLocalMatrixList := AllocMem(SizeOf(TMatrix) * Rotation.Count);
+          FLocalMatrixList := AllocMem(SizeOf(TGLMatrix) * Rotation.Count);
           for i := 0 to Rotation.Count - 1 do
           for i := 0 to Rotation.Count - 1 do
           begin
           begin
             if Rotation[i].X <> 0 then
             if Rotation[i].X <> 0 then
@@ -1908,7 +1908,7 @@ begin
         end;
         end;
       sftQuaternion:
       sftQuaternion:
         begin
         begin
-          FLocalMatrixList := AllocMem(SizeOf(TMatrix) * Quaternion.Count);
+          FLocalMatrixList := AllocMem(SizeOf(TGLMatrix) * Quaternion.Count);
           for i := 0 to Quaternion.Count - 1 do
           for i := 0 to Quaternion.Count - 1 do
           begin
           begin
             quat := Quaternion[i];
             quat := Quaternion[i];
@@ -1938,7 +1938,7 @@ procedure TGLSkeletonFrame.ConvertQuaternionsToRotations(KeepQuaternions: Boolea
 var
 var
   i: Integer;
   i: Integer;
   t: TTransformations;
   t: TTransformations;
-  m: TMatrix;
+  m: TGLMatrix;
 begin
 begin
   Rotation.Clear;
   Rotation.Clear;
   for i := 0 to Quaternion.Count - 1 do
   for i := 0 to Quaternion.Count - 1 do
@@ -1956,7 +1956,7 @@ end;
 procedure TGLSkeletonFrame.ConvertRotationsToQuaternions(KeepRotations: Boolean = True);
 procedure TGLSkeletonFrame.ConvertRotationsToQuaternions(KeepRotations: Boolean = True);
 var
 var
   i: Integer;
   i: Integer;
-  mat, rmat: TMatrix;
+  mat, rmat: TGLMatrix;
   s, c: Single;
   s, c: Single;
 begin
 begin
   Quaternion.Clear;
   Quaternion.Clear;
@@ -2323,12 +2323,12 @@ begin
   inherited;
   inherited;
 end;
 end;
 
 
-procedure TGLSkeletonBone.SetGlobalMatrix(const Matrix: TMatrix); // ragdoll
+procedure TGLSkeletonBone.SetGlobalMatrix(const Matrix: TGLMatrix); // ragdoll
 begin
 begin
   FGlobalMatrix := Matrix;
   FGlobalMatrix := Matrix;
 end;
 end;
 
 
-procedure TGLSkeletonBone.SetGlobalMatrixForRagDoll(const RagDollMatrix: TMatrix);
+procedure TGLSkeletonBone.SetGlobalMatrixForRagDoll(const RagDollMatrix: TGLMatrix);
 // ragdoll
 // ragdoll
 begin
 begin
   FGlobalMatrix := MatrixMultiply(RagDollMatrix,
   FGlobalMatrix := MatrixMultiply(RagDollMatrix,
@@ -2366,7 +2366,7 @@ begin
       WriteInteger(FBone.BoneID)
       WriteInteger(FBone.BoneID)
     else
     else
       WriteInteger(-1);
       WriteInteger(-1);
-    Write(FLocalMatrix, SizeOf(TMatrix));
+    Write(FLocalMatrix, SizeOf(TGLMatrix));
   end;
   end;
 end;
 end;
 
 
@@ -2380,7 +2380,7 @@ begin
     with reader do
     with reader do
     begin
     begin
       FBoneID := ReadInteger;
       FBoneID := ReadInteger;
-      Read(FLocalMatrix, SizeOf(TMatrix));
+      Read(FLocalMatrix, SizeOf(TGLMatrix));
     end
     end
   else
   else
     RaiseFilerException(archiveVersion);
     RaiseFilerException(archiveVersion);
@@ -2388,7 +2388,7 @@ end;
 
 
 procedure TGLSkeletonCollider.AlignCollider;
 procedure TGLSkeletonCollider.AlignCollider;
 var
 var
-  mat: TMatrix;
+  mat: TGLMatrix;
 begin
 begin
   if Assigned(FBone) then
   if Assigned(FBone) then
   begin
   begin
@@ -2410,7 +2410,7 @@ begin
     FBone := val;
     FBone := val;
 end;
 end;
 
 
-procedure TGLSkeletonCollider.SetLocalMatrix(const val: TMatrix);
+procedure TGLSkeletonCollider.SetLocalMatrix(const val: TGLMatrix);
 begin
 begin
   FLocalMatrix := val;
   FLocalMatrix := val;
 end;
 end;
@@ -4910,7 +4910,7 @@ procedure TGLSkeletonMeshObject.PrepareBoneMatrixInvertedMeshes;
 var
 var
   i, k, boneIndex: Integer;
   i, k, boneIndex: Integer;
   invMesh: TGLBaseMeshObject;
   invMesh: TGLBaseMeshObject;
-  invMat: TMatrix;
+  invMat: TGLMatrix;
   Bone: TGLSkeletonBone;
   Bone: TGLSkeletonBone;
   p: TGLVector;
   p: TGLVector;
 begin
 begin
@@ -6638,10 +6638,10 @@ begin
   Result := Octree.TriangleIntersect(t1, t2, t3);
   Result := Octree.TriangleIntersect(t1, t2, t3);
 end;
 end;
 
 
-function TGLFreeForm.OctreeAABBIntersect(const AABB: TAABB; objMatrix, invObjMatrix: TMatrix;
+function TGLFreeForm.OctreeAABBIntersect(const AABB: TAABB; objMatrix, invObjMatrix: TGLMatrix;
   triangles: TAffineVectorList = nil): Boolean;
   triangles: TAffineVectorList = nil): Boolean;
 var
 var
-  m1to2, m2to1: TMatrix;
+  m1to2, m2to1: TGLMatrix;
 begin
 begin
   Assert(Assigned(FOctree), strOctreeMustBePreparedBeforeUse);
   Assert(Assigned(FOctree), strOctreeMustBePreparedBeforeUse);
 
 

+ 126 - 128
Source/GLS.VectorGeometry.pas

@@ -141,8 +141,6 @@ type
   PVector2f = ^TVector2f;
   PVector2f = ^TVector2f;
 
 
   // some simplified names
   // some simplified names
-///  PGLVector = ^TGLVector;
-  TGLVector = THomogeneousFltVector;
 
 
   PHomogeneousVector = ^THomogeneousVector;
   PHomogeneousVector = ^THomogeneousVector;
   THomogeneousVector = THomogeneousFltVector;
   THomogeneousVector = THomogeneousFltVector;
@@ -178,10 +176,10 @@ type
   TAffineExtMatrix = array [0 .. 2] of TAffineExtVector;
   TAffineExtMatrix = array [0 .. 2] of TAffineExtVector;
 
 
   // Some simplified names
   // Some simplified names
-  PMatrix = ^TMatrix;
-  TMatrix = THomogeneousFltMatrix;
+///  PGLMatrix = ^TGLMatrix;
+///  TGLMatrix = THomogeneousFltMatrix;
 
 
-  TMatrixArray = array [0 .. MaxInt shr 7] of TMatrix;
+  TMatrixArray = array [0 .. MaxInt shr 7] of TGLMatrix;
   PMatrixArray = ^TMatrixArray;
   PMatrixArray = ^TMatrixArray;
 
 
   PHomogeneousMatrix = ^THomogeneousMatrix;
   PHomogeneousMatrix = ^THomogeneousMatrix;
@@ -272,14 +270,14 @@ const
 
 
   IdentityMatrix: TAffineMatrix = (V: ((X: 1; Y: 0; Z: 0), (X: 0; Y: 1;
   IdentityMatrix: TAffineMatrix = (V: ((X: 1; Y: 0; Z: 0), (X: 0; Y: 1;
     Z: 0), (X: 0; Y: 0; Z: 1)));
     Z: 0), (X: 0; Y: 0; Z: 1)));
-  IdentityHmgMatrix: TMatrix = (V: ((X: 1; Y: 0; Z: 0; W: 0), (X: 0; Y: 1; Z: 0;
+  IdentityHmgMatrix: TGLMatrix = (V: ((X: 1; Y: 0; Z: 0; W: 0), (X: 0; Y: 1; Z: 0;
     W: 0), (X: 0; Y: 0; Z: 1; W: 0), (X: 0; Y: 0; Z: 0; W: 1)));
     W: 0), (X: 0; Y: 0; Z: 1; W: 0), (X: 0; Y: 0; Z: 0; W: 1)));
   IdentityHmgDblMatrix: THomogeneousDblMatrix = (V: ((X: 1; Y: 0; Z: 0;
   IdentityHmgDblMatrix: THomogeneousDblMatrix = (V: ((X: 1; Y: 0; Z: 0;
     W: 0), (X: 0; Y: 1; Z: 0; W: 0), (X: 0; Y: 0; Z: 1; W: 0), (X: 0; Y: 0;
     W: 0), (X: 0; Y: 1; Z: 0; W: 0), (X: 0; Y: 0; Z: 1; W: 0), (X: 0; Y: 0;
     Z: 0; W: 1)));
     Z: 0; W: 1)));
   EmptyMatrix: TAffineMatrix = (V: ((X: 0; Y: 0; Z: 0), (X: 0; Y: 0;
   EmptyMatrix: TAffineMatrix = (V: ((X: 0; Y: 0; Z: 0), (X: 0; Y: 0;
     Z: 0), (X: 0; Y: 0; Z: 0)));
     Z: 0), (X: 0; Y: 0; Z: 0)));
-  EmptyHmgMatrix: TMatrix = (V: ((X: 0; Y: 0; Z: 0; W: 0), (X: 0; Y: 0; Z: 0;
+  EmptyHmgMatrix: TGLMatrix = (V: ((X: 0; Y: 0; Z: 0; W: 0), (X: 0; Y: 0; Z: 0;
     W: 0), (X: 0; Y: 0; Z: 0; W: 0), (X: 0; Y: 0; Z: 0; W: 0)));
     W: 0), (X: 0; Y: 0; Z: 0; W: 0), (X: 0; Y: 0; Z: 0; W: 0)));
 
 
 
 
@@ -594,7 +592,7 @@ function Lerp(const start, stop, T: Single): Single; inline;
 function AngleLerp(start, stop, T: Single): Single; inline;
 function AngleLerp(start, stop, T: Single): Single; inline;
 (* This is used for interpolating between 2 matrices. The result
 (* This is used for interpolating between 2 matrices. The result
   is used to reposition the model parts each frame. *)
   is used to reposition the model parts each frame. *)
-function MatrixLerp(const m1, m2: TMatrix; const delta: Single): TMatrix;
+function MatrixLerp(const m1, m2: TGLMatrix; const delta: Single): TGLMatrix;
 
 
 (* Calculates the angular distance between two angles in radians.
 (* Calculates the angular distance between two angles in radians.
   Result is in the [0; PI] range. *)
   Result is in the [0; PI] range. *)
@@ -817,84 +815,84 @@ function IsColinear(const V1, V2: TGLVector): Boolean; overload;
 (* ----------------------------------------------------------------------------
 (* ----------------------------------------------------------------------------
   Matrix functions
   Matrix functions
  ---------------------------------------------------------------------------- *)
  ---------------------------------------------------------------------------- *)
-procedure SetMatrix(var dest: THomogeneousDblMatrix; const src: TMatrix); overload;
-procedure SetMatrix(var dest: TAffineMatrix; const src: TMatrix); overload;
-procedure SetMatrix(var dest: TMatrix; const src: TAffineMatrix); overload;
-procedure SetMatrixRow(var dest: TMatrix; rowNb: Integer; const aRow: TGLVector); overload;
+procedure SetMatrix(var dest: THomogeneousDblMatrix; const src: TGLMatrix); overload;
+procedure SetMatrix(var dest: TAffineMatrix; const src: TGLMatrix); overload;
+procedure SetMatrix(var dest: TGLMatrix; const src: TAffineMatrix); overload;
+procedure SetMatrixRow(var dest: TGLMatrix; rowNb: Integer; const aRow: TGLVector); overload;
 
 
 // Creates scale matrix
 // Creates scale matrix
-function CreateScaleMatrix(const V: TAffineVector): TMatrix; overload;
+function CreateScaleMatrix(const V: TAffineVector): TGLMatrix; overload;
 // Creates scale matrix
 // Creates scale matrix
-function CreateScaleMatrix(const V: TGLVector): TMatrix; overload;
+function CreateScaleMatrix(const V: TGLVector): TGLMatrix; overload;
 // Creates translation matrix
 // Creates translation matrix
-function CreateTranslationMatrix(const V: TAffineVector): TMatrix; overload;
+function CreateTranslationMatrix(const V: TAffineVector): TGLMatrix; overload;
 // Creates translation matrix
 // Creates translation matrix
-function CreateTranslationMatrix(const V: TGLVector): TMatrix; overload;
+function CreateTranslationMatrix(const V: TGLVector): TGLMatrix; overload;
 { Creates a scale+translation matrix.
 { Creates a scale+translation matrix.
   Scale is applied BEFORE applying offset }
   Scale is applied BEFORE applying offset }
-function CreateScaleAndTranslationMatrix(const scale, offset: TGLVector): TMatrix; overload;
+function CreateScaleAndTranslationMatrix(const scale, offset: TGLVector): TGLMatrix; overload;
 // Creates matrix for rotation about x-axis (angle in rad)
 // Creates matrix for rotation about x-axis (angle in rad)
-function CreateRotationMatrixX(const sine, cosine: Single): TMatrix; overload;
-function CreateRotationMatrixX(const angle: Single): TMatrix; overload;
+function CreateRotationMatrixX(const sine, cosine: Single): TGLMatrix; overload;
+function CreateRotationMatrixX(const angle: Single): TGLMatrix; overload;
 // Creates matrix for rotation about y-axis (angle in rad)
 // Creates matrix for rotation about y-axis (angle in rad)
-function CreateRotationMatrixY(const sine, cosine: Single): TMatrix; overload;
-function CreateRotationMatrixY(const angle: Single): TMatrix; overload;
+function CreateRotationMatrixY(const sine, cosine: Single): TGLMatrix; overload;
+function CreateRotationMatrixY(const angle: Single): TGLMatrix; overload;
 // Creates matrix for rotation about z-axis (angle in rad)
 // Creates matrix for rotation about z-axis (angle in rad)
-function CreateRotationMatrixZ(const sine, cosine: Single): TMatrix; overload;
-function CreateRotationMatrixZ(const angle: Single): TMatrix; overload;
+function CreateRotationMatrixZ(const sine, cosine: Single): TGLMatrix; overload;
+function CreateRotationMatrixZ(const angle: Single): TGLMatrix; overload;
 // Creates a rotation matrix along the given Axis by the given Angle in radians.
 // Creates a rotation matrix along the given Axis by the given Angle in radians.
-function CreateRotationMatrix(const anAxis: TAffineVector; angle: Single): TMatrix; overload;
-function CreateRotationMatrix(const anAxis: TGLVector; angle: Single): TMatrix; overload; 
+function CreateRotationMatrix(const anAxis: TAffineVector; angle: Single): TGLMatrix; overload;
+function CreateRotationMatrix(const anAxis: TGLVector; angle: Single): TGLMatrix; overload; 
 // Creates a rotation matrix along the given Axis by the given Angle in radians.
 // Creates a rotation matrix along the given Axis by the given Angle in radians.
 function CreateAffineRotationMatrix(const anAxis: TAffineVector; angle: Single): TAffineMatrix;
 function CreateAffineRotationMatrix(const anAxis: TAffineVector; angle: Single): TAffineMatrix;
 
 
 // Multiplies two 3x3 matrices
 // Multiplies two 3x3 matrices
 function MatrixMultiply(const m1, m2: TAffineMatrix): TAffineMatrix; overload; 
 function MatrixMultiply(const m1, m2: TAffineMatrix): TAffineMatrix; overload; 
 // Multiplies two 4x4 matrices
 // Multiplies two 4x4 matrices
-function MatrixMultiply(const m1, m2: TMatrix): TMatrix; overload;
+function MatrixMultiply(const m1, m2: TGLMatrix): TGLMatrix; overload;
 // Multiplies M1 by M2 and places result in MResult
 // Multiplies M1 by M2 and places result in MResult
-procedure MatrixMultiply(const m1, m2: TMatrix; var MResult: TMatrix); overload;
+procedure MatrixMultiply(const m1, m2: TGLMatrix; var MResult: TGLMatrix); overload;
 
 
 // Transforms a homogeneous vector by multiplying it with a matrix
 // Transforms a homogeneous vector by multiplying it with a matrix
-function VectorTransform(const V: TGLVector; const M: TMatrix): TGLVector; overload; 
+function VectorTransform(const V: TGLVector; const M: TGLMatrix): TGLVector; overload; 
 // Transforms a homogeneous vector by multiplying it with a matrix
 // Transforms a homogeneous vector by multiplying it with a matrix
 function VectorTransform(const V: TGLVector; const M: TAffineMatrix): TGLVector; overload; 
 function VectorTransform(const V: TGLVector; const M: TAffineMatrix): TGLVector; overload; 
 // Transforms an affine vector by multiplying it with a matrix
 // Transforms an affine vector by multiplying it with a matrix
-function VectorTransform(const V: TAffineVector; const M: TMatrix): TAffineVector; overload; 
+function VectorTransform(const V: TAffineVector; const M: TGLMatrix): TAffineVector; overload; 
 // Transforms an affine vector by multiplying it with a matrix
 // Transforms an affine vector by multiplying it with a matrix
 function VectorTransform(const V: TAffineVector; const M: TAffineMatrix): TAffineVector; overload; 
 function VectorTransform(const V: TAffineVector; const M: TAffineMatrix): TAffineVector; overload; 
 
 
 // Determinant of a 3x3 matrix
 // Determinant of a 3x3 matrix
 function MatrixDeterminant(const M: TAffineMatrix): Single; overload; 
 function MatrixDeterminant(const M: TAffineMatrix): Single; overload; 
 // Determinant of a 4x4 matrix
 // Determinant of a 4x4 matrix
-function MatrixDeterminant(const M: TMatrix): Single; overload;
+function MatrixDeterminant(const M: TGLMatrix): Single; overload;
 
 
 // Adjoint of a 4x4 matrix, used in the computation of the inverse of a 4x4 matrix 
 // Adjoint of a 4x4 matrix, used in the computation of the inverse of a 4x4 matrix 
-procedure AdjointMatrix(var M: TMatrix); overload;
+procedure AdjointMatrix(var M: TGLMatrix); overload;
 // Adjoint of a 3x3 matrix, used in the computation of the inverse of a 3x3 matrix 
 // Adjoint of a 3x3 matrix, used in the computation of the inverse of a 3x3 matrix 
 procedure AdjointMatrix(var M: TAffineMatrix); overload;
 procedure AdjointMatrix(var M: TAffineMatrix); overload;
 
 
 // Multiplies all elements of a 3x3 matrix with a factor
 // Multiplies all elements of a 3x3 matrix with a factor
 procedure ScaleMatrix(var M: TAffineMatrix; const factor: Single); overload;
 procedure ScaleMatrix(var M: TAffineMatrix; const factor: Single); overload;
 // Multiplies all elements of a 4x4 matrix with a factor
 // Multiplies all elements of a 4x4 matrix with a factor
-procedure ScaleMatrix(var M: TMatrix; const factor: Single); overload;
+procedure ScaleMatrix(var M: TGLMatrix; const factor: Single); overload;
 
 
 // Adds the translation vector into the matrix
 // Adds the translation vector into the matrix
-procedure TranslateMatrix(var M: TMatrix; const V: TAffineVector); overload;
-procedure TranslateMatrix(var M: TMatrix; const V: TGLVector); overload;
+procedure TranslateMatrix(var M: TGLMatrix; const V: TAffineVector); overload;
+procedure TranslateMatrix(var M: TGLMatrix; const V: TGLVector); overload;
 
 
 (* Normalize the matrix and remove the translation component.
 (* Normalize the matrix and remove the translation component.
   The resulting matrix is an orthonormal matrix (Y direction preserved, then Z) *)
   The resulting matrix is an orthonormal matrix (Y direction preserved, then Z) *)
-procedure NormalizeMatrix(var M: TMatrix);
+procedure NormalizeMatrix(var M: TGLMatrix);
 
 
 // Computes transpose of 3x3 matrix
 // Computes transpose of 3x3 matrix
 procedure TransposeMatrix(var M: TAffineMatrix); overload;
 procedure TransposeMatrix(var M: TAffineMatrix); overload;
 // Computes transpose of 4x4 matrix
 // Computes transpose of 4x4 matrix
-procedure TransposeMatrix(var M: TMatrix); overload;
+procedure TransposeMatrix(var M: TGLMatrix); overload;
 
 
 // Finds the inverse of a 4x4 matrix
 // Finds the inverse of a 4x4 matrix
-procedure InvertMatrix(var M: TMatrix); overload;
-function MatrixInvert(const M: TMatrix): TMatrix; overload;
+procedure InvertMatrix(var M: TGLMatrix); overload;
+function MatrixInvert(const M: TGLMatrix): TGLMatrix; overload;
 
 
 // Finds the inverse of a 3x3 matrix;
 // Finds the inverse of a 3x3 matrix;
 procedure InvertMatrix(var M: TAffineMatrix); overload;
 procedure InvertMatrix(var M: TAffineMatrix); overload;
@@ -903,20 +901,20 @@ function  MatrixInvert(const M: TAffineMatrix): TAffineMatrix; overload;
 (* Finds the inverse of an angle preserving matrix.
 (* Finds the inverse of an angle preserving matrix.
   Angle preserving matrices can combine translation, rotation and isotropic
   Angle preserving matrices can combine translation, rotation and isotropic
   scaling, other matrices won't be properly inverted by this function. *)
   scaling, other matrices won't be properly inverted by this function. *)
-function AnglePreservingMatrixInvert(const mat: TMatrix): TMatrix;
+function AnglePreservingMatrixInvert(const mat: TGLMatrix): TGLMatrix;
 
 
 (* Decompose a non-degenerated 4x4 transformation matrix into the sequence of transformations that produced it.
 (* Decompose a non-degenerated 4x4 transformation matrix into the sequence of transformations that produced it.
   Modified by ml then eg, original Author: Spencer W. Thomas, University of Michigan
   Modified by ml then eg, original Author: Spencer W. Thomas, University of Michigan
   The coefficient of each transformation is returned in the corresponding
   The coefficient of each transformation is returned in the corresponding
   element of the vector Tran. Returns true upon success, false if the matrix is singular. *)
   element of the vector Tran. Returns true upon success, false if the matrix is singular. *)
-function MatrixDecompose(const M: TMatrix; var Tran: TTransformations): Boolean;
-function CreateLookAtMatrix(const eye, center, normUp: TGLVector): TMatrix;
-function CreateMatrixFromFrustum(Left, Right, Bottom, Top, ZNear, ZFar: Single): TMatrix;
-function CreatePerspectiveMatrix(FOV, Aspect, ZNear, ZFar: Single): TMatrix;
-function CreateOrthoMatrix(Left, Right, Bottom, Top, ZNear, ZFar: Single): TMatrix;
-function CreatePickMatrix(X, Y, deltax, deltay: Single; const viewport: TVector4i): TMatrix;
-function Project(objectVector: TGLVector; const ViewProjMatrix: TMatrix; const viewport: TVector4i; out WindowVector: TGLVector): Boolean;
-function UnProject(WindowVector: TGLVector; ViewProjMatrix: TMatrix; const viewport: TVector4i; out objectVector: TGLVector): Boolean;
+function MatrixDecompose(const M: TGLMatrix; var Tran: TTransformations): Boolean;
+function CreateLookAtMatrix(const eye, center, normUp: TGLVector): TGLMatrix;
+function CreateMatrixFromFrustum(Left, Right, Bottom, Top, ZNear, ZFar: Single): TGLMatrix;
+function CreatePerspectiveMatrix(FOV, Aspect, ZNear, ZFar: Single): TGLMatrix;
+function CreateOrthoMatrix(Left, Right, Bottom, Top, ZNear, ZFar: Single): TGLMatrix;
+function CreatePickMatrix(X, Y, deltax, deltay: Single; const viewport: TVector4i): TGLMatrix;
+function Project(objectVector: TGLVector; const ViewProjMatrix: TGLMatrix; const viewport: TVector4i; out WindowVector: TGLVector): Boolean;
+function UnProject(WindowVector: TGLVector; ViewProjMatrix: TGLMatrix; const viewport: TVector4i; out objectVector: TGLVector): Boolean;
 
 
 (* ----------------------------------------------------------------------------
 (* ----------------------------------------------------------------------------
  Plane functions
  Plane functions
@@ -1028,11 +1026,11 @@ function QuaternionFromPoints(const V1, V2: TAffineVector): TQuaternion;
 // Converts a unit quaternion into two points on a unit sphere
 // Converts a unit quaternion into two points on a unit sphere
 procedure QuaternionToPoints(const Q: TQuaternion; var ArcFrom, ArcTo: TAffineVector);
 procedure QuaternionToPoints(const Q: TQuaternion; var ArcFrom, ArcTo: TAffineVector);
 // Constructs a unit quaternion from a rotation matrix
 // Constructs a unit quaternion from a rotation matrix
-function QuaternionFromMatrix(const mat: TMatrix): TQuaternion;
+function QuaternionFromMatrix(const mat: TGLMatrix): TQuaternion;
 (* Constructs a rotation matrix from (possibly non-unit) quaternion.
 (* Constructs a rotation matrix from (possibly non-unit) quaternion.
   Assumes matrix is used to multiply column vector on the left: vnew = mat vold.
   Assumes matrix is used to multiply column vector on the left: vnew = mat vold.
   Works correctly for right-handed coordinate system and right-handed rotations *)
   Works correctly for right-handed coordinate system and right-handed rotations *)
-function QuaternionToMatrix(quat: TQuaternion): TMatrix;
+function QuaternionToMatrix(quat: TQuaternion): TGLMatrix;
 // Constructs an affine rotation matrix from (possibly non-unit) quaternion
 // Constructs an affine rotation matrix from (possibly non-unit) quaternion
 function QuaternionToAffineMatrix(quat: TQuaternion): TAffineMatrix;
 function QuaternionToAffineMatrix(quat: TQuaternion): TAffineMatrix;
 // Constructs quaternion from angle (in deg) and axis
 // Constructs quaternion from angle (in deg) and axis
@@ -1262,17 +1260,17 @@ procedure DivMod(Dividend: Integer; Divisor: Word; var result, Remainder: Word);
 // Coordinate system manipulation functions
 // Coordinate system manipulation functions
 
 
 // Rotates the given coordinate system (represented by the matrix) around its Y-axis
 // Rotates the given coordinate system (represented by the matrix) around its Y-axis
-function Turn(const Matrix: TMatrix; Angle: Single): TMatrix; overload;
+function Turn(const Matrix: TGLMatrix; Angle: Single): TGLMatrix; overload;
 // Rotates the given coordinate system (represented by the matrix) around MasterUp
 // Rotates the given coordinate system (represented by the matrix) around MasterUp
-function Turn(const Matrix: TMatrix; const MasterUp: TAffineVector; Angle: Single): TMatrix; overload;
+function Turn(const Matrix: TGLMatrix; const MasterUp: TAffineVector; Angle: Single): TGLMatrix; overload;
 // Rotates the given coordinate system (represented by the matrix) around its X-axis
 // Rotates the given coordinate system (represented by the matrix) around its X-axis
-function Pitch(const Matrix: TMatrix; Angle: Single): TMatrix; overload;
+function Pitch(const Matrix: TGLMatrix; Angle: Single): TGLMatrix; overload;
 // Rotates the given coordinate system (represented by the matrix) around MasterRight
 // Rotates the given coordinate system (represented by the matrix) around MasterRight
-function Pitch(const Matrix: TMatrix; const MasterRight: TAffineVector; Angle: Single): TMatrix; overload;
+function Pitch(const Matrix: TGLMatrix; const MasterRight: TAffineVector; Angle: Single): TGLMatrix; overload;
 // Rotates the given coordinate system (represented by the matrix) around its Z-axis
 // Rotates the given coordinate system (represented by the matrix) around its Z-axis
-function Roll(const Matrix: TMatrix; Angle: Single): TMatrix; overload;
+function Roll(const Matrix: TGLMatrix; Angle: Single): TGLMatrix; overload;
 // Rotates the given coordinate system (represented by the matrix) around MasterDirection
 // Rotates the given coordinate system (represented by the matrix) around MasterDirection
-function Roll(const Matrix: TMatrix; const MasterDirection: TAffineVector; Angle: Single): TMatrix; overload;
+function Roll(const Matrix: TGLMatrix; const MasterDirection: TAffineVector; Angle: Single): TGLMatrix; overload;
 
 
 // Intersection functions
 // Intersection functions
 
 
@@ -1295,7 +1293,7 @@ function IntersectTriangleBox(const p1, p2, p3, aMinExtent, aMaxExtent: TAffineV
    Up, Direction and Right must be normalized!
    Up, Direction and Right must be normalized!
    Use CubDepth, CubeHeight and CubeWidth to scale TGLCube *)
    Use CubDepth, CubeHeight and CubeWidth to scale TGLCube *)
 function IntersectSphereBox(const SpherePos: TGLVector;
 function IntersectSphereBox(const SpherePos: TGLVector;
-  const SphereRadius: Single; const BoxMatrix: TMatrix;
+  const SphereRadius: Single; const BoxMatrix: TGLMatrix;
   const BoxScale: TAffineVector; intersectPoint: PAffineVector = nil;
   const BoxScale: TAffineVector; intersectPoint: PAffineVector = nil;
   normal: PAffineVector = nil; depth: PSingle = nil): Boolean;
   normal: PAffineVector = nil; depth: PSingle = nil): Boolean;
 
 
@@ -1341,7 +1339,7 @@ function RectangleContains(const ACenterOfBigRect1, ACenterOfSmallRect2,
   intersection testing. *)
   intersection testing. *)
 function SphereVisibleRadius(distance, radius: Single): Single;
 function SphereVisibleRadius(distance, radius: Single): Single;
 // Extracts a TFrustum for combined modelview and projection matrices
 // Extracts a TFrustum for combined modelview and projection matrices
-function ExtractFrustumFromModelViewProjection(const modelViewProj: TMatrix): TFrustum;
+function ExtractFrustumFromModelViewProjection(const modelViewProj: TGLMatrix): TFrustum;
 // Determines if volume is clipped or not
 // Determines if volume is clipped or not
 function IsVolumeClipped(const objPos: TAffineVector; const objRadius: Single;
 function IsVolumeClipped(const objPos: TAffineVector; const objRadius: Single;
   const Frustum: TFrustum): Boolean; overload;
   const Frustum: TFrustum): Boolean; overload;
@@ -1353,22 +1351,22 @@ function IsVolumeClipped(const min, max: TAffineVector; const Frustum: TFrustum)
 
 
 (* Creates a parallel projection matrix.
 (* Creates a parallel projection matrix.
   Transformed points will projected on the plane along the specified direction *)
   Transformed points will projected on the plane along the specified direction *)
-function MakeParallelProjectionMatrix(const plane: THmgPlane; const dir: TGLVector): TMatrix;
+function MakeParallelProjectionMatrix(const plane: THmgPlane; const dir: TGLVector): TGLMatrix;
 (* Creates a shadow projection matrix.
 (* Creates a shadow projection matrix.
   Shadows will be projected onto the plane defined by planePoint and planeNormal,
   Shadows will be projected onto the plane defined by planePoint and planeNormal,
   from lightPos *)
   from lightPos *)
-function MakeShadowMatrix(const planePoint, planeNormal, lightPos: TGLVector): TMatrix;
+function MakeShadowMatrix(const planePoint, planeNormal, lightPos: TGLVector): TGLMatrix;
 (* Builds a reflection matrix for the given plane.
 (* Builds a reflection matrix for the given plane.
   Reflection matrix allow implementing planar reflectors (mirrors) *)
   Reflection matrix allow implementing planar reflectors (mirrors) *)
-function MakeReflectionMatrix(const planePoint, planeNormal: TAffineVector): TMatrix;
+function MakeReflectionMatrix(const planePoint, planeNormal: TAffineVector): TGLMatrix;
 (* Packs an homogeneous rotation matrix to 6 bytes.
 (* Packs an homogeneous rotation matrix to 6 bytes.
   The 6:64 (or 6:36) compression ratio is achieved by computing the quaternion
   The 6:64 (or 6:36) compression ratio is achieved by computing the quaternion
   associated to the matrix and storing its Imaginary components at 16 bits
   associated to the matrix and storing its Imaginary components at 16 bits
   precision each. Deviation is typically below 0.01% and around 0.1% in worst case situations.
   precision each. Deviation is typically below 0.01% and around 0.1% in worst case situations.
   Note: quaternion conversion is faster and more robust than an angle decomposition *)
   Note: quaternion conversion is faster and more robust than an angle decomposition *)
-function PackRotationMatrix(const mat: TMatrix): TPackedRotationMatrix;
+function PackRotationMatrix(const mat: TGLMatrix): TPackedRotationMatrix;
 // Restores a packed rotation matrix. See PackRotationMatrix
 // Restores a packed rotation matrix. See PackRotationMatrix
-function UnPackRotationMatrix(const packedMatrix: TPackedRotationMatrix): TMatrix;
+function UnPackRotationMatrix(const packedMatrix: TPackedRotationMatrix): TGLMatrix;
 
 
 (* Calculates the barycentric coordinates for the point p on the triangle
 (* Calculates the barycentric coordinates for the point p on the triangle
   defined by the vertices v1, v2 and v3. That is, solves
   defined by the vertices v1, v2 and v3. That is, solves
@@ -2220,7 +2218,7 @@ end;
 function VectorAngleLerp(const V1, V2: TAffineVector; T: Single): TAffineVector;
 function VectorAngleLerp(const V1, V2: TAffineVector; T: Single): TAffineVector;
 var
 var
   q1, q2, qR: TQuaternion;
   q1, q2, qR: TQuaternion;
-  M: TMatrix;
+  M: TGLMatrix;
   Tran: TTransformations;
   Tran: TTransformations;
 begin
 begin
   if VectorEquals(V1, V2) then
   if VectorEquals(V1, V2) then
@@ -2396,7 +2394,7 @@ begin
     result := (stop - start) * Power(delta, DistortionDegree) + start;
     result := (stop - start) * Power(delta, DistortionDegree) + start;
 end;
 end;
 
 
-function MatrixLerp(const m1, m2: TMatrix; const delta: Single): TMatrix;
+function MatrixLerp(const m1, m2: TGLMatrix; const delta: Single): TGLMatrix;
 var
 var
   i, J: Integer;
   i, J: Integer;
 begin
 begin
@@ -2969,7 +2967,7 @@ begin
   result := (a * c - b * b) < cColinearBias;
   result := (a * c - b * b) < cColinearBias;
 end;
 end;
 
 
-procedure SetMatrix(var dest: THomogeneousDblMatrix; const src: TMatrix);
+procedure SetMatrix(var dest: THomogeneousDblMatrix; const src: TGLMatrix);
 var
 var
   i: Integer;
   i: Integer;
 begin
 begin
@@ -2982,7 +2980,7 @@ begin
   end;
   end;
 end;
 end;
 
 
-procedure SetMatrix(var dest: TAffineMatrix; const src: TMatrix);
+procedure SetMatrix(var dest: TAffineMatrix; const src: TGLMatrix);
 begin
 begin
   dest.X.X := src.X.X;
   dest.X.X := src.X.X;
   dest.X.Y := src.X.Y;
   dest.X.Y := src.X.Y;
@@ -2995,7 +2993,7 @@ begin
   dest.Z.Z := src.Z.Z;
   dest.Z.Z := src.Z.Z;
 end;
 end;
 
 
-procedure SetMatrix(var dest: TMatrix; const src: TAffineMatrix);
+procedure SetMatrix(var dest: TGLMatrix; const src: TAffineMatrix);
 begin
 begin
   dest.X.X := src.X.X;
   dest.X.X := src.X.X;
   dest.X.Y := src.X.Y;
   dest.X.Y := src.X.Y;
@@ -3015,7 +3013,7 @@ begin
   dest.W.W := 1;
   dest.W.W := 1;
 end;
 end;
 
 
-procedure SetMatrixRow(var dest: TMatrix; rowNb: Integer; const aRow: TGLVector);
+procedure SetMatrixRow(var dest: TGLMatrix; rowNb: Integer; const aRow: TGLVector);
 begin
 begin
   dest.X.V[rowNb] := aRow.X;
   dest.X.V[rowNb] := aRow.X;
   dest.Y.V[rowNb] := aRow.Y;
   dest.Y.V[rowNb] := aRow.Y;
@@ -3023,7 +3021,7 @@ begin
   dest.W.V[rowNb] := aRow.W;
   dest.W.V[rowNb] := aRow.W;
 end;
 end;
 
 
-function CreateScaleMatrix(const V: TAffineVector): TMatrix;
+function CreateScaleMatrix(const V: TAffineVector): TGLMatrix;
 begin
 begin
   result := IdentityHmgMatrix;
   result := IdentityHmgMatrix;
   result.X.X := V.V[X];
   result.X.X := V.V[X];
@@ -3031,7 +3029,7 @@ begin
   result.Z.Z := V.V[Z];
   result.Z.Z := V.V[Z];
 end;
 end;
 
 
-function CreateScaleMatrix(const V: TGLVector): TMatrix;
+function CreateScaleMatrix(const V: TGLVector): TGLMatrix;
 begin
 begin
   result := IdentityHmgMatrix;
   result := IdentityHmgMatrix;
   result.X.X := V.V[X];
   result.X.X := V.V[X];
@@ -3039,7 +3037,7 @@ begin
   result.Z.Z := V.V[Z];
   result.Z.Z := V.V[Z];
 end;
 end;
 
 
-function CreateTranslationMatrix(const V: TAffineVector): TMatrix;
+function CreateTranslationMatrix(const V: TAffineVector): TGLMatrix;
 begin
 begin
   result := IdentityHmgMatrix;
   result := IdentityHmgMatrix;
   result.W.X := V.V[X];
   result.W.X := V.V[X];
@@ -3047,7 +3045,7 @@ begin
   result.W.Z := V.V[Z];
   result.W.Z := V.V[Z];
 end;
 end;
 
 
-function CreateTranslationMatrix(const V: TGLVector): TMatrix;
+function CreateTranslationMatrix(const V: TGLVector): TGLMatrix;
 begin
 begin
   result := IdentityHmgMatrix;
   result := IdentityHmgMatrix;
   result.W.X := V.V[X];
   result.W.X := V.V[X];
@@ -3055,7 +3053,7 @@ begin
   result.W.Z := V.V[Z];
   result.W.Z := V.V[Z];
 end;
 end;
 
 
-function CreateScaleAndTranslationMatrix(const scale, offset: TGLVector): TMatrix;
+function CreateScaleAndTranslationMatrix(const scale, offset: TGLVector): TGLMatrix;
 begin
 begin
   result := IdentityHmgMatrix;
   result := IdentityHmgMatrix;
   result.X.X := scale.V[X];
   result.X.X := scale.V[X];
@@ -3066,7 +3064,7 @@ begin
   result.W.Z := offset.V[Z];
   result.W.Z := offset.V[Z];
 end;
 end;
 
 
-function CreateRotationMatrixX(const sine, cosine: Single): TMatrix;
+function CreateRotationMatrixX(const sine, cosine: Single): TGLMatrix;
 begin
 begin
   result := EmptyHmgMatrix;
   result := EmptyHmgMatrix;
   result.X.X := 1;
   result.X.X := 1;
@@ -3077,7 +3075,7 @@ begin
   result.W.W := 1;
   result.W.W := 1;
 end;
 end;
 
 
-function CreateRotationMatrixX(const angle: Single): TMatrix;
+function CreateRotationMatrixX(const angle: Single): TGLMatrix;
 var
 var
   S, c: Single;
   S, c: Single;
 begin
 begin
@@ -3085,7 +3083,7 @@ begin
   result := CreateRotationMatrixX(S, c);
   result := CreateRotationMatrixX(S, c);
 end;
 end;
 
 
-function CreateRotationMatrixY(const sine, cosine: Single): TMatrix;
+function CreateRotationMatrixY(const sine, cosine: Single): TGLMatrix;
 begin
 begin
   result := EmptyHmgMatrix;
   result := EmptyHmgMatrix;
   result.X.X := cosine;
   result.X.X := cosine;
@@ -3096,7 +3094,7 @@ begin
   result.W.W := 1;
   result.W.W := 1;
 end;
 end;
 
 
-function CreateRotationMatrixY(const angle: Single): TMatrix;
+function CreateRotationMatrixY(const angle: Single): TGLMatrix;
 var
 var
   S, c: Single;
   S, c: Single;
 begin
 begin
@@ -3104,7 +3102,7 @@ begin
   result := CreateRotationMatrixY(S, c);
   result := CreateRotationMatrixY(S, c);
 end;
 end;
 
 
-function CreateRotationMatrixZ(const sine, cosine: Single): TMatrix;
+function CreateRotationMatrixZ(const sine, cosine: Single): TGLMatrix;
 begin
 begin
   result := EmptyHmgMatrix;
   result := EmptyHmgMatrix;
   result.X.X := cosine;
   result.X.X := cosine;
@@ -3115,7 +3113,7 @@ begin
   result.W.W := 1;
   result.W.W := 1;
 end;
 end;
 
 
-function CreateRotationMatrixZ(const angle: Single): TMatrix;
+function CreateRotationMatrixZ(const angle: Single): TGLMatrix;
 var
 var
   S, c: Single;
   S, c: Single;
 begin
 begin
@@ -3124,7 +3122,7 @@ begin
 end;
 end;
 
 
 function CreateRotationMatrix(const anAxis: TAffineVector;
 function CreateRotationMatrix(const anAxis: TAffineVector;
-  angle: Single): TMatrix;
+  angle: Single): TGLMatrix;
 var
 var
   axis: TAffineVector;
   axis: TAffineVector;
   cosine, sine, one_minus_cosine: Single;
   cosine, sine, one_minus_cosine: Single;
@@ -3154,7 +3152,7 @@ begin
   result.W.W := 1;
   result.W.W := 1;
 end;
 end;
 
 
-function CreateRotationMatrix(const anAxis: TGLVector; angle: Single): TMatrix;
+function CreateRotationMatrix(const anAxis: TGLVector; angle: Single): TGLMatrix;
 begin
 begin
   result := CreateRotationMatrix(PAffineVector(@anAxis)^, angle);
   result := CreateRotationMatrix(PAffineVector(@anAxis)^, angle);
 end;
 end;
@@ -3195,7 +3193,7 @@ begin
   result.Z.Z := m1.Z.X * m2.X.Z + m1.Z.Y * m2.Y.Z + m1.Z.Z * m2.Z.Z;
   result.Z.Z := m1.Z.X * m2.X.Z + m1.Z.Y * m2.Y.Z + m1.Z.Z * m2.Z.Z;
 end;
 end;
 
 
-function MatrixMultiply(const m1, m2: TMatrix): TMatrix;
+function MatrixMultiply(const m1, m2: TGLMatrix): TGLMatrix;
 begin
 begin
   result.X.X := m1.X.X * m2.X.X + m1.X.Y * m2.Y.X + m1.X.Z * m2.Z.X +
   result.X.X := m1.X.X * m2.X.X + m1.X.Y * m2.Y.X + m1.X.Z * m2.Z.X +
     m1.X.W * m2.W.X;
     m1.X.W * m2.W.X;
@@ -3231,7 +3229,7 @@ begin
     m1.W.W * m2.W.W;
     m1.W.W * m2.W.W;
 end;
 end;
 
 
-procedure MatrixMultiply(const m1, m2: TMatrix; var MResult: TMatrix);
+procedure MatrixMultiply(const m1, m2: TGLMatrix; var MResult: TGLMatrix);
 begin
 begin
   MResult.X.X := m1.X.X * m2.X.X + m1.X.Y * m2.Y.X + m1.X.Z * m2.Z.X +  m1.X.W * m2.W.X;
   MResult.X.X := m1.X.X * m2.X.X + m1.X.Y * m2.Y.X + m1.X.Z * m2.Z.X +  m1.X.W * m2.W.X;
   MResult.X.Y := m1.X.X * m2.X.Y + m1.X.Y * m2.Y.Y + m1.X.Z * m2.Z.Y +  m1.X.W * m2.W.Y;
   MResult.X.Y := m1.X.X * m2.X.Y + m1.X.Y * m2.Y.Y + m1.X.Z * m2.Z.Y +  m1.X.W * m2.W.Y;
@@ -3252,7 +3250,7 @@ begin
 
 
 end;
 end;
 
 
-function VectorTransform(const V: TGLVector; const M: TMatrix): TGLVector;
+function VectorTransform(const V: TGLVector; const M: TGLMatrix): TGLVector;
 begin
 begin
     result.V[X] := V.V[X] * M.X.X + V.V[Y] * M.Y.X + V.V[Z] * M.Z.X + V.V[W] * M.W.X;
     result.V[X] := V.V[X] * M.X.X + V.V[Y] * M.Y.X + V.V[Z] * M.Z.X + V.V[W] * M.W.X;
     result.V[Y] := V.V[X] * M.X.Y + V.V[Y] * M.Y.Y + V.V[Z] * M.Z.Y + V.V[W] * M.W.Y;
     result.V[Y] := V.V[X] * M.X.Y + V.V[Y] * M.Y.Y + V.V[Z] * M.Z.Y + V.V[W] * M.W.Y;
@@ -3268,7 +3266,7 @@ begin
   result.W := V.W;
   result.W := V.W;
 end;
 end;
 
 
-function VectorTransform(const V: TAffineVector; const M: TMatrix)
+function VectorTransform(const V: TAffineVector; const M: TGLMatrix)
   : TAffineVector;
   : TAffineVector;
 begin
 begin
   result.X := V.X * M.V[X].X + V.Y * M.V[Y].X + V.Z * M.V[Z].X + M.V[W].X;
   result.X := V.X * M.V[X].X + V.Y * M.V[Y].X + V.Z * M.V[Z].X + M.V[W].X;
@@ -3298,7 +3296,7 @@ begin
     (a2 * b3 - a3 * b2);
     (a2 * b3 - a3 * b2);
 end;
 end;
 
 
-function MatrixDeterminant(const M: TMatrix): Single;
+function MatrixDeterminant(const M: TGLMatrix): Single;
 begin
 begin
   result := M.X.X * MatrixDetInternal(M.Y.Y, M.Z.Y, M.W.Y, M.Y.Z, M.Z.Z, M.W.Z,
   result := M.X.X * MatrixDetInternal(M.Y.Y, M.Z.Y, M.W.Y, M.Y.Z, M.Z.Z, M.W.Z,
     M.Y.W, M.Z.W, M.W.W) - M.X.Y * MatrixDetInternal(M.Y.X, M.Z.X, M.W.X, M.Y.Z,
     M.Y.W, M.Z.W, M.W.W) - M.X.Y * MatrixDetInternal(M.Y.X, M.Z.X, M.W.X, M.Y.Z,
@@ -3308,7 +3306,7 @@ begin
     M.Z.Z, M.W.Z);
     M.Z.Z, M.W.Z);
 end;
 end;
 
 
-procedure AdjointMatrix(var M: TMatrix);
+procedure AdjointMatrix(var M: TGLMatrix);
 var
 var
   a1, a2, a3, a4, b1, b2, b3, b4, c1, c2, c3, c4, d1, d2, d3, d4: Single;
   a1, a2, a3, a4, b1, b2, b3, b4, c1, c2, c3, c4, d1, d2, d3, d4: Single;
 begin
 begin
@@ -3389,7 +3387,7 @@ begin
   end;
   end;
 end;
 end;
 
 
-procedure ScaleMatrix(var M: TMatrix; const factor: Single);
+procedure ScaleMatrix(var M: TGLMatrix; const factor: Single);
 var
 var
   i: Integer;
   i: Integer;
 begin
 begin
@@ -3402,21 +3400,21 @@ begin
   end;
   end;
 end;
 end;
 
 
-procedure TranslateMatrix(var M: TMatrix; const V: TAffineVector);
+procedure TranslateMatrix(var M: TGLMatrix; const V: TAffineVector);
 begin
 begin
   M.W.X := M.W.X + V.X;
   M.W.X := M.W.X + V.X;
   M.W.Y := M.W.Y + V.Y;
   M.W.Y := M.W.Y + V.Y;
   M.W.Z := M.W.Z + V.Z;
   M.W.Z := M.W.Z + V.Z;
 end;
 end;
 
 
-procedure TranslateMatrix(var M: TMatrix; const V: TGLVector);
+procedure TranslateMatrix(var M: TGLMatrix; const V: TGLVector);
 begin
 begin
   M.W.X := M.W.X + V.X;
   M.W.X := M.W.X + V.X;
   M.W.Y := M.W.Y + V.Y;
   M.W.Y := M.W.Y + V.Y;
   M.W.Z := M.W.Z + V.Z;
   M.W.Z := M.W.Z + V.Z;
 end;
 end;
 
 
-procedure NormalizeMatrix(var M: TMatrix);
+procedure NormalizeMatrix(var M: TGLMatrix);
 begin
 begin
   M.X.W := 0;
   M.X.W := 0;
   NormalizeVector(M.X);
   NormalizeVector(M.X);
@@ -3442,7 +3440,7 @@ begin
   M.Z.Y := f;
   M.Z.Y := f;
 end;
 end;
 
 
-procedure TransposeMatrix(var M: TMatrix);
+procedure TransposeMatrix(var M: TGLMatrix);
 var
 var
   f: Single;
   f: Single;
 begin
 begin
@@ -3466,7 +3464,7 @@ begin
   M.W.Z := f;
   M.W.Z := f;
 end;
 end;
 
 
-procedure InvertMatrix(var M: TMatrix);
+procedure InvertMatrix(var M: TGLMatrix);
 var
 var
   det: Single;
   det: Single;
 begin
 begin
@@ -3480,7 +3478,7 @@ begin
   end;
   end;
 end;
 end;
 
 
-function MatrixInvert(const M: TMatrix): TMatrix;
+function MatrixInvert(const M: TGLMatrix): TGLMatrix;
 begin
 begin
   result := M;
   result := M;
   InvertMatrix(result);
   InvertMatrix(result);
@@ -3506,7 +3504,7 @@ begin
   InvertMatrix(result);
   InvertMatrix(result);
 end;
 end;
 
 
-procedure Transpose_Scale_M33(const src: TMatrix; var dest: TMatrix;
+procedure Transpose_Scale_M33(const src: TGLMatrix; var dest: TGLMatrix;
   var scale: Single);
   var scale: Single);
 begin
 begin
   dest.X.X := scale * src.X.X;
   dest.X.X := scale * src.X.X;
@@ -3521,7 +3519,7 @@ begin
 end;
 end;
 
 
 
 
-function AnglePreservingMatrixInvert(const mat: TMatrix): TMatrix;
+function AnglePreservingMatrixInvert(const mat: TGLMatrix): TGLMatrix;
 var
 var
   scale: Single;
   scale: Single;
 begin
 begin
@@ -3558,10 +3556,10 @@ begin
     mat.W.Y + result.Z.Z * mat.W.Z);
     mat.W.Y + result.Z.Z * mat.W.Z);
 end;
 end;
 
 
-function MatrixDecompose(const M: TMatrix; var Tran: TTransformations): Boolean;
+function MatrixDecompose(const M: TGLMatrix; var Tran: TTransformations): Boolean;
 var
 var
   I, J: Integer;
   I, J: Integer;
-  LocMat, pmat, invpmat: TMatrix;
+  LocMat, pmat, invpmat: TGLMatrix;
   prhs, psol: TGLVector;
   prhs, psol: TGLVector;
   row0, row1, row2: TAffineVector;
   row0, row1, row2: TAffineVector;
   f: Single;
   f: Single;
@@ -3694,7 +3692,7 @@ begin
   result := True;
   result := True;
 end;
 end;
 
 
-function CreateLookAtMatrix(const eye, center, normUp: TGLVector): TMatrix;
+function CreateLookAtMatrix(const eye, center, normUp: TGLVector): TGLMatrix;
 var
 var
   XAxis, YAxis, ZAxis, negEye: TGLVector;
   XAxis, YAxis, ZAxis, negEye: TGLVector;
 begin
 begin
@@ -3717,7 +3715,7 @@ begin
 end;
 end;
 
 
 function CreateMatrixFromFrustum(Left, Right, Bottom, Top, ZNear,
 function CreateMatrixFromFrustum(Left, Right, Bottom, Top, ZNear,
-  ZFar: Single): TMatrix;
+  ZFar: Single): TGLMatrix;
 begin
 begin
   result.X.X := 2 * ZNear / (Right - Left);
   result.X.X := 2 * ZNear / (Right - Left);
   result.X.Y := 0;
   result.X.Y := 0;
@@ -3740,7 +3738,7 @@ begin
   result.W.W := 0;
   result.W.W := 0;
 end;
 end;
 
 
-function CreatePerspectiveMatrix(FOV, Aspect, ZNear, ZFar: Single): TMatrix;
+function CreatePerspectiveMatrix(FOV, Aspect, ZNear, ZFar: Single): TGLMatrix;
 var
 var
   X, Y: Single;
   X, Y: Single;
 begin
 begin
@@ -3751,7 +3749,7 @@ begin
 end;
 end;
 
 
 function CreateOrthoMatrix(Left, Right, Bottom, Top, ZNear,
 function CreateOrthoMatrix(Left, Right, Bottom, Top, ZNear,
-  ZFar: Single): TMatrix;
+  ZFar: Single): TGLMatrix;
 begin
 begin
   result.X.X := 2 / (Right - Left);
   result.X.X := 2 / (Right - Left);
   result.X.Y := 0;
   result.X.Y := 0;
@@ -3775,7 +3773,7 @@ begin
 end;
 end;
 
 
 function CreatePickMatrix(X, Y, deltax, deltay: Single;
 function CreatePickMatrix(X, Y, deltax, deltay: Single;
-  const viewport: TVector4i): TMatrix;
+  const viewport: TVector4i): TGLMatrix;
 begin
 begin
   if (deltax <= 0) or (deltay <= 0) then
   if (deltax <= 0) or (deltay <= 0) then
   begin
   begin
@@ -3790,7 +3788,7 @@ begin
   result.Y.Y := viewport.W / deltay;
   result.Y.Y := viewport.W / deltay;
 end;
 end;
 
 
-function Project(objectVector: TGLVector; const ViewProjMatrix: TMatrix;
+function Project(objectVector: TGLVector; const ViewProjMatrix: TGLMatrix;
   const viewport: TVector4i; out WindowVector: TGLVector): Boolean;
   const viewport: TVector4i; out WindowVector: TGLVector): Boolean;
 begin
 begin
   result := False;
   result := False;
@@ -3812,7 +3810,7 @@ begin
   result := True;
   result := True;
 end;
 end;
 
 
-function UnProject(WindowVector: TGLVector; ViewProjMatrix: TMatrix;
+function UnProject(WindowVector: TGLVector; ViewProjMatrix: TGLMatrix;
   const viewport: TVector4i; out objectVector: TGLVector): Boolean;
   const viewport: TVector4i; out objectVector: TGLVector): Boolean;
 begin
 begin
   result := False;
   result := False;
@@ -4415,7 +4413,7 @@ begin
   result.RealPart := Sqrt((VectorDotProduct(V1, V2) + 1) / 2);
   result.RealPart := Sqrt((VectorDotProduct(V1, V2) + 1) / 2);
 end;
 end;
 
 
-function QuaternionFromMatrix(const mat: TMatrix): TQuaternion;
+function QuaternionFromMatrix(const mat: TGLMatrix): TQuaternion;
 // the matrix must be a rotation matrix!
 // the matrix must be a rotation matrix!
 var
 var
   traceMat, S, invS: Double;
   traceMat, S, invS: Double;
@@ -4483,7 +4481,7 @@ begin
   result := Temp;
   result := Temp;
 end;
 end;
 
 
-function QuaternionToMatrix(quat: TQuaternion): TMatrix;
+function QuaternionToMatrix(quat: TQuaternion): TGLMatrix;
 var
 var
   W, X, Y, Z, xx, xy, xz, xw, yy, yz, yw, zz, zw: Single;
   W, X, Y, Z, xx, xy, xz, xw, yy, yz, yw, zz, zw: Single;
 begin
 begin
@@ -5678,7 +5676,7 @@ function ConvertRotation(const Angles: TAffineVector): TGLVector;
 }
 }
 var
 var
   Axis1, Axis2: TVector3f;
   Axis1, Axis2: TVector3f;
-  M, m1, m2: TMatrix;
+  M, m1, m2: TGLMatrix;
   cost, cost1, sint, s1, s2, s3: Single;
   cost, cost1, sint, s1, s2, s3: Single;
   i: Integer;
   i: Integer;
 begin
 begin
@@ -5891,41 +5889,41 @@ end;
 
 
 // ----------------- coordinate system manipulation functions -----------------------------------------------------------
 // ----------------- coordinate system manipulation functions -----------------------------------------------------------
 
 
-function Turn(const Matrix: TMatrix; angle: Single): TMatrix;
+function Turn(const Matrix: TGLMatrix; angle: Single): TGLMatrix;
 begin
 begin
   result := MatrixMultiply(Matrix,
   result := MatrixMultiply(Matrix,
     CreateRotationMatrix(AffineVectorMake(Matrix.Y.X, Matrix.Y.Y,
     CreateRotationMatrix(AffineVectorMake(Matrix.Y.X, Matrix.Y.Y,
     Matrix.Y.Z), angle));
     Matrix.Y.Z), angle));
 end;
 end;
 
 
-function Turn(const Matrix: TMatrix; const MasterUp: TAffineVector;
-  angle: Single): TMatrix;
+function Turn(const Matrix: TGLMatrix; const MasterUp: TAffineVector;
+  angle: Single): TGLMatrix;
 begin
 begin
   result := MatrixMultiply(Matrix, CreateRotationMatrix(MasterUp, angle));
   result := MatrixMultiply(Matrix, CreateRotationMatrix(MasterUp, angle));
 end;
 end;
 
 
-function Pitch(const Matrix: TMatrix; angle: Single): TMatrix;
+function Pitch(const Matrix: TGLMatrix; angle: Single): TGLMatrix;
 begin
 begin
   result := MatrixMultiply(Matrix,
   result := MatrixMultiply(Matrix,
     CreateRotationMatrix(AffineVectorMake(Matrix.X.X, Matrix.X.Y,
     CreateRotationMatrix(AffineVectorMake(Matrix.X.X, Matrix.X.Y,
     Matrix.X.Z), angle));
     Matrix.X.Z), angle));
 end;
 end;
 
 
-function Pitch(const Matrix: TMatrix; const MasterRight: TAffineVector;
-  angle: Single): TMatrix; overload;
+function Pitch(const Matrix: TGLMatrix; const MasterRight: TAffineVector;
+  angle: Single): TGLMatrix; overload;
 begin
 begin
   result := MatrixMultiply(Matrix, CreateRotationMatrix(MasterRight, angle));
   result := MatrixMultiply(Matrix, CreateRotationMatrix(MasterRight, angle));
 end;
 end;
 
 
-function Roll(const Matrix: TMatrix; angle: Single): TMatrix;
+function Roll(const Matrix: TGLMatrix; angle: Single): TGLMatrix;
 begin
 begin
   result := MatrixMultiply(Matrix,
   result := MatrixMultiply(Matrix,
     CreateRotationMatrix(AffineVectorMake(Matrix.Z.X, Matrix.Z.Y,
     CreateRotationMatrix(AffineVectorMake(Matrix.Z.X, Matrix.Z.Y,
     Matrix.Z.Z), angle));
     Matrix.Z.Z), angle));
 end;
 end;
 
 
-function Roll(const Matrix: TMatrix; const MasterDirection: TAffineVector;
-  angle: Single): TMatrix; overload;
+function Roll(const Matrix: TGLMatrix; const MasterDirection: TAffineVector;
+  angle: Single): TGLMatrix; overload;
 begin
 begin
   result := MatrixMultiply(Matrix,
   result := MatrixMultiply(Matrix,
     CreateRotationMatrix(MasterDirection, angle));
     CreateRotationMatrix(MasterDirection, angle));
@@ -6269,21 +6267,21 @@ begin
 end;
 end;
 
 
 function IntersectSphereBox(const SpherePos: TGLVector;
 function IntersectSphereBox(const SpherePos: TGLVector;
-  const SphereRadius: Single; const BoxMatrix: TMatrix;
+  const SphereRadius: Single; const BoxMatrix: TGLMatrix;
   // Up Direction and Right must be normalized!
   // Up Direction and Right must be normalized!
   // Use CubDepht, CubeHeight and CubeWidth
   // Use CubDepht, CubeHeight and CubeWidth
   // for scale TGLCube.
   // for scale TGLCube.
   const BoxScale: TAffineVector; intersectPoint: PAffineVector = nil;
   const BoxScale: TAffineVector; intersectPoint: PAffineVector = nil;
   normal: PAffineVector = nil; depth: PSingle = nil): Boolean;
   normal: PAffineVector = nil; depth: PSingle = nil): Boolean;
 
 
-  function dDOTByColumn(const V: TAffineVector; const M: TMatrix;
+  function dDOTByColumn(const V: TAffineVector; const M: TGLMatrix;
     const aColumn: Integer): Single;
     const aColumn: Integer): Single;
   begin
   begin
     result := V.X * M.X.V[aColumn] + V.Y * M.Y.V[aColumn] + V.Z *
     result := V.X * M.X.V[aColumn] + V.Y * M.Y.V[aColumn] + V.Z *
       M.Z.V[aColumn];
       M.Z.V[aColumn];
   end;
   end;
 
 
-  function dDotByRow(const V: TAffineVector; const M: TMatrix;
+  function dDotByRow(const V: TAffineVector; const M: TGLMatrix;
     const aRow: Integer): Single;
     const aRow: Integer): Single;
   begin
   begin
     // Equal with: Result := VectorDotProduct(v, AffineVectorMake(m[aRow]));
     // Equal with: Result := VectorDotProduct(v, AffineVectorMake(m[aRow]));
@@ -6291,7 +6289,7 @@ function IntersectSphereBox(const SpherePos: TGLVector;
       M.V[aRow].Z;
       M.V[aRow].Z;
   end;
   end;
 
 
-  function dDotMatrByColumn(const V: TAffineVector; const M: TMatrix)
+  function dDotMatrByColumn(const V: TAffineVector; const M: TGLMatrix)
     : TAffineVector;
     : TAffineVector;
   begin
   begin
     result.X := dDOTByColumn(V, M, 0);
     result.X := dDOTByColumn(V, M, 0);
@@ -6299,7 +6297,7 @@ function IntersectSphereBox(const SpherePos: TGLVector;
     result.Z := dDOTByColumn(V, M, 2);
     result.Z := dDOTByColumn(V, M, 2);
   end;
   end;
 
 
-  function dDotMatrByRow(const V: TAffineVector; const M: TMatrix)
+  function dDotMatrByRow(const V: TAffineVector; const M: TGLMatrix)
     : TAffineVector;
     : TAffineVector;
   begin
   begin
     result.X := dDotByRow(V, M, 0);
     result.X := dDotByRow(V, M, 0);
@@ -6397,7 +6395,7 @@ begin
   end;
   end;
 end;
 end;
 
 
-function ExtractFrustumFromModelViewProjection(const modelViewProj: TMatrix)
+function ExtractFrustumFromModelViewProjection(const modelViewProj: TGLMatrix)
   : TFrustum;
   : TFrustum;
 begin
 begin
   with result do
   with result do
@@ -6470,7 +6468,7 @@ begin
 end;
 end;
 
 
 function MakeParallelProjectionMatrix(const plane: THmgPlane;
 function MakeParallelProjectionMatrix(const plane: THmgPlane;
-  const dir: TGLVector): TMatrix;
+  const dir: TGLVector): TGLMatrix;
 // Based on material from a course by William D. Shoaff (www.cs.fit.edu)
 // Based on material from a course by William D. Shoaff (www.cs.fit.edu)
 var
 var
   dot, invDot: Single;
   dot, invDot: Single;
@@ -6505,7 +6503,7 @@ begin
 end;
 end;
 
 
 function MakeShadowMatrix(const planePoint, planeNormal,
 function MakeShadowMatrix(const planePoint, planeNormal,
-  lightPos: TGLVector): TMatrix;
+  lightPos: TGLVector): TGLMatrix;
 var
 var
   planeNormal3, dot: Single;
   planeNormal3, dot: Single;
 begin
 begin
@@ -6539,7 +6537,7 @@ begin
 end;
 end;
 
 
 function MakeReflectionMatrix(const planePoint, planeNormal
 function MakeReflectionMatrix(const planePoint, planeNormal
-  : TAffineVector): TMatrix;
+  : TAffineVector): TGLMatrix;
 var
 var
   pv2: Single;
   pv2: Single;
 begin
 begin
@@ -6567,7 +6565,7 @@ begin
   result.W.W := 1;
   result.W.W := 1;
 end;
 end;
 
 
-function PackRotationMatrix(const mat: TMatrix): TPackedRotationMatrix;
+function PackRotationMatrix(const mat: TGLMatrix): TPackedRotationMatrix;
 var
 var
   Q: TQuaternion;
   Q: TQuaternion;
 const
 const
@@ -6592,7 +6590,7 @@ begin
 end;
 end;
 
 
 function UnPackRotationMatrix(const packedMatrix
 function UnPackRotationMatrix(const packedMatrix
-  : TPackedRotationMatrix): TMatrix;
+  : TPackedRotationMatrix): TGLMatrix;
 var
 var
   Q: TQuaternion;
   Q: TQuaternion;
 const
 const

+ 4 - 4
Source/GLS.VectorLists.pas

@@ -161,10 +161,10 @@ type
     procedure CombineItem(Index: Integer; const vector: TAffineVector; const f: Single);
     procedure CombineItem(Index: Integer; const vector: TAffineVector; const f: Single);
     (*Transforms all items by the matrix as if they were points.
     (*Transforms all items by the matrix as if they were points.
       ie. the translation component of the matrix is honoured. *)
       ie. the translation component of the matrix is honoured. *)
-    procedure TransformAsPoints(const matrix: TMatrix);
+    procedure TransformAsPoints(const matrix: TGLMatrix);
     (* Transforms all items by the matrix as if they were vectors.
     (* Transforms all items by the matrix as if they were vectors.
        ie. the translation component of the matrix is not honoured. *)
        ie. the translation component of the matrix is not honoured. *)
-    procedure TransformAsVectors(const matrix: TMatrix); overload;
+    procedure TransformAsVectors(const matrix: TGLMatrix); overload;
     procedure TransformAsVectors(const matrix: TAffineMatrix); overload;
     procedure TransformAsVectors(const matrix: TAffineMatrix); overload;
     procedure Normalize; override;
     procedure Normalize; override;
     procedure Lerp(const list1, list2: TBaseVectorList; lerpFactor: Single); override;
     procedure Lerp(const list1, list2: TBaseVectorList; lerpFactor: Single); override;
@@ -1474,7 +1474,7 @@ begin
   Inc(FRevision);
   Inc(FRevision);
 end;
 end;
 
 
-procedure TAffineVectorList.TransformAsPoints(const matrix: TMatrix);
+procedure TAffineVectorList.TransformAsPoints(const matrix: TGLMatrix);
 var
 var
   I: Integer;
   I: Integer;
 begin
 begin
@@ -1483,7 +1483,7 @@ begin
   Inc(FRevision);
   Inc(FRevision);
 end;
 end;
 
 
-procedure TAffineVectorList.TransformAsVectors(const matrix: TMatrix);
+procedure TAffineVectorList.TransformAsVectors(const matrix: TGLMatrix);
 var
 var
   m: TAffineMatrix;
   m: TAffineMatrix;
 begin
 begin

+ 1 - 1
Source/GLS.VectorTypes.pas

@@ -447,7 +447,7 @@ type
       1 : (M : TMatrix4f);
       1 : (M : TMatrix4f);
   end;
   end;
 
 
-  PGLMatrix = ^TMatrix4f;
+  PGLMatrix = ^TGLMatrix;
   TGLMatrix = TMatrix4f;
   TGLMatrix = TMatrix4f;
 
 
 //-----------------------------------------------  
 //-----------------------------------------------  

+ 2 - 2
Source/GLS.VectorTypesExt.pas

@@ -1024,7 +1024,7 @@ const
   DefaultRowCount = 3;
   DefaultRowCount = 3;
   DefaultColCount = 3;
   DefaultColCount = 3;
   VectorTypeName = 'TGLVector';
   VectorTypeName = 'TGLVector';
-  MatrixTypeName = 'TMatrix';
+  MatrixTypeName = 'TGLMatrix';
 var
 var
   RTTIContext: TRttiContext;
   RTTIContext: TRttiContext;
   Field : TRttiField;
   Field : TRttiField;
@@ -1382,4 +1382,4 @@ begin
 end;
 end;
 
 
 
 
-end.
+end.


+ 2 - 2
Source/GLSL.ProjectedTextures.pas

@@ -56,7 +56,7 @@ type
     FUseQuadraticAttenuation: boolean;
     FUseQuadraticAttenuation: boolean;
   protected
   protected
     ProjectedTexturesObject: TGLSLProjectedTextures;
     ProjectedTexturesObject: TGLSLProjectedTextures;
-    TexMatrix: TMatrix;
+    TexMatrix: TGLMatrix;
     procedure SetupTexMatrix;
     procedure SetupTexMatrix;
     procedure SetStyle(val: TGLSLProjectedTexturesStyle);
     procedure SetStyle(val: TGLSLProjectedTexturesStyle);
     procedure SetUseAttenuation(val: boolean);
     procedure SetUseAttenuation(val: boolean);
@@ -191,7 +191,7 @@ end;
 
 
 procedure TGLSLTextureEmitter.SetupTexMatrix;
 procedure TGLSLTextureEmitter.SetupTexMatrix;
 const
 const
-  cBaseMat: TMatrix = (V:((X:0.5; Y:0;   Z:0; W:0),
+  cBaseMat: TGLMatrix = (V:((X:0.5; Y:0;   Z:0; W:0),
                           (X:0;   Y:0.5; Z:0; W:0),
                           (X:0;   Y:0.5; Z:0; W:0),
                           (X:0;   Y:0;   Z:1; W:0),
                           (X:0;   Y:0;   Z:1; W:0),
                           (X:0.5; Y:0.5; Z:0; W:1)));
                           (X:0.5; Y:0.5; Z:0; W:1)));

+ 4 - 4
Source/GLSL.TextureShaders.pas

@@ -45,7 +45,7 @@ type
 
 
   TGLTextureSharingShaderMaterial = class(TGLInterfacedCollectionItem, IGLMaterialLibrarySupported)
   TGLTextureSharingShaderMaterial = class(TGLInterfacedCollectionItem, IGLMaterialLibrarySupported)
   private
   private
-    FTextureMatrix: TMatrix;
+    FTextureMatrix: TGLMatrix;
     FNeedToUpdateTextureMatrix: Boolean;
     FNeedToUpdateTextureMatrix: Boolean;
     FTextureMatrixIsUnitary: Boolean;
     FTextureMatrixIsUnitary: Boolean;
     FLibMaterial: TGLLibMaterial;
     FLibMaterial: TGLLibMaterial;
@@ -70,7 +70,7 @@ type
     procedure SetLibMaterial(const Value: TGLLibMaterial);
     procedure SetLibMaterial(const Value: TGLLibMaterial);
     procedure SetTexOffset(const Value: TGLCoordinates2);
     procedure SetTexOffset(const Value: TGLCoordinates2);
     procedure SetTexScale(const Value: TGLCoordinates2);
     procedure SetTexScale(const Value: TGLCoordinates2);
-    function GetTextureMatrix: TMatrix;
+    function GetTextureMatrix: TGLMatrix;
     function GetTextureMatrixIsUnitary: Boolean;
     function GetTextureMatrixIsUnitary: Boolean;
   protected
   protected
     procedure coordNotifychange(Sender: TObject);
     procedure coordNotifychange(Sender: TObject);
@@ -85,7 +85,7 @@ type
     constructor Create(Collection: TCollection); override;
     constructor Create(Collection: TCollection); override;
     destructor Destroy; override;
     destructor Destroy; override;
     property LibMaterial: TGLLibMaterial read FLibMaterial write SetLibMaterial;
     property LibMaterial: TGLLibMaterial read FLibMaterial write SetLibMaterial;
-    property TextureMatrix: TMatrix read GetTextureMatrix;
+    property TextureMatrix: TGLMatrix read GetTextureMatrix;
     property TextureMatrixIsUnitary: Boolean read GetTextureMatrixIsUnitary;
     property TextureMatrixIsUnitary: Boolean read GetTextureMatrixIsUnitary;
   published
   published
     property TexOffset: TGLCoordinates2 read FTexOffset write SetTexOffset;
     property TexOffset: TGLCoordinates2 read FTexOffset write SetTexOffset;
@@ -376,7 +376,7 @@ begin
   Result := FMaterialLibrary;
   Result := FMaterialLibrary;
 end;
 end;
 
 
-function TGLTextureSharingShaderMaterial.GetTextureMatrix: TMatrix;
+function TGLTextureSharingShaderMaterial.GetTextureMatrix: TGLMatrix;
 begin
 begin
   if FNeedToUpdateTextureMatrix then
   if FNeedToUpdateTextureMatrix then
   begin
   begin

+ 16 - 16
Source/Physics.NGDManager.pas

@@ -23,7 +23,7 @@ uses
   /// Import.Newton,    // new version
   /// Import.Newton,    // new version
 
 
   GLS.VectorTypes,
   GLS.VectorTypes,
-  GLS.VectorGeometry, // PGLVector TGLVector TMatrix PMatrix NullHmgVector...
+  GLS.VectorGeometry, // PGLVector TGLVector TGLMatrix PGLMatrix NullHmgVector...
   GLS.VectorLists, // TAffineVectorList for Tree
   GLS.VectorLists, // TAffineVectorList for Tree
   GLS.XCollection, // TXCollection file function
   GLS.XCollection, // TXCollection file function
   GLS.GeometryBB, // For show debug
   GLS.GeometryBB, // For show debug
@@ -238,7 +238,7 @@ type
     FInitialized: Boolean;
     FInitialized: Boolean;
     FNewtonBody: PNewtonBody;
     FNewtonBody: PNewtonBody;
     FCollision: PNewtonCollision;
     FCollision: PNewtonCollision;
-    FNewtonBodyMatrix: TMatrix; // Position and Orientation
+    FNewtonBodyMatrix: TGLMatrix; // Position and Orientation
     FContinuousCollisionMode: Boolean; // Default=False
     FContinuousCollisionMode: Boolean; // Default=False
     FNGDCollisions: TGLNGDCollisions;
     FNGDCollisions: TGLNGDCollisions;
     FCollisionIteratorEvent: TCollisionIteratorEvent;
     FCollisionIteratorEvent: TCollisionIteratorEvent;
@@ -256,9 +256,9 @@ type
     procedure ReadFromFiler(reader: TReader); override;
     procedure ReadFromFiler(reader: TReader); override;
     procedure Loaded; override;
     procedure Loaded; override;
     procedure SetManager(Value: TGLNGDManager);
     procedure SetManager(Value: TGLNGDManager);
-    procedure SetNewtonBodyMatrix(const Value: TMatrix);
+    procedure SetNewtonBodyMatrix(const Value: TGLMatrix);
     procedure SetContinuousCollisionMode(const Value: Boolean);
     procedure SetContinuousCollisionMode(const Value: Boolean);
-    function GetNewtonBodyMatrix: TMatrix;
+    function GetNewtonBodyMatrix: TGLMatrix;
     function GetNewtonBodyAABB: TAABB;
     function GetNewtonBodyAABB: TAABB;
     procedure UpdCollision; virtual;
     procedure UpdCollision; virtual;
     procedure Render; virtual;
     procedure Render; virtual;
@@ -292,7 +292,7 @@ type
     procedure Reinitialize;
     procedure Reinitialize;
     property Initialized: Boolean read FInitialized;
     property Initialized: Boolean read FInitialized;
     class function UniqueItem: Boolean; override;
     class function UniqueItem: Boolean; override;
-    property NewtonBodyMatrix: TMatrix read GetNewtonBodyMatrix
+    property NewtonBodyMatrix: TGLMatrix read GetNewtonBodyMatrix
       write SetNewtonBodyMatrix;
       write SetNewtonBodyMatrix;
     property NewtonBodyAABB: TAABB read GetNewtonBodyAABB;
     property NewtonBodyAABB: TAABB read GetNewtonBodyAABB;
     procedure Serialize(filename: string);
     procedure Serialize(filename: string);
@@ -1090,7 +1090,7 @@ procedure TGLNGDManager.RebuildAllJoint(Sender: TObject);
 
 
   procedure BuildCustomBallAndSocket(Joint: TGLNGDJoint);
   procedure BuildCustomBallAndSocket(Joint: TGLNGDJoint);
   var
   var
-    pinAndPivot: TMatrix;
+    pinAndPivot: TGLMatrix;
   begin
   begin
     with Joint do
     with Joint do
       if Assigned(FParentObject) and Assigned(FChildObject) then
       if Assigned(FParentObject) and Assigned(FChildObject) then
@@ -1115,7 +1115,7 @@ procedure TGLNGDManager.RebuildAllJoint(Sender: TObject);
 
 
   procedure BuildCustomHinge(Joint: TGLNGDJoint);
   procedure BuildCustomHinge(Joint: TGLNGDJoint);
   var
   var
-    pinAndPivot: TMatrix;
+    pinAndPivot: TGLMatrix;
     bso: TGLBaseSceneObject;
     bso: TGLBaseSceneObject;
   begin
   begin
     (* Newton wait from FPinAndPivotMatrix a structure like that:
     (* Newton wait from FPinAndPivotMatrix a structure like that:
@@ -1153,7 +1153,7 @@ procedure TGLNGDManager.RebuildAllJoint(Sender: TObject);
 
 
   procedure BuildCustomSlider(Joint: TGLNGDJoint);
   procedure BuildCustomSlider(Joint: TGLNGDJoint);
   var
   var
-    pinAndPivot: TMatrix;
+    pinAndPivot: TGLMatrix;
     bso: TGLBaseSceneObject;
     bso: TGLBaseSceneObject;
 
 
   begin
   begin
@@ -1430,7 +1430,7 @@ end;
 function TGLNGDBehaviour.GetBSphereCollision: PNewtonCollision;
 function TGLNGDBehaviour.GetBSphereCollision: PNewtonCollision;
 var
 var
   boundingSphere: TBSphere;
   boundingSphere: TBSphere;
-  collisionOffsetMatrix: TMatrix;
+  collisionOffsetMatrix: TGLMatrix;
 begin
 begin
   AABBToBSphere(FOwnerBaseSceneObject.AxisAlignedBoundingBoxEx, boundingSphere);
   AABBToBSphere(FOwnerBaseSceneObject.AxisAlignedBoundingBoxEx, boundingSphere);
 
 
@@ -1526,7 +1526,7 @@ begin
     Result := GetNullCollision;
     Result := GetNullCollision;
 end;
 end;
 
 
-function TGLNGDBehaviour.GetNewtonBodyMatrix: TMatrix;
+function TGLNGDBehaviour.GetNewtonBodyMatrix: TGLMatrix;
 begin
 begin
   if Assigned(FManager) then
   if Assigned(FManager) then
     NewtonBodyGetmatrix(FNewtonBody, @FNewtonBodyMatrix);
     NewtonBodyGetmatrix(FNewtonBody, @FNewtonBodyMatrix);
@@ -1561,7 +1561,7 @@ end;
 
 
 function TGLNGDBehaviour.GetPrimitiveCollision: PNewtonCollision;
 function TGLNGDBehaviour.GetPrimitiveCollision: PNewtonCollision;
 var
 var
-  collisionOffsetMatrix: TMatrix; // For cone capsule and cylinder
+  collisionOffsetMatrix: TGLMatrix; // For cone capsule and cylinder
 begin
 begin
   collisionOffsetMatrix := IdentityHmgMatrix;
   collisionOffsetMatrix := IdentityHmgMatrix;
 
 
@@ -1754,7 +1754,7 @@ end;
 
 
 procedure TGLNGDBehaviour.Render;
 procedure TGLNGDBehaviour.Render;
 var
 var
-  M: TMatrix;
+  M: TGLMatrix;
 begin
 begin
   // Rebuild collision in design time
   // Rebuild collision in design time
   if (csDesigning in FOwnerBaseSceneObject.ComponentState) then
   if (csDesigning in FOwnerBaseSceneObject.ComponentState) then
@@ -1849,7 +1849,7 @@ begin
   end;
   end;
 end;
 end;
 
 
-procedure TGLNGDBehaviour.SetNewtonBodyMatrix(const Value: TMatrix);
+procedure TGLNGDBehaviour.SetNewtonBodyMatrix(const Value: TGLMatrix);
 begin
 begin
   FNewtonBodyMatrix := Value;
   FNewtonBodyMatrix := Value;
   if Assigned(FManager) then
   if Assigned(FManager) then
@@ -2114,7 +2114,7 @@ procedure TGLNGDDynamic.Render;
 
 
   function GetAbsCom(): TGLVector;
   function GetAbsCom(): TGLVector;
   var
   var
-    M: TMatrix;
+    M: TGLMatrix;
   begin
   begin
     NewtonBodyGetCentreOfMass(FNewtonBody, @Result);
     NewtonBodyGetCentreOfMass(FNewtonBody, @Result);
     M := IdentityHmgMatrix;
     M := IdentityHmgMatrix;
@@ -2413,7 +2413,7 @@ begin
     else
     else
       // Make the Position and orientation of the glscene-Object relative to the
       // Make the Position and orientation of the glscene-Object relative to the
       // NewtonBody position and orientation.
       // NewtonBody position and orientation.
-      FOwnerBaseSceneObject.AbsoluteMatrix := pMatrix(cmatrix)^;
+      FOwnerBaseSceneObject.AbsoluteMatrix := PGLMatrix(cmatrix)^;
 end;
 end;
 
 
 // ------------------------
 // ------------------------
@@ -2723,7 +2723,7 @@ procedure TGLNGDJoint.Render;
 
 
   procedure DrawKinematic;
   procedure DrawKinematic;
   var
   var
-    pickedMatrix: TMatrix;
+    pickedMatrix: TGLMatrix;
     size: Single;
     size: Single;
   begin
   begin
     size := FManager.DebugOption.DotAxisSize;
     size := FManager.DebugOption.DotAxisSize;

+ 5 - 5
Source/Physics.NGDRagdoll.pas

@@ -30,9 +30,9 @@ type
     Actor: TGLActor;
     Actor: TGLActor;
     Bodies: TList;
     Bodies: TList;
     Joints: array of PNewtonJoint;
     Joints: array of PNewtonJoint;
-    Norm_matrices: array of TMatrix;
+    Norm_matrices: array of TGLMatrix;
     Envelopes: array of record kind: byte;
     Envelopes: array of record kind: byte;
-    Mat: TMatrix;
+    Mat: TGLMatrix;
     Pt: TVector3f;
     Pt: TVector3f;
     W, D, H, Mass: single;
     W, D, H, Mass: single;
   end;
   end;
@@ -122,8 +122,8 @@ var
   d: single;
   d: single;
   Collision: PNewtonCollision;
   Collision: PNewtonCollision;
   CollisionBox, CollisionCylinder, CollisionSphere: PNewtonCollision;
   CollisionBox, CollisionCylinder, CollisionSphere: PNewtonCollision;
-  Matrix: Tmatrix;
-  CollisionOffsetMatrix: TMatrix; // For cone capsule and cylinder
+  Matrix: TGLMatrix;
+  CollisionOffsetMatrix: TGLMatrix; // For cone capsule and cylinder
 begin
 begin
   collisionOffsetMatrix := IdentityHmgMatrix;
   collisionOffsetMatrix := IdentityHmgMatrix;
   d := 0;
   d := 0;
@@ -256,7 +256,7 @@ end;
 procedure TNewtonRagdoll.SetEnabled;
 procedure TNewtonRagdoll.SetEnabled;
 var
 var
   i: integer;
   i: integer;
-  a: TMatrix;
+  a: TGLMatrix;
   v: TVector3f;
   v: TVector3f;
 begin
 begin
   if FEnabled = value then
   if FEnabled = value then

+ 30 - 30
Source/Physics.ODEManager.pas

@@ -196,7 +196,7 @@ type
     procedure Loaded; override;
     procedure Loaded; override;
     procedure SetManager(Value: TGLODEManager);
     procedure SetManager(Value: TGLODEManager);
     procedure SetSurface(Value: TGLODECollisionSurface);
     procedure SetSurface(Value: TGLODECollisionSurface);
-    function GetAbsoluteMatrix: TMatrix;
+    function GetAbsoluteMatrix: TGLMatrix;
   public
   public
     constructor Create(AOwner: TXCollection); override;
     constructor Create(AOwner: TXCollection); override;
     destructor Destroy; override;
     destructor Destroy; override;
@@ -204,7 +204,7 @@ type
     procedure Render(var rci: TGLRenderContextInfo); virtual;
     procedure Render(var rci: TGLRenderContextInfo); virtual;
     procedure Reinitialize;
     procedure Reinitialize;
     property Initialized: Boolean read FInitialized;
     property Initialized: Boolean read FInitialized;
-    property AbsoluteMatrix: TMatrix read GetAbsoluteMatrix;
+    property AbsoluteMatrix: TGLMatrix read GetAbsoluteMatrix;
   published
   published
     property Manager: TGLODEManager read FManager write SetManager;
     property Manager: TGLODEManager read FManager write SetManager;
     property Surface: TGLODECollisionSurface read FSurface write SetSurface;
     property Surface: TGLODECollisionSurface read FSurface write SetSurface;
@@ -225,7 +225,7 @@ type
     procedure ReadFromFiler(reader: TReader); override;
     procedure ReadFromFiler(reader: TReader); override;
     procedure SetMass(const Value: TdMass);
     procedure SetMass(const Value: TdMass);
     function GetMass: TdMass;
     function GetMass: TdMass;
-    procedure AlignBodyToMatrix(Mat: TMatrix);
+    procedure AlignBodyToMatrix(Mat: TGLMatrix);
     procedure SetEnabled(const Value: Boolean);
     procedure SetEnabled(const Value: Boolean);
     function GetEnabled: Boolean;
     function GetEnabled: Boolean;
     procedure RegisterJoint(Joint: TGLODEJointBase);
     procedure RegisterJoint(Joint: TGLODEJointBase);
@@ -297,7 +297,7 @@ type
     FPosition, 
     FPosition, 
 	FDirection, 
 	FDirection, 
 	FUp: TGLCoordinates;
 	FUp: TGLCoordinates;
-    FLocalMatrix: TMatrix;
+    FLocalMatrix: TGLMatrix;
     FRealignODE,
     FRealignODE,
 	FInitialized,
 	FInitialized,
 	FDynamic,
 	FDynamic,
@@ -312,13 +312,13 @@ type
     procedure WriteToFiler(writer: TWriter); override;
     procedure WriteToFiler(writer: TWriter); override;
     procedure ReadFromFiler(reader: TReader); override;
     procedure ReadFromFiler(reader: TReader); override;
     function IsODEInitialized: Boolean;
     function IsODEInitialized: Boolean;
-    procedure AlignGeomElementToMatrix(Mat: TMatrix); virtual;
+    procedure AlignGeomElementToMatrix(Mat: TGLMatrix); virtual;
     procedure SetGeomElement(aGeom: PdxGeom);
     procedure SetGeomElement(aGeom: PdxGeom);
     procedure RebuildMatrix;
     procedure RebuildMatrix;
     procedure RebuildVectors;
     procedure RebuildVectors;
     procedure SetDensity(const Value: TdReal);
     procedure SetDensity(const Value: TdReal);
-    procedure SetMatrix(const Value: TMatrix);
-    function GetMatrix: TMatrix;
+    procedure SetMatrix(const Value: TGLMatrix);
+    function GetMatrix: TGLMatrix;
     procedure SetPosition(const Value: TGLCoordinates);
     procedure SetPosition(const Value: TGLCoordinates);
     procedure SetDirection(const Value: TGLCoordinates);
     procedure SetDirection(const Value: TGLCoordinates);
     procedure SetUp(const Value: TGLCoordinates);
     procedure SetUp(const Value: TGLCoordinates);
@@ -326,9 +326,9 @@ type
     constructor Create(AOwner: TXCollection); override;
     constructor Create(AOwner: TXCollection); override;
     destructor Destroy; override;
     destructor Destroy; override;
     procedure Render(var rci: TGLRenderContextInfo); virtual;
     procedure Render(var rci: TGLRenderContextInfo); virtual;
-    function AbsoluteMatrix: TMatrix;
+    function AbsoluteMatrix: TGLMatrix;
     function AbsolutePosition: TAffineVector;
     function AbsolutePosition: TAffineVector;
-    property Matrix: TMatrix read GetMatrix write SetMatrix;
+    property Matrix: TGLMatrix read GetMatrix write SetMatrix;
     property GeomTransform: PdxGeom read FGeomTransform;
     property GeomTransform: PdxGeom read FGeomTransform;
     property Geom: PdxGeom read FGeomElement;
     property Geom: PdxGeom read FGeomElement;
     property Initialized: Boolean read FInitialized;
     property Initialized: Boolean read FInitialized;
@@ -474,7 +474,7 @@ type
     procedure Initialize; override;
     procedure Initialize; override;
     procedure WriteToFiler(writer: TWriter); override;
     procedure WriteToFiler(writer: TWriter); override;
     procedure ReadFromFiler(reader: TReader); override;
     procedure ReadFromFiler(reader: TReader); override;
-    procedure AlignGeomElementToMatrix(Mat: TMatrix); override;
+    procedure AlignGeomElementToMatrix(Mat: TGLMatrix); override;
   public
   public
     class function FriendlyName: String; override;
     class function FriendlyName: String; override;
     class function FriendlyDescription: String; override;
     class function FriendlyDescription: String; override;
@@ -811,7 +811,7 @@ type
     FGeom: PdxGeom;
     FGeom: PdxGeom;
     FContactList,
     FContactList,
       FContactCache: TList;
       FContactCache: TList;
-    FTransform: TMatrix;
+    FTransform: TGLMatrix;
     FContactResolution: Single;
     FContactResolution: Single;
     FRenderContacts: Boolean;
     FRenderContacts: Boolean;
     FContactRenderPoints: TAffineVectorList;
     FContactRenderPoints: TAffineVectorList;
@@ -834,7 +834,7 @@ type
     function ApplyContacts(o1, o2: PdxGeom; flags: Integer;
     function ApplyContacts(o1, o2: PdxGeom; flags: Integer;
       contact: PdContactGeom; skip: Integer): Integer;
       contact: PdContactGeom; skip: Integer): Integer;
     // Set the transform used that transforms contact points generated with AddContact
     // Set the transform used that transforms contact points generated with AddContact
-    procedure SetTransform(ATransform: TMatrix);
+    procedure SetTransform(ATransform: TGLMatrix);
     procedure SetContactResolution(const Value: Single);
     procedure SetContactResolution(const Value: Single);
     procedure SetRenderContacts(const Value: Boolean);
     procedure SetRenderContacts(const Value: Boolean);
     procedure SetPointSize(const Value: Single);
     procedure SetPointSize(const Value: Single);
@@ -1053,7 +1053,7 @@ var
   i, j, res: Integer;
   i, j, res: Integer;
   pos: PdVector3;
   pos: PdVector3;
   R: PdMatrix3;
   R: PdMatrix3;
-  rmat, mat: TMatrix;
+  rmat, mat: TGLMatrix;
   rad, dx, dy, dz: TdReal;
   rad, dx, dy, dz: TdReal;
 begin
 begin
   Result := 0;
   Result := 0;
@@ -1099,7 +1099,7 @@ var
   s: TdVector3;
   s: TdVector3;
   pos: PdVector3;
   pos: PdVector3;
   R: PdMatrix3;
   R: PdMatrix3;
-  mat: TMatrix;
+  mat: TGLMatrix;
 begin
 begin
   Result := 0;
   Result := 0;
   Collider := GetColliderFromGeom(o1);
   Collider := GetColliderFromGeom(o1);
@@ -1179,7 +1179,7 @@ var
   i, j, res: Integer;
   i, j, res: Integer;
   pos: PdVector3;
   pos: PdVector3;
   R: PdMatrix3;
   R: PdMatrix3;
-  mat, rmat: TMatrix;
+  mat, rmat: TGLMatrix;
   rad, len, dx, dy, dz: TdReal;
   rad, len, dx, dy, dz: TdReal;
 begin
 begin
   Result := 0;
   Result := 0;
@@ -1226,7 +1226,7 @@ var
   i, j, res: Integer;
   i, j, res: Integer;
   pos: PdVector3;
   pos: PdVector3;
   R: PdMatrix3;
   R: PdMatrix3;
-  mat: TMatrix;
+  mat: TGLMatrix;
   rad, len, dx, dy: TdReal;
   rad, len, dx, dy: TdReal;
 begin
 begin
   Result := 0;
   Result := 0;
@@ -2026,7 +2026,7 @@ begin
   FSurface.Assign(Value);
   FSurface.Assign(Value);
 end;
 end;
 
 
-function TGLODEBehaviour.GetAbsoluteMatrix: TMatrix;
+function TGLODEBehaviour.GetAbsoluteMatrix: TGLMatrix;
 begin
 begin
   Result := IdentityHMGMatrix;
   Result := IdentityHMGMatrix;
   if Assigned(Owner.Owner) then
   if Assigned(Owner.Owner) then
@@ -2056,7 +2056,7 @@ end;
 
 
 procedure TGLODEDynamic.Render(var rci: TGLRenderContextInfo);
 procedure TGLODEDynamic.Render(var rci: TGLRenderContextInfo);
 var
 var
-  Mat: TMatrix;
+  Mat: TGLMatrix;
 begin
 begin
   if Assigned(Owner.Owner) then
   if Assigned(Owner.Owner) then
   begin
   begin
@@ -2179,7 +2179,7 @@ procedure TGLODEDynamic.AlignObject;
 var
 var
   Pos: PdVector3;
   Pos: PdVector3;
   R: PdMatrix3;
   R: PdMatrix3;
-  m: TMatrix;
+  m: TGLMatrix;
 begin
 begin
   Pos := dBodyGetPosition(Body);
   Pos := dBodyGetPosition(Body);
   R := dBodyGetRotation(Body);
   R := dBodyGetRotation(Body);
@@ -2189,7 +2189,7 @@ begin
   OwnerBaseSceneObject.SetMatrix(m);
   OwnerBaseSceneObject.SetMatrix(m);
 end;
 end;
 
 
-procedure TGLODEDynamic.AlignBodyToMatrix(Mat: TMatrix);
+procedure TGLODEDynamic.AlignBodyToMatrix(Mat: TGLMatrix);
 var
 var
   R: TdMatrix3;
   R: TdMatrix3;
 begin
 begin
@@ -2340,7 +2340,7 @@ end;
 
 
 procedure TGLODEStatic.Render(var rci: TGLRenderContextInfo);
 procedure TGLODEStatic.Render(var rci: TGLRenderContextInfo);
 var
 var
-  Mat: TMatrix;
+  Mat: TGLMatrix;
 begin
 begin
   if Assigned(Owner.Owner) then
   if Assigned(Owner.Owner) then
   begin
   begin
@@ -2602,9 +2602,9 @@ begin
   NotifyChange(Self);
   NotifyChange(Self);
 end;
 end;
 
 
-function TGLODEElementBase.AbsoluteMatrix: TMatrix;
+function TGLODEElementBase.AbsoluteMatrix: TGLMatrix;
 var
 var
-  Mat: TMatrix;
+  Mat: TGLMatrix;
 begin
 begin
   Mat := IdentityHMGMatrix;
   Mat := IdentityHMGMatrix;
   if Owner.Owner is TGLODEBehaviour then
   if Owner.Owner is TGLODEBehaviour then
@@ -2617,7 +2617,7 @@ begin
   Result := AffineVectorMake(AbsoluteMatrix.W);
   Result := AffineVectorMake(AbsoluteMatrix.W);
 end;
 end;
 
 
-procedure TGLODEElementBase.AlignGeomElementToMatrix(Mat: TMatrix);
+procedure TGLODEElementBase.AlignGeomElementToMatrix(Mat: TGLMatrix);
 var
 var
   R: TdMatrix3;
   R: TdMatrix3;
 begin
 begin
@@ -2730,7 +2730,7 @@ begin
   ODERebuild;
   ODERebuild;
 end;
 end;
 
 
-function TGLODEElementBase.GetMatrix: TMatrix;
+function TGLODEElementBase.GetMatrix: TGLMatrix;
 begin
 begin
   Result := FLocalMatrix;
   Result := FLocalMatrix;
 end;
 end;
@@ -2755,7 +2755,7 @@ begin
   FDensity := Value;
   FDensity := Value;
 end;
 end;
 
 
-procedure TGLODEElementBase.SetMatrix(const Value: TMatrix);
+procedure TGLODEElementBase.SetMatrix(const Value: TGLMatrix);
 begin
 begin
   FLocalMatrix := Value;
   FLocalMatrix := Value;
   RebuildVectors;
   RebuildVectors;
@@ -3602,7 +3602,7 @@ begin
       Result := True;
       Result := True;
 end;
 end;
 
 
-procedure TGLODEElementPlane.AlignGeomElementToMatrix(Mat: TMatrix);
+procedure TGLODEElementPlane.AlignGeomElementToMatrix(Mat: TGLMatrix);
 var
 var
   d: Single;
   d: Single;
 begin
 begin
@@ -5189,7 +5189,7 @@ begin
   end;
   end;
 end;
 end;
 
 
-procedure TGLODECustomCollider.SetTransform(ATransform: TMatrix);
+procedure TGLODECustomCollider.SetTransform(ATransform: TGLMatrix);
 begin
 begin
   FTransform := ATransform;
   FTransform := ATransform;
 end;
 end;
@@ -5317,7 +5317,7 @@ function TGLODEHeightField.Collide(aPos: TAffineVector; var Depth: Single;
 
 
   function AbsoluteToLocal(vec: TGLVector): TGLVector;
   function AbsoluteToLocal(vec: TGLVector): TGLVector;
   var
   var
-    mat: TMatrix;
+    mat: TGLMatrix;
   begin
   begin
     if Owner.Owner is TGLHeightField then
     if Owner.Owner is TGLHeightField then
       Result := TGLHeightField(Owner.Owner).AbsoluteToLocal(vec)
       Result := TGLHeightField(Owner.Owner).AbsoluteToLocal(vec)
@@ -5334,7 +5334,7 @@ function TGLODEHeightField.Collide(aPos: TAffineVector; var Depth: Single;
 
 
   function LocalToAbsolute(vec: TGLVector): TGLVector;
   function LocalToAbsolute(vec: TGLVector): TGLVector;
   var
   var
-    mat: TMatrix;
+    mat: TGLMatrix;
   begin
   begin
     if Owner.Owner is TGLHeightField then
     if Owner.Owner is TGLHeightField then
       Result := TGLHeightField(Owner.Owner).LocalToAbsolute(vec)
       Result := TGLHeightField(Owner.Owner).LocalToAbsolute(vec)

+ 95 - 86
Source/Physics.ODERagdoll.pas

@@ -27,9 +27,9 @@ type
   TGLODERagdollBone = class;
   TGLODERagdollBone = class;
 
 
   TGLODERagdollCube = class(TGLCube)
   TGLODERagdollCube = class(TGLCube)
-   public
-    Bone:TGLODERagdollBone; // Useful in Oncollision Event
-    Ragdoll:TGLODERagdoll;  // Useful in Oncollision Event
+  public
+    Bone: TGLODERagdollBone; // Useful in Oncollision Event
+    Ragdoll: TGLODERagdoll; // Useful in Oncollision Event
   end;
   end;
 
 
   TGLODERagdollWorld = class
   TGLODERagdollWorld = class
@@ -38,11 +38,12 @@ type
     FWorld: PdxWorld;
     FWorld: PdxWorld;
     FContactGroup: TdJointGroupID;
     FContactGroup: TdJointGroupID;
     FRagdoll: TGLODERagdoll;
     FRagdoll: TGLODERagdoll;
-    isWorldCreated : Boolean; // NEW1
+    isWorldCreated: Boolean; // NEW1
   public
   public
     constructor Create;
     constructor Create;
     // Create the world from any existing ODE world
     // Create the world from any existing ODE world
-    constructor CreateFrom(World: PdxWorld; Space: PdxSpace; ContactGroup: TdJointGroupID);
+    constructor CreateFrom(World: PdxWorld; Space: PdxSpace;
+      ContactGroup: TdJointGroupID);
     destructor Destroy; override;
     destructor Destroy; override;
     procedure WorldUpdate;
     procedure WorldUpdate;
     property World: PdxWorld read FWorld;
     property World: PdxWorld read FWorld;
@@ -54,16 +55,15 @@ type
   TGLODERagdollDummyJoint = class(TGLRagdolJoint)
   TGLODERagdollDummyJoint = class(TGLRagdolJoint)
   end;
   end;
 
 
-
   TGLODERagdollHingeJoint = class(TGLRagdolJoint)
   TGLODERagdollHingeJoint = class(TGLRagdolJoint)
   private
   private
     FParamHiStop: Single;
     FParamHiStop: Single;
     FParamLoStop: Single;
     FParamLoStop: Single;
     FAxis: TAffineVector;
     FAxis: TAffineVector;
   public
   public
-    constructor Create(Axis: TAffineVector;
-      ParamLoStop: Single; ParamHiStop: Single);
-    property Axis : TAffineVector read FAxis;
+    constructor Create(Axis: TAffineVector; ParamLoStop: Single;
+      ParamHiStop: Single);
+    property Axis: TAffineVector read FAxis;
     property ParamLoStop: Single read FParamLoStop write FParamLoStop;
     property ParamLoStop: Single read FParamLoStop write FParamLoStop;
     property ParamHiStop: Single read FParamHiStop write FParamHiStop;
     property ParamHiStop: Single read FParamHiStop write FParamHiStop;
   end;
   end;
@@ -74,28 +74,29 @@ type
     FParamLoStop2: Single;
     FParamLoStop2: Single;
     FAxis2: TAffineVector;
     FAxis2: TAffineVector;
   public
   public
-    constructor Create(Axis: TAffineVector; ParamLoStop: Single; ParamHiStop: Single;
-                       Axis2: TAffineVector; ParamLoStop2: Single; ParamHiStop2: Single);
-    property Axis2 : TAffineVector read FAxis2;
+    constructor Create(Axis: TAffineVector; ParamLoStop: Single;
+      ParamHiStop: Single; Axis2: TAffineVector; ParamLoStop2: Single;
+      ParamHiStop2: Single);
+    property Axis2: TAffineVector read FAxis2;
     property ParamLoStop2: Single read FParamLoStop2 write FParamLoStop2;
     property ParamLoStop2: Single read FParamLoStop2 write FParamLoStop2;
     property ParamHiStop2: Single read FParamHiStop2 write FParamHiStop2;
     property ParamHiStop2: Single read FParamHiStop2 write FParamHiStop2;
   end;
   end;
 
 
-	TGLODERagdollBone = class (TGLRagdolBone)
+  TGLODERagdollBone = class(TGLRagdolBone)
   private
   private
     FOwner: TGLODERagdollBone;
     FOwner: TGLODERagdollBone;
     FRagdoll: TGLODERagdoll;
     FRagdoll: TGLODERagdoll;
     FBody: PdxBody;
     FBody: PdxBody;
     FGeom: PdxGeom;
     FGeom: PdxGeom;
     FJointId: TdJointID;
     FJointId: TdJointID;
-    procedure AlignBodyToMatrix(Mat: TMatrix);
+    procedure AlignBodyToMatrix(Mat: TGLMatrix);
   protected
   protected
     procedure Start; override;
     procedure Start; override;
     procedure Align; override;
     procedure Align; override;
     procedure Update; override;
     procedure Update; override;
     procedure Stop; override;
     procedure Stop; override;
   public
   public
-    constructor CreateOwned(aOwner : TGLODERagdollBone);
+    constructor CreateOwned(aOwner: TGLODERagdollBone);
     constructor Create(Ragdoll: TGLODERagdoll);
     constructor Create(Ragdoll: TGLODERagdoll);
     property Body: PdxBody read FBody;
     property Body: PdxBody read FBody;
     property Geom: PdxGeom read FGeom;
     property Geom: PdxGeom read FGeom;
@@ -106,34 +107,37 @@ type
     FODEWorld: TGLODERagdollWorld;
     FODEWorld: TGLODERagdollWorld;
     FGLSceneRoot: TGLBaseSceneObject;
     FGLSceneRoot: TGLBaseSceneObject;
     FShowBoundingBoxes: Boolean;
     FShowBoundingBoxes: Boolean;
+    FEnabled: Boolean;
   public
   public
-    constructor Create(AOwner : TGLBaseMesh);
+    constructor Create(aOwner: TGLBaseMesh);
     property ODEWorld: TGLODERagdollWorld read FODEWorld write FODEWorld;
     property ODEWorld: TGLODERagdollWorld read FODEWorld write FODEWorld;
-    property GLSceneRoot: TGLBaseSceneObject read FGLSceneRoot write FGLSceneRoot;
-    property ShowBoundingBoxes: Boolean read FShowBoundingBoxes write FShowBoundingBoxes;
+    property GLSceneRoot: TGLBaseSceneObject read FGLSceneRoot
+      write FGLSceneRoot;
+    property ShowBoundingBoxes: Boolean read FShowBoundingBoxes
+      write FShowBoundingBoxes;
+    property Enabled: Boolean read FEnabled write FEnabled;
   end;
   end;
 
 
-
 var
 var
-  vODERagdoll_cDensity : Single;
-  vODERagdoll_cMass : Single;
+  vODERagdoll_cDensity: Single;
+  vODERagdoll_cMass: Single;
 
 
-//----------------------------------------
+// ----------------------------------------
 implementation
 implementation
-//----------------------------------------
 
 
-//
+//-------------------------------------
 // TGLODERagdollWorld
 // TGLODERagdollWorld
-//
+// ----------------------------------------
+
 constructor TGLODERagdollWorld.Create;
 constructor TGLODERagdollWorld.Create;
 begin
 begin
-  //Create default physics
+  // Create default physics
   FWorld := dWorldCreate();
   FWorld := dWorldCreate();
   dWorldSetQuickStepNumIterations(FWorld, 8);
   dWorldSetQuickStepNumIterations(FWorld, 8);
-  FSpace := dHashSpaceCreate (nil);
+  FSpace := dHashSpaceCreate(nil);
   FContactGroup := dJointGroupCreate(0);
   FContactGroup := dJointGroupCreate(0);
   dWorldSetGravity(FWorld, 0, 0, -0.81);
   dWorldSetGravity(FWorld, 0, 0, -0.81);
-  dWorldSetCFM(FWorld, 1e-5);
+  dWorldSetCFM(FWorld, 1E-5);
   isWorldCreated := True; // NEW1
   isWorldCreated := True; // NEW1
 end;
 end;
 
 
@@ -176,7 +180,7 @@ begin
     for i := 0 to n - 1 do
     for i := 0 to n - 1 do
     begin
     begin
       contact[i].surface.mode := ord(dContactBounce) or ord(dContactSoftCFM) or
       contact[i].surface.mode := ord(dContactBounce) or ord(dContactSoftCFM) or
-	    ord(dContactSlip1) or ord(dContactSlip2);
+        ord(dContactSlip1) or ord(dContactSlip2);
       contact[i].surface.mu := 10E9;
       contact[i].surface.mu := 10E9;
       contact[i].surface.mu2 := 0;
       contact[i].surface.mu2 := 0;
       contact[i].surface.soft_cfm := 0.001;
       contact[i].surface.soft_cfm := 0.001;
@@ -185,8 +189,10 @@ begin
       contact[i].surface.slip1 := 0.1;
       contact[i].surface.slip1 := 0.1;
       contact[i].surface.slip2 := 0.1;
       contact[i].surface.slip2 := 0.1;
 
 
-      c := dJointCreateContact(TGLODERagdollWorld(Data).World, TGLODERagdollWorld(Data).ContactGroup, @contact[i]);
-      dJointAttach(c, dGeomGetBody(contact[i].Geom.g1), dGeomGetBody(contact[i].Geom.g2));
+      c := dJointCreateContact(TGLODERagdollWorld(data).World,
+        TGLODERagdollWorld(data).ContactGroup, @contact[i]);
+      dJointAttach(c, dGeomGetBody(contact[i].Geom.g1),
+        dGeomGetBody(contact[i].Geom.g2));
     end;
     end;
   end;
   end;
 
 
@@ -206,7 +212,8 @@ end;
 //
 //
 // TGLODERagdollHingeJoint
 // TGLODERagdollHingeJoint
 //
 //
-constructor TGLODERagdollHingeJoint.Create(Axis: TAffineVector; ParamLoStop, ParamHiStop: Single);
+constructor TGLODERagdollHingeJoint.Create(Axis: TAffineVector;
+  ParamLoStop, ParamHiStop: Single);
 begin
 begin
   inherited Create;
   inherited Create;
   FAxis := Axis;
   FAxis := Axis;
@@ -217,16 +224,17 @@ end;
 //
 //
 // TGLODERagdollUniversalJoint
 // TGLODERagdollUniversalJoint
 //
 //
-constructor TGLODERagdollUniversalJoint.Create(Axis: TAffineVector; ParamLoStop, ParamHiStop: Single; Axis2: TAffineVector;
+constructor TGLODERagdollUniversalJoint.Create(Axis: TAffineVector;
+  ParamLoStop, ParamHiStop: Single; Axis2: TAffineVector;
   ParamLoStop2, ParamHiStop2: Single);
   ParamLoStop2, ParamHiStop2: Single);
 begin
 begin
   inherited Create(Axis, ParamLoStop, ParamHiStop);
   inherited Create(Axis, ParamLoStop, ParamHiStop);
-  FAxis2:= Axis2;
-  FParamLoStop:= ParamLoStop;
-  FParamHiStop:= ParamHiStop;
+  FAxis2 := Axis2;
+  FParamLoStop := ParamLoStop;
+  FParamHiStop := ParamHiStop;
 
 
-  FParamLoStop2:= ParamLoStop2;
-  FParamHiStop2:= ParamHiStop2;
+  FParamLoStop2 := ParamLoStop2;
+  FParamHiStop2 := ParamHiStop2;
 end;
 end;
 
 
 //
 //
@@ -245,26 +253,26 @@ begin
   FRagdoll := aOwner.FRagdoll;
   FRagdoll := aOwner.FRagdoll;
 end;
 end;
 
 
-procedure TGLODERagdollBone.AlignBodyToMatrix(Mat:TMatrix);
+procedure TGLODERagdollBone.AlignBodyToMatrix(Mat: TGLMatrix);
 var
 var
   R: TdMatrix3;
   R: TdMatrix3;
 begin
 begin
-  if not Assigned(FBody) then
+  if not assigned(FBody) then
     exit;
     exit;
-  R[0]:=Mat.X.X;
-  R[1]:=Mat.Y.X; 
-  R[2]:= Mat.Z.X;
-  R[3]:= 0;
-  R[4]:=Mat.X.Y; 
-  R[5]:=Mat.Y.Y; 
-  R[6]:= Mat.Z.Y; 
-  R[7]:= 0;
-  R[8]:=Mat.X.Z; 
-  R[9]:=Mat.Y.Z; 
-  R[10]:=Mat.Z.Z;
-  R[11]:=0;
-  dBodySetRotation(FBody,R);
-  dBodySetPosition(FBody,Mat.W.X,Mat.W.Y,Mat.W.Z);
+  R[0] := Mat.X.X;
+  R[1] := Mat.Y.X;
+  R[2] := Mat.Z.X;
+  R[3] := 0;
+  R[4] := Mat.X.Y;
+  R[5] := Mat.Y.Y;
+  R[6] := Mat.Z.Y;
+  R[7] := 0;
+  R[8] := Mat.X.Z;
+  R[9] := Mat.Y.Z;
+  R[10] := Mat.Z.Z;
+  R[11] := 0;
+  dBodySetRotation(FBody, R);
+  dBodySetPosition(FBody, Mat.W.X, Mat.W.Y, Mat.W.Z);
 end;
 end;
 
 
 procedure TGLODERagdollBone.Start;
 procedure TGLODERagdollBone.Start;
@@ -275,23 +283,23 @@ var
 
 
   function RotateAxis(Axis: TAffineVector): TAffineVector;
   function RotateAxis(Axis: TAffineVector): TAffineVector;
   var
   var
-    absMat: TMatrix;
+    absMat: TGLMatrix;
   begin
   begin
-    absMat:= ReferenceMatrix;
-    absMat.W:= NullHmgVector;
-    Result:= VectorNormalize(VectorTransform(Axis, absMat));
+    absMat := ReferenceMatrix;
+    absMat.W := NullHmgVector;
+    Result := VectorNormalize(VectorTransform(Axis, absMat));
   end;
   end;
 
 
 begin
 begin
-  FBody:= dBodyCreate(FRagdoll.ODEWorld.World);
-  boneSize.X:= Size.X*VectorLength(BoneMatrix.X);
-  boneSize.Y:= Size.Y*VectorLength(BoneMatrix.Y);
-  boneSize.Z:= Size.Z*VectorLength(BoneMatrix.Z);
+  FBody := dBodyCreate(FRagdoll.ODEWorld.World);
+  boneSize.X := Size.X * VectorLength(BoneMatrix.X);
+  boneSize.Y := Size.Y * VectorLength(BoneMatrix.Y);
+  boneSize.Z := Size.Z * VectorLength(BoneMatrix.Z);
 
 
   // prevent ODE 0.9 "bNormalizationResult failed" error:
   // prevent ODE 0.9 "bNormalizationResult failed" error:
-  for n:= 0 to 2 do
+  for n := 0 to 2 do
     if (boneSize.V[n] = 0) then
     if (boneSize.V[n] = 0) then
-      boneSize.V[n]:= 0.000001;
+      boneSize.V[n] := 0.000001;
 
 
   dMassSetBox(mass, vODERagdoll_cDensity, boneSize.X, boneSize.Y, boneSize.Z);
   dMassSetBox(mass, vODERagdoll_cDensity, boneSize.X, boneSize.Y, boneSize.Z);
 
 
@@ -300,31 +308,32 @@ begin
 
 
   AlignBodyToMatrix(ReferenceMatrix);
   AlignBodyToMatrix(ReferenceMatrix);
 
 
-  FGeom:= dCreateBox(FRagdoll.ODEWorld.Space, boneSize.X, boneSize.Y, boneSize.Z);
-  FGeom.data:= FRagdoll.GLSceneRoot.AddNewChild(TGLODERagdollCube);
+  FGeom := dCreateBox(FRagdoll.ODEWorld.Space, boneSize.X, boneSize.Y,
+    boneSize.Z);
+  FGeom.data := FRagdoll.GLSceneRoot.AddNewChild(TGLODERagdollCube);
   if (Joint is TGLODERagdollDummyJoint) then
   if (Joint is TGLODERagdollDummyJoint) then
     dGeomSetBody(FGeom, FOwner.Body)
     dGeomSetBody(FGeom, FOwner.Body)
   else
   else
     dGeomSetBody(FGeom, FBody);
     dGeomSetBody(FGeom, FBody);
   if (Owner <> nil) then
   if (Owner <> nil) then
   begin
   begin
-      if (Joint is TGLODERagdollHingeJoint) then
+    if (Joint is TGLODERagdollHingeJoint) then
       with (Joint as TGLODERagdollHingeJoint) do
       with (Joint as TGLODERagdollHingeJoint) do
       begin
       begin
-        vAxis:= RotateAxis(Axis);
-        FJointId:= dJointCreateHinge(FRagdoll.ODEWorld.World, nil);
+        vAxis := RotateAxis(Axis);
+        FJointId := dJointCreateHinge(FRagdoll.ODEWorld.World, nil);
         dJointAttach(FJointId, TGLODERagdollBone(Owner).Body, FBody);
         dJointAttach(FJointId, TGLODERagdollBone(Owner).Body, FBody);
         dJointSetHingeAnchor(FJointId, Anchor.X, Anchor.Y, Anchor.Z);
         dJointSetHingeAnchor(FJointId, Anchor.X, Anchor.Y, Anchor.Z);
         dJointSetHingeAxis(FJointId, vAxis.X, vAxis.Y, vAxis.Z);
         dJointSetHingeAxis(FJointId, vAxis.X, vAxis.Y, vAxis.Z);
         dJointSetHingeParam(FJointId, dParamLoStop, ParamLoStop);
         dJointSetHingeParam(FJointId, dParamLoStop, ParamLoStop);
         dJointSetHingeParam(FJointId, dParamHiStop, ParamHiStop);
         dJointSetHingeParam(FJointId, dParamHiStop, ParamHiStop);
       end;
       end;
-      if (Joint is TGLODERagdollUniversalJoint) then
+    if (Joint is TGLODERagdollUniversalJoint) then
       with (Joint as TGLODERagdollUniversalJoint) do
       with (Joint as TGLODERagdollUniversalJoint) do
       begin
       begin
-        vAxis:= RotateAxis(Axis);
-        vAxis2:= RotateAxis(Axis2);
-        FJointId:= dJointCreateUniversal(FRagdoll.ODEWorld.World, nil);
+        vAxis := RotateAxis(Axis);
+        vAxis2 := RotateAxis(Axis2);
+        FJointId := dJointCreateUniversal(FRagdoll.ODEWorld.World, nil);
         dJointAttach(FJointId, TGLODERagdollBone(Owner).Body, FBody);
         dJointAttach(FJointId, TGLODERagdollBone(Owner).Body, FBody);
         dJointSetUniversalAnchor(FJointId, Anchor.X, Anchor.Y, Anchor.Z);
         dJointSetUniversalAnchor(FJointId, Anchor.X, Anchor.Y, Anchor.Z);
         dJointSetUniversalAxis1(FJointId, vAxis.X, vAxis.Y, vAxis.Z);
         dJointSetUniversalAxis1(FJointId, vAxis.X, vAxis.Y, vAxis.Z);
@@ -334,16 +343,16 @@ begin
         dJointSetUniversalParam(FJointId, dParamLoStop2, ParamLoStop2);
         dJointSetUniversalParam(FJointId, dParamLoStop2, ParamLoStop2);
         dJointSetUniversalParam(FJointId, dParamHiStop2, ParamHiStop2);
         dJointSetUniversalParam(FJointId, dParamHiStop2, ParamHiStop2);
       end;
       end;
-    end;
+  end;
   with TGLODERagdollCube(FGeom.data) do
   with TGLODERagdollCube(FGeom.data) do
   begin
   begin
     Visible := FRagdoll.ShowBoundingBoxes;
     Visible := FRagdoll.ShowBoundingBoxes;
     Material.FrontProperties.Diffuse.SetColor(1, 0, 0, 0.4);
     Material.FrontProperties.Diffuse.SetColor(1, 0, 0, 0.4);
-    CubeWidth:= boneSize.X;
-    CubeHeight:= boneSize.Y;
-    CubeDepth:= boneSize.Z;
-    Bone:= Self;
-    Ragdoll:= Self.FRagdoll;
+    CubeWidth := boneSize.X;
+    CubeHeight := boneSize.Y;
+    CubeDepth := boneSize.Z;
+    Bone := Self;
+    Ragdoll := Self.FRagdoll;
   end;
   end;
 end;
 end;
 
 
@@ -353,7 +362,7 @@ var
 begin
 begin
   inherited;
   inherited;
   dBodyDestroy(FBody);
   dBodyDestroy(FBody);
-  if Assigned(FGeom.data) then
+  if assigned(FGeom.data) then
   begin
   begin
     o := TGLBaseSceneObject(FGeom.data);
     o := TGLBaseSceneObject(FGeom.data);
     FRagdoll.GLSceneRoot.Remove(o, False);
     FRagdoll.GLSceneRoot.Remove(o, False);
@@ -367,8 +376,8 @@ end;
 procedure TGLODERagdollBone.Update;
 procedure TGLODERagdollBone.Update;
 begin
 begin
   PositionSceneObject(TGLBaseSceneObject(PdxGeom(FGeom.data)), FGeom);
   PositionSceneObject(TGLBaseSceneObject(PdxGeom(FGeom.data)), FGeom);
-  Ragdoll.Owner.Skeleton.BoneByID(BoneID).SetGlobalMatrixForRagDoll(
-    TGLBaseSceneObject(PdxGeom(FGeom.data)).AbsoluteMatrix);
+  Ragdoll.Owner.Skeleton.BoneByID(BoneID).SetGlobalMatrixForRagDoll
+    (TGLBaseSceneObject(PdxGeom(FGeom.data)).AbsoluteMatrix);
 end;
 end;
 
 
 procedure TGLODERagdollBone.Align;
 procedure TGLODERagdollBone.Align;
@@ -382,16 +391,16 @@ end;
 //
 //
 constructor TGLODERagdoll.Create(aOwner: TGLBaseMesh);
 constructor TGLODERagdoll.Create(aOwner: TGLBaseMesh);
 begin
 begin
-  inherited Create(AOwner);
+  inherited Create(aOwner);
   FShowBoundingBoxes := False;
   FShowBoundingBoxes := False;
 end;
 end;
 
 
-//-------------------------------------------------
+// -------------------------------------------------
 initialization
 initialization
-//-------------------------------------------------
+
+// -------------------------------------------------
 
 
 vODERagdoll_cDensity := 20;
 vODERagdoll_cDensity := 20;
 vODERagdoll_cMass := 1;
 vODERagdoll_cMass := 1;
 
 
-
 end.
 end.

+ 3 - 2
Source/Physics.ODESkeletonColliders.pas

@@ -1,7 +1,6 @@
 //
 //
 // The graphics rendering engine GLScene http://glscene.org
 // The graphics rendering engine GLScene http://glscene.org
 //
 //
-
 unit Physics.ODESkeletonColliders;
 unit Physics.ODESkeletonColliders;
 
 
 (* Skeleton colliders for defining and controlling ODE geoms. *)
 (* Skeleton colliders for defining and controlling ODE geoms. *)
@@ -10,6 +9,8 @@ interface
 
 
 uses
 uses
   System.Classes,
   System.Classes,
+
+  GLS.VectorTypes,
   GLS.PersistentClasses,
   GLS.PersistentClasses,
   GLS.VectorGeometry,
   GLS.VectorGeometry,
   GLS.VectorFileObjects,
   GLS.VectorFileObjects,
@@ -133,7 +134,7 @@ end;
 procedure TSCODEBase.AlignCollider;
 procedure TSCODEBase.AlignCollider;
 var
 var
   R: TdMatrix3;
   R: TdMatrix3;
-  Mat: TMatrix;
+  Mat: TGLMatrix;
 begin
 begin
   inherited;
   inherited;
   if Assigned(FGeom) then
   if Assigned(FGeom) then

+ 12 - 12
Source/Physics.ODEUtils.pas

@@ -35,10 +35,10 @@ procedure DrawBox(Sides: TdVector3);
 procedure setTransform(pos: TdVector3; R: TdMatrix3);
 procedure setTransform(pos: TdVector3; R: TdMatrix3);
 procedure dsDrawBox(pos: PdVector3; R: PdMatrix3; Sides: TdVector3); overload;
 procedure dsDrawBox(pos: PdVector3; R: PdMatrix3; Sides: TdVector3); overload;
 procedure dsDrawBox(pos: TdVector3; R: TdMatrix3; Sides: TdVector3); overload;
 procedure dsDrawBox(pos: TdVector3; R: TdMatrix3; Sides: TdVector3); overload;
-procedure ODERToGLSceneMatrix(var m: TMatrix; R: TdMatrix3; pos: TdVector3); overload;
-procedure ODERToGLSceneMatrix(var m: TMatrix; R: PdMatrix3; pos: PdVector3); overload;
-procedure ODERToGLSceneMatrix(var m: TMatrix; R: TdMatrix3_As3x4; pos:  TdVector3); overload;
-function GLSceneMatrixToODER(m: TMatrix): TdMatrix3;
+procedure ODERToGLSceneMatrix(var m: TGLMatrix; R: TdMatrix3; pos: TdVector3); overload;
+procedure ODERToGLSceneMatrix(var m: TGLMatrix; R: PdMatrix3; pos: PdVector3); overload;
+procedure ODERToGLSceneMatrix(var m: TGLMatrix; R: TdMatrix3_As3x4; pos:  TdVector3); overload;
+function GLSceneMatrixToODER(m: TGLMatrix): TdMatrix3;
 
 
 // Converting between ODE and GLScene formats
 // Converting between ODE and GLScene formats
 function ConvertdVector3ToVector3f(R: TdVector3): TVector3f; overload;
 function ConvertdVector3ToVector3f(R: TdVector3): TVector3f; overload;
@@ -73,7 +73,7 @@ function CreateTriMeshFromBaseMesh(
   var Vertices: PdVector3Array;
   var Vertices: PdVector3Array;
   var Indices: PdIntegerArray): PdxGeom;
   var Indices: PdIntegerArray): PdxGeom;
 
 
-function GLMatrixFromGeom(Geom: PdxGeom): TMatrix;
+function GLMatrixFromGeom(Geom: PdxGeom): TGLMatrix;
 function GLDirectionFromGeom(Geom: PdxGeom): TGLVector;
 function GLDirectionFromGeom(Geom: PdxGeom): TGLVector;
 function CreateODEPlaneFromGLPlane(Plane: TGLPlane; Space: PdxSpace): PdxGeom;
 function CreateODEPlaneFromGLPlane(Plane: TGLPlane; Space: PdxSpace): PdxGeom;
 procedure RenderGeomList(GeomList: TGeomList);
 procedure RenderGeomList(GeomList: TGeomList);
@@ -85,7 +85,7 @@ function RandomColorVector: TGLVector;
 implementation
 implementation
 //---------------------------------------------------------------------------
 //---------------------------------------------------------------------------
 
 
-procedure ODERToGLSceneMatrix(var m: TMatrix; R: TdMatrix3_As3x4; pos: TdVector3); overload;
+procedure ODERToGLSceneMatrix(var m: TGLMatrix; R: TdMatrix3_As3x4; pos: TdVector3); overload;
 begin
 begin
   m.X.X := r[0][0];
   m.X.X := r[0][0];
   m.X.Y := r[0][1];
   m.X.Y := r[0][1];
@@ -108,12 +108,12 @@ begin
   m.W.W := 1; //}
   m.W.W := 1; //}
 end;
 end;
 
 
-procedure ODERToGLSceneMatrix(var m: TMatrix; 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: TMatrix; 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;
@@ -163,7 +163,7 @@ begin
   gl.End_();
   gl.End_();
 end;
 end;
 
 
-function GLSceneMatrixToODER(m: TMatrix): TdMatrix3;
+function GLSceneMatrixToODER(m: TGLMatrix): TdMatrix3;
 begin
 begin
   TransposeMatrix(m);
   TransposeMatrix(m);
   Result[0] := m.X.X;
   Result[0] := m.X.X;
@@ -302,7 +302,7 @@ begin
     PositionSceneObject(TGLBaseSceneObject(Geom.Data), Geom);
     PositionSceneObject(TGLBaseSceneObject(Geom.Data), Geom);
 end;
 end;
 
 
-function GLMatrixFromGeom(Geom: PdxGeom): TMatrix;
+function GLMatrixFromGeom(Geom: PdxGeom): TGLMatrix;
 var
 var
   pos, Pos2: PdVector3;
   pos, Pos2: PdVector3;
   R, R2: PdMatrix3;
   R, R2: PdMatrix3;
@@ -346,7 +346,7 @@ end;
 
 
 function GLDirectionFromGeom(Geom: PdxGeom): TGLVector;
 function GLDirectionFromGeom(Geom: PdxGeom): TGLVector;
 var
 var
-  m: TMatrix;
+  m: TGLMatrix;
 begin
 begin
   m := GLMatrixFromGeom(Geom);
   m := GLMatrixFromGeom(Geom);
 
 
@@ -376,7 +376,7 @@ end;
 procedure CopyPosFromGeomToGL(Geom: PdxGeom; GLBaseSceneObject: TGLBaseSceneObject);
 procedure CopyPosFromGeomToGL(Geom: PdxGeom; GLBaseSceneObject: TGLBaseSceneObject);
 var
 var
   v: TGLVector;
   v: TGLVector;
-  m: TMatrix;
+  m: TGLMatrix;
 
 
   R: PdMatrix3;
   R: PdMatrix3;
   pos: PdVector3;
   pos: PdVector3;

+ 3 - 3
Source/Physics.SPIInertias.pas

@@ -158,7 +158,7 @@ type
     class function FriendlyName: String; override;
     class function FriendlyName: String; override;
     class function FriendlyDescription: String; override;
     class function FriendlyDescription: String; override;
     class function UniqueItem: Boolean; override;
     class function UniqueItem: Boolean; override;
-    // function Star(Vector:TAffineVector):TMatrix;
+    // function Star(Vector:TAffineVector):TGLMatrix;
     function QuaternionToString(Quat: TQuaternion): String;
     function QuaternionToString(Quat: TQuaternion): String;
     procedure RemoveForces(); override;
     procedure RemoveForces(); override;
     procedure SetTorque(x, y, z: Real);
     procedure SetTorque(x, y, z: Real);
@@ -700,7 +700,7 @@ begin
 end;
 end;
 
 
 (*
 (*
- function TGLRigidBodyInertia.Star(Vector:TAffineVector):TMatrix;
+ function TGLRigidBodyInertia.Star(Vector:TAffineVector):TGLMatrix;
   begin
   begin
   Result.X.X:=0;             Result[0][1]:=-Vector[2];  Result[0][2]:=Vector[1];  Result[0][3]:=0;
   Result.X.X:=0;             Result[0][1]:=-Vector[2];  Result[0][2]:=Vector[1];  Result[0][3]:=0;
   Result[1][0]:=Vector[2];   Result[1][1]:=0;           Result[1][2]:=-Vector[0]; Result[1][3]:=0;
   Result[1][0]:=Vector[2];   Result[1][1]:=0;           Result[1][2]:=-Vector[0]; Result[1][3]:=0;
@@ -792,7 +792,7 @@ var
   IRt: TAffineMAtrix;
   IRt: TAffineMAtrix;
   Rt: TAffineMAtrix;
   Rt: TAffineMAtrix;
   Scale: TAffineVector;
   Scale: TAffineVector;
-  RMatrix: TMatrix;
+  RMatrix: TGLMatrix;
 begin
 begin
   // TODO: sort this out
   // TODO: sort this out
   fBodyInverseInertiaTensor := IdentityMatrix;
   fBodyInverseInertiaTensor := IdentityMatrix;

+ 2 - 2
Source/Physics.SPIJoints.pas

@@ -1,7 +1,6 @@
 //
 //
 // The graphics rendering engine GLScene http://glscene.org
 // The graphics rendering engine GLScene http://glscene.org
 //
 //
-
 unit Physics.SPIJoints;
 unit Physics.SPIJoints;
 
 
 (*
 (*
@@ -12,6 +11,7 @@ unit Physics.SPIJoints;
 interface
 interface
 
 
 uses
 uses
+  GLS.VectorTypes,
   GLS.Scene,
   GLS.Scene,
   GLS.VectorGeometry;
   GLS.VectorGeometry;
 
 
@@ -71,7 +71,7 @@ type
     // [    0               0                            0                 1         ]
     // [    0               0                            0                 1         ]
     //
     //
 *)
 *)
-    A: TMatrix;
+    A: TGLMatrix;
     constructor Create(LinkLength, TwistAngle, LinkAngle, LinkDistance: Real);
     constructor Create(LinkLength, TwistAngle, LinkAngle, LinkDistance: Real);
     // constructor Create();virtual;
     // constructor Create();virtual;
   end;
   end;

+ 1 - 0
Source/Sounds.OpenAL.pas

@@ -28,6 +28,7 @@ uses
   Vcl.Forms,
   Vcl.Forms,
   Vcl.Dialogs,
   Vcl.Dialogs,
 
 
+  GLS.VectorTypes,
   GLS.Scene,
   GLS.Scene,
   GLS.VectorGeometry,
   GLS.VectorGeometry,
   GLS.Sound,
   GLS.Sound,