Monday, January 3, 2011

Terrain and Bullet Physics

I've had the ability to load custom heightmaps based on targa files since pretty much the beginning of the project. When I was writing my own physics procedures for the engine, I was able to access the height values directly and therefore integrate collision between objects and the heightmap seamlessly. However, now that I've integrated Bullet Physics into the engine, I need to come up with a different way to do this.

Currently, as displayed in the last two posted videos, the ground is represented by an infinite plane. The method used to produce this is extremely straightforward:

btCollisionShape* groundShape = new btStaticPlaneShape(btVector3(0,1,0),1);

Likewise, the ability to add a custom heightmap is a one-liner:

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

The only problem is that I am not sure in what form the heightfieldData needs to be passed to the above constructor. Compounding the issue is that documentation is null, and there seems to be no information online regarding proper syntax.

Time for trial and error, I suppose.

No comments:

Post a Comment