Class TransformedShape
Applies translation, rotation, scaling, or shear to another shape in local coordinates.
public class TransformedShape : RigidBodyShape, IDynamicTreeProxy, IPartitionedSetIndex, IUpdatableBoundingBox, ISupportFeature, ISupportMappable, IRayCastable, IAngularSweepTestable, ISweepTestable, IDistanceTestable, IDebugDrawable
- Inheritance
-
TransformedShape
- Implements
- Inherited Members
Constructors
TransformedShape(RigidBodyShape, JMatrix)
Creates a shape with rotation, scaling, or shear and no translation.
public TransformedShape(RigidBodyShape shape, JMatrix transform)
Parameters
shapeRigidBodyShapetransformJMatrix
TransformedShape(RigidBodyShape, JVector)
Applies a translation to the shape, with no rotation or scaling.
public TransformedShape(RigidBodyShape shape, JVector translation)
Parameters
shapeRigidBodyShapetranslationJVector
TransformedShape(RigidBodyShape, in JVector, in JMatrix)
Creates a shape with a linear transformation followed by a translation.
public TransformedShape(RigidBodyShape shape, in JVector translation, in JMatrix transform)
Parameters
shapeRigidBodyShapeThe shape to transform.
translationJVectorThe translation component of the affine transform.
transformJMatrixThe linear component of the affine transform.
Exceptions
- ArgumentNullException
Thrown when
shapeis null.- ArgumentException
Thrown when
translationortransformcontains a non-finite value.
Properties
OriginalShape
Gets the original shape that is being transformed.
public RigidBodyShape OriginalShape { get; }
Property Value
Transformation
Gets or sets the linear transformation (rotation, scale, or shear) applied to the shape.
public JMatrix Transformation { get; set; }
Property Value
Translation
Gets or sets the translation applied to the shape.
public JVector Translation { get; set; }
Property 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 JSymmetricMatrix, out JVector, out float)
Calculates the shape's mass, center of mass, and inertia at unit density. The default implementation approximates the surface; overrides can provide exact mass properties.
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)
Draws the shape's surface as triangles in local coordinates.
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 to provide custom debug geometry; otherwise, the surface is approximated. Use outward-facing triangles for closed surfaces. Body and shape transforms are applied automatically.
GetCenter(out JVector)
Returns a point inside the shape. It does not need to be the center of mass.
public override void GetCenter(out JVector point)
Parameters
pointJVectorAn interior point in local space.
SupportFeature(in JVector, float, Span<JVector>)
Writes the outermost feature of the shape in the given direction.
public override int SupportFeature(in JVector direction, float tolerance, Span<JVector> vertices)
Parameters
directionJVectorThe direction in local space. Does not need to be normalized.
tolerancefloatThe sine of the angle within which directions share the feature.
verticesSpan<JVector>Receives the vertices in local space: one for a point, two for a segment, three or more for a convex polygon in winding order. At least MaxVertices entries long.
Returns
- int
The number of vertices written, at least one.
Remarks
The default samples the support mapping with SupportFeatureSampler. Shapes that know their features analytically should override it.
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)