void ControlSuper::loadXML(TiXmlElement &root)
{
	root.QueryBoolAttribute("enabled",&enabled);
	root.QueryBoolAttribute("hidden",&hidden);
	root.QueryFloatAttribute("left",  &controlPos.left);
	root.QueryFloatAttribute("right", &controlPos.right);
	root.QueryFloatAttribute("top",   &controlPos.top);
	root.QueryFloatAttribute("bottom",&controlPos.bottom);

}
Example #2
0
void XMLScene::processLights(TiXmlElement* lights)
{
	float position[4], ambient[4], diffuse[4], specular[4];
	float angle = 0, exponent = 0, target[3];
	bool enabled, marked;
	string type;
	char* id;
	Light* light;
	TiXmlElement* element = lights->FirstChildElement();
	TiXmlElement* component = element ->FirstChildElement();
	while(element!=NULL)
	{
		element->QueryBoolAttribute("enabled",&enabled);
		element->QueryBoolAttribute("marker",&marked);
		id = (char*)element->Attribute("id");
		read3Float("pos", element, position[0], position[1], position[2]);
		if(element->Attribute("target")!=NULL)
		{
			type="spot";
			read3Float("target", element, target[0], target[1],
				target[2]);
			read1Float("angle",element, angle);
			read1Float("exponent",element, exponent);

		}
		while(component != NULL)
		{
			if(component->Attribute("type")=="ambient"){
				read4Float("value", element, ambient[0], ambient[1], ambient[2],ambient[3]);
			}

			if(component->Attribute("type")=="diffuse"){
				read4Float("value", element, diffuse[0], diffuse[1], diffuse[2],diffuse[3]);
			}

			if(component->Attribute("type")=="specular"){
				read4Float("value", element, specular[0], specular[1], specular[2],specular[3]);
			}
			component=component->NextSiblingElement();
		}


		light = new Light(id,enabled,type,position,ambient,diffuse,specular,angle,exponent,target,marked);
		this->sceneLights.push_back(light);
		if(enabled)
			activeLights.push_back(1);
		else 
			activeLights.push_back(0);

		element=element->NextSiblingElement();
	}
}
Example #3
0
void YafFile::processLights(TiXmlElement* lights)
{
	float location[4], ambient[4], diffuse[4], specular[4];
	float angle = 0, exponent = 0, direction[3];
	bool enabled;
	string type;
	char* id;
	Light* light;
	TiXmlElement* element = lights->FirstChildElement();
	while(element!=NULL)
	{
		element->QueryBoolAttribute("enabled",&enabled);
		id = (char*)element->Attribute("id");
		read3Float("location", element, location[0], location[1], location[2]);
		read4Float("ambient", element, ambient[0], ambient[1], ambient[2],
			ambient[3]);
		read4Float("diffuse", element, diffuse[0], diffuse[1], diffuse[2],
			diffuse[3]);
		read4Float("specular", element, specular[0], specular[1], specular[2],
			specular[3]);
		if(element->Attribute("angle")!=NULL)
		{
			type="spot";
			element->QueryFloatAttribute("angle", &angle);
			element->QueryFloatAttribute("exponent", &exponent);
			read3Float("direction", element, direction[0], direction[1],
				direction[2]);
		}
		light = new Light(id,enabled,type,location,ambient,diffuse,specular,angle,exponent,direction);
		this->sceneLights.push_back(light);
		element=element->NextSiblingElement();
	}
}
Example #4
0
BOOL GetBkgPingCheckOpt(PBBS_BKG_PINGCHECK_OPT pPingOpt)
{
	TiXmlDocument doc;
	const char *pszCustomDest = NULL;
	bool bOperating = false;
	int nBreakInt = 0;
	int nPingInt = 0;
	int nMaxCount = 0;

	if( CheckValidXML(&doc) == FALSE )
	{
		return FALSE;
	}

	TiXmlElement* pElem = doc.FirstChild("BBS_WiFiConfig")->FirstChild("Setting")->FirstChild("Option")->FirstChildElement("BkgPingCheck");


	pElem->QueryBoolAttribute("Operating", &bOperating);
	pElem->QueryIntAttribute("BreakInterval",  &nBreakInt);
	pElem->QueryIntAttribute("PingInterval", &nPingInt);
	pElem->QueryIntAttribute("MaxCheckCnt", &nMaxCount);
	pszCustomDest = pElem->Attribute("CustomDestAddr");


	pPingOpt->bOperating = bOperating;
	pPingOpt->dwBreakInterval = nBreakInt;
	pPingOpt->dwPingInterval = nPingInt;
	pPingOpt->dwMaxCheckCount = nMaxCount;

	mbstowcs(pPingOpt->tszCustomDestAddr, pszCustomDest, strlen(pszCustomDest));

	return TRUE;
}
wxString Boat::OpenXML(wxString filename)
{
    TiXmlDocument doc;
    if(!doc.LoadFile( filename.mb_str() ))
        return _("Failed to load file");

    TiXmlHandle root( doc.RootElement() );
    if(strcmp(doc.RootElement()->Value(), "OCPNWeatherRoutingBoat"))
        return _("Failed to read xml file (no OCPWeatherRoutingBoat node)");

    bool cleared = false;
    for(unsigned int i=0; i<Plans.size(); i++)
        delete Plans[i];
    Plans.clear();
    
    Plans.push_back(new BoatPlan(_("Initial Plan"), *this));
    Plans[0]->ComputeBoatSpeeds(*this);

    for(TiXmlElement* e = root.FirstChild().Element(); e; e = e->NextSiblingElement()) {
        if(!strcmp(e->Value(), "BoatCharacteristics")) {
            displacement_tons = AttributeDouble(e, "displacement_tons", 4);
            lwl_ft = AttributeDouble(e, "lwl_ft", 24);
            loa_ft = AttributeDouble(e, "loa_ft", 27);
            beam_ft = AttributeDouble(e, "beam_ft", 8);
        } else
        if(!strcmp(e->Value(), "BoatDrag")) {
            frictional_drag = AttributeDouble(e, "frictional_drag", 0);
            wake_drag = AttributeDouble(e, "wake_drag", 0);
        } else
        if(!strcmp(e->Value(), "Plan")) {
            if(!cleared) {
                for(unsigned int i=0; i<Plans.size(); i++)
                    delete Plans[i];
                Plans.clear();
                cleared = true;
            }

            BoatPlan *plan = new BoatPlan(wxString::FromUTF8(e->Attribute("Name")), *this);

            plan->computed = AttributeDouble(e, "computed", 1);

            if(plan->computed) {
                plan->eta = AttributeDouble(e, "eta", .5);
                plan->luff_angle = AttributeDouble(e, "luff_angle", 15);
                plan->wind_speed_step = 3;
                plan->wind_degree_step = DEGREE_STEP;
                plan->ComputeBoatSpeeds(*this);
            } else {
                plan->csvFileName = wxString::FromUTF8(e->Attribute("csvFileName"));
                BoatSpeedTable table;
                if(table.Open(plan->csvFileName.mb_str(), plan->wind_speed_step, plan->wind_degree_step)) {
                    plan->SetSpeedsFromTable(table);
                } else
                    return _("Failed to open file: ") + plan->csvFileName;
            }

            for(TiXmlElement* f = e->FirstChildElement(); f; f = f->NextSiblingElement()) {
                if(!strcmp(e->Value(), "SwitchPlan")) {
                    SwitchPlan switchplan;
                    switchplan.MaxWindSpeed = strtod(f->Attribute("MaxWindSpeed"), 0);
                    switchplan.MinWindSpeed = strtod(f->Attribute("MinWindSpeed"), 0);
                    switchplan.MaxWindDirection = strtod(f->Attribute("MaxWindDirection"), 0);
                    switchplan.MinWindDirection = strtod(f->Attribute("MinWindDirection"), 0);
                    switchplan.MaxWaveHeight = strtod(f->Attribute("MaxWaveHeight"), 0);
                    switchplan.MinWaveHeight = strtod(f->Attribute("MinWaveHeight"), 0);
                    if(f->QueryBoolAttribute("DayTime", &switchplan.DayTime) != TIXML_SUCCESS)
                        switchplan.DayTime = true;
                    if(f->QueryBoolAttribute("NightTime", &switchplan.NightTime) != TIXML_SUCCESS)
                        switchplan.NightTime = true;
                    switchplan.Name = wxString::FromUTF8(f->Attribute("Name"));
                    plan->SwitchPlans.push_back(switchplan);
                }
            }

            Plans.push_back(plan);
        }
    }
    return wxString();
}
Example #6
0
void YafFile::processGraph(TiXmlElement* graphElement)
{
	string rootid=graphElement->Attribute("rootid");
	TiXmlElement* nodeElement = graphElement->FirstChildElement("node");
	sceneGraph = new Graph();
	sceneGraph->setRootId(rootid);
	while(nodeElement!=NULL)
	{
		Node* node = new Node(nodeElement->Attribute("id"));
		bool displaylist=false;
		nodeElement->QueryBoolAttribute("displaylist",&displaylist);
		if(displaylist!=NULL)
			node->setDisplayList(displaylist);

		string animID;
		TiXmlElement* animationsN = nodeElement->FirstChildElement("animationref");
		if(animationsN!=NULL)
			animID=animationsN->Attribute("id");


		TiXmlElement* transformations = nodeElement->FirstChildElement("transforms");
		TiXmlElement* transformation=transformations->FirstChildElement();

		while(transformation!=NULL)
		{
			if(transformation->Attribute("axis")!=NULL)
			{
				string axis=transformation->Attribute("axis");
				float angle;
				transformation->QueryFloatAttribute("angle",&angle);
				Transformation* rot = new Rotation(axis,angle);
				node->addTransformation(rot);
			}
			else if (transformation->Attribute("to")!=NULL)
			{
				float translation[3];
				read3Float("to",transformation,translation[0],translation[1],translation[2]);
				Transformation* translationElement = new Translation(translation[0],translation[1],translation[2]);
				node->addTransformation(translationElement);
			}

			else if (transformation->Attribute("factor")!=NULL)
			{
				float factor[3];
				read3Float("factor",transformation,factor[0],factor[1],factor[2]);
				Transformation* scaling = new Scaling(factor[0],factor[1],factor[2]);
				node->addTransformation(scaling);
			}

			transformation = transformation->NextSiblingElement();
		}

		TiXmlElement* appearanceRef = nodeElement->FirstChildElement("appearanceref");
		if(appearanceRef!=NULL)
		{

			node->setNodeAppearance(make_pair(appearanceRef->Attribute("id"),appearances[appearanceRef->Attribute("id")]));
		}
		else
		{
			node->setNodeAppearance(make_pair("",new Appearance()));
		}
		TiXmlElement* children = nodeElement->FirstChildElement("children");
		TiXmlElement* childrenAnalyzer = children->FirstChildElement();
		while(childrenAnalyzer!=NULL)
		{
			if(childrenAnalyzer->Attribute("xy1")!=NULL)
			{
				float xy1[2],xy2[2];
				read2Float("xy1",childrenAnalyzer,xy1[0],xy1[1]);
				read2Float("xy2",childrenAnalyzer,xy2[0],xy2[1]);
				SceneObject* rectangle = new SceneRectangle(xy1[0],xy1[1],xy2[0],xy2[1]);
				node->addObject(rectangle);
			}

			else if(childrenAnalyzer->Attribute("xyz1")!=NULL)
			{
				float xyz1[3],xyz2[3],xyz3[3];
				read3Float("xyz1",childrenAnalyzer,xyz1[0],xyz1[1],xyz1[2]);
				read3Float("xyz2",childrenAnalyzer,xyz2[0],xyz2[1],xyz2[2]);
				read3Float("xyz3",childrenAnalyzer,xyz3[0],xyz3[1],xyz3[2]);
				SceneObject* triangle = new SceneTriangle(xyz1,xyz2,xyz3);
				node->addObject(triangle);
			}

			else if(childrenAnalyzer->Attribute("base")!=NULL)
			{
				float base,top,height;
				int slices,stacks;
				childrenAnalyzer->QueryFloatAttribute("base",&base);
				childrenAnalyzer->QueryFloatAttribute("top",&top);
				childrenAnalyzer->QueryFloatAttribute("height",&height);
				childrenAnalyzer->QueryIntAttribute("slices",&slices);
				childrenAnalyzer->QueryIntAttribute("stacks",&stacks);
				SceneObject* cylinder = new SceneCylinder(base,top,height,slices,stacks);
				node->addObject(cylinder);
			}
			else if(childrenAnalyzer->Attribute("radius")!=NULL)
			{
				float radius;
				int slices,stacks;
				childrenAnalyzer->QueryFloatAttribute("radius",&radius);
				childrenAnalyzer->QueryIntAttribute("slices",&slices);
				childrenAnalyzer->QueryIntAttribute("stacks",&stacks);
				SceneObject* sphere = new SceneSphere(radius,slices,stacks);
				node->addObject(sphere);
			}
			else if(childrenAnalyzer->Attribute("inner")!=NULL)
			{
				float inner,outer;
				int slices,loops;
				childrenAnalyzer->QueryFloatAttribute("inner",&inner);
				childrenAnalyzer->QueryFloatAttribute("outer",&outer);
				childrenAnalyzer->QueryIntAttribute("slices",&slices);
				childrenAnalyzer->QueryIntAttribute("loops",&loops);
				SceneObject* thorus = new SceneTorus(inner,outer,slices,loops);
				node->addObject(thorus);
			}
			else if(childrenAnalyzer->Attribute("parts")!=NULL)
			{
				int parts;
				childrenAnalyzer->QueryIntAttribute("parts",&parts);
				SceneObject* plane = new ScenePlane(parts);
				node->addObject(plane);
			}
			else if(strcmp(childrenAnalyzer->Value(),"patch")==0)
			{
				int order,partsU,partsV;
				float x,y,z;
				string compute;

				childrenAnalyzer->QueryIntAttribute("order",&order);
				childrenAnalyzer->QueryIntAttribute("partsU",&partsU);
				childrenAnalyzer->QueryIntAttribute("partsV",&partsV);
				compute=childrenAnalyzer->Attribute("compute");

				ScenePatch* patch = new ScenePatch(order,partsU,partsV,compute);

				TiXmlElement* points = childrenAnalyzer->FirstChildElement("controlpoint");

				while(points!=NULL)
				{
					points->QueryFloatAttribute("x",&x);
					points->QueryFloatAttribute("y",&y);
					points->QueryFloatAttribute("z",&z);

					cout<<x<<","<<y<<","<<z<<endl;
					patch->addCntrPoint(x,y,z);

					points = points->NextSiblingElement("controlpoint");
				}
				node->addObject(patch);

			}

			else if(strcmp(childrenAnalyzer->Value(),"vehicle")==0)
			{
				SceneObject* vehicle = new SceneVehicle();
				node->addObject(vehicle);
			}

			else if(childrenAnalyzer->Attribute("heightmap")!=NULL)
			{
				string heightMap,textureMap,fragmentShader,vertexShader;
				heightMap=childrenAnalyzer->Attribute("heightmap");
				textureMap=childrenAnalyzer->Attribute("texturemap");
				fragmentShader=childrenAnalyzer->Attribute("fragmentshader");
				vertexShader=childrenAnalyzer->Attribute("vertexshader");

				SceneObject* shader = new SceneShader(heightMap,textureMap,fragmentShader,vertexShader);
				node->addObject(shader);
			}


			else if (childrenAnalyzer->Attribute("id")!=NULL)
			{
				node->addchildId(childrenAnalyzer->Attribute("id"));
			}
			childrenAnalyzer=childrenAnalyzer->NextSiblingElement();
		}
		//set animation
		Animation* anime=animations[animID];

		if(anime!=NULL)
		{
			node->setAnimation(anime);
		}
		sceneGraph->addNode(node);
		nodeElement=nodeElement->NextSiblingElement("node");
	}
	sceneGraph->createSonNodes();
}
Example #7
0
void XMLScene::processGraph(TiXmlElement* graphElement)
{
	string rootid=graphElement->Attribute("rootid");
	TiXmlElement* nodeElement = graphElement->FirstChildElement("node");
	sceneGraph = new Graph();
	sceneGraph->setRootId(rootid);
	while(nodeElement!=NULL)
	{
		bool displayList=false;
		string nodeId = nodeElement->Attribute("id");
		if(nodeElement->Attribute("displaylist") != NULL)
			nodeElement->QueryBoolAttribute("displaylist",&displayList);
		Node* node = new Node(nodeId, displayList);

		string animationID;
		TiXmlElement* animations = nodeElement->FirstChildElement("animationref");
		if(animations!=NULL)
			animationID=animations->Attribute("id");

		TiXmlElement* transformations = nodeElement->FirstChildElement("transforms");
		TiXmlElement* transformation = transformations->FirstChildElement();

		while(transformation!=NULL)
		{
			if(transformation->Attribute("axis")!=NULL)
			{
				string axis=transformation->Attribute("axis");
				float angle;
				read1Float("angle",transformation,angle);
				Transformation* rot = new Rotation(axis,angle);
				node->addTransformation(rot);
			}
			else if (transformation->Attribute("to")!=NULL)
			{
				float translation[3];
				read3Float("to",transformation,translation[0],translation[1],translation[2]);
				Transformation* translationElement = new Translation(translation[0],translation[1],translation[2]);
				node->addTransformation(translationElement);
			}

			else if (transformation->Attribute("factor")!=NULL)
			{
				float factor[3];
				read3Float("factor",transformation,factor[0],factor[1],factor[2]);
				Transformation* scaling = new Scaling(factor[0],factor[1],factor[2]);
				node->addTransformation(scaling);
			}

			transformation = transformation->NextSiblingElement();
		}

		TiXmlElement* appearanceRef = nodeElement->FirstChildElement("appearanceref");
		if(appearanceRef->Attribute("id")!="inherit")
		{
			node->setNodeAppearance(make_pair(appearanceRef->Attribute("id"),appearances[appearanceRef->Attribute("id")]));
		}
		else
		{
			node->setNodeAppearance(make_pair("inherit",new Appearance()));
		}
		TiXmlElement* primitive = nodeElement->FirstChildElement("primitives");
		TiXmlElement* primitiveAnalyzer = primitive->FirstChildElement();
		while(primitiveAnalyzer!=NULL)
		{
			if(primitiveAnalyzer->Attribute("xy1")!=NULL)
			{
				float xy1[2],xy2[2];
				read2Float("xy1",primitiveAnalyzer,xy1[0],xy1[1]);
				read2Float("xy2",primitiveAnalyzer,xy2[0],xy2[1]);
				SceneObject* rectangle = new SceneRectangle(xy1[0],xy1[1],xy2[0],xy2[1]);
				node->addObject(rectangle);
			}

			else if(primitiveAnalyzer->Attribute("xyz1")!=NULL)
			{
				float xyz1[3],xyz2[3],xyz3[3];
				read3Float("xyz1",primitiveAnalyzer,xyz1[0],xyz1[1],xyz1[2]);
				read3Float("xyz2",primitiveAnalyzer,xyz2[0],xyz2[1],xyz2[2]);
				read3Float("xyz3",primitiveAnalyzer,xyz3[0],xyz3[1],xyz3[2]);
				
				SceneObject* triangle = new SceneTriangle(xyz1,xyz2,xyz3);
				node->addObject(triangle);
			}

			else if(primitiveAnalyzer->Attribute("base")!=NULL)
			{
				float base,top,height;
				int slices,stacks;
				read1Float("base",primitiveAnalyzer,base);
				read1Float("top",primitiveAnalyzer,top);
				read1Float("height",primitiveAnalyzer,height);
				read1Int("slices",primitiveAnalyzer,slices);
				read1Int("stacks",primitiveAnalyzer,stacks);
				SceneObject* cylinder = new SceneCylinder(base,top,height,slices,stacks);
				node->addObject(cylinder);
			}

			else if(primitiveAnalyzer->Attribute("radius")!=NULL)
			{
				float radius;
				int slices,stacks;
				read1Float("radius",primitiveAnalyzer,radius);
				read1Int("slices",primitiveAnalyzer,slices);
				read1Int("stacks",primitiveAnalyzer,stacks);
				SceneObject* sphere = new SceneSphere(radius,slices,stacks);
				node->addObject(sphere);
			}

			else if(primitiveAnalyzer->Attribute("inner")!=NULL)
			{
				float inner,outer;
				int slices,loops;
				read1Float("inner",primitiveAnalyzer,inner);
				read1Float("outer",primitiveAnalyzer,outer);
				read1Int("slices",primitiveAnalyzer,slices);
				read1Int("loops",primitiveAnalyzer,loops);
				
				SceneObject* thorus = new SceneTorus(inner,outer,slices,loops);
				node->addObject(thorus);
			}

			else if(primitiveAnalyzer->Attribute("parts")!=NULL)
			{
				int parts;
				read1Int("parts",primitiveAnalyzer,parts);

				SceneObject* plane = new ScenePlane(parts);
				node->addObject(plane);

			}
			else if(strcmp(primitiveAnalyzer->Value(),"patch")==0)
			{
				int order,partsU,partsV;
				float x,y,z;
				string compute;

				primitiveAnalyzer->QueryIntAttribute("order",&order);
				primitiveAnalyzer->QueryIntAttribute("partsU",&partsU);
				primitiveAnalyzer->QueryIntAttribute("partsV",&partsV);
				compute=primitiveAnalyzer->Attribute("compute");

				ScenePatch* patch = new ScenePatch(order,partsU,partsV,compute);

				TiXmlElement* ControlPoints = primitiveAnalyzer->FirstChildElement("controlpoint");

				while(ControlPoints!=NULL)
				{
					ControlPoints->QueryFloatAttribute("x",&x);
					ControlPoints->QueryFloatAttribute("y",&y);
					ControlPoints->QueryFloatAttribute("z",&z);

					patch->addCntrPoint(x,y,z);

					ControlPoints = ControlPoints->NextSiblingElement("controlpoint");
				}
				node->addObject(patch);

			}
			else if(primitiveAnalyzer->Attribute("texture") != NULL) {
				std::string texture;
				texture = primitiveAnalyzer->Attribute("texture");
				SceneObject* flag = new SceneFlag(texture);
				node->addObject(flag);
				std::cout << "Added flag with texture: " << texture << std::endl;
			}

			primitiveAnalyzer = primitiveAnalyzer->NextSiblingElement();
		}
		TiXmlElement* descendants = nodeElement->FirstChildElement("descendants");
		TiXmlElement* descendantsAnalyzer = descendants->FirstChildElement();
		while(descendantsAnalyzer!=NULL)
		{
			node->addchildId(descendantsAnalyzer->Attribute("id"));
			
			descendantsAnalyzer=descendantsAnalyzer->NextSiblingElement();
		}

		sceneGraph->addNode(node);
		nodeElement=nodeElement->NextSiblingElement("node");

	}
}
bool XmlSceneLoader::loadScene(std::string file, interface::Scene& scene, vector<ObjectLoaded>& objects)
{
    TiXmlDocument doc(file);

    if(!doc.LoadFile())
        return false;

    TiXmlElement* root=doc.FirstChildElement();
    TiXmlElement* elem = root;

    // first parse meshasset
    std::map<int, vector<XmlMeshAssetLoader::MeshElementModel>> meshAssets;
    std::map<int, std::string> meshAssetsName;

    int nbObject=0;

    while(elem)
    {
        if(elem->ValueStr() == std::string("MeshAsset"))
        {
            int index=-1;
            elem->QueryIntAttribute("index", &index);

            std::string name;
            meshAssets[index] = interface::XmlMeshAssetLoader::parseMeshAssetElement(elem, name);
            meshAssetsName[index] = name;
        }
        else if(elem->ValueStr() == std::string("Object"))
        {
            nbObject++;
        }
        else if(elem->ValueStr() == std::string("DirLight"))
        {
            int shadow=0;
            vec3 color = {1,1,1};
            vec3 dir={0,0,-1};

            elem->QueryIntAttribute("shadows", &shadow);
            std::string strColor = StringUtils::str(elem->Attribute("color"));
            std::string strDir = StringUtils::str(elem->Attribute("direction"));
            if(!strColor.empty()) color = toVec<3>(strColor);
            if(!strDir.empty()) dir = toVec<3>(strDir);

            scene.globalLight.dirLights.push_back({dir, vec4(color,1), shadow==1});
        }

        elem=elem->NextSiblingElement();
    }

    elem = root;
    vector<std::string> skybox;

    while(elem)
    {
        if(elem->ValueStr() == std::string("Object"))
        {
            std::string name;
            elem->QueryStringAttribute("name", &name);

            int index=-1;
            elem->QueryIntAttribute("model", &index);

            if(index < 0 || meshAssets.find(index)==meshAssets.end())
            {
                elem=elem->NextSiblingElement();
                continue;
            }

            bool isStatic = true, isPhysic = true, isVisible = true;
            elem->QueryBoolAttribute("isStatic", &isStatic);
            elem->QueryBoolAttribute("isPhysic", &isPhysic);
            elem->QueryBoolAttribute("isVisible", &isVisible);

            vec3 tr, sc;
            mat3 rot;
            ObjectLoaded obj;
            parseTransformation(elem, tr, sc, rot, &obj.collider);

            obj.name = name;
            obj.model = meshAssetsName[index];
            obj.type = ObjectLoaded::MESH_INSTANCE;
            obj.asset = meshAssets[index];
            obj.isPhysic = isPhysic;
            obj.isStatic = isStatic;
            obj.isVisible = isVisible;
            obj.scale = sc;
            obj.translation = tr;
            obj.rotation = rot;

            if(isVisible)
                obj.meshInstance = &scene.scene.add<MeshInstance>(XmlMeshAssetLoader::constructMesh(meshAssets[index], Texture::genParam(true,true,true, 0), false),
                                                                  mat4::constructTransformation(rot, tr, sc));
            else
                obj.meshInstance = nullptr;

            objects.push_back(obj);
        }
        else if(elem->ValueStr() == std::string("Skybox"))
        {
            skybox = parseSkyboxXmlElement(elem);
        }

        elem=elem->NextSiblingElement();
    }

    if(skybox.size() == 6)
    {
        scene.globalLight.skybox = renderer::IndirectLightRenderer::loadAndProcessSkybox(skybox, ShaderPool::instance().get("processSpecularCubeMap"));
    }

    return true;
}
Example #9
0
void ClassifierSVM::loadSettings(TiXmlElement* settings){
	string tmp;

	cacheEnabled = true;
	TiXmlElement* pPtr = settings->FirstChildElement("cache");
	if(!pPtr){
		throw "Bad settings file - no cache setting for ClassifierSVM";
	}
	pPtr->QueryBoolAttribute("enabled", &cacheEnabled);

	pPtr = settings->FirstChildElement("svm");
	if(!pPtr){
		throw "Bad settings file - no svm settings";
	}

	int svmType;
	pPtr->QueryStringAttribute("type", &tmp);
	if(tmp == "C_SVC"){
		svmType = C_SVC;
	}
	else if(tmp == "NU_SVC"){
		svmType = NU_SVC;
	}
	else if(tmp == "ONE_CLASS"){
		svmType = ONE_CLASS;
	}
	else{
		throw "Bad settings file - wrong SVM type";
	}

	int kernelType;
	TiXmlElement* svmPtr = pPtr->FirstChildElement("kernelType");
	if(!svmPtr){
		throw "Bad settings file - no kernel type";
	}
	svmPtr->QueryStringAttribute("value", &tmp);
	if(tmp == "LINEAR"){
		kernelType = LINEAR;
	}
	else if(tmp == "POLY"){
		kernelType = POLY;
	}
	else if(tmp == "RBF"){
		kernelType = RBF;
	}
	else if(tmp == "SIGMOID"){
		kernelType = SIGMOID;
	}
	else{
		throw "Bad settings file - wrong kernel type";
	}

	double gamma = 0.5;
	svmPtr = pPtr->FirstChildElement("gamma");
	if(!svmPtr){
		throw "Bad settings file - no gamma value";
	}
	svmPtr->QueryDoubleAttribute("value", &gamma);

	double degree = 2;
	svmPtr = pPtr->FirstChildElement("degree");
	if(!svmPtr){
		throw "Bad settings file - no degree value";
	}
	svmPtr->QueryDoubleAttribute("value", &degree);

	double C = 1;
	svmPtr = pPtr->FirstChildElement("C");
	if(!svmPtr){
		throw "Bad settings file - no C value";
	}
	svmPtr->QueryDoubleAttribute("value", &C);

	svmParams.svm_type = svmType;
	svmParams.kernel_type = kernelType;
	svmParams.gamma = gamma;
	svmParams.degree = degree;
	svmParams.C = C;
}