CHICO
03-09-2008 12:11:15
Hey, I'm trying to get terrain working from a manual heightfield but I'm having issues, probably due to a lack of understanding on my part. There are 2 issues that I'm having. The first is that I can't figure out how to get the NxOgre visualization working even though the terrain is displayed in the debugger. The second is that the 2 test cubes fall right through the terrain in the debugger as if the terrain wasn't even there.
Here is a screenshot of the debugger and the associated NxOgre window. You can see that even though there are cube-terrain contacts being generated, the cubes are passing through the terrain.

Here is some of the code I am using (its spread across a few functions):
Any help would be appreciated.
Here is a screenshot of the debugger and the associated NxOgre window. You can see that even though there are cube-terrain contacts being generated, the cubes are passing through the terrain.
Here is some of the code I am using (its spread across a few functions):
//Create World and main scene
NxOgre::PhysXParams pparams;
pparams.mTimeController = NxOgre::PhysXParams::TC_PTR;
pparams.mCustomTimeControllerPtr = time;
world = new NxOgre::World(pparams);
//attach physX driver to time controller
time->physXDriver = world->getPhysXDriver();
//Attach to debugger
world->getPhysXDriver()->createDebuggerConnection();
//Create physics scene
NxOgre::SceneParams sparams;
sparams.mRenderer = NxOgre::SceneParams::RN_OGRE;
sparams.mController = NxOgre::SceneParams::CN_VARIABLE;
sparams.mSceneFlags.mSimulateSeperateThread = false;
sparams.mGravity = NxVec3(0, 0, 0);
sparams.mFloor = false;
sparams.mMaxTimestep = 1.0f;
scene = world->createScene("NABEMphysics",sparams);
//Add land and sea materials
land = scene->createMaterial("land");
land->setAll(0.1,0.1,0.1);
usea = scene->createMaterial("usea");
usea->setAll(0.1,0.1,0.1);
//Start the heighfield creation by initializing the manual heightfield
NxOgre::Resources::ManualHeightfield* mhf = new NxOgre::Resources::ManualHeightfield();
mhf->setTesselation(NxOgre::Resources::ManualHeightfield::TT_TopLeft_to_BottomRight);
mhf->begin(cols, rows);
//Add each data point to the heightfield (row major order)
for(GridMapIndex i = 0; i != rows; ++i)
for(GridMapIndex j = 0; j != cols; ++j)
{
NxMaterialIndex matInd = land;
short datum = (*data)[i][j];
//Set the material for undersea if below sea level
if(datum < 0) matInd = usea;
//Add sample to heightfield
mhf->sample(datum,matInd);
}
//Set how far down the bottom of the heighfield extends
mhf->setThickness(maxHeight - minHeight);
NxOgre::Resources::Heightfield* hf = mhf->end(true);
void SimulationPhysics::addHeightField(NxOgre::Resources::Heightfield *hf, Point3D *botLeft, Point3D *topRight, int maxHeight)
{
//Calculate size of the terrain
double xWidth = topRight->x - botLeft->x;
double yWidth = topRight->y - botLeft->y;
//Set up the terrain parameters
NxOgre::TerrainParams tparams;
tparams.mCentering = NxOgre::TerrainParams::TC_CenterXZ;
tparams.mHoleMaterial = 65535;
tparams.mFlags.mVisualiseTerrain = true;
//Create the terrain
NxOgre::Terrain* terrain = new NxOgre::Terrain(hf, NxOgre::float3(xWidth,maxHeight,yWidth), "", tparams);
scene->createActor("terrain_actor", terrain, Ogre::Vector3(0,0,0), "static: yes");
//Add test object to the scene
NxOgre::ActorParams aparams;
aparams.mMass = 15;
scene->createBody("Cube1; cube.10m.mesh", new NxOgre::Cube(10), Ogre::Vector3(0, 100, 10), aparams);
scene->createBody("Cube2; cube.10m.mesh", new NxOgre::Cube(10), Ogre::Vector3(10,100, 0), aparams);
}
Any help would be appreciated.