btHeightfieldTerrainShape Class Reference

btHeightfieldTerrainShape simulates a 2D heightfield terrain More...

#include <btHeightfieldTerrainShape.h>

Inheritance diagram for btHeightfieldTerrainShape:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 btHeightfieldTerrainShape (int heightStickWidth, int heightStickLength, void *heightfieldData, btScalar maxHeight, int upAxis, bool useFloatData, bool flipQuadEdges)
 legacy constructor
 btHeightfieldTerrainShape (int heightStickWidth, int heightStickLength, void *heightfieldData, btScalar heightScale, btScalar minHeight, btScalar maxHeight, int upAxis, PHY_ScalarType heightDataType, bool flipQuadEdges)
 preferred constructor
virtual void calculateLocalInertia (btScalar mass, btVector3 &inertia) const
virtual void getAabb (const btTransform &t, btVector3 &aabbMin, btVector3 &aabbMax) const
 getAabb returns the axis aligned bounding box in the coordinate frame of the given transform t.
virtual const btVector3 & getLocalScaling () const
virtual const char * getName () const
virtual void processAllTriangles (btTriangleCallback *callback, const btVector3 &aabbMin, const btVector3 &aabbMax) const
virtual void setLocalScaling (const btVector3 &scaling)
void setUseDiamondSubdivision (bool useDiamondSubdivision=true)
virtual ~btHeightfieldTerrainShape ()

Protected Member Functions

virtual btScalar getRawHeightFieldValue (int x, int y) const
void getVertex (int x, int y, btVector3 &vertex) const
void initialize (int heightStickWidth, int heightStickLength, void *heightfieldData, btScalar heightScale, btScalar minHeight, btScalar maxHeight, int upAxis, PHY_ScalarType heightDataType, bool flipQuadEdges)
 protected initialization
void quantizeWithClamp (int *out, const btVector3 &point, int isMax) const

Protected Attributes

union {
   btScalar *   m_heightfieldDataFloat
   short *   m_heightfieldDataShort
   void *   m_heightfieldDataUnknown
   unsigned char *   m_heightfieldDataUnsignedChar
}; 
bool m_flipQuadEdges
PHY_ScalarType m_heightDataType
btScalar m_heightScale
int m_heightStickLength
int m_heightStickWidth
 terrain data
btScalar m_length
btVector3 m_localAabbMax
btVector3 m_localAabbMin
btVector3 m_localOrigin
btVector3 m_localScaling
btScalar m_maxHeight
btScalar m_minHeight
int m_upAxis
bool m_useDiamondSubdivision
btScalar m_width

Detailed Description

btHeightfieldTerrainShape simulates a 2D heightfield terrain

The caller is responsible for maintaining the heightfield array; this class does not make a copy.

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).

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.

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.

Definition at line 71 of file btHeightfieldTerrainShape.h.


Constructor & Destructor Documentation

btHeightfieldTerrainShape::btHeightfieldTerrainShape ( int  heightStickWidth,
int  heightStickLength,
void *  heightfieldData,
btScalar  heightScale,
btScalar  minHeight,
btScalar  maxHeight,
int  upAxis,
PHY_ScalarType  heightDataType,
bool  flipQuadEdges 
)

preferred constructor

This constructor supports a range of heightfield data types, and allows for a non-zero minimum height value. heightScale is needed for any integer-based heightfield data types.

btHeightfieldTerrainShape::btHeightfieldTerrainShape ( int  heightStickWidth,
int  heightStickLength,
void *  heightfieldData,
btScalar  maxHeight,
int  upAxis,
bool  useFloatData,
bool  flipQuadEdges 
)

legacy constructor

The legacy constructor assumes the heightfield has a minimum height of zero. Only unsigned char or floats are supported. For legacy compatibility reasons, heightScale is calculated as maxHeight / 65535 (and is only used when useFloatData = false).

virtual btHeightfieldTerrainShape::~btHeightfieldTerrainShape (  )  [virtual]

Member Function Documentation

virtual void btHeightfieldTerrainShape::calculateLocalInertia ( btScalar  mass,
btVector3 &  inertia 
) const [virtual]

Implements btCollisionShape.

virtual void btHeightfieldTerrainShape::getAabb ( const btTransform t,
btVector3 &  aabbMin,
btVector3 &  aabbMax 
) const [virtual]

getAabb returns the axis aligned bounding box in the coordinate frame of the given transform t.

Implements btCollisionShape.

virtual const btVector3& btHeightfieldTerrainShape::getLocalScaling (  )  const [virtual]

Implements btCollisionShape.

virtual const char* btHeightfieldTerrainShape::getName (  )  const [inline, virtual]

Implements btCollisionShape.

Definition at line 157 of file btHeightfieldTerrainShape.h.

virtual btScalar btHeightfieldTerrainShape::getRawHeightFieldValue ( int  x,
int  y 
) const [protected, virtual]
void btHeightfieldTerrainShape::getVertex ( int  x,
int  y,
btVector3 &  vertex 
) const [protected]
void btHeightfieldTerrainShape::initialize ( int  heightStickWidth,
int  heightStickLength,
void *  heightfieldData,
btScalar  heightScale,
btScalar  minHeight,
btScalar  maxHeight,
int  upAxis,
PHY_ScalarType  heightDataType,
bool  flipQuadEdges 
) [protected]

protected initialization

Handles the work of constructors so that public constructors can be backwards-compatible without a lot of copy/paste.

virtual void btHeightfieldTerrainShape::processAllTriangles ( btTriangleCallback callback,
const btVector3 &  aabbMin,
const btVector3 &  aabbMax 
) const [virtual]

Implements btConcaveShape.

void btHeightfieldTerrainShape::quantizeWithClamp ( int *  out,
const btVector3 &  point,
int  isMax 
) const [protected]
virtual void btHeightfieldTerrainShape::setLocalScaling ( const btVector3 &  scaling  )  [virtual]

Implements btCollisionShape.

void btHeightfieldTerrainShape::setUseDiamondSubdivision ( bool  useDiamondSubdivision = true  )  [inline]

Definition at line 143 of file btHeightfieldTerrainShape.h.


Member Data Documentation

union { ... } [protected]

Definition at line 95 of file btHeightfieldTerrainShape.h.

Definition at line 94 of file btHeightfieldTerrainShape.h.

Definition at line 90 of file btHeightfieldTerrainShape.h.

Definition at line 89 of file btHeightfieldTerrainShape.h.

Definition at line 91 of file btHeightfieldTerrainShape.h.

Definition at line 88 of file btHeightfieldTerrainShape.h.

Definition at line 85 of file btHeightfieldTerrainShape.h.

Definition at line 80 of file btHeightfieldTerrainShape.h.

terrain data

Definition at line 79 of file btHeightfieldTerrainShape.h.

Definition at line 84 of file btHeightfieldTerrainShape.h.

Definition at line 75 of file btHeightfieldTerrainShape.h.

Definition at line 74 of file btHeightfieldTerrainShape.h.

Definition at line 76 of file btHeightfieldTerrainShape.h.

Definition at line 100 of file btHeightfieldTerrainShape.h.

Definition at line 82 of file btHeightfieldTerrainShape.h.

Definition at line 81 of file btHeightfieldTerrainShape.h.

Definition at line 98 of file btHeightfieldTerrainShape.h.

Definition at line 96 of file btHeightfieldTerrainShape.h.

Definition at line 83 of file btHeightfieldTerrainShape.h.


The documentation for this class was generated from the following file:
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines


bullet
Author(s): Erwin Coumans, ROS package maintained by Tully Foote
autogenerated on Fri Jan 11 10:11:04 2013