basic support for height fields. They are producing temporary triangles, similar to the plane shape.
VehicleDemo demonstrates heightfield support.
This commit is contained in:
@@ -19,6 +19,7 @@ subject to the following restrictions:
|
|||||||
/// A function that maps user input (throttle) into torque/force applied on the wheels
|
/// A function that maps user input (throttle) into torque/force applied on the wheels
|
||||||
/// with gears etc.
|
/// with gears etc.
|
||||||
#include "btBulletDynamicsCommon.h"
|
#include "btBulletDynamicsCommon.h"
|
||||||
|
#include "BulletCollision/CollisionShapes/btHeightfieldTerrainShape.h"
|
||||||
|
|
||||||
//
|
//
|
||||||
// By default, Bullet Vehicle uses Y as up axis.
|
// By default, Bullet Vehicle uses Y as up axis.
|
||||||
@@ -128,8 +129,9 @@ void VehicleDemo::setupPhysics()
|
|||||||
#endif
|
#endif
|
||||||
m_dynamicsWorld->setDebugDrawer(&debugDrawer);
|
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
|
#ifdef USE_TRIMESH_GROUND
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@@ -197,6 +199,22 @@ const float TRIANGLE_SIZE=20.f;
|
|||||||
bool useQuantizedAabbCompression = true;
|
bool useQuantizedAabbCompression = true;
|
||||||
groundShape = new btBvhTriangleMeshShape(indexVertexArrays,useQuantizedAabbCompression);
|
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 //
|
#endif //
|
||||||
|
|
||||||
btTransform tr;
|
btTransform tr;
|
||||||
@@ -204,6 +222,8 @@ const float TRIANGLE_SIZE=20.f;
|
|||||||
|
|
||||||
tr.setOrigin(btVector3(0,-4.5f,0));
|
tr.setOrigin(btVector3(0,-4.5f,0));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//create ground object
|
//create ground object
|
||||||
localCreateRigidBody(0,tr,groundShape);
|
localCreateRigidBody(0,tr,groundShape);
|
||||||
|
|
||||||
@@ -520,6 +540,12 @@ void VehicleDemo::specialKeyboard(int key, int x, int y)
|
|||||||
|
|
||||||
void VehicleDemo::updateCamera()
|
void VehicleDemo::updateCamera()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
//#define DISABLE_CAMERA 1
|
||||||
|
#ifdef DISABLE_CAMERA
|
||||||
|
DemoApplication::updateCamera();
|
||||||
|
return;
|
||||||
|
#endif //DISABLE_CAMERA
|
||||||
|
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
|
|||||||
Reference in New Issue
Block a user