Click or drag to resize
DigitalRuneTriangleMeshShape Class
Represents a shape defined by an ITriangleMesh.
Inheritance Hierarchy
SystemObject
  DigitalRune.Geometry.ShapesShape
    DigitalRune.Geometry.ShapesTriangleMeshShape

Namespace: DigitalRune.Geometry.Shapes
Assembly: DigitalRune.Geometry (in DigitalRune.Geometry.dll) Version: 1.18.0.0 (1.18.2.14427)
Syntax
[SerializableAttribute]
public class TriangleMeshShape : Shape

The TriangleMeshShape type exposes the following members.

Constructors
  NameDescription
Public methodTriangleMeshShape
Initializes a new instance of the TriangleMeshShape class.
Public methodTriangleMeshShape(ITriangleMesh)
Initializes a new instance of the TriangleMeshShape class from the given triangle mesh.
Public methodTriangleMeshShape(ITriangleMesh, Boolean)
Initializes a new instance of the TriangleMeshShape class from the given triangle mesh.
Public methodTriangleMeshShape(ITriangleMesh, Boolean, ISpatialPartitionInt32)
Initializes a new instance of the TriangleMeshShape class from the given triangle mesh.
Top
Methods
  NameDescription
Public methodClone
Creates a new Shape that is a clone (deep copy) of the current instance.
(Inherited from Shape.)
Protected methodCloneCore
Makes the instance a clone (deep copy) of the specified Shape.
(Overrides ShapeCloneCore(Shape).)
Protected methodCreateInstanceCore
When implemented in a derived class, creates a new instance of the Shape derived class.
(Overrides ShapeCreateInstanceCore.)
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetAabb
Computes the axis-aligned bounding box (AABB) for this shape in local space.
(Inherited from Shape.)
Public methodGetAabb(Pose)
Computes the axis-aligned bounding box (AABB) for this shape positioned in world space using the given Pose.
(Inherited from Shape.)
Public methodGetAabb(Vector3F, Pose)
Computes the axis-aligned bounding box (AABB) for this shape positioned in world space using the given scale and Pose.
(Overrides ShapeGetAabb(Vector3F, Pose).)
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public methodGetMesh
Gets a mesh that represents this shape.
(Inherited from Shape.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodGetVolume
Computes the enclosed volume of the mesh.
Public methodGetVolume(Single, Int32)
Computes the enclosed volume of the mesh.
(Overrides ShapeGetVolume(Single, Int32).)
Public methodInvalidate
Invalidates the triangle mesh.
Public methodInvalidate(Boolean)
Invalidates the triangle mesh.
Public methodInvalidate(Int32, Boolean)
Invalidates the whole triangle mesh or a single triangle.
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Protected methodOnChanged
Raises the Changed event.
(Inherited from Shape.)
Protected methodOnGetMesh
Called when a mesh should be generated for the shape.
(Overrides ShapeOnGetMesh(Single, Int32).)
Public methodToString
Returns a String that represents the current Object.
(Overrides ObjectToString.)
Top
Properties
  NameDescription
Public propertyEnableContactWelding
Gets or sets a value indicating whether contact welding is enabled.
Public propertyInnerPoint
Gets an inner point.
(Overrides ShapeInnerPoint.)
Public propertyIsTwoSided
Gets or sets a value indicating whether the mesh is two-sided.
Public propertyMesh
Gets or sets the triangle mesh.
Public propertyPartition
Gets or set the spatial partition used to improve the performance of geometric queries.
Top
Events
  NameDescription
Public eventChanged
Occurs when the shape was changed.
(Inherited from Shape.)
Top
Remarks

One-sided and two-sided meshes: Per default, the collision detection treats the triangle mesh as one-sided (IsTwoSided is ); that means, only the front side of a triangle is solid. If the collision detection is used in a physics simulation, then objects can pass through the back side of a triangle. IsTwoSided can be set to to treat the mesh as two-sided (double-sided).

Meshes are hollow: Further, meshes are not treated as solid volumes. For example if a triangle mesh represents a sphere and another object is inside the sphere but does not touch any triangles, then no collision is reported.

Spatial Partitioning: A spatial partitioning method (see Partition can be used to improve runtime performance if the Mesh consists of a lot of triangles. A spatial partition improves the collision detection speed at the cost of additional memory. If Partition is , no spatial partitioning method is used (which is the default). If a spatial partitioning scheme should be used, the property Partition must be set to a ISpatialPartitionT instance. The items in the spatial partition will be the indices of the mesh triangles. The triangle mesh shape will automatically fill and update the spatial partition. Following example shows how a complex triangle mesh shape can be improved by using an AABB tree:

C#
myTriangleMeshShape.Partition = new AabbTree<int>();

Shape Features: If a TriangleMeshShape is involved in a Contact the shape feature property (FeatureA and FeatureB) contains the index of the triangle that causes the Contact.

Cloning: A TriangleMeshShape can be cloned. The clone will reference the same ITriangleMesh (shallow copy)! If a Partition is in use, the spatial partition will be cloned.

See Also