.OSM + OgreNewt

lonwolf

14-08-2006 17:43:45

hello, im trying to make the oSceneLoader create a tree collision of each object im exporting... That worked fine untill we've finished the main city from the game. Now it starts crashing when atempting to create its colision objects. The mesh, as entityes are loaded very well and they work. But i think this is to much for ogrenewt. Or am i wrong?

after the entity is attached to the pObjNode ive put this code, that worked on the very begining


SceneNode *pObjNode=createNode(pMeshElem, pSceneRoot);

// Attach the mesh entity to node
pObjNode->attachObject(pEntity);

OgreNewt::Collision* colDotScen = new OgreNewt::CollisionPrimitives::TreeCollision(mWorld, pObjNode, true);
OgreNewt::Body*bodDotScen = new OgreNewt::Body( mWorld, colDotScen );
delete colDotScen;
bodDotScen->attachToNode(pObjNode);
bodDotScen->setPositionOrientation(pObjNode->getPosition(), pObjNode->getOrientation());


is there any way to enhance ogrenewts memory or something like that?

By the way, ive removed some houses and some walls from the city and tryed to insert them into the game and now im getting an assertion failure in OgreSharedPtr, Expresion : pRep

any sugestions walaber what can cause this? pls help, we need to finish this in less then a month, and this is a very annoying problem in our project. :roll: please

walaber

14-08-2006 21:44:47

can you step through the TreeCollision creation, and determine exactly where the crash is occuring? I don't think a (very) large mesh should screw up the TreeCollision generator function...

lonwolf

15-08-2006 10:18:41

well u see thats the problem. Ive put only the walls of the city and used treecolision on them. The result: only 1/4 of the walls had a body (although they were attached in a single mesh) the treeColision suddenly stopped at the gate. It did only a small left part of them after its stoped, and the result was a body that wasnt complete. I tryed with TCSceneParser and finally i have a body for the walls. Ill see what i will do with the houses and street lamps but there is a problem with loadin very large meshes, especialy those made from separate chunks... My whole world ( city + 20 trees + water + terrain) ha s a total of 440.000 of triangles... and when i tryed to make colision objects for the whole city, the game crashed ( i mean sometimes gave an assert error and sometimes just work nonstop and basically it was blocked )..
I will try to insert the houses again ( without the walls ) in the scene but i think the only way it would work with no erors would be to unite them all in one mesh and then use TC, or TCSceneParser, and see which of 'em will work. But that isnt very good because if i wanted to enter one house i wanted to implement Raycasting and see what boy intersects, and if it was a house, load the coresponding interior scene.. So ill need to put the houses one colision body at a time...

I dont know were this problem comes but there is something wrong when dealing with high-poly single/or more meshes. I dont think ive done something wrong because all i did is load the .osm scene and parsed the nodes that had an entity attached to TC, or pass the parent node to TCSceneParser... there is something going on with ogrenewt. Do you have any ideea of ONewts max body "memory"? If so, is there any chance of enhancing it? or perfect TreeColision so crashing when trying to create a colision object wont occur anymore?

Best regards, lonwolf

lonwolf

15-08-2006 12:14:49

after 8 hours of intensive mesh editing, exporting, modifing scale/position rotaion i finally got a body for the city

Unfortunately the whole big city is wrapped up into one whole huge mesh. And making its colison body takes about 1 minute.
In case you were wondering how this city looks like heres some screenshots with it normal, and body-view using OgreNewt::Debug system
it only worked with TreeColSceneParser, becoz TreeColision stops somewhere up the gate the colision building, dont understand why but theres a bug somewhere perhaps in the mesh...


walaber

15-08-2006 17:03:10

remember that the TreeCollision system supports "serialization", where you can save it out to a file, and load it in later to avoid the generation time.

lonwolf

15-08-2006 17:14:32

i would love to do that if there is a way to store this colision object in a file

SceneNode* oras_node=main_var.mSceneMgr->getRootSceneNode()->createChildSceneNode("oras", Vector3(26000,250,21000));
Entity* entz = main_var.mSceneMgr->createEntity("ziduri", "orascuzid.mesh");
oras_node->attachObject(entz);
oras_node->pitch(Degree(90));
oras_node->scale(0.5,0.5,0.5);
OgreNewt::Collision* colz = new OgreNewt::CollisionPrimitives::TreeCollisionSceneParser(mWorld, oras_node, true);
OgreNewt::Body* bodz = new OgreNewt::Body(mWorld, colz);
bodz->attachToNode(oras_node);


but unfortunately i do not know how to do this. Any piece of code is greatly accepted.