Body. Creating with existing entity

Lexx

27-03-2007 14:53:08

Hi all.
Is there some way - how to create a nxOgre-body with existing SceneNode and Entity?
i found parameter _params.mNode in constructor of nxOgre_body, but i can't find anything about preloaded Entity...
currently, i'm change some part of nxOgre_body.cpp:
ln 149

NXD("a");
if (_meshName != "") {
[b]if( owner->mSceneMgr->hasEntity(mName) )
mEntity = owner->mSceneMgr->getEntity(mName);
else[/b]
mEntity = owner->mSceneMgr->createEntity(mName + ".entity", _meshName);

if (_params.mShadows)
mEntity->setCastShadows(true);

if (_params.mOrientation != Ogre::Quaternion(1,0,0,0) || _params.mOffset != Ogre::Vector3(0,0,0)) {
Ogre::SceneNode *subNode = mNode->createChildSceneNode(_params.mOffset,_params.mOrientation);
subNode->attachObject(mEntity);
}
else
mNode->attachObject(mEntity);
}
else {
mEntity = 0;
}
NXD("b");

but, it's bad way, i think... So, any solution for me?

betajaen

27-03-2007 15:23:35

That's a little bad, but why not? :D

if( owner->mSceneMgr->hasEntity(_meshName) )
mEntity = owner->mSceneMgr->getEntity(_meshName);
else
mEntity = owner->mSceneMgr->createEntity(mName + ".entity", _meshName);


And just use the entities name as a meshName when you create it.

Lexx

28-03-2007 03:47:00

ok, thx! i'll do it )