dbrock
21-12-2007 01:10:31
Does this seem like the proper way to be setting up a character?
It seems like a waste because I have to create an entity and a node to get the dimensions of my mesh to create the character, then use mCharacter->attachMesh( "donkey.mesh" ) to create the visible character, which is a 2nd entity to be created, along with mCharacter->createNode().
Does it also matter in which order you call createNode and attachMesh?
Ogre::Entity *charEntity = mSceneMgr->createEntity( "Entity", "Donkey.mesh" );
Ogre::SceneNode *charNode = mSceneMgr->getRootSceneNode()->createChildSceneNode( "Entity" );
charNode->attachObject( charEntity );
charNode->setScale( Ogre::Vector3(1, 1, 1) );
charNode->showBoundingBox( true );
Ogre::AxisAlignedBox charAAB = charNode->getAttachedObject( "Entity" )->getBoundingBox();
Ogre::Vector3 min = ( charAAB.getMinimum() * charNode->getScale() );
Ogre::Vector3 max = ( charAAB.getMaximum() * charNode->getScale() );
Ogre::Vector3 center = ( charAAB.getCenter() * charNode->getScale() );
Ogre::Vector3 size( fabs( max.x - min.x), fabs( max.y - min.y), fabs( max.z - min.z ) );
NxOgre::CharacterParams characterParams;
characterParams.setToDefault();
characterParams.mDimensions.set( NxVec3( size.x, size.y, size.z ) );
characterParams.mType = NxOgre::CharacterParams::CT_Box;
mCharacter = mPhysScene->createCharacter(
"Player_Donkey",
NxOgre::Pose( Ogre::Vector3( 430, 230, 984 ), Ogre::Quaternion::IDENTITY ),
characterParams
);
It seems like a waste because I have to create an entity and a node to get the dimensions of my mesh to create the character, then use mCharacter->attachMesh( "donkey.mesh" ) to create the visible character, which is a 2nd entity to be created, along with mCharacter->createNode().
Does it also matter in which order you call createNode and attachMesh?