BigB
10-06-2008 10:32:07
Hi,
I'm tryng to integrate PhysX with ET, but so far i haven't had much sucess with it
I have been browsing this forums, and altough i found some information about it, i haven't been able to make this work.
The code i'm using to get the heightmap into PhysX is the following :
And then, i create my actor :
Now, the problem, i don't see the heightmap anywhere, neither inside Ogre, or in Remote Debugging, i see all the other bodys falling, but not the heightmap.
Is there some trivial mistake in my code ?
thanks for any help,
Bruno
I'm tryng to integrate PhysX with ET, but so far i haven't had much sucess with it
I have been browsing this forums, and altough i found some information about it, i haven't been able to make this work.
The code i'm using to get the heightmap into PhysX is the following :
//Copy image data into PhysX as a heightfield
NxHeightFieldDesc mNxHeightFieldDesc;
mNxHeightFieldDesc.nbColumns = 512;
mNxHeightFieldDesc.nbRows = 512;
mNxHeightFieldDesc.verticalExtent = -1000;
mNxHeightFieldDesc.convexEdgeThreshold = 0;
mNxHeightFieldDesc.flags = NX_SF_FEATURE_INDICES | NX_SF_VISUALIZATION;
//Allocate storage for data
mNxHeightFieldDesc.samples = new NxU32[mNxHeightFieldDesc.nbColumns * mNxHeightFieldDesc.nbRows];
mNxHeightFieldDesc.sampleStride = sizeof(NxU32);
NxU8* currentByte = (NxU8*)mNxHeightFieldDesc.samples;
NxU32 index = 0;
NxI16 height = 0;
const Ogre::uchar* pSrc = mRawData->getPtr();
for (NxU32 row = 0; row < mNxHeightFieldDesc.nbRows; row++)
{
for (NxU32 column = 0; column < mNxHeightFieldDesc.nbColumns; column++)
{
NxHeightFieldSample* currentSample = (NxHeightFieldSample*)currentByte;
index = row + (column * mNxHeightFieldDesc.nbRows);
index *= 2;
height = pSrc[index];
height += pSrc[index + 1] * 256.0;
height -= 32768;
currentSample->height = height;
currentSample->materialIndex0 = 0;
currentSample->materialIndex1 = 0;
currentSample->tessFlag = 0;
currentByte += mNxHeightFieldDesc.sampleStride;
}
}
NxHeightField* mHeightField = NXmWorld->getPhysXDriver()->getSDK()->createHeightField(mNxHeightFieldDesc);
//Data has been copied, buffer can be deleted
delete[] mNxHeightFieldDesc.samples;
And then, i create my actor :
static NxReal sixtyFourKb = 65536.0f;
static NxReal thirtyTwoKb = 32767.5f;
NxVec3 size = NxVec3(512,100,512);
// shape
NxHeightFieldShapeDesc heightFieldShapeDesc;
heightFieldShapeDesc.heightField = mHeightField;
heightFieldShapeDesc.shapeFlags = NX_SF_FEATURE_INDICES | NX_SF_VISUALIZATION;
heightFieldShapeDesc.heightScale = size.y / sixtyFourKb;
heightFieldShapeDesc.rowScale = size.x / NxReal(513-1);
heightFieldShapeDesc.columnScale = size.z / NxReal(513-1);
heightFieldShapeDesc.meshFlags = NX_MESH_SMOOTH_SPHERE_COLLISIONS;
heightFieldShapeDesc.materialIndexHighBits = 0;
heightFieldShapeDesc.holeMaterial = 2;
// ator
NxActorDesc actorTerrainDesc;
actorTerrainDesc.globalPose.t = NxVec3(0, 0, 0);
NxActor *newActor = NXpmScene->getNxScene()->createActor(actorTerrainDesc);
Now, the problem, i don't see the heightmap anywhere, neither inside Ogre, or in Remote Debugging, i see all the other bodys falling, but not the heightmap.
Is there some trivial mistake in my code ?
thanks for any help,
Bruno