problem with ManualHeightField

lgomide

25-11-2008 13:55:31

I'm having a problem when trying to create a ManualHeightField, in order to the physics floor coincide with my ogre terrain

here is the code


mSceneMgr -> setWorldGeometry( terrain_cfg );
/*...*/
w = new NxOgre::World("time-controller: ogre");

mScene = w->createScene("Demo de tiro", "renderer: ogre, controller: accumulator, gravity: yes, floor: yes");
mScene->setGravity(Ogre::Vector3(0.0, -9.8*10.0, 0.0));

/* put some bobies */


//trying to put the heightfield
NxOgre::Resources::ManualHeightfield* heightmap = new NxOgre::Resources::ManualHeightfield();
int size = static_cast<Ogre::TerrainSceneManager*>(mSceneMgr)->getPageSize();
Ogre::Vector3 scale = static_cast<Ogre::TerrainSceneManager*>(mSceneMgr)->getScale();

//we're supposing that scale.x == scale.z
size=(int)(size*scale.x);
heightmap->begin(size,size);



for(int i=0;i<=size;i++)
for(int j=0;j<=size;j++)
{ heightmap->sample(static_cast<Ogre::TerrainSceneManager*>(mSceneMgr)->getHeightAt(i,j));
cout <<"I'm in (" <<heightmap->whereAmI().i<<", "<<heightmap->whereAmI().j<<" )"<<endl;
}


NxOgre::Resources::Heightfield* actualHeightmap = heightmap->end();
NxOgre::Resources::ResourceSystem::getSingleton()->addHeightfield("heightmap", actualHeightmap);





but the inner loop always prints (0,0). In fact, the physics floor that appears in the app is a plane, in spite of the graphical terrain being very irregular.

does anyone knows what is wrong?

I'm using NsOgre 1.0.22T2

lgomide

26-11-2008 13:22:52

ok, looks like I've forgotten to create a terrain actor...

but I've seen something strange in the NxOgre source Code :

NxOgreManualHeightField.cpp

int2 ManualHeightfield::whereAmI() const {
int2 coords(0,0);
// probably mSamples->_size() % nbColumns, mSamples->_size() - mSamples->_size() & nbColumns
return coords;
}


looks like a bug, or maybe I've found some unfinished stuff (with a bug)...