Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef BT_HEIGHTFIELD_TERRAIN_SHAPE_H
00017 #define BT_HEIGHTFIELD_TERRAIN_SHAPE_H
00018
00019 #include "btConcaveShape.h"
00020
00022
00071 class btHeightfieldTerrainShape : public btConcaveShape
00072 {
00073 protected:
00074 btVector3 m_localAabbMin;
00075 btVector3 m_localAabbMax;
00076 btVector3 m_localOrigin;
00077
00079 int m_heightStickWidth;
00080 int m_heightStickLength;
00081 btScalar m_minHeight;
00082 btScalar m_maxHeight;
00083 btScalar m_width;
00084 btScalar m_length;
00085 btScalar m_heightScale;
00086 union
00087 {
00088 unsigned char* m_heightfieldDataUnsignedChar;
00089 short* m_heightfieldDataShort;
00090 btScalar* m_heightfieldDataFloat;
00091 void* m_heightfieldDataUnknown;
00092 };
00093
00094 PHY_ScalarType m_heightDataType;
00095 bool m_flipQuadEdges;
00096 bool m_useDiamondSubdivision;
00097
00098 int m_upAxis;
00099
00100 btVector3 m_localScaling;
00101
00102 virtual btScalar getRawHeightFieldValue(int x,int y) const;
00103 void quantizeWithClamp(int* out, const btVector3& point,int isMax) const;
00104 void getVertex(int x,int y,btVector3& vertex) const;
00105
00106
00107
00109
00113 void initialize(int heightStickWidth, int heightStickLength,
00114 void* heightfieldData, btScalar heightScale,
00115 btScalar minHeight, btScalar maxHeight, int upAxis,
00116 PHY_ScalarType heightDataType, bool flipQuadEdges);
00117
00118 public:
00120
00125 btHeightfieldTerrainShape(int heightStickWidth,int heightStickLength,
00126 void* heightfieldData, btScalar heightScale,
00127 btScalar minHeight, btScalar maxHeight,
00128 int upAxis, PHY_ScalarType heightDataType,
00129 bool flipQuadEdges);
00130
00132
00138 btHeightfieldTerrainShape(int heightStickWidth,int heightStickLength,void* heightfieldData, btScalar maxHeight,int upAxis,bool useFloatData,bool flipQuadEdges);
00139
00140 virtual ~btHeightfieldTerrainShape();
00141
00142
00143 void setUseDiamondSubdivision(bool useDiamondSubdivision=true) { m_useDiamondSubdivision = useDiamondSubdivision;}
00144
00145
00146 virtual void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const;
00147
00148 virtual void processAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const;
00149
00150 virtual void calculateLocalInertia(btScalar mass,btVector3& inertia) const;
00151
00152 virtual void setLocalScaling(const btVector3& scaling);
00153
00154 virtual const btVector3& getLocalScaling() const;
00155
00156
00157 virtual const char* getName()const {return "HEIGHTFIELD";}
00158
00159 };
00160
00161 #endif //BT_HEIGHTFIELD_TERRAIN_SHAPE_H