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:
com.jme3.export.Savable
,com.jme3.util.clone.JmeCloneable
,Cloneable
,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
ModifierConstructorDescriptionprotected
No-argument constructor needed by SavableClassUtil.HullCollisionShape
(float... coordinates) Instantiate a shape based on the specified array of coordinates.HullCollisionShape
(com.jme3.math.Vector3f... locations) Instantiate a shape based on the specified array of locations.HullCollisionShape
(com.jme3.scene.Mesh... meshes) Instantiate a shape based on the specified JME mesh(es).HullCollisionShape
(FloatBuffer flippedBuffer) Instantiate a shape based on a flipped buffer containing coordinates.HullCollisionShape
(Collection<com.jme3.math.Vector3f> locations) Instantiate a shape based on the specified collection of locations.HullCollisionShape
(jme3utilities.math.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.void
cloneFields
(com.jme3.util.clone.Cloner cloner, Object original) Callback fromCloner
to convert this shallow-cloned shape into a deep-cloned one, using the specified Cloner and original to resolve copied fields.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.com.jme3.math.Vector3f
getHalfExtents
(com.jme3.math.Vector3f storeResult) Calculate the unscaled half extents of the hull.float
Calculate how far this shape extends from its center, including margin.void
read
(com.jme3.export.JmeImporter importer) De-serialize the shape from the specified importer, for example when loading from a J3O file.protected void
Recalculate the shape's bounding box if necessary.split
(com.jme3.math.Triangle splittingTriangle) Attempt to divide this shape into 2 child shapes.void
write
(com.jme3.export.JmeExporter exporter) Serialize this shape to the specified exporter, for example when saving to a J3O file.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, aabbScaledVolume, boundingBox, boundingBox, canScale, copyShapeProperties, getDefaultMargin, getMargin, getScale, getScaleDp, getShapeType, getShapeType, isContactFilterEnabled, isInfinite, isNonMoving, isPolyhedral, jmeClone, nativeMargin, readShapeProperties, 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
protected HullCollisionShape()No-argument constructor needed by SavableClassUtil. -
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
public HullCollisionShape(com.jme3.scene.Mesh... meshes) Instantiate a shape based on the specified JME mesh(es). For best performance and stability, the convex hull should have no more than 100 vertices.- Parameters:
meshes
- the mesh(es) on which to base the shape (all non-null, at least one vertex, unaffected)
-
HullCollisionShape
public HullCollisionShape(jme3utilities.math.RectangularSolid rectangularSolid) Instantiate an 8-vertex shape to match the specified rectangular solid.- Parameters:
rectangularSolid
- the solid on which to base the shape (not null)
-
HullCollisionShape
public HullCollisionShape(com.jme3.math.Vector3f... locations) 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
public com.jme3.math.Vector3f getHalfExtents(com.jme3.math.Vector3f storeResult) 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
-
cloneFields
Callback fromCloner
to convert this shallow-cloned shape into a deep-cloned one, using the specified Cloner and original to resolve copied fields.- Specified by:
cloneFields
in interfacecom.jme3.util.clone.JmeCloneable
- Overrides:
cloneFields
in classCollisionShape
- Parameters:
cloner
- the Cloner that's cloning this shape (not null)original
- the instance from which this shape was shallow-cloned (not null, unaffected)
-
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)
-
read
De-serialize the shape from the specified importer, for example when loading from a J3O file.- Specified by:
read
in interfacecom.jme3.export.Savable
- Overrides:
read
in classCollisionShape
- Parameters:
importer
- (not null)- Throws:
IOException
- from the importer
-
recalculateAabb
protected void recalculateAabb()Recalculate the shape's bounding box if necessary.- Overrides:
recalculateAabb
in classCollisionShape
-
write
Serialize this shape to the specified exporter, for example when saving to a J3O file.- Specified by:
write
in interfacecom.jme3.export.Savable
- Overrides:
write
in classCollisionShape
- Parameters:
exporter
- (not null)- Throws:
IOException
- from the exporter
-