basic support for height fields. They are producing temporary triangles, similar to the plane shape.

VehicleDemo demonstrates heightfield support.
This commit is contained in:
ejcoumans 2007-06-27 03:21:00 +00:00
parent 3ca6d7385e
commit 59cb275c9c

View File

@ -19,6 +19,7 @@ subject to the following restrictions:
/// A function that maps user input (throttle) into torque/force applied on the wheels
/// with gears etc.
#include "btBulletDynamicsCommon.h"
#include "BulletCollision/CollisionShapes/btHeightfieldTerrainShape.h"
//
// By default, Bullet Vehicle uses Y as up axis.
@ -128,8 +129,9 @@ void VehicleDemo::setupPhysics()
#endif
m_dynamicsWorld->setDebugDrawer(&debugDrawer);
//m_dynamicsWorld->setGravity(btVector3(0,0,0));
#define USE_TRIMESH_GROUND 1
//#define USE_TRIMESH_GROUND 1
#ifdef USE_TRIMESH_GROUND
int i;
@ -197,6 +199,22 @@ const float TRIANGLE_SIZE=20.f;
bool useQuantizedAabbCompression = true;
groundShape = new btBvhTriangleMeshShape(indexVertexArrays,useQuantizedAabbCompression);
#else
//testing btHeightfieldTerrainShape
int width=128;
int length=128;
unsigned char* heightfieldData = new unsigned char[width*length];
// mRawData = new unsigned char [mSize*mSize]; //allocate memory for data
// loadFile(filename,mSize*mSize,mRawData);
btScalar maxHeight = 1.f;
groundShape = new btHeightfieldTerrainShape(width,length,heightfieldData,maxHeight,upIndex);
btVector3 localScaling(10,10,10);
localScaling[upIndex]=1.f;
groundShape->setLocalScaling(localScaling);
#endif //
btTransform tr;
@ -204,6 +222,8 @@ const float TRIANGLE_SIZE=20.f;
tr.setOrigin(btVector3(0,-4.5f,0));
//create ground object
localCreateRigidBody(0,tr,groundShape);
@ -520,6 +540,12 @@ void VehicleDemo::specialKeyboard(int key, int x, int y)
void VehicleDemo::updateCamera()
{
//#define DISABLE_CAMERA 1
#ifdef DISABLE_CAMERA
DemoApplication::updateCamera();
return;
#endif //DISABLE_CAMERA
glMatrixMode(GL_PROJECTION);
glLoadIdentity();