Table of Contents

Class BoxShape

Namespace
Jitter2.Collision.Shapes
Assembly
Jitter2.dll

Represents a three-dimensional box shape.

public class BoxShape : RigidBodyShape, IDynamicTreeProxy, IPartitionedSetIndex, IUpdatableBoundingBox, ISupportMappable, IRayCastable, ISweepTestable, IDistanceTestable
Inheritance
BoxShape
Implements
Inherited Members

Constructors

BoxShape(JVector)

Creates a box shape with specified dimensions.

public BoxShape(JVector size)

Parameters

size JVector

The dimensions of the box.

Exceptions

ArgumentOutOfRangeException

Thrown when any component of size is less than or equal to zero.

BoxShape(float)

Creates a cube shape with sides of equal length.

public BoxShape(float size)

Parameters

size float

The length of each side.

Exceptions

ArgumentOutOfRangeException

Thrown when size is less than or equal to zero.

BoxShape(float, float, float)

Creates a box shape with the specified length, height, and width.

public BoxShape(float width, float height, float length)

Parameters

width float

The width of the box.

height float

The height of the box.

length float

The length of the box.

Exceptions

ArgumentOutOfRangeException

Thrown when length, height, or width is less than or equal to zero.

Properties

Size

Gets or sets the dimensions of the box.

public JVector Size { get; set; }

Property Value

JVector

Exceptions

ArgumentOutOfRangeException

Thrown when any component of value is 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

orientation JQuaternion
position JVector
box JBoundingBox

CalculateMassInertia(out JMatrix, 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 JMatrix inertia, out JVector com, out float mass)

Parameters

inertia JMatrix
com JVector
mass float

Remarks

The inertia tensor is computed relative to the coordinate system origin (0,0,0), not the center of mass.

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

point JVector

A point guaranteed to be inside the convex hull, typically the center of mass.

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

When this method returns, contains the surface normal at the point of intersection, if an intersection occurs.

lambda float

When this method returns, contains the scalar value representing the distance along the ray's direction vector from the origin to the intersection point. The hit point can be calculated as: origin + lambda * direction.

Returns

bool

true if 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)

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.