Пример #1
0
void OgreXmlSerializer::ReadSkeleton(Skeleton *skeleton)
{
    if (NextNode() != nnSkeleton) {
        throw DeadlyImportError("Root node is <" + m_currentNodeName + "> expecting <skeleton>");
    }

    DefaultLogger::get()->debug("Reading Skeleton");

    // Optional blend mode from root node
    if (HasAttribute("blendmode")) {
        skeleton->blendMode = (ToLower(ReadAttribute<std::string>("blendmode")) == "cumulative"
            ? Skeleton::ANIMBLEND_CUMULATIVE : Skeleton::ANIMBLEND_AVERAGE);
    }

    NextNode();

    // Root level nodes
    while(m_currentNodeName == nnBones         ||
          m_currentNodeName == nnBoneHierarchy ||
          m_currentNodeName == nnAnimations    ||
          m_currentNodeName == nnAnimationLinks)
    {
        if (m_currentNodeName == nnBones)
            ReadBones(skeleton);
        else if (m_currentNodeName == nnBoneHierarchy)
            ReadBoneHierarchy(skeleton);
        else if (m_currentNodeName == nnAnimations)
            ReadAnimations(skeleton);
        else
            SkipCurrentNode();
    }
}
Пример #2
0
    void DiMotionSerializerImpl::ReadSkeleton( DiDataStreamPtr& stream,DiMotion* motion )
    {
        DiSkeleton* skel = motion->CreateSkeleton();
    
        uint16 blendmode;
        ReadShorts(stream,&blendmode,1);
        skel->SetBlendMode(SkeletonBlendMode(blendmode));

        if (!stream->Eof())
        {
            uint16 streamID = ReadChunk(stream);
            while(!stream->Eof() &&
                (streamID == DI_BONES ||
                streamID == DI_BONES_PARENT))
            {
                switch(streamID)
                {
                case DI_BONES:
                    ReadBones(stream,skel);
                    break;

                case DI_BONES_PARENT:
                    ReadBonesParents(stream,skel);
                    break;
                }

                if (!stream->Eof())
                {
                    streamID = ReadChunk(stream);
                }

            }
            if (!stream->Eof())
            {
                stream->Skip(-MSTREAM_OVERHEAD_SIZE);
            }
        }
    }