Entity* ninja = mSceneMgr->createEntity("ninja", "ninja.mesh");
mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(ninja);
Entity* robot = mSceneMgr->createEntity("robot", "robot.mesh");
SceneNode* node = mSceneMgr->getRootSceneNode()->createChildSceneNode(Vector3(100.0f, 0.0f, 0.0f), Quaternion(Radian(Math::PI / 2), Vector3::UNIT_Y));
node->attachObject(robot);
robot->getMesh()->_notifySkeleton(const_cast<SkeletonPtr&>(ninja->getMesh()->getSkeleton()));
robot->shareSkeletonInstanceWith(ninja);
VertexBoneAssignment vba;
size_t vertexCount, i;
Bone* bone;
SubMesh* submesh;
Skeleton::BoneIterator it = ninja->getSkeleton()->getBoneIterator();
while (it.hasMoreElements())
{
bone = it.getNext();
if (bone->getName() == "Joint1")
{
Mesh::SubMeshIterator smit = robot->getMesh()->getSubMeshIterator();
while (smit.hasMoreElements())
{
submesh = smit.getNext();
vertexCount = submesh->vertexData->vertexCount;
for (i = 0; i < vertexCount; i++)
{
vba.vertexIndex = i;
vba.boneIndex = bone->getHandle();
vba.weight = 1.0f;
submesh->addBoneAssignment(vba);
}
//submesh->_compileBoneAssignments();
}
break;
}
}
robot散架。不太明白如何设置骨骼的权重,即使我遍历所有顶点,把每根骨头对此顶点的权重都设置为0,依然散架。望赐教。
回复 更多评论