|
问题:
一个人物模型,一个装备模型,用装备模型共享人物的骨骼信息...
之后需要重新设置装备模型的骨骼权重,就是说,需要在人物播放跑动动画的时候,只有身子,肩膀的骨骼能影响到装备,其他的都不能影响..这一步怎么做啊..
下面是我的测试代码..把所有骨骼权重都设置成0了.但是总是没有效果..人物模型和装备模型都看不见了 - -
typedef std::map<int,Ogre::Bone*> MBLI;
MBLI blist;
Ogre::SkeletonInstance* SkeleIns = testEnt->getSkeleton();
Ogre::Skeleton::BoneIterator iter = SkeleIns->getBoneIterator();
while (iter.hasMoreElements())
{
Ogre::Bone* bone = iter.getNext();
blist.insert(MBLI::value_type(bone->getHandle(),bone));
}
Ogre::Mesh::SubMeshIterator ni = mSword->getMesh()->getSubMeshIterator();
while (ni.hasMoreElements())
{
Ogre::SubMesh* mSub = ni.getNext();
Ogre::SubMesh::BoneAssignmentIterator itor = mSub->getBoneAssignmentIterator();
std::vector<Ogre::VertexBoneAssignment> VBAV;
while (itor.hasMoreElements())
{
Ogre::VertexBoneAssignment vba = itor.getNext();
int weight = vba.weight;
MBLI::iterator it = blist.find(vba.boneIndex);
Ogre::Bone* mB = blist[vba.boneIndex];
std::string mBName = mB->getName();
vba.weight = 0;
VBAV.push_back(vba);
}
mSub->clearBoneAssignments();
for (std::vector<Ogre::VertexBoneAssignment>::iterator i = VBAV.begin(); i != VBAV.end(); i++)
{
Ogre::VertexBoneAssignment vba = (*i);
mSub->addBoneAssignment(vba);
}
mSub->_compileBoneAssignments();
}
如果把mSub->_compileBoneAssignments();这一行拿掉...就没有任何效果,两个模型都能看见,但是装备模型会散架.
|
|