Package com.jme3.bullet.collision.shapes
Class SimplexCollisionShape
java.lang.Object
com.jme3.bullet.NativePhysicsObject
com.jme3.bullet.collision.shapes.CollisionShape
com.jme3.bullet.collision.shapes.ConvexShape
com.jme3.bullet.collision.shapes.SimplexCollisionShape
- All Implemented Interfaces:
Comparable<NativePhysicsObject>
A simple point, line-segment, triangle, or tetrahedron collision shape based
on Bullet's
btBU_Simplex1to4
. These shapes cannot be scaled.-
Field Summary
Fields inherited from class com.jme3.bullet.collision.shapes.ConvexShape
loggerX
Fields inherited from class com.jme3.bullet.collision.shapes.CollisionShape
enableContactFilter, logger, margin, scale
Fields inherited from class com.jme3.bullet.NativePhysicsObject
loggerN
-
Constructor Summary
ConstructorDescriptionSimplexCollisionShape
(Vector3f location) Instantiate a point shape based on the specified location.SimplexCollisionShape
(Vector3f[] vertices) Instantiate a simplex shape based on the specified array.SimplexCollisionShape
(Vector3f point1, Vector3f point2) Instantiate a line-segment shape based on the specified endpoints.SimplexCollisionShape
(Vector3f vertex1, Vector3f vertex2, Vector3f vertex3) Instantiate a triangular shape based on the specified vertices.SimplexCollisionShape
(Vector3f vertex1, Vector3f vertex2, Vector3f vertex3, Vector3f vertex4) Instantiate a tetrahedral shape based on the specified vertices.SimplexCollisionShape
(FloatBuffer buffer, int startPosition, int endPosition) Instantiate a simplex shape based on the specified FloatBuffer range. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Test whether the specified scale factors can be applied to the shape.copyVertex
(int index, Vector3f storeResult) Copy the indexed vertex.float[]
Copy the unscaled vertex locations.int
Count the points used to generate the simplex.getHalfExtents
(Vector3f storeResult) Calculate the unscaled half extents of the simplex.float
Calculate how far the shape extends from its origin, including margin.protected void
Recalculate the shape's bounding box if necessary.Approximate this shape with a HullCollisionShape.float
Calculate the unscaled volume of the simplex.Methods inherited from class com.jme3.bullet.collision.shapes.ConvexShape
isConcave, isConvex, scaledVolume, toSplittableShape
Methods inherited from class com.jme3.bullet.collision.shapes.CollisionShape
aabbCenter, boundingBox, boundingBox, canSplit, getDefaultMargin, getMargin, getScale, getScaleDp, getShapeType, getShapeType, isContactFilterEnabled, isInfinite, isNonMoving, isPolyhedral, nativeMargin, setContactFilterEnabled, setDefaultMargin, setMargin, setNativeId, setScale, setScale, setUserIndex, setUserIndex2, toString, updateScale, userIndex, userIndex2
Methods inherited from class com.jme3.bullet.NativePhysicsObject
compareTo, countTrackers, dumpTrackers, equals, freeUnusedObjects, hasAssignedNativeObject, hashCode, nativeId, reassignNativeId, setNativeIdNotTracked, unassignNativeObject
-
Field Details
-
logger2
message logger for this class
-
-
Constructor Details
-
SimplexCollisionShape
Instantiate a point shape based on the specified location.- Parameters:
location
- the location of the point (in shape coordinates, not null, unaffected)
-
SimplexCollisionShape
Instantiate a line-segment shape based on the specified endpoints.- Parameters:
point1
- the location of first endpoint (in shape coordinates, not null, unaffected)point2
- the location of 2nd endpoint (in shape coordinates, not null, unaffected)
-
SimplexCollisionShape
Instantiate a triangular shape based on the specified vertices.- Parameters:
vertex1
- the location of first vertex (in shape coordinates, not null, unaffected)vertex2
- the location of 2nd vertex (in shape coordinates, not null, unaffected)vertex3
- the location of 3rd vertex (in shape coordinates, not null, unaffected)
-
SimplexCollisionShape
public SimplexCollisionShape(Vector3f vertex1, Vector3f vertex2, Vector3f vertex3, Vector3f vertex4) Instantiate a tetrahedral shape based on the specified vertices.- Parameters:
vertex1
- the location of first vertex (in shape coordinates, not null, unaffected)vertex2
- the location of 2nd vertex (in shape coordinates, not null, unaffected)vertex3
- the location of 3rd vertex (in shape coordinates, not null, unaffected)vertex4
- the location of 4th vertex (in shape coordinates, not null, unaffected)
-
SimplexCollisionShape
Instantiate a simplex shape based on the specified FloatBuffer range.- Parameters:
buffer
- the buffer that contains the vertex locations (not null, unaffected)startPosition
- the buffer position at which the vertex locations start (≥0, ≤endPosition-3)endPosition
- the buffer position at which the vertex locations end (≥startPosition+3, ≤capacity)
-
SimplexCollisionShape
Instantiate a simplex shape based on the specified array.- Parameters:
vertices
- an array of vertex locations (not null, not empty, unaffected)
-
-
Method Details
-
copyVertex
Copy the indexed vertex.- Parameters:
index
- (≥0, <4)storeResult
- storage for the result (modified if not null)- Returns:
- the location of the vertex (either storeResult or a new instance)
-
copyVertices
public float[] copyVertices()Copy the unscaled vertex locations.- Returns:
- a new array (not null)
-
countMeshVertices
public int countMeshVertices()Count the points used to generate the simplex.- Returns:
- the count (≥1, ≤4)
-
getHalfExtents
Calculate the unscaled half extents of the simplex.- Parameters:
storeResult
- storage for the result (modified if not null)- Returns:
- the unscaled half extent for each local axis (either storeResult or a new vector, not null, no negative component)
-
unscaledVolume
public float unscaledVolume()Calculate the unscaled volume of the simplex.- Returns:
- the volume (in shape units cubed, ≥0)
-
canScale
Test whether the specified scale factors can be applied to the shape. For simplex shapes, scaling must be unity.- Overrides:
canScale
in classCollisionShape
- Parameters:
scale
- the desired scale factor for each local axis (may be null, unaffected)- Returns:
- true if applicable, otherwise false
-
maxRadius
public float maxRadius()Calculate how far the shape extends from its origin, including margin.- Overrides:
maxRadius
in classCollisionShape
- Returns:
- the distance (in physics-space units, ≥0)
-
recalculateAabb
protected void recalculateAabb()Recalculate the shape's bounding box if necessary.- Overrides:
recalculateAabb
in classCollisionShape
-
toHullShape
Approximate this shape with a HullCollisionShape.- Overrides:
toHullShape
in classConvexShape
- Returns:
- a new shape
-