Critter::createBody what is the name of created entity?

lordmonkey

23-04-2011 14:26:17

Hello,
as in the topic: I would like to know what is the name of Entity created together with the critter::body. As the function description says :
/** \brief Create a Body; alternate helper function, Which creates the SceneNode and Entity "meshName" for you. */

but when I create a body with e.g. "boy.mesh" and then try to access it like this :
mSceneMgr->getEntity("boy.mesh");
or
mSceneMgr->getEntity("boy");
Ogre says that this entity does not exist.

betajaen

23-04-2011 14:28:48

Ogre usually creates the name which is usually an unique string.

If you need to get access to the entity. Then the Critter::Node class (mBody->getNode()), has plenty of helper functions for you to get at it.

lordmonkey

23-04-2011 14:35:19

Yeah I have seen this Critter::Node.

But maybe there is another solution for me: what I want to do is to assign a material to the object - maybe I should attach it to other member of Body in Critter ?

betajaen

23-04-2011 15:23:22

Just do it the normal way you would do it in Ogre. Get the Entity then set the Material.

lordmonkey

23-04-2011 15:31:15

hmm... yes but I do not know how to access the entity created like that in critter :
Critter::BodyDescription bodyDescription;
bodyDescription.mMass = 100.0f;

NxOgre::BoxDescription boxDecr = NxOgre::BoxDescription(30,10,10);

mBody = mRenderSystem->createBody(boxDecr , NxOgre::Matrix44::IDENTITY, "dominik1.mesh", bodyDescription);

mBody->setGlobalPosition(0,50,0);
mBody->getNode()->setScale(1);


mBody->getNode() does not have any method to access an entity associated with it. Anyway I have launched my Ogre application now and the material is set properly without any code - I think just renaming the material file name to the same as mesh file did the trick - BUT still - I don't know how to access this entity.

betajaen

23-04-2011 15:45:29

There are two ways of getting the Entity. The Ogre way or the NxOgre way.

static_cast<Entity*>(mSceneNode->getMovableObject(0))

getNode()->getEntityAt(0);


Both could be found by looking at the class header, or letting intellisense show you the member functions. A little bit of research in the future, please.

lordmonkey

23-04-2011 16:18:13

Thanks again betajaen. I will do more research next time I promise :) but I have to admit that more documentation or Wiki on Critter and/or NxOgre would great :) (I have found something on github but it is incomplete and it is really hard sometimes to find what particular function does or things like that.

And in some parts of NxOgre really cool and informative comments can be found although in other parts there are no comments whatsoever :(