@NoOffset @Properties(inherit=BulletCollision.class) public class btHeightfieldTerrainShape extends btConcaveShape
The heightfield can be dynamic so long as the min/max height values capture the extremes (heights must always be in that range).
The local origin of the heightfield is assumed to be the exact center (as determined by width and length and height, with each axis multiplied by the localScaling).
\b NOTE: be careful with coordinates. If you have a heightfield with a local min height of -100m, and a max height of +500m, you may be tempted to place it at the origin (0,0) and expect the heights in world coordinates to be -100 to +500 meters. Actually, the heights will be -300 to +300m, because bullet will re-center the heightfield based on its AABB (which is determined by the min/max heights). So keep in mind that once you create a btHeightfieldTerrainShape object, the heights will be adjusted relative to the center of the AABB. This is different to the behavior of many rendering engines, but is useful for physics engines.
Most (but not all) rendering and heightfield libraries assume upAxis = 1 (that is, the y-axis is "up"). This class allows any of the 3 coordinates to be "up". Make sure your choice of axis is consistent with your rendering system.
The heightfield heights are determined from the data type used for the heightfieldData array.
- unsigned char: height at a point is the uchar value at the grid point, multipled by heightScale. uchar isn't recommended because of its inability to deal with negative values, and low resolution (8-bit).
- short: height at a point is the short int value at that grid point, multipled by heightScale.
- float or dobule: height at a point is the value at that grid point.
Whatever the caller specifies as minHeight and maxHeight will be honored. The class will not inspect the heightfield to discover the actual minimum or maximum heights. These values are used to determine the heightfield's axis-aligned bounding box, multiplied by localScaling.
For usage and testing see the TerrainDemo.
| Modifier and Type | Class and Description |
|---|---|
static class |
btHeightfieldTerrainShape.Range |
Pointer.CustomDeallocator, Pointer.Deallocator, Pointer.NativeDeallocator, Pointer.ReferenceCounter| Constructor and Description |
|---|
btHeightfieldTerrainShape(int heightStickWidth,
int heightStickLength,
byte[] heightfieldData,
double heightScale,
double minHeight,
double maxHeight,
int upAxis,
boolean flipQuadEdges) |
btHeightfieldTerrainShape(int heightStickWidth,
int heightStickLength,
ByteBuffer heightfieldData,
double heightScale,
double minHeight,
double maxHeight,
int upAxis,
boolean flipQuadEdges) |
btHeightfieldTerrainShape(int heightStickWidth,
int heightStickLength,
BytePointer heightfieldData,
double heightScale,
double minHeight,
double maxHeight,
int upAxis,
boolean flipQuadEdges) |
btHeightfieldTerrainShape(int heightStickWidth,
int heightStickLength,
double[] heightfieldData,
double minHeight,
double maxHeight,
int upAxis,
boolean flipQuadEdges) |
btHeightfieldTerrainShape(int heightStickWidth,
int heightStickLength,
DoubleBuffer heightfieldData,
double minHeight,
double maxHeight,
int upAxis,
boolean flipQuadEdges) |
btHeightfieldTerrainShape(int heightStickWidth,
int heightStickLength,
DoublePointer heightfieldData,
double minHeight,
double maxHeight,
int upAxis,
boolean flipQuadEdges) |
btHeightfieldTerrainShape(int heightStickWidth,
int heightStickLength,
float[] heightfieldData,
double minHeight,
double maxHeight,
int upAxis,
boolean flipQuadEdges) |
btHeightfieldTerrainShape(int heightStickWidth,
int heightStickLength,
FloatBuffer heightfieldData,
double minHeight,
double maxHeight,
int upAxis,
boolean flipQuadEdges) |
btHeightfieldTerrainShape(int heightStickWidth,
int heightStickLength,
FloatPointer heightfieldData,
double minHeight,
double maxHeight,
int upAxis,
boolean flipQuadEdges)
preferred constructors
|
btHeightfieldTerrainShape(int heightStickWidth,
int heightStickLength,
Pointer heightfieldData,
double heightScale,
double minHeight,
double maxHeight,
int upAxis,
int heightDataType,
boolean flipQuadEdges)
legacy constructor
/**
This constructor supports a range of heightfield
data types, and allows for a non-zero minimum height value.
|
btHeightfieldTerrainShape(int heightStickWidth,
int heightStickLength,
Pointer heightfieldData,
double maxHeight,
int upAxis,
boolean useFloatData,
boolean flipQuadEdges)
legacy constructor
/**
The legacy constructor assumes the heightfield has a minimum height
of zero.
|
btHeightfieldTerrainShape(int heightStickWidth,
int heightStickLength,
short[] heightfieldData,
double heightScale,
double minHeight,
double maxHeight,
int upAxis,
boolean flipQuadEdges) |
btHeightfieldTerrainShape(int heightStickWidth,
int heightStickLength,
ShortBuffer heightfieldData,
double heightScale,
double minHeight,
double maxHeight,
int upAxis,
boolean flipQuadEdges) |
btHeightfieldTerrainShape(int heightStickWidth,
int heightStickLength,
ShortPointer heightfieldData,
double heightScale,
double minHeight,
double maxHeight,
int upAxis,
boolean flipQuadEdges) |
btHeightfieldTerrainShape(Pointer p)
Pointer cast constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
buildAccelerator() |
void |
buildAccelerator(int chunkSize) |
void |
calculateLocalInertia(double mass,
btVector3 inertia) |
void |
clearAccelerator() |
void |
getAabb(btTransform t,
btVector3 aabbMin,
btVector3 aabbMax)
getAabb returns the axis aligned bounding box in the coordinate frame of the given transform t.
|
BytePointer |
getHeightfieldRawData() |
btVector3 |
getLocalScaling() |
BytePointer |
getName() |
btTriangleInfoMap |
getTriangleInfoMap() |
int |
getUpAxis() |
double |
getUserValue3() |
void |
getVertex(int x,
int y,
btVector3 vertex) |
void |
performRaycast(btTriangleCallback callback,
btVector3 raySource,
btVector3 rayTarget) |
void |
processAllTriangles(btTriangleCallback callback,
btVector3 aabbMin,
btVector3 aabbMax) |
void |
setFlipTriangleWinding(boolean flipTriangleWinding) |
void |
setLocalScaling(btVector3 scaling) |
void |
setTriangleInfoMap(btTriangleInfoMap map) |
void |
setUseDiamondSubdivision() |
void |
setUseDiamondSubdivision(boolean useDiamondSubdivision) |
void |
setUserValue3(double value) |
void |
setUseZigzagSubdivision() |
void |
setUseZigzagSubdivision(boolean useZigzagSubdivision)
could help compatibility with Ogre heightfields.
|
getMargin, setMargincalculateSerializeBufferSize, calculateTemporalAabb, getAngularMotionDisc, getAnisotropicRollingFrictionDirection, getBoundingSphere, getBoundingSphere, getBoundingSphere, getContactBreakingThreshold, getShapeType, getUserIndex, getUserIndex2, getUserPointer, isCompound, isConcave, isConvex, isConvex2d, isInfinite, isNonMoving, isPolyhedral, isSoftBody, serialize, serializeSingleShape, setUserIndex, setUserIndex2, setUserPointeraddress, asBuffer, asByteBuffer, availablePhysicalBytes, calloc, capacity, capacity, close, deallocate, deallocate, deallocateReferences, deallocator, deallocator, equals, fill, formatBytes, free, getDirectBufferAddress, getPointer, getPointer, getPointer, getPointer, hashCode, interruptDeallocatorThread, isNull, isNull, limit, limit, malloc, maxBytes, maxPhysicalBytes, memchr, memcmp, memcpy, memmove, memset, offsetAddress, offsetof, offsetof, parseBytes, physicalBytes, physicalBytesInaccurate, position, position, put, realloc, referenceCount, releaseReference, retainReference, setNull, sizeof, sizeof, toString, totalBytes, totalCount, totalPhysicalBytes, withDeallocator, zeropublic btHeightfieldTerrainShape(Pointer p)
Pointer(Pointer).public btHeightfieldTerrainShape(int heightStickWidth,
int heightStickLength,
@Const
FloatPointer heightfieldData,
@Cast(value="btScalar")
double minHeight,
@Cast(value="btScalar")
double maxHeight,
int upAxis,
@Cast(value="bool")
boolean flipQuadEdges)
public btHeightfieldTerrainShape(int heightStickWidth,
int heightStickLength,
@Const
FloatBuffer heightfieldData,
@Cast(value="btScalar")
double minHeight,
@Cast(value="btScalar")
double maxHeight,
int upAxis,
@Cast(value="bool")
boolean flipQuadEdges)
public btHeightfieldTerrainShape(int heightStickWidth,
int heightStickLength,
@Const
float[] heightfieldData,
@Cast(value="btScalar")
double minHeight,
@Cast(value="btScalar")
double maxHeight,
int upAxis,
@Cast(value="bool")
boolean flipQuadEdges)
public btHeightfieldTerrainShape(int heightStickWidth,
int heightStickLength,
@Const
DoublePointer heightfieldData,
@Cast(value="btScalar")
double minHeight,
@Cast(value="btScalar")
double maxHeight,
int upAxis,
@Cast(value="bool")
boolean flipQuadEdges)
public btHeightfieldTerrainShape(int heightStickWidth,
int heightStickLength,
@Const
DoubleBuffer heightfieldData,
@Cast(value="btScalar")
double minHeight,
@Cast(value="btScalar")
double maxHeight,
int upAxis,
@Cast(value="bool")
boolean flipQuadEdges)
public btHeightfieldTerrainShape(int heightStickWidth,
int heightStickLength,
@Const
double[] heightfieldData,
@Cast(value="btScalar")
double minHeight,
@Cast(value="btScalar")
double maxHeight,
int upAxis,
@Cast(value="bool")
boolean flipQuadEdges)
public btHeightfieldTerrainShape(int heightStickWidth,
int heightStickLength,
@Const
ShortPointer heightfieldData,
@Cast(value="btScalar")
double heightScale,
@Cast(value="btScalar")
double minHeight,
@Cast(value="btScalar")
double maxHeight,
int upAxis,
@Cast(value="bool")
boolean flipQuadEdges)
public btHeightfieldTerrainShape(int heightStickWidth,
int heightStickLength,
@Const
ShortBuffer heightfieldData,
@Cast(value="btScalar")
double heightScale,
@Cast(value="btScalar")
double minHeight,
@Cast(value="btScalar")
double maxHeight,
int upAxis,
@Cast(value="bool")
boolean flipQuadEdges)
public btHeightfieldTerrainShape(int heightStickWidth,
int heightStickLength,
@Const
short[] heightfieldData,
@Cast(value="btScalar")
double heightScale,
@Cast(value="btScalar")
double minHeight,
@Cast(value="btScalar")
double maxHeight,
int upAxis,
@Cast(value="bool")
boolean flipQuadEdges)
public btHeightfieldTerrainShape(int heightStickWidth,
int heightStickLength,
@Cast(value="const unsigned char*")
BytePointer heightfieldData,
@Cast(value="btScalar")
double heightScale,
@Cast(value="btScalar")
double minHeight,
@Cast(value="btScalar")
double maxHeight,
int upAxis,
@Cast(value="bool")
boolean flipQuadEdges)
public btHeightfieldTerrainShape(int heightStickWidth,
int heightStickLength,
@Cast(value="const unsigned char*")
ByteBuffer heightfieldData,
@Cast(value="btScalar")
double heightScale,
@Cast(value="btScalar")
double minHeight,
@Cast(value="btScalar")
double maxHeight,
int upAxis,
@Cast(value="bool")
boolean flipQuadEdges)
public btHeightfieldTerrainShape(int heightStickWidth,
int heightStickLength,
@Cast(value="const unsigned char*")
byte[] heightfieldData,
@Cast(value="btScalar")
double heightScale,
@Cast(value="btScalar")
double minHeight,
@Cast(value="btScalar")
double maxHeight,
int upAxis,
@Cast(value="bool")
boolean flipQuadEdges)
public btHeightfieldTerrainShape(int heightStickWidth,
int heightStickLength,
@Const
Pointer heightfieldData,
@Cast(value="btScalar")
double heightScale,
@Cast(value="btScalar")
double minHeight,
@Cast(value="btScalar")
double maxHeight,
int upAxis,
@Cast(value="PHY_ScalarType")
int heightDataType,
@Cast(value="bool")
boolean flipQuadEdges)
This legacy constructor considers PHY_FLOAT to mean btScalar.
With BT_USE_DOUBLE_PRECISION, it will expect heightfieldData
to be double-precision.
public btHeightfieldTerrainShape(int heightStickWidth,
int heightStickLength,
@Const
Pointer heightfieldData,
@Cast(value="btScalar")
double maxHeight,
int upAxis,
@Cast(value="bool")
boolean useFloatData,
@Cast(value="bool")
boolean flipQuadEdges)
public void setUseDiamondSubdivision(@Cast(value="bool") boolean useDiamondSubdivision)
public void setUseDiamondSubdivision()
public void setUseZigzagSubdivision(@Cast(value="bool") boolean useZigzagSubdivision)
public void setUseZigzagSubdivision()
public void setFlipTriangleWinding(@Cast(value="bool") boolean flipTriangleWinding)
public void getAabb(@Const @ByRef btTransform t, @ByRef btVector3 aabbMin, @ByRef btVector3 aabbMax)
btCollisionShapegetAabb in class btCollisionShapepublic void processAllTriangles(btTriangleCallback callback, @Const @ByRef btVector3 aabbMin, @Const @ByRef btVector3 aabbMax)
processAllTriangles in class btConcaveShapepublic void calculateLocalInertia(@Cast(value="btScalar") double mass, @ByRef btVector3 inertia)
calculateLocalInertia in class btCollisionShapepublic void setLocalScaling(@Const @ByRef btVector3 scaling)
setLocalScaling in class btCollisionShape@Const @ByRef public btVector3 getLocalScaling()
getLocalScaling in class btCollisionShapepublic void performRaycast(btTriangleCallback callback, @Const @ByRef btVector3 raySource, @Const @ByRef btVector3 rayTarget)
public void buildAccelerator(int chunkSize)
public void buildAccelerator()
public void clearAccelerator()
public int getUpAxis()
@Cast(value="const char*") public BytePointer getName()
getName in class btCollisionShapepublic btTriangleInfoMap getTriangleInfoMap()
public void setTriangleInfoMap(btTriangleInfoMap map)
@Cast(value="const unsigned char*") public BytePointer getHeightfieldRawData()
Copyright © 2024. All rights reserved.