Ageia PhysX Terrain

Started by
4 comments, last by jezham 16 years, 1 month ago
My objects wont go below y=0 even though I have set my groundplane to -9999; Above y=0 the object collide nice with the terrain and follow the contours of it. Here is how I create the terrain desc:

NxTriangleMeshDesc mTerrainBlockDesc;
mTerrainBlockDesc.numVertices 			= mVertexBuffer.Size();
mTerrainBlockDesc.numTriangles 			= mIndexBuffer.Size() / 3;
mTerrainBlockDesc.pointStrideBytes		= sizeof(Vec3f);
mTerrainBlockDesc.triangleStrideBytes		= 3*sizeof(unsigned int);
mTerrainBlockDesc.points			= mVertexBuffer.Vertices();
mTerrainBlockDesc.triangles			= mIndexBuffer.Indices();
mTerrainBlockDesc.heightFieldVerticalAxis	= NX_Y;
mTerrainBlockDesc.heightFieldVerticalExtent	= -9999;

And here is how I create the triangle mesh:

NxActor* NxPhysX::CreateTriangleMesh(NxTriangleMeshDesc& desc)
{
	NxTriangleMeshShapeDesc shapedesc;

	// Cooking from memory
	NXU::MemoryWriteBuffer buffer;
	if(_NxCookingInterface->NxCookTriangleMesh(desc, buffer))
	{
		shapedesc.meshData = _PhysicsSDK->createTriangleMesh(NXU::MemoryReadBuffer(buffer.data));

		if (shapedesc.meshData)
		{
			NxActorDesc actorDesc;
			actorDesc.shapes.pushBack(&shapedesc);
			NxActor* actor = _NxScene->createActor(actorDesc);

			return actor;
		}
	}

	return NULL;
}

Advertisement
Sounds like you have an actual ground plane shape created elsewhere.
The only groundplane I have created it this one:

NxPlaneShapeDesc planeDesc;planeDesc.d = -2000;NxActorDesc actorDesc;actorDesc.shapes.pushBack(&planeDesc);mNxScene->createActor(actorDesc);


Removing it doenst help. When removing the terrain all object drop down to the expected -2000;
Hm your code looks normal, except the heightFieldVerticalExtent default is -1000.0
Can't imagine why you have it set 8k below your ground plane's position?

Only other suggestion is to move the triangle mesh up, so it's lowest point is at 0.0
But you shouldn't have to, I've never had this problem with a -1000.0 limit or not setting a limit (not recommended)
I found the problem.
http://members.home.nl/skynet2097/Temp/01.PNG

Terrain object and Water are of the same class. so I was automaticly creating a NxTriangleMeshDesc mTerrainBlockDesc; for the water also.

stupid stupid stupid
Ah, must be winter ;)
Glad you sorted it.

This topic is closed to new replies.

Advertisement