Class BoxShape
Represents a three-dimensional box shape.
public class BoxShape : RigidBodyShape, IDynamicTreeProxy, IPartitionedSetIndex, IUpdatableBoundingBox, ISupportMappable, IRayCastable, ISweepTestable, IDistanceTestable, IDebugDrawable
- Inheritance
-
BoxShape
- Implements
- Inherited Members
Constructors
BoxShape(JVector)
Creates a box shape with specified dimensions.
public BoxShape(JVector size)
Parameters
sizeJVectorThe full extents of the box in the local x-, y-, and z-directions.
Exceptions
- ArgumentOutOfRangeException
Thrown when any component of
sizeis less than or equal to zero.
BoxShape(float)
Creates a cube shape with sides of equal length.
public BoxShape(float size)
Parameters
sizefloatThe length of each side.
Exceptions
- ArgumentOutOfRangeException
Thrown when
sizeis less than or equal to zero.
BoxShape(float, float, float)
Creates a box shape with the specified extents in the local x-, y-, and z-directions.
public BoxShape(float sizeX, float sizeY, float sizeZ)
Parameters
sizeXfloatThe full extent of the box in the local x-direction.
sizeYfloatThe full extent of the box in the local y-direction.
sizeZfloatThe full extent of the box in the local z-direction.
Exceptions
- ArgumentOutOfRangeException
Thrown when
sizeX,sizeY, orsizeZis less than or equal to zero.
Properties
Size
Gets or sets the full extents of the box in the local x-, y-, and z-directions.
public JVector Size { get; set; }
Property Value
Exceptions
- ArgumentOutOfRangeException
Thrown when any component of
valueis less than or equal to zero.
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 JSymmetricMatrix, out JVector, out float)
Calculates the mass and inertia of the shape. Can be overridden by child classes to improve performance or accuracy. The default implementation relies on an approximation of the shape constructed using the support map function.
public override void CalculateMassInertia(out JSymmetricMatrix inertia, out JVector com, out float mass)
Parameters
inertiaJSymmetricMatrixcomJVectormassfloat
Remarks
The inertia tensor is computed relative to the coordinate system origin (0,0,0), not the center of mass.
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
triangleSinkTSinkThe destination for generated triangles.
settingsDebugDrawSettingsThe 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
pointJVectorA point inside the convex hull.
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.
normalJVectorThe surface normal at the point of intersection, if an intersection occurs.
lambdafloatThe ray parameter from the
originto the intersection point. Becausedirectionneed not be normalized, this is not necessarily a distance. The hit point is: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)