Trying to get entities out of the ofusion hashtable

ColorWolf

27-01-2007 08:44:02

Hi,

I'm trying to get all the entities out of an OSM file so I can do a treecollision with them using mogrenewt...However, the following code only gives me a runtime error. I'm no programming ace so I'm sure it's just something minor that I'm doing wrong but I'm out of ideas.


foreach (DictionaryEntry it in loader.Entities)
{
Entity myent = (Entity)it.Value;
SceneNode myNode = mgr.RootSceneNode.CreateChildSceneNode("test");
myNode.AttachObject(myent);

}


Thanks

cdkeito

27-01-2007 11:12:40

osmloader build nodes for you.

"test" node is one time, but if you have 2 entities?

foreach (DictionaryEntry it in loader.Entities)
{
Entity myent = (Entity)it.Value;
SceneNode myNode = mgr.RootSceneNode.CreateChildSceneNode(myent.Name); //<<<
myNode.AttachObject(myent);

}

or (to test)
foreach (DictionaryEntry it in loader.Entities)
{
mgr.RootSceneNode.CreateChildSceneNode(it.key).AttachObject((Entity)it.Value);

}

Bekas

27-01-2007 14:22:03

the following code only gives me a runtime error
You actually get an Ogre exception (because you are trying to create multiple scene nodes with the same name). In order to see an Ogre exception, check the Mogre demos, they are doing something like this:
try
{
Skeletal app = new Skeletal();
app.Go();
}
catch (System.Runtime.InteropServices.SEHException)
{
// Check if it's an Ogre Exception
if (OgreException.IsThrown)
ExampleApplication.Example.ShowOgreException();
else
throw;
}

smernesto

27-01-2007 18:12:52

oFusion CE creates and setup, ambientlight, shadows,skybox, scenemanager, cameras, lights, Entities, SceneNodes, and if there is no viewports it create one viewport.

If you create it again with the same name you will get an exception.

All the scenenodes created by the osm loader will be also in the scene graph.

ColorWolf

28-01-2007 09:28:44

Thanks a lot guys. Very helpful!