本文整理汇总了C++中Bone::AddChild方法的典型用法代码示例。如果您正苦于以下问题:C++ Bone::AddChild方法的具体用法?C++ Bone::AddChild怎么用?C++ Bone::AddChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bone
的用法示例。
在下文中一共展示了Bone::AddChild方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReadBoneHierarchy
void OgreXmlSerializer::ReadBoneHierarchy(Skeleton *skeleton)
{
if (skeleton->bones.empty()) {
throw DeadlyImportError("Cannot read <bonehierarchy> for a Skeleton without bones");
}
while(NextNode() == nnBoneParent)
{
const std::string name = ReadAttribute<std::string>("bone");
const std::string parentName = ReadAttribute<std::string>("parent");
Bone *bone = skeleton->BoneByName(name);
Bone *parent = skeleton->BoneByName(parentName);
if (bone && parent)
parent->AddChild(bone);
else
throw DeadlyImportError("Failed to find bones for parenting: Child " + name + " for parent " + parentName);
}
// Calculate bone matrices for root bones. Recursively calculates their children.
for (size_t i=0, len=skeleton->bones.size(); i<len; ++i)
{
Bone *bone = skeleton->bones[i];
if (!bone->IsParented())
bone->CalculateWorldMatrixAndDefaultPose(skeleton);
}
}
示例2: bone
SkeletonSprite::SkeletonSprite(const String& filename) : Sprite(NULL) {
// Cargamos los datos del XML
SkeletonData* data = new SkeletonData(filename);
root = new Bone("world", NULL, 0, 0, 0, 0);
// Generamos huesos
for ( uint32 i = 0; i < data->GetBoneDatas().Size(); i++ ) {
// Obtenemos hueso
const BoneData& boneData = data->GetBoneDatas()[i];
// Obtenemos padre del hueso
Bone* parent = root;
if ( boneData.GetParentName() != "world" )
parent = root->FindChild(boneData.GetParentName());
// Obtenemos imagen
Image* image = ResourceManager::Instance().LoadImage(filename.ExtractDir() + "/" + boneData.GetImageFilename());
// Creamos hueso
Bone bone(boneData.GetId(), image, boneData.GetPivotX(), boneData.GetPivotY(), boneData.GetHandleX(), boneData.GetHandleY());
// Aniadimos frames
for ( uint32 i = 0; i < boneData.GetFrames().Size(); i++ )
bone.AddFrame(boneData.GetFrames()[i]);
// Aniadimos hueso
parent->AddChild(bone);
}
// Establecemos el rango de la animacion
const Bone* bone = root->GetChild(0);
int32 lastframe = 0;
for ( uint32 index = 0; index < bone->CountFrames(); index++ ) {
lastframe = max(lastframe, bone->GetFrame(index)->GetId());
}
SetFrameRange(0, lastframe);
// Eliminamos los datos cargados del XML
delete data;
}