Table of Contents

Class TriangleShape

Namespace
Jitter2.Collision.Shapes
Assembly
Jitter2.dll

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, IDebugDrawable
Inheritance
TriangleShape
Implements
Inherited Members

Constructors

TriangleShape(TriangleMesh, int)

Initializes a new instance of the TriangleShape class.

public TriangleShape(TriangleMesh mesh, int index)

Parameters

mesh TriangleMesh

The triangle mesh to which this triangle belongs.

index int

The index representing the position of the triangle within the mesh.

Exceptions

ArgumentNullException

Thrown when mesh is null.

ArgumentOutOfRangeException

Thrown when index is 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

int

Mesh

The triangle mesh to which this triangle belongs.

public readonly TriangleMesh Mesh

Field Value

TriangleMesh

Methods

CalculateBoundingBox(in JQuaternion, in JVector, out JBoundingBox)

public override void CalculateBoundingBox(in JQuaternion orientation, in JVector position, out JBoundingBox box)

Parameters

orientation JQuaternion
position JVector
box JBoundingBox

CalculateMassInertia(out JSymmetricMatrix, out JVector, out float)

public override void CalculateMassInertia(out JSymmetricMatrix inertia, out JVector com, out float mass)

Parameters

inertia JSymmetricMatrix
com JVector
mass float

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

mesh TriangleMesh

Returns

IEnumerable<TriangleShape>

DebugDrawLocal<TSink>(ref TSink, in DebugDrawSettings)

Appends debug triangles in the coordinate system used by SupportMap(in JVector, out JVector).

protected override void DebugDrawLocal<TSink>(ref TSink triangleSink, in DebugDrawSettings settings) where TSink : ISink<JTriangle>

Parameters

triangleSink TSink

The destination for generated triangles.

settings DebugDrawSettings

The visualization settings.

Type Parameters

TSink

Remarks

Override this method to supply custom surface geometry. Rigid-body and affine transforms are applied by the caller. Use outward-facing triangles for closed surfaces. Without an override, the shape is drawn as an approximate surface.

GetCenter(out JVector)

Computes a representative point within the convex hull, used as an initial search point in GJK-based algorithms.

public override void GetCenter(out JVector point)

Parameters

point JVector

A point inside the convex hull.

GetWorldVertices(out JVector, out JVector, out JVector)

Gets the vertices transformed by the attached rigid body. If the shape is unattached, returns the mesh vertices without a world transform.

public void GetWorldVertices(out JVector a, out JVector b, out JVector c)

Parameters

a JVector

The transformed coordinate of the first vertex.

b JVector

The transformed coordinate of the second vertex.

c JVector

The 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

origin JVector

The starting point of the ray.

direction JVector

The direction of the ray. This vector does not need to be normalized.

normal JVector

The surface normal at the point of intersection, if an intersection occurs.

lambda float

The ray parameter from the origin to the intersection point. Because direction need not be normalized, this is not necessarily a distance. The hit point is: origin + lambda * direction.

Returns

bool

true if the ray intersects with the object; otherwise, false.

Remarks

Back-facing triangles are culled.

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)

Parameters

direction JVector

The search direction in local space. Does not need to be normalized.

result JVector

The point on the shape's surface furthest along direction.