Record TTransformation

Hierarchy
Properties

Unit

Declaration

type TTransformation = record

Description

Describe transformation in a way comfortable to apply it in both ways.

Overview

Fields

Public Transform: TMatrix4;
Public InverseTransform: TMatrix4;
Public Scale: Single;
Public UniformScale: Boolean;

Methods

Public procedure Init;
Public procedure Multiply( const Center: TVector3; const Rotation: TVector4; const ScaleVector: TVector3; const ScaleOrientation: TVector4; const Translation: TVector3); overload;
Public procedure Multiply( const Rotation: TVector4; const ScaleVector: TVector3; const Translation: TVector3); overload;
Public procedure MultiplyMatrix(const Matrix: TMatrix4);
Public procedure Translate(const Translation: TVector3);

Description

Fields

Public Transform: TMatrix4;

Transformation from local to outside coordinate space.

Public InverseTransform: TMatrix4;

Inverted Transform matrix.

Note that any scale with zero component along the way will make this partially invalid (we'll substitute identity in place of inverted scaling matrix). This is unavoidable, there's no reverse matrix for scaling with zero factor, since one resulting point may correpond to infinitely many source points (i.e., it's natural that such scaling function cannot be reversed).

Public Scale: Single;

A uniform scale of the matrix Transform. If the matrix causes non-uniform scaling, this value represents an average scale.

Public UniformScale: Boolean;

Is the underlying scale uniform (which means that Scale accurately represents the scaling, is not only approximate).

Methods

Public procedure Init;

Make no transformation (identity matrix, scale 1).

Public procedure Multiply( const Center: TVector3; const Rotation: TVector4; const ScaleVector: TVector3; const ScaleOrientation: TVector4; const Translation: TVector3); overload;

Modify transformation by an additional translation, rotation, scaling.

Multiplies at the same time transformation matrix in Transform, and it's inverse in InverseTransform. The precise meaning of Center, Translation and other parameters follows exactly the X3D Transform node definition (see http://www.web3d.org/files/specifications/19775-1/V3.2/Part01/components/group.html#Transform ).

Parameters
Rotation
Rotation is expressed as a 4D vector, in which the first 3 components specify the rotation axis (does not need to be normalized, but must be non-zero), and the last component is the rotation angle in radians.
Public procedure Multiply( const Rotation: TVector4; const ScaleVector: TVector3; const Translation: TVector3); overload;
 
Public procedure MultiplyMatrix(const Matrix: TMatrix4);

Modify transformation by an additional transformation matrix.

Using this is very discouraged, as we need to assume UniformScale=false, which in turn e.g. makes sphere collisions worse (at some transformations, they have to treat sphere as something larger). That is because matrix can contain any transformation, and even using MatrixDecompose and then analyzing whether resulting scale has X=Y=Z would be unreliable. Testcases:

- Rendering ghost teeth in castle-game.

This shows that we cannot just replace matrix with translation+rotation+scale by MatrixDecompose, matrix can contain other transformations like shear. So we need to account whole matrix. Replacing MultiplyMatrix(matrix) with MatrixDecompose + Multiply(vectors) makes wrong rendering.

- Graves on "The Gate" level in castle-game.

This shows that even calculating UniformScale based on scale resulting from MatrixDecompose doesn't work reliably. Replacing inside MultiplyMatrix the UniformScale detection, to assume true when scale (from MatrixDecompose) has X=Y=Z, results in blocked movement. MatrixDecompose cannot account fo arbitrary matrix that can contain anything.

- Beginng position (blocked movement) on "castle hall" level in castle-game.

Same as above. Shows that we cannot detect UniformScale smartly.

Use the Multiply instead to provide separate translation, rotation etc. vectors. Use this method only when you are forced to do so, i.e. your input is already a matrix.

Public procedure Translate(const Translation: TVector3);

Modify transformation by an additional translation.


Generated by PasDoc 0.16.0.