Class TriangleShape
Represents a triangle shape defined by a reference to a TriangleMesh and an index.
public class TriangleShape : RigidBodyShape, IDynamicTreeProxy, IPartitionedSetIndex, IUpdatableBoundingBox, ISupportMappable, IRayCastable, ISweepTestable, IDistanceTestable
- Inheritance
-
TriangleShape
- Implements
- Inherited Members
Constructors
TriangleShape(TriangleMesh, int)
Initializes a new instance of the TriangleShape class.
public TriangleShape(TriangleMesh mesh, int index)
Parameters
meshTriangleMeshThe triangle mesh to which this triangle belongs.
indexintThe index representing the position of the triangle within the mesh.
Exceptions
- ArgumentNullException
Thrown when
meshisnull.- ArgumentOutOfRangeException
Thrown when
indexis negative or greater than or equal to the number of triangles in the mesh.
Fields
Index
The index representing the position of the triangle within the mesh.
public readonly int Index
Field Value
Mesh
The triangle mesh to which this triangle belongs.
public readonly TriangleMesh Mesh
Field Value
Methods
CalculateBoundingBox(in JQuaternion, in JVector, out JBoundingBox)
public override void CalculateBoundingBox(in JQuaternion orientation, in JVector position, out JBoundingBox box)
Parameters
orientationJQuaternionpositionJVectorboxJBoundingBox
CalculateMassInertia(out JMatrix, out JVector, out float)
public override void CalculateMassInertia(out JMatrix inertia, out JVector com, out float mass)
Parameters
Exceptions
- NotSupportedException
Always thrown because a triangle has no volume and therefore no mass properties.
CreateAllShapes(TriangleMesh)
Creates and returns all instances of type TriangleShape for as given TriangleMesh.
public static IEnumerable<TriangleShape> CreateAllShapes(TriangleMesh mesh)
Parameters
meshTriangleMesh
Returns
GetCenter(out JVector)
Computes a point deep within the shape, used as an initial search point in GJK-based algorithms.
public override void GetCenter(out JVector point)
Parameters
pointJVectorA point guaranteed to be inside the convex hull, typically the center of mass.
GetWorldVertices(out JVector, out JVector, out JVector)
Retrieves the vertices transformed to world space coordinates, as affected by the rigid body's transformation.
public void GetWorldVertices(out JVector a, out JVector b, out JVector c)
Parameters
aJVectorThe transformed coordinate of the first vertex.
bJVectorThe transformed coordinate of the second vertex.
cJVectorThe transformed coordinate of the third vertex.
LocalRayCast(in JVector, in JVector, out JVector, out float)
Performs a local ray cast against the shape, checking if a ray originating from a specified point and traveling in a specified direction intersects with the object. It does not take into account the transformation of the associated rigid body.
public override bool LocalRayCast(in JVector origin, in JVector direction, out JVector normal, out float lambda)
Parameters
originJVectorThe starting point of the ray.
directionJVectorThe direction of the ray. This vector does not need to be normalized.
normalJVectorWhen this method returns, contains the surface normal at the point of intersection, if an intersection occurs.
lambdafloatWhen this method returns, contains the scalar value representing the distance along the ray's direction vector from the
originto the intersection point. The hit point can be calculated as:origin + lambda * direction.
Returns
- bool
trueif the ray intersects with the object; otherwise,false.
SupportMap(in JVector, out JVector)
Computes the point on the shape that is furthest in the specified direction.
public override void SupportMap(in JVector direction, out JVector result)