Ogre::Terrain + OgreOde::TerrainGeometry

Mrowa

21-07-2010 23:35:41

Hi everyone.

I'm trying to add collision with terrain to my project. I saw source code of Landscape demo, but it doesn't helped me. Well, maybe some information at beginning will helped you understand my problem. I'm using .scene format, so I use OctreeSceneManager, TerrainGroup, but i have only one page. I get this only one Terrain from group, get informations and I'm creating OgreOde::TerrainGeometry. After define and load terrain i do this:


Ogre::Terrain *terrain = mTerrainGroup->getTerrain(pageX, pageY);

int nodes_per_side = terrain->getSize();
Ogre::Real world_size = terrain->getWorldSize();
Ogre::Vector3 scale = Ogre::Vector3(world_size / (nodes_per_side-1), terrain->getMaxHeight(), world_size / (nodes_per_side-1));

mTerrainGeometry = new OgreOde::TerrainGeometry(world, world->getDefaultSpace(), scale, nodes_per_side, nodes_per_side, world_size, world_size, false);


I don't know Is "world_size / (nodes_per_side-1)" good calculation, but I look on source code of Landscape, check constructor arguments values and size and world size of terrain in demo and when i do this calculations i get right result. But my problem is that program crashes when TerrainGeometry is creating. I get that message.


Uploaded with ImageShack.us

I tried put false and true in the last parameter of constructor.
I don't know, maybe i missed something.

EDIT:
I got this error in debug mode, in release i got something about that my scene manager doesn't have something with scene query. I change scene manager type to ST_EXTERIOR_CLOSE. Everything seems to be OK, but collisions doesn't work. My object go through the terrain :? .

EDIT 2:
Maybe it will help somebody. I solved this: I created Manual Object. Get height of all terrain's vertices and create terrain mesh in that way. Next I got entity from manual object and create TriangleMeshGeometry. It works, but i think it isn't the best way :).


Thx for help and sorry for my English
Mrowa