Пример #1
0
void YafFile::loadFile(char* filename)
{
	TiXmlDocument* doc=new TiXmlDocument( filename );
	bool loadOkay = doc->LoadFile();
	if ( !loadOkay )
	{
		printf( "Could not load file '%s'. Error='%s'. Exiting.\n", filename, doc->ErrorDesc() );
		exit( 1 );
	}

	TiXmlElement* yafElement= doc->FirstChildElement( "yaf" );

	if (yafElement == NULL)
	{
		printf("Main yaf block element not found! Exiting!\n");
		exit(1);
	}
	TiXmlElement* globalsElement = yafElement->FirstChildElement( "globals" );
	processGlobals(globalsElement);
	TiXmlElement* lightingElement = yafElement->FirstChildElement("lighting");
	processGlobalLight(lightingElement);
	processLights(lightingElement);
	TiXmlElement* camerasElement = yafElement->FirstChildElement("cameras");
	processCameras(camerasElement);
	TiXmlElement* texturesElement = yafElement->FirstChildElement("textures");
	processTextures(texturesElement);

	TiXmlElement* appearanceElement = yafElement->FirstChildElement("appearances");
	processAppearances(appearanceElement);

	TiXmlElement* animationsElement = yafElement->FirstChildElement("animations");
	if(animationsElement!=NULL)
	{
		processAnimations(animationsElement);
		map<string,Animation*>::iterator it = animations.begin();
		for(;it!=animations.end();it++)
		{
			(*it->second).print();
		}
	}

	TiXmlElement* graphElement = yafElement->FirstChildElement("graph");
	processGraph(graphElement);
}
Пример #2
0
void XMLScene::loadFile()
{
	TiXmlDocument* doc=new TiXmlDocument( filename );
	bool loadOkay = doc->LoadFile();
	if ( !loadOkay )
	{
		printf( "Could not load file '%s'. Error='%s'. Exiting.\n", filename, doc->ErrorDesc() );
		exit( 1 );
	}

	TiXmlElement* anfElement= doc->FirstChildElement( "anf" );

	if (anfElement == NULL)
	{
		printf("Main anf block element not found! Exiting!\n");
		exit(1);
	}
	TiXmlElement* globalsElement = anfElement->FirstChildElement( "globals" );
	processGlobals(globalsElement);
	TiXmlElement* camerasElement = anfElement->FirstChildElement("cameras");
	processCameras(camerasElement);
	TiXmlElement* lightingElement = anfElement->FirstChildElement("lights");
	defineGlobalVariables();
	processLights(lightingElement);
	defineGlobalVariables();
	TiXmlElement* texturesElement = anfElement->FirstChildElement("textures");
	processTextures(texturesElement);

	TiXmlElement* appearanceElement = anfElement->FirstChildElement("appearances");
	processAppearances(appearanceElement);

	TiXmlElement* graphElement = anfElement->FirstChildElement("graph");
	processGraph(graphElement);
	//sets the children to the correct bool
	sceneGraph->setChildDisplay();

}