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:
com.jme3.export.Savable,com.jme3.util.clone.JmeCloneable,Cloneable,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
FieldsFields inherited from class com.jme3.bullet.collision.shapes.ConvexShape
loggerXFields inherited from class com.jme3.bullet.collision.shapes.CollisionShape
enableContactFilter, logger, margin, scaleFields inherited from class com.jme3.bullet.NativePhysicsObject
loggerN -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedNo-argument constructor needed by SavableClassUtil.SimplexCollisionShape(com.jme3.math.AbstractTriangle triangle) Instantiate a triangular shape based on the specified AbstractTriangle.SimplexCollisionShape(com.jme3.math.LineSegment segment) Instantiate a line-segment shape based on the specified LineSegment.SimplexCollisionShape(com.jme3.math.Vector3f location) Instantiate a point shape based on the specified location.SimplexCollisionShape(com.jme3.math.Vector3f[] vertices) Instantiate a simplex shape based on the specified array.SimplexCollisionShape(com.jme3.math.Vector3f point1, com.jme3.math.Vector3f point2) Instantiate a line-segment shape based on the specified endpoints.SimplexCollisionShape(com.jme3.math.Vector3f vertex1, com.jme3.math.Vector3f vertex2, com.jme3.math.Vector3f vertex3) Instantiate a triangular shape based on the specified vertices.SimplexCollisionShape(com.jme3.math.Vector3f vertex1, com.jme3.math.Vector3f vertex2, com.jme3.math.Vector3f vertex3, com.jme3.math.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 TypeMethodDescriptionbooleancanScale(com.jme3.math.Vector3f scale) Test whether the specified scale factors can be applied to the shape.voidcloneFields(com.jme3.util.clone.Cloner cloner, Object original) Callback fromClonerto convert this shallow-cloned shape into a deep-cloned one, using the specified Cloner and original to resolve copied fields.com.jme3.math.Vector3fcopyVertex(int index, com.jme3.math.Vector3f storeResult) Copy the indexed vertex.float[]Copy the unscaled vertex locations.intCount the points used to generate the simplex.com.jme3.math.Vector3fgetHalfExtents(com.jme3.math.Vector3f storeResult) Calculate the unscaled half extents of the simplex.floatCalculate how far the shape extends from its origin, including margin.voidread(com.jme3.export.JmeImporter importer) De-serialize the shape from the specified importer, for example when loading from a J3O file.protected voidRecalculate the shape's bounding box if necessary.Approximate this shape with a HullCollisionShape.floatCalculate the unscaled volume of the simplex.voidwrite(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, toSplittableShapeMethods inherited from class com.jme3.bullet.collision.shapes.CollisionShape
aabbCenter, aabbScaledVolume, boundingBox, boundingBox, canSplit, 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, userIndex2Methods 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
protected SimplexCollisionShape()No-argument constructor needed by SavableClassUtil. -
SimplexCollisionShape
public SimplexCollisionShape(com.jme3.math.Vector3f location) Instantiate a point shape based on the specified location.- Parameters:
location- the location of the point (in shape coordinates, not null, unaffected)
-
SimplexCollisionShape
public SimplexCollisionShape(com.jme3.math.Vector3f point1, com.jme3.math.Vector3f point2) 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
public SimplexCollisionShape(com.jme3.math.Vector3f vertex1, com.jme3.math.Vector3f vertex2, com.jme3.math.Vector3f vertex3) 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(com.jme3.math.Vector3f vertex1, com.jme3.math.Vector3f vertex2, com.jme3.math.Vector3f vertex3, com.jme3.math.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
public SimplexCollisionShape(com.jme3.math.AbstractTriangle triangle) Instantiate a triangular shape based on the specified AbstractTriangle.- Parameters:
triangle- the triangle (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
public SimplexCollisionShape(com.jme3.math.LineSegment segment) Instantiate a line-segment shape based on the specified LineSegment.- Parameters:
segment- the segment (not null, unaffected)
-
SimplexCollisionShape
public SimplexCollisionShape(com.jme3.math.Vector3f[] vertices) Instantiate a simplex shape based on the specified array.- Parameters:
vertices- an array of vertex locations (not null, not empty, unaffected)
-
-
Method Details
-
copyVertex
public com.jme3.math.Vector3f copyVertex(int index, com.jme3.math.Vector3f storeResult) 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
public com.jme3.math.Vector3f getHalfExtents(com.jme3.math.Vector3f storeResult) 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
public boolean canScale(com.jme3.math.Vector3f scale) Test whether the specified scale factors can be applied to the shape. For simplex shapes, scaling must be unity.- Overrides:
canScalein classCollisionShape- Parameters:
scale- the desired scale factor for each local axis (may be null, unaffected)- Returns:
- true if applicable, otherwise false
-
cloneFields
Callback fromClonerto convert this shallow-cloned shape into a deep-cloned one, using the specified Cloner and original to resolve copied fields.- Specified by:
cloneFieldsin interfacecom.jme3.util.clone.JmeCloneable- Overrides:
cloneFieldsin 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 the shape extends from its origin, including margin.- Overrides:
maxRadiusin 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:
readin interfacecom.jme3.export.Savable- Overrides:
readin classCollisionShape- Parameters:
importer- (not null)- Throws:
IOException- from the importer
-
recalculateAabb
protected void recalculateAabb()Recalculate the shape's bounding box if necessary.- Overrides:
recalculateAabbin classCollisionShape
-
toHullShape
Approximate this shape with a HullCollisionShape.- Overrides:
toHullShapein classConvexShape- Returns:
- a new shape
-
write
Serialize this shape to the specified exporter, for example when saving to a J3O file.- Specified by:
writein interfacecom.jme3.export.Savable- Overrides:
writein classCollisionShape- Parameters:
exporter- (not null)- Throws:
IOException- from the exporter
-