public class HeightfieldCollisionShape extends CollisionShape
This is much more efficient than a regular mesh, but it has a couple limitations:
Modifier and Type | Field and Description |
---|---|
protected java.nio.ByteBuffer |
bbuf
buffer for passing height data to Bullet
|
protected boolean |
flipQuadEdges |
protected float[] |
heightfieldData
array of heightfield samples
|
protected float |
heightScale |
protected int |
heightStickLength
number of columns in the heightfield (>1)
|
protected int |
heightStickWidth
number of rows in the heightfield (>1)
|
protected float |
maxHeight |
protected float |
minHeight |
protected int |
upAxis
index of the height axis (0→X, 1→Y, 2→Z)
|
margin, objectId, scale
Modifier | Constructor and Description |
---|---|
protected |
HeightfieldCollisionShape()
No-argument constructor needed by SavableClassUtil.
|
|
HeightfieldCollisionShape(float[] heightmap)
Instantiate a new shape for the specified height map.
|
|
HeightfieldCollisionShape(float[] heightmap,
Vector3f scale)
Instantiate a new shape for the specified height map and scale vector.
|
Modifier and Type | Method and Description |
---|---|
protected void |
createCollisionHeightfield(float[] heightmap,
Vector3f worldScale) |
Mesh |
createJmeMesh()
Does nothing.
|
protected void |
createShape()
Instantiate the configured shape in Bullet.
|
void |
read(JmeImporter im)
De-serialize this shape, for example when loading from a J3O file.
|
void |
write(JmeExporter ex)
Serialize this shape, for example when saving to a J3O file.
|
finalize, getDefaultMargin, getMargin, getObjectId, getScale, isNonMoving, setDefaultMargin, setMargin, setObjectId, setScale
protected int heightStickWidth
protected int heightStickLength
protected float[] heightfieldData
protected float heightScale
protected float minHeight
protected float maxHeight
protected int upAxis
protected boolean flipQuadEdges
protected java.nio.ByteBuffer bbuf
A Java reference must persist after createShape() completes, or else the buffer might get garbage collected.
protected HeightfieldCollisionShape()
public HeightfieldCollisionShape(float[] heightmap)
heightmap
- (not null, length≥4, length a perfect square)public HeightfieldCollisionShape(float[] heightmap, Vector3f scale)
heightmap
- (not null, length≥4, length a perfect square)scale
- (not null, no negative component, unaffected, default=1,1,1)protected void createCollisionHeightfield(float[] heightmap, Vector3f worldScale)
protected void createShape()
public Mesh createJmeMesh()
public void write(JmeExporter ex) throws java.io.IOException
write
in interface Savable
write
in class CollisionShape
ex
- exporter (not null)java.io.IOException
- from exporterpublic void read(JmeImporter im) throws java.io.IOException
read
in interface Savable
read
in class CollisionShape
im
- importer (not null)java.io.IOException
- from importer