OSM scene and Tree collision

aida

22-08-2007 10:56:29

Hi

Is there a similar code as the following to parse an osm scene file to build a treecollision (the following code uses the dotSceneManager plugin i.e. parses a .scene file)


//needs Plugin_DotSceneManager.dll
DotSceneOctreeManager * mDotSceneMgr = (DotSceneOctreeManager *)root->createSceneManager("DotSceneOctreeManager");
mDotSceneMgr->setWorldGeometry("scene.scene");

int numMeshes;
mDotSceneMgr->getOption("NumMeshes", &numMeshes);
StringVector keyss;
mDotSceneMgr->getOptionKeys(keyss);
for (int meshIndex = 0; meshIndex < numMeshes; meshIndex++)
{
int numVerts = 0;
mDotSceneMgr->getOption("NumVertices" + StringConverter::toString(meshIndex), &numVerts);
int numIndices = 0;
mDotSceneMgr->getOption("NumIndex" + StringConverter::toString(meshIndex), &numIndices);
float* vertPtr = 0;
mDotSceneMgr->getOption("VerticesPtr" + StringConverter::toString(meshIndex), &vertPtr);
int* indicesPtr = 0;
mDotSceneMgr->getOption("IndexPtr" + StringConverter::toString(meshIndex), &indicesPtr);
OgreNewt::CollisionPrimitives::TreeCollision* col_dotscene
= new OgreNewt::CollisionPrimitives::TreeCollision
(pWorld,numVerts,numIndices,vertPtr,indicesPtr, true);
OgreNewt::Body* bod = new OgreNewt::Body(pWorld, col_dotscene);
delete col_dotscene;
}


It's just that I use ofusion to export meshes from 3DSMax and create the scene in Ogre. So I already parse the osm file once to load the scene. It's a shame to do it again with dotSceneManager to build the collision body....

ProfesorX

24-08-2007 20:40:25

use TreeCollisionSceneParser::parseScene (Ogre::SceneNode *startNode, bool optimize=false), if you want all nodes, use The Root SceneNode as the parent (start) node, like the following example:


OgreNewt::CollisionPrimitives::TreeCollisionSceneParser* col;
col = new OgreNewt::CollisionPrimitives::TreeCollisionSceneParser(m_World);

col->parseScene(mSceneMgr->getRootSceneNode());

OgreNewt::Body* bod = new OgreNewt::Body(m_World, col);