本文整理汇总了C++中ogre::Bone::addChild方法的典型用法代码示例。如果您正苦于以下问题:C++ Bone::addChild方法的具体用法?C++ Bone::addChild怎么用?C++ Bone::addChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::Bone
的用法示例。
在下文中一共展示了Bone::addChild方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: doExportSkeleton
//.........这里部分代码省略.........
int numBones = msModel_GetBoneCount(pModel);
msg = "Number of bones: " + Ogre::StringConverter::toString(numBones);
logMgr.logMessage(msg);
int i;
// Create all the bones in turn
for (i = 0; i < numBones; ++i)
{
msBone* bone = msModel_GetBoneAt(pModel, i);
Ogre::Bone* ogrebone = ogreskel->createBone(bone->szName);
msVec3 msBonePos, msBoneRot;
msBone_GetPosition(bone, msBonePos);
msBone_GetRotation(bone, msBoneRot);
Ogre::Vector3 bonePos(msBonePos[0], msBonePos[1], msBonePos[2]);
ogrebone->setPosition(bonePos);
// Hmm, Milkshape has chosen a Euler angle representation of orientation which is not smart
// Rotation Matrix or Quaternion would have been the smarter choice
// Might we have Gimbal lock here? What order are these 3 angles supposed to be applied?
// Grr, we'll try our best anyway...
Ogre::Quaternion qx, qy, qz, qfinal;
qx.FromAngleAxis(Ogre::Radian(msBoneRot[0]), Ogre::Vector3::UNIT_X);
qy.FromAngleAxis(Ogre::Radian(msBoneRot[1]), Ogre::Vector3::UNIT_Y);
qz.FromAngleAxis(Ogre::Radian(msBoneRot[2]), Ogre::Vector3::UNIT_Z);
// Assume rotate by x then y then z
qfinal = qz * qy * qx;
ogrebone->setOrientation(qfinal);
Ogre::LogManager::getSingleton().stream()
<< "Bone #" << i << ": " <<
"Name='" << bone->szName << "' " <<
"Position: " << bonePos << " " <<
"Ms3d Rotation: {" << msBoneRot[0] << ", " << msBoneRot[1] << ", " << msBoneRot[2] << "} " <<
"Orientation: " << qfinal;
}
// Now we've created all the bones, link them up
logMgr.logMessage("Establishing bone hierarchy..");
for (i = 0; i < numBones; ++i)
{
msBone* bone = msModel_GetBoneAt(pModel, i);
if (strlen(bone->szParentName) == 0)
{
// Root bone
msg = "Root bone detected: Name='" + Ogre::String(bone->szName) + "' Index="
+ Ogre::StringConverter::toString(i);
logMgr.logMessage(msg);
}
else
{
Ogre::Bone* ogrechild = ogreskel->getBone(bone->szName);
Ogre::Bone* ogreparent = ogreskel->getBone(bone->szParentName);
if (ogrechild == 0)
{
msg = "Error: could not locate child bone '" +
Ogre::String(bone->szName) + "'";
logMgr.logMessage(msg);
continue;
}
if (ogreparent == 0)
{
msg = "Error: could not locate parent bone '"
+ Ogre::String(bone->szParentName) + "'";
logMgr.logMessage(msg);
continue;
}
// Make child
ogreparent->addChild(ogrechild);
}
}
logMgr.logMessage("Bone hierarchy established.");
// Create the Animation(s)
doExportAnimations(pModel, ogreskel);
// Create skeleton serializer & export
Ogre::SkeletonSerializer serializer;
msg = "Exporting skeleton to " + Ogre::String(szFile);
logMgr.logMessage(msg);
serializer.exportSkeleton(ogreskel.getPointer(), szFile);
logMgr.logMessage("Skeleton exported");
msg = "Linking mesh to skeleton file '" + skelName + "'";
Ogre::LogManager::getSingleton().logMessage(msg);
mesh->_notifySkeleton(ogreskel);
return ogreskel;
}