Package com.jme3.bullet.collision.shapes
Class HeightfieldCollisionShape
java.lang.Object
com.jme3.bullet.NativePhysicsObject
com.jme3.bullet.collision.shapes.CollisionShape
com.jme3.bullet.collision.shapes.HeightfieldCollisionShape
- All Implemented Interfaces:
Comparable<NativePhysicsObject>
A collision shape for terrain defined by a matrix of height values, based on
Bullet's
btHeightfieldTerrainShape
. Should be more efficient than an
equivalent MeshCollisionShape
. Not for use in dynamic bodies.
Collisions between HeightfieldCollisionShape
,
MeshCollisionShape
, and PlaneCollisionShape
objects are never
detected.-
Field Summary
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
ConstructorDescriptionHeightfieldCollisionShape
(float[] heightArray) Instantiate a square shape for the specified array of heights.HeightfieldCollisionShape
(float[] heightArray, Vector3f scale) Instantiate a square shape for the specified height array and scale vector.HeightfieldCollisionShape
(int stickLength, int stickWidth, float[] heightmap, Vector3f scale, int upAxis, boolean flipQuadEdges, boolean flipTriangleWinding, boolean useDiamond, boolean useZigzag) Instantiate a rectangular shape for the specified parameters. -
Method Summary
Modifier and TypeMethodDescriptionint
Count how many columns are in the heightfield.int
Count how many heights are in the heightfield.int
Count how many rows are in the heightfield.Approximate this shape with a splittable shape.int
upAxis()
Return the index of the height axis.Methods inherited from class com.jme3.bullet.collision.shapes.CollisionShape
aabbCenter, boundingBox, boundingBox, canScale, canSplit, getDefaultMargin, getMargin, getScale, getScaleDp, getShapeType, getShapeType, isConcave, isContactFilterEnabled, isConvex, isInfinite, isNonMoving, isPolyhedral, maxRadius, nativeMargin, recalculateAabb, scaledVolume, 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
-
HeightfieldCollisionShape
public HeightfieldCollisionShape(float[] heightArray) Instantiate a square shape for the specified array of heights.- Parameters:
heightArray
- (not null, length≥4, length a perfect square, unaffected)
-
HeightfieldCollisionShape
Instantiate a square shape for the specified height array and scale vector.- Parameters:
heightArray
- (not null, length≥4, length a perfect square, unaffected)scale
- the desired scale factor for each local axis (not null, no negative component, unaffected, default=(1,1,1))
-
HeightfieldCollisionShape
public HeightfieldCollisionShape(int stickLength, int stickWidth, float[] heightmap, Vector3f scale, int upAxis, boolean flipQuadEdges, boolean flipTriangleWinding, boolean useDiamond, boolean useZigzag) Instantiate a rectangular shape for the specified parameters.- Parameters:
stickLength
- the number of rows in the heightfield (>1)stickWidth
- number of columns in the heightfield (>1)heightmap
- (not null, length≥stickLength*stickWidth, unaffected)scale
- the desired scale factor for each local axis (not null, no negative component, unaffected, default=(1,1,1))upAxis
- the height-axis index (0→X, 1→Y, 2→Z, default=1)flipQuadEdges
- true→reverse the direction of the first diagonal (default=true)flipTriangleWinding
- true→left-hand winding of triangles (default=false)useDiamond
- true→diagonals alternate on both horizontal axes (default=false)useZigzag
- true→diagonals alternate on one horizontal axis (default=false)
-
-
Method Details
-
countColumns
public int countColumns()Count how many columns are in the heightfield.- Returns:
- the count (≥2)
-
countMeshVertices
public int countMeshVertices()Count how many heights are in the heightfield.- Returns:
- the count (≥4)
-
countRows
public int countRows()Count how many rows are in the heightfield.- Returns:
- the count (≥2)
-
upAxis
public int upAxis()Return the index of the height axis.- Returns:
- the axis index: 0→X, 1→Y, 2→Z
-
toSplittableShape
Approximate this shape with a splittable shape.- Overrides:
toSplittableShape
in classCollisionShape
- Returns:
- a new splittable shape
-