Package com.jme3.bullet.collision.shapes
Class HullCollisionShape
java.lang.Object
com.jme3.bullet.NativePhysicsObject
com.jme3.bullet.collision.shapes.CollisionShape
com.jme3.bullet.collision.shapes.ConvexShape
com.jme3.bullet.collision.shapes.HullCollisionShape
- All Implemented Interfaces:
Comparable<NativePhysicsObject>
A convex-hull collision shape based on Bullet's
btConvexHullShape
.
For a 2-D convex hull, use Convex2dShape
.-
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
ConstructorDescriptionHullCollisionShape
(float... coordinates) Instantiate a shape based on the specified array of coordinates.HullCollisionShape
(Vector3f... locations) Instantiate a shape based on the specified array of locations.HullCollisionShape
(FloatBuffer flippedBuffer) Instantiate a shape based on a flipped buffer containing coordinates.HullCollisionShape
(Collection<Vector3f> locations) Instantiate a shape based on the specified collection of locations.HullCollisionShape
(RectangularSolid rectangularSolid) Instantiate an 8-vertex shape to match the specified rectangular solid.HullCollisionShape
(VHACDHull vhacdHull) Instantiate a shape based on a VHACDHull.HullCollisionShape
(Vhacd4Hull vhacd4Hull) Instantiate a shape based on a Vhacd4Hull. -
Method Summary
Modifier and TypeMethodDescriptionfloat
Calculate a quick upper bound for the unscaled volume of the hull, based on its axis-aligned bounding box.boolean
canSplit()
Test whether the shape can be split by an arbitrary plane.float[]
Copy the unscaled vertex locations of the optimized convex hull.int
Count the number of vertices in the optimized convex hull.int
Count the vertices used to generate the hull.getHalfExtents
(Vector3f storeResult) Calculate the unscaled half extents of the hull.float
Calculate how far this shape extends from its center, including margin.protected void
Recalculate the shape's bounding box if necessary.Attempt to divide this shape into 2 child shapes.Methods inherited from class com.jme3.bullet.collision.shapes.ConvexShape
isConcave, isConvex, scaledVolume, toHullShape, toSplittableShape
Methods inherited from class com.jme3.bullet.collision.shapes.CollisionShape
aabbCenter, boundingBox, boundingBox, canScale, 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
-
HullCollisionShape
Instantiate a shape based on the specified collection of locations. For best performance and stability, the convex hull should have no more than 100 vertices.- Parameters:
locations
- a collection of location vectors on which to base the shape (not null, not empty, unaffected)
-
HullCollisionShape
public HullCollisionShape(float... coordinates) Instantiate a shape based on the specified array of coordinates. For best performance and stability, the convex hull should have no more than 100 vertices.- Parameters:
coordinates
- an array of coordinates on which to base the shape (not null, not empty, length a multiple of 3, unaffected)
-
HullCollisionShape
Instantiate a shape based on a flipped buffer containing coordinates. For best performance and stability, the convex hull should have no more than 100 vertices.- Parameters:
flippedBuffer
- the coordinates on which to base the shape (not null, limit>0, limit a multiple of 3, unaffected)
-
HullCollisionShape
Instantiate an 8-vertex shape to match the specified rectangular solid.- Parameters:
rectangularSolid
- the solid on which to base the shape (not null)
-
HullCollisionShape
Instantiate a shape based on the specified array of locations. For best performance and stability, the convex hull should have no more than 100 vertices.- Parameters:
locations
- an array of location vectors (in shape coordinates, not null, not empty, unaffected)
-
HullCollisionShape
Instantiate a shape based on a Vhacd4Hull. For best performance and stability, the convex hull should have no more than 100 vertices.- Parameters:
vhacd4Hull
- (not null, unaffected)
-
HullCollisionShape
Instantiate a shape based on a VHACDHull. For best performance and stability, the convex hull should have no more than 100 vertices.- Parameters:
vhacdHull
- (not null, unaffected)
-
-
Method Details
-
aabbVolume
public float aabbVolume()Calculate a quick upper bound for the unscaled volume of the hull, based on its axis-aligned bounding box.- Returns:
- the volume (in unscaled shape units cubed, ≥0)
-
copyHullVertices
public float[] copyHullVertices()Copy the unscaled vertex locations of the optimized convex hull.- Returns:
- a new array (not null)
-
countHullVertices
public int countHullVertices()Count the number of vertices in the optimized convex hull.- Returns:
- the count (≥0)
-
countMeshVertices
public int countMeshVertices()Count the vertices used to generate the hull.- Returns:
- the count (>0)
-
getHalfExtents
Calculate the unscaled half extents of the hull.- 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)
-
split
Attempt to divide this shape into 2 child shapes.- Parameters:
splittingTriangle
- to define the splitting plane (in shape coordinates, not null, unaffected)- Returns:
- a pair of hull-based children, the first child generated by the plane's minus side and the 2nd child generated by its plus side; either child may be null, indicating an empty shape
-
canSplit
public boolean canSplit()Test whether the shape can be split by an arbitrary plane.- Overrides:
canSplit
in classCollisionShape
- Returns:
- true
-
maxRadius
public float maxRadius()Calculate how far this shape extends from its center, 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
-