DirectX and btHeightfieldTerrainShape are they compatible?

mickey
Posts: 107
Joined: Fri Sep 19, 2008 6:08 pm

DirectX and btHeightfieldTerrainShape are they compatible?

Post by mickey »

I'm sure they are, but its driving me nuts.

I copied the code from VehicleDemo - constructing the vertex and index buffer using DX - setting camera, projection and world matrices etc and the sphere mesh i drop above just won't collide with the terrain mesh.

I must be missing something, must be the coordinate system? I added no additional function call than what is already in the vehicle demo.

Any insights would be really great!

Thanks in advance!
mickey
Posts: 107
Joined: Fri Sep 19, 2008 6:08 pm

Re: DirectX and btHeightfieldTerrainShape are they compatible?

Post by mickey »

Nevermind, I got it working by debugging the terrain shape using btTriangleCallback and creating a vertex buffer from calling btHeightfieldTerrainShape::processAllTriangles(...).

But would anyone care to explain why the max height is being divided by 65535 to limit the height?

unsigned char heightFieldValue = m_heightfieldDataUnsignedChar[(y*m_heightStickWidth)+x];
val = heightFieldValue* (m_maxHeight/btScalar(65535));

Usually i see it done this way if for instance a height map file has a max value of 255:

( currentHeightInHeightMap / 255 ) * maxHeight;

to limit the height.

Thanks.