在Irrlicht中的人物添加武器 其实相当简单:找到关节然后attach上去就ok了。
scene::IAnimatedMesh* pManMesh = smgr->getMesh("../../media/noblade.ms3d");
scene::IAnimatedMeshSceneNode* pnMan = smgr->addAnimatedMeshSceneNode( pManMesh );
pnMan->setMaterialTexture(0, driver->getTexture("../../media/skin.jpg"));
pnMan->setMaterialFlag(video::EMF_LIGHTING, false);
pnMan->setPosition(core::vector3df(50,50,-60));
pnMan->setScale(core::vector3df(5,5,5));
pnMan->setAnimationSpeed(25*10);
// this is a scene node where we can attach things to joints
scene::ISceneNode* pJointNode = pnMan->getMS3DJointNode("leftWeaponJoint");
if(pJointNode)
{
scene::IAnimatedMesh* pWeapon = smgr->getMesh("../../media/blade.ms3d");
scene::IAnimatedMeshSceneNode* pnWeapon = smgr->addAnimatedMeshSceneNode( pWeapon );
pnWeapon->setScale(core::vector3df(2,2,2));
core::vector3df jointPos = pJointNode->getAbsolutePosition();
//pnWeapon->setPosition(jointPos);
pJointNode->addChild( pnWeapon );
printf("Join weapon to body, x=%d, y=%d, z=%d\n", jointPos.X, jointPos.Y, jointPos.Z);
}