Assembly: DigitalRune.Geometry (in DigitalRune.Geometry.dll) Version: 1.9.0.0 (1.9.3.9490)
Syntax
| C# |
|---|
[SerializableAttribute] public class TriangleMeshShape : Shape |
| Visual Basic |
|---|
<SerializableAttribute> _ Public Class TriangleMeshShape _ Inherits Shape |
| Visual C++ |
|---|
[SerializableAttribute] public ref class TriangleMeshShape : public Shape |
Remarks
One-sided and two-sided meshes: Per default, the collision detection treats the triangle mesh as one-sided (IsTwoSided is falseFalsefalsefalse (False in Visual Basic)); 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 trueTruetruetrue (True in Visual Basic) to treat the mesh as two-sided (double-sided).
Meshes are hollow: Further, meshes are not treated as solid volumes. For example if a the 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 nullNothingnullptra null reference (Nothing in Visual Basic), 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 ISpatialPartition<(Of <(<'T>)>)> 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. When the contained ITriangleMesh implements ICloneable then ITriangleMesh is cloned (deep copy); otherwise only the reference to ITriangleMesh is copied (shallow copy). If a Partition is in use, the spatial partition will be cloned if it implements ICloneable. If it does not implement ICloneable, the clone will not have a spatial partition.
Inheritance Hierarchy
DigitalRune.Geometry.Shapes..::..Shape
DigitalRune.Geometry.Shapes..::..TriangleMeshShape