How to know entity type

feanor91

23-07-2008 14:52:22

Hello

I'm writing an oFusion scene Viewer in VB .Net to learn how to use Mogre, but I found nothing nowhere to help me to identify if an entity or a scene node is a camera, a mesh or a light. As I want to be able to open any type of scene, I assume, that name of camera or lights may change from one scene to another. By now, I get camera by name but if it change ine another scene.... How can I achive that stuff as I want be able to change camera if ther is more than one, hide/unhide object, change light parameters and over stuff like that too.

If someone is interested by my code, I'll be glad to post it somewhere.

For now, I can open scene, move in it, I show a treelist with hierachical scenemanger in it....I use windows event to take care of input because as I have embeded Ogre in a picturebox, I can't use MOIS to handle them. But I'm happy, after a little week of coding and knowing nothing from Ogre before, I have a satisfying result, so thansk to different wikis and pieces of code found here or elsewhere.

ProfesorX

23-07-2008 19:13:48

In Ogre, there is a getMovableType() method, that returns a string wiith the type of movable (entity, light, camera, etc.)

in Mogre, we have a MovableType property that does the same.

All classes derived from MovableObject have that property (entities, cameras, ...)

many "get" methods in Ogre are implemented in Mogre in the form of properties.

Hope this help you.

feanor91

23-07-2008 21:07:54

Thanks a lot but how can I use it....It works on entitty, camera, lights...But when I use get function on scenmanager, I have an exeption return. For example if I use getentity to return an entity but I have select a camera in my tree, I have exeption. The only way I fund is to catch exeption in cascade ie, I try to get entity, if exeption, i try to get a camera, if exeption, i try to get a light....It works, but it seems not very efficient. And I can't find how to apply movabletype on a higher scene level.

Bekas

23-07-2008 22:06:27

You can use something like this:
MovableObject object = sceneNode.GetAttachedObject(0);
if (object is Entity)
{
...
}
else if (object is Camera)
{
...
}
else
{
...
}

That's an advantage of using Mogre instead of native Ogre.

feanor91

24-07-2008 06:21:17

OK, I see....So it's get a number and not a name....So I will adapt my tree list to put scennode in tag for each node.

Thanks a lot