Example #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();
    }
}
Example #2
0
    void DiMotionSerializerImpl::ImportMotion( DiDataStreamPtr& stream, DiMotion* pDest )
    {
        ReadFileHeader(stream);

        if (!stream->Eof())
        {
            uint16 streamID = ReadChunk(stream);
            while(!stream->Eof() &&
                (streamID == DI_SKELETON ||
                streamID == DI_POSE ||
                streamID == DI_ANIMATION))
            {
                switch(streamID)
                {
                case DI_SKELETON:
                    ReadSkeleton(stream,pDest);
                    break;

                case DI_ANIMATION:
                    ReadAnimations(stream, pDest);
                    break;

                case DI_POSE:
                    ReadPoses(stream,pDest);
                    break;
                }

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

            }
            if (!stream->Eof())
                stream->Skip(-MSTREAM_OVERHEAD_SIZE);
        }
    }
Example #3
0
bool ACAMTLoader::LoadFromFile( const CHAR* path, AMT_MODEL* outModel)
{
	// open the file
	mpFile = fopen( path, "rb" );
	if( !mpFile ) return false;

	ReadHeader(outModel);    
	ReadVertices(outModel);  
	ReadFaces(outModel);     
	ReadMesh(outModel);      
	ReadMaterials(outModel);
	ReadJoints(outModel);
	ReadAnimations(outModel);

	return CloseFile( true );
};
Example #4
0
void ColladaParser::Parse(const char* colladaFileData)
{
	XmlParser p;
	p.Parse(colladaFileData);

	if (p.root.tagName != "COLLADA")
		throw "expected COLLADA as root element";

	if (!p.root.HasAttribute("xmlns", "http://www.collada.org/2005/11/COLLADASchema") || !p.root.HasAttribute("version", "1.4.1"))
		throw "expected COLLADA as root element";

	XmlElement* root = &p.root;

	{
		auto v = root->Child("library_geometries")->Childs("geometry");

		for (int ia = 0; ia < v.size(); ia++)
			ReadGeometry(v[ia]);
	}

	if (root->HasChild("library_animations"))
	{
		auto v = root->Child("library_animations")->Childs("animation");

		for (int ia = 0; ia < v.size(); ia++)
			ReadAnimations(v[ia]);
	}

	{
		auto v = root->Child("library_visual_scenes")->Childs("visual_scene");

		for (int ia = 0; ia < v.size(); ia++)
		{
			ReadScene(v[ia]);
		}
	}

	auto sceneId = ReadId(root->Child("scene")->Child("instance_visual_scene")->Attribute("url"));
	currentScene = &scenes[sceneId];
	int x = 2;
}