btHeightTerrainShape inverted?

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

btHeightTerrainShape inverted?

Post by mickey »

Hi

When i do a call on processAllTriangles to create and render the shape, it seems to be a inverted in DX?

I believe it has something to do with this one (btHeightfieldTerrainShape::getVertex):

Code: Select all

	case 1:
		{
			vertex.setValue(
			(-m_width/btScalar(2.0)) + x,
			height,
			(-m_length/btScalar(2.0)) + y
			);
			break;
		};
But I'm not sure what it is exactly. So what I did is i copied the same algorithm to construct my terrain mesh but then I had to set my directional lights going up in the Y axis, instead of going down the Y axis so that tells me that the mesh is inverted.
mickey
Posts: 107
Joined: Fri Sep 19, 2008 6:08 pm

Re: btHeightTerrainShape inverted?

Post by mickey »

Hi

Can anyone explain? I must be confuse. Also on a related post I was asking this:

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!