Class TMeshManipulator

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type TMeshManipulator = class(TReferenceCounted)

Description

An interface for easy manipulation of meshes. Scale, set alpha value, flip surfaces, and so on. This exists for fixing problems with wrong imported or exported meshes quickly after loading. It is not intended for doing mesh modifications and/or animations during runtime.

Hierarchy

Overview

Methods

Public function Apply(Func: TMeshManipulatorMethod; Mesh: TMesh; UpdateBoundingBox: Boolean=False): Boolean; overload; inline;
Public function Apply(Func: TMeshManipulatorMethod; Buffer: TMeshBuffer; UpdateBoundingBox: Boolean=False): Boolean; overload; inline;
Public function Apply(Func: TMeshManipulatorFunction; Mesh: TMesh; UpdateBoundingBox: Boolean=False): Boolean; overload; inline;
Public function Apply(Func: TMeshManipulatorFunction; Buffer: TMeshBuffer; UpdateBoundingBox: Boolean=False): Boolean; overload; inline;
Public function CreateAnimatedMesh(Mesh: TMesh; MeshType: TAnimatedMeshType = amUnknown): TAnimatedMesh; inline;
Public function CreateMeshCopy(Mesh: TMesh): TMesh; inline;
Public function CreateMeshUniquePrimitives(Mesh: TMesh): TMesh; inline;
Public function CreateMeshWelded(Mesh: TMesh; Tolerance: Single = 0.000001): TMesh; inline;
Public function CreateMeshWith1TCoords(Mesh: TMesh): TMesh; inline;
Public function CreateMeshWith2TCoords(Mesh: TMesh): TMesh; inline;
Public function CreateMeshWithTangents(Mesh: TMesh; RecalculateNormals: Boolean = False; Smooth: Boolean = False; AngleWeighted: Boolean = False; RecalculateTangents: Boolean = True): TMesh; inline;
Public function GetPolyCount(Mesh: TMesh): LongInt; overload; inline;
Public function GetPolyCount(Mesh: TAnimatedMesh): LongInt; overload; inline;
Public procedure FlipSurfaces(Mesh: TMesh); inline;
Public procedure MakePlanarTextureMapping(Mesh: TMesh; Resolution: Single = 0.001); inline;
Public procedure MakePlanarTextureMapping(Buffer: TMeshBuffer; Resolution: Single = 0.001); overload; inline;
Public procedure MakePlanarTextureMapping(Buffer: TMeshBuffer; ResolutionS, ResolutionT: Single; Axis: Byte; const Offset: TVector3D); overload; inline;
Public procedure RecalculateNormals(Mesh: TMesh; Smooth: Boolean = False; AngleWeighted: Boolean = False); overload; inline;
Public procedure RecalculateNormals(Buffer: TMeshBuffer; Smooth: Boolean = False; AngleWeighted: Boolean = False); overload; inline;
Public procedure RecalculateTangents(Mesh: TMesh; RecalculateNormals: Boolean = False; Smooth: Boolean = False; AngleWeighted: Boolean = False); inline;
Public procedure Scale(Mesh: TMesh; const Factor: TVector3D); overload; inline;
Public procedure Scale(Buffer: TMeshBuffer; const Factor: TVector3D); overload; inline;
Public procedure ScaleTCoords(Mesh: TMesh; const Factor: TVector2D; Level: LongWord=1); overload; inline;
Public procedure ScaleTCoords(Buffer: TMeshBuffer; const Factor: TVector2D; Level: LongWord=1); overload; inline;
Public procedure SetVertexColorAlpha(Mesh: TMesh; Alpha: LongInt); overload; inline;
Public procedure SetVertexColors(Mesh: TMesh; Color: TARGBColor); overload; inline;
Public procedure Transform(Mesh: TMesh; const Matrix: TMatrix4); overload; inline;
Public procedure Transform(Buffer: TMeshBuffer; const Matrix: TMatrix4); overload; inline;

Description

Methods

Public function Apply(Func: TMeshManipulatorMethod; Mesh: TMesh; UpdateBoundingBox: Boolean=False): Boolean; overload; inline;

Apply a member function manipulator on the Mesh.

Parameters
Func
A member function defining the mesh manipulation.
Mesh
The Mesh to apply the manipulator to.
UpdateBoundingBox
Specifies if the bounding box should be updated during manipulation.
Returns

True if the functor was successfully applied, else false.

Public function Apply(Func: TMeshManipulatorMethod; Buffer: TMeshBuffer; UpdateBoundingBox: Boolean=False): Boolean; overload; inline;

Apply a member function manipulator on a MeshBuffer.

Parameters
Func
A member function defining the mesh buffer manipulation.
Mesh
The Mesh to apply the manipulator to.
UpdateBoundingBox
Specifies if the bounding box should be updated during manipulation.
Returns

True if the functor was successfully applied, else false.

Public function Apply(Func: TMeshManipulatorFunction; Mesh: TMesh; UpdateBoundingBox: Boolean=False): Boolean; overload; inline;

