游戏开发论坛

 找回密码
 立即注册
搜索
查看: 1975|回复: 0

求助:关于Ogre骨骼共享的问题..

[复制链接]

9

主题

22

帖子

54

积分

注册会员

Rank: 2

积分
54
发表于 2010-10-27 15:36:00 | 显示全部楼层 |阅读模式
问题:
    一个人物模型,一个装备模型,用装备模型共享人物的骨骼信息...
    之后需要重新设置装备模型的骨骼权重,就是说,需要在人物播放跑动动画的时候,只有身子,肩膀的骨骼能影响到装备,其他的都不能影响..这一步怎么做啊..
    下面是我的测试代码..把所有骨骼权重都设置成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();这一行拿掉...就没有任何效果,两个模型都能看见,但是装备模型会散架.
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2025-8-18 08:28

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表