All SupraEngine.Math matrices are also compatible with OpenGL (and Vulkan,
of course). SupraEngine.Math's TMatrix3x3 and TMatrix4x4 implementation
have also advanced stuff as such as lerp, nlerp, slerp interpolation method
functions, decomposing (into Perspective, Translation, Scale, Skew and
Rotation components), recomposing (from Perspective, Translation, Scale,
Skew and Rotation components). And SupraEngine.Math have also GLSL-style
and in the most cases GLSL-Function-Parameter-compatible functions as such
as Cross, Dot, Normalize, FaceForward, Reflect, Refract, Clamp, Mix, Step,
SmoothStep, etc.

Example usages:

FaceNormal := (p2 - p0).Cross(p1 - p0).Normalize; // or alternatively also:
FaceNormal := Normalize(Cross(p2 - p0,p1 - p0));
if FaceNormal.Dot((Normals[NormalIndices[0]]+
                               Normals[NormalIndices[1]]+
                               Normals[NormalIndices[2]]).Normalize) < 0.0
then begin
   FaceNormal := -FaceNormal;
end;

 TriangleTangent:=((p2-p0)*(uv1.v-uv0.v))-((p1-p0)*(uv2.v-uv0.v));
 TriangleBitangent:=((p2-p0)*(uv1.u-uv0.u))-((p1-p0)*(uv2.u-uv0.u));
 
TriangleTangent:=(TriangleTangent-(TriangleNormal*TriangleTangent.Dot(TriangleNormal))).Normalize;
 
TriangleBitangent:=(TriangleBitangent-(TriangleNormal*TriangleBitangent.Dot(TriangleNormal))).Normalize;
 if (TriangleBitangent.Cross(TriangleTangent)).Dot(TriangleNormal)<0.0 then
begin
   TriangleTangent:=-TriangleTangent;
   TriangleBitangent:=-TriangleBitangent;
 end;

 Matrix := Transform.Matrix * Matrix;

 Vector := Matrix * Vector; (like at GLSL)
 Vector := Vector * Matrix; (in the other way transposed mul like at GLSL)

 Vector := Quaternion * Vector;
 Vector := Vector * Quaternion; (with the same transposed-matrix-like
effect)

 Vector := DualQuaternion * Vector;
 Vector := Vector * DualQuaternion; (with the same transposed-matrix-like
effect)

 RightVector := Matrix.Right.xyz;
 UpVector := Matrix.Up.xyz;
 ForwardVector := Matrix.Forwards.xyz;
 TranslationVector := Matrix.Translation.xyz;

 Matrix := Matrix.Normalize;
 Matrix := Matrix.OrthoNormalize;
 Matrix := Matrix.RobustOrthoNormalize;

 Quaternion := Matrix.ToQuaternion;

 QTangent := Matrix.ToQTangent;

 Matrix3x3 := Matrix4x4.ToMatrix3x3;

 ModelMatrix := Matrix4x4Identity;
 ViewMatrix := TMatrix4x4.CreateTranslation(0.0, 0.0, -4.0);
 ProjectionMatrix := TMatrix4x4.CreatePerspective(45.0, Width / Heighz,
1.0, 1024.0);
 ModelViewMatrix := ModelMatrix * ViewMatrix;
 InverseModelViewMatrix := ModelViewMatrix.Inverse;
 ModelViewProjectionMatrix := ModelMatrix * ViewMatrix * ProjectionMatrix;
 InverseModelViewProjectionMatrix := ModelViewMatrixProjection.Inverse;
 TangentSpaceRotationMatrix := ModelViewMatrix.Inverse.Transpose;
 InverseTangentSpaceRotationMatrix := TangentSpaceRotationMatrix.Transpose;

 ClipMatrix := CreateProjectionMatrixClip(ProjectionMatrix, ClipPlane);

etc.
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to