Apply a manipulator on the Mesh.

Parameters
Func
A function defining the mesh manipulation.
Mesh
The Mesh to apply the manipulator to.
UpdateBoundingBox
Specifies if the bounding box should be updated during manipulation.
Returns

True if the functor was successfully applied, else false.

Public function Apply(Func: TMeshManipulatorFunction; Buffer: TMeshBuffer; UpdateBoundingBox: Boolean=False): Boolean; overload; inline;

Apply a manipulator on a MeshBuffer.

Parameters
Func
A function defining the mesh buffer manipulation.
Mesh
The Mesh to apply the manipulator to.
UpdateBoundingBox
Specifies if the bounding box should be updated during manipulation.
Returns

True if the functor was successfully applied, else false.

Public function CreateAnimatedMesh(Mesh: TMesh; MeshType: TAnimatedMeshType = amUnknown): TAnimatedMesh; inline;

Create a new AnimatedMesh and adds the mesh to it.

Parameters
Mesh
Input mesh
MeshType
The type of the animated mesh to create.
Returns

Newly created animated mesh with mesh as its only content. When you don't need the animated mesh anymore, you should call TAnimatedMesh.Drop(). See TReferenceCounted.Drop() for more information.

Public function CreateMeshCopy(Mesh: TMesh): TMesh; inline;

Clones a static IMesh into a modifiable SMesh.
(All meshbuffers in the returned SMesh are of type SMeshBuffer or SMeshBufferLightMap.)

Parameters
Mesh
Mesh to copy.
Returns

The Cloned mesh. If you no longer need the cloned mesh, you should call TMesh.Drop(). See TReferenceCounted.Drop() for more information.

Public function CreateMeshUniquePrimitives(Mesh: TMesh): TMesh; inline;

Creates a copy of a mesh with all vertices unwelded.

Parameters
Mesh
Input mesh
Returns

Mesh consisting only of unique faces. All vertices which were previously shared are now duplicated. If you no longer need the cloned mesh, you should call TMesh.Drop(). See TReferenceCounted.Drop() for more information.

Public function CreateMeshWelded(Mesh: TMesh; Tolerance: Single = 0.000001): TMesh; inline;

Creates a copy of a mesh with vertices welded.

Parameters
Mesh
Input mesh
Tolerance
The threshold for vertex comparisons.
Returns

Mesh without redundant vertices. If you no longer need the cloned mesh, you should call TMesh.Drop(). See TReferenceCounted.Drop() for more information.

Public function CreateMeshWith1TCoords(Mesh: TMesh): TMesh; inline;

Creates a copy of the mesh, which will only consist of TVertex vertices.

Parameters
Mesh
Input mesh
Returns

Mesh consisting only of TVertex vertices. If you no longer need the cloned mesh, you should call TMesh.Drop(). See TReferenceCounted.Drop() for more information.

Public function CreateMeshWith2TCoords(Mesh: TMesh): TMesh; inline;

Creates a copy of the mesh, which will only consist of TVertex2TCoords vertices.

Parameters
Mesh
Input mesh
Returns

Mesh consisting only of TVertex2TCoords vertices. If you no longer need the cloned mesh, you should call TMesh.Drop(). See TReferenceCounted.Drop() for more information.

Public function CreateMeshWithTangents(Mesh: TMesh; RecalculateNormals: Boolean = False; Smooth: Boolean = False; AngleWeighted: Boolean = False; RecalculateTangents: Boolean = True): TMesh; inline;

Creates a copy of the mesh, which will only consist of S3DVertexTangents vertices.
This is useful if you want to draw tangent space normal mapped geometry because it calculates the tangent and binormal data which is needed there.

Parameters
Mesh
Input mesh
RecalculateNormals
The normals are recalculated if set, otherwise the original ones are kept. Note that keeping the normals may introduce inaccurate tangents if the normals are very different to those calculated from the faces.
Smooth
The normals/tangents are smoothed across the meshbuffer's faces if this flag is set.
AngleWeighted
Improved smoothing calculation used
RecalculateTangents
Whether are actually calculated, or just the mesh with proper type is created.
Returns

Mesh consisting only of S3DVertexTangents vertices. If you no longer need the cloned mesh, you should call TMesh.Drop(). See TReferenceCounted.Drop() for more information.

Public function GetPolyCount(Mesh: TMesh): LongInt; overload; inline;

Get amount of polygons in mesh.

Parameters
Mesh
Input mesh
Returns

Number of polygons in mesh.

Public function GetPolyCount(Mesh: TAnimatedMesh): LongInt; overload; inline;

Get amount of polygons in mesh.

Parameters
Mesh
Input mesh
Returns

Number of polygons in mesh.

Public procedure FlipSurfaces(Mesh: TMesh); inline;

Flips the direction of surfaces.
Changes backfacing triangles to frontfacing triangles and vice versa.

Parameters
Mesh
Mesh on which the operation is performed.
Public procedure MakePlanarTextureMapping(Mesh: TMesh; Resolution: Single = 0.001); inline;

Creates a planar texture mapping on the mesh.

Parameters
Mesh
Mesh on which the operation is performed.
Resolution
Resolution of the planar mapping. This is the value specifying which is the relation between world space and texture coordinate space.
Public procedure MakePlanarTextureMapping(Buffer: TMeshBuffer; Resolution: Single = 0.001); overload; inline;

Creates a planar texture mapping on the meshbuffer.

Parameters
MeshBuffer
Buffer on which the operation is performed.
Resolution
Resolution of the planar mapping. This is the value specifying which is the relation between world space and texture coordinate space.
Public procedure MakePlanarTextureMapping(Buffer: TMeshBuffer; ResolutionS, ResolutionT: Single; Axis: Byte; const Offset: TVector3D); overload; inline;

Creates a planar texture mapping on the meshbuffer.
This method is currently implemented towards the LWO planar mapping. A more general biasing might be required.

Parameters
Buffer
Buffer on which the operation is performed.
ResolutionS
Resolution of the planar mapping in horizontal direction. This is the ratio between object space and texture space.
ResolutionT
Resolution of the planar mapping in vertical direction. This is the ratio between object space and texture space.
Axis
The axis along which the texture is projected. The allowed values are 0 (X), 1(Y), and 2(Z).
Offset
Vector added to the vertex positions (in object coordinates).
Public procedure RecalculateNormals(Mesh: TMesh; Smooth: Boolean = False; AngleWeighted: Boolean = False); overload; inline;

Recalculates all normals of the mesh.

Parameters
Mesh
Mesh on which the operation is performed.
Smooth
If the normals shall be smoothed.
AngleWeighted
If the normals shall be smoothed in relation to their angles. More expensive, but also higher precision.
Public procedure RecalculateNormals(Buffer: TMeshBuffer; Smooth: Boolean = False; AngleWeighted: Boolean = False); overload; inline;

Recalculates all normals of the mesh buffer.

Parameters
Buffer
Mesh buffer on which the operation is performed.
Smooth
If the normals shall be smoothed.
AngleWeighted
If the normals shall be smoothed in relation to their angles. More expensive, but also higher precision.
Public procedure RecalculateTangents(Mesh: TMesh; RecalculateNormals: Boolean = False; Smooth: Boolean = False; AngleWeighted: Boolean = False); inline;

Recalculates tangents, requires a tangent mesh.

Parameters
Mesh
Mesh on which the operation is performed.
RecalculateNormals
If the normals shall be recalculated, otherwise original normals of the mesh are used unchanged.
Smooth
If the normals shall be smoothed.
AngleWeighted
If the normals shall be smoothed in relation to their angles. More expensive, but also higher precision.
Public procedure Scale(Mesh: TMesh; const Factor: TVector3D); overload; inline;

Scales the actual mesk not a scene node.

Parameters
Mesh
Mesh on which the operation is performed.
Factor
Scale factor for each axis.
Public procedure Scale(Buffer: TMeshBuffer; const Factor: TVector3D); overload; inline;

Scales the actual meshbuffer, not a scene node.

Parameters
Buffer
Meshbuffer on which the operation is performed.
Factor
Scale factor for each axis.
Public procedure ScaleTCoords(Mesh: TMesh; const Factor: TVector2D; Level: LongWord=1); overload; inline;

Scale the texture coords of a mesh.

Parameters
Mesh
Mesh on which the operation is performed.
Factor
Vector which defines the scale for each axis.
Level
Number of texture coord, starting from 1. Support for level 2 exists for LightMap buffers.
Public procedure ScaleTCoords(Buffer: TMeshBuffer; const Factor: TVector2D; Level: LongWord=1); overload; inline;

Scale the texture coords of a meshbuffer.

Parameters
Buffer
Meshbuffer on which the operation is performed.
Factor
Vector which defines the scale for each axis.
Level
Number of texture coord, starting from 1. Support for level 2 exists for LightMap buffers.
Public procedure SetVertexColorAlpha(Mesh: TMesh; Alpha: LongInt); overload; inline;

Sets the alpha vertex color value of the whole mesh to a new value.

Parameters
Mesh
Mesh on which the operation is performed.
Alpha
New alpha value. Must be a value between 0 and 255.
Public procedure SetVertexColors(Mesh: TMesh; Color: TARGBColor); overload; inline;

Sets the colors of all vertices to one color.

Parameters
Mesh
Mesh on which the operation is performed.
Color
New color.
Public procedure Transform(Mesh: TMesh; const Matrix: TMatrix4); overload; inline;

Applies a transformation to a mesh.

Parameters
Mesh
Mesh on which the operation is performed.
Matrix
Transformation matrix.
Public procedure Transform(Buffer: TMeshBuffer; const Matrix: TMatrix4); overload; inline;

Applies a transformation to a meshbuffer.

Parameters
Buffer
Meshbuffer on which the operation is performed.
Matrix
Transformation matrix.

Generated by PasDoc 0.12.1 on 2012-09-14 17:32:22