Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

Diff Revisions 336 vs 337 for /trunk/Source Code/Server/Utility/XMLParser.cpp

Diff revisions: vs.
  @@ -5,118 +5,118 @@
5 5 namespace Divide {
6 6 namespace XML
7 7 {
8 - using boost::property_tree::ptree;
9 - ptree pt;
8 + using boost::property_tree::ptree;
9 + ptree pt;
10 10
11 - void loadScene(const stringImpl& sceneName)
12 - {
13 - pt.clear();
14 - std::cout << "XML: Loading scene [ " << stringAlg::fromBase(sceneName) << " ] " << std::endl;
15 - read_xml(stringAlg::fromBase("Scenes/" + sceneName + ".xml"), pt);
11 + void loadScene(const stringImpl& sceneName)
12 + {
13 + pt.clear();
14 + std::cout << "XML: Loading scene [ " << stringAlg::fromBase(sceneName) << " ] " << std::endl;
15 + read_xml(stringAlg::fromBase("Scenes/" + sceneName + ".xml"), pt);
16 16 std::string assetLocation(stringAlg::fromBase("Scenes/" + sceneName + "/"));
17 - loadGeometry(stringAlg::toBase(assetLocation + pt.get("assets", "assets.xml")));
18 - }
17 + loadGeometry(stringAlg::toBase(assetLocation + pt.get("assets", "assets.xml")));
18 + }
19 19
20 - void loadGeometry(const stringImpl &file)
21 - {
22 - pt.clear();
23 - std::cout << "XML: Loading Geometry: [ " << stringAlg::fromBase(file) << " ] " << std::endl;
24 - read_xml(stringAlg::fromBase(file), pt);
25 - ptree::iterator it;
26 - for (it = pt.get_child("geometry").begin(); it != pt.get_child("geometry").end(); ++it )
27 - {
28 - std::string name(it->second.data());
29 - std::string format(it->first.data());
20 + void loadGeometry(const stringImpl &file)
21 + {
22 + pt.clear();
23 + std::cout << "XML: Loading Geometry: [ " << stringAlg::fromBase(file) << " ] " << std::endl;
24 + read_xml(stringAlg::fromBase(file), pt);
25 + ptree::iterator it;
26 + for (it = pt.get_child("geometry").begin(); it != pt.get_child("geometry").end(); ++it )
27 + {
28 + std::string name(it->second.data());
29 + std::string format(it->first.data());
30 30
31 - if (format.find("<xmlcomment>") != stringImpl::npos) {
31 + if (format.find("<xmlcomment>") != stringImpl::npos) {
32 32 continue;
33 33 }
34 34
35 - FileData model;
36 - model.ItemName = name.c_str();
37 - model.ModelName = "Assets/";
35 + FileData model;
36 + model.ItemName = name.c_str();
37 + model.ModelName = "Assets/";
38 38 model.ModelName.append(stringAlg::toBase(pt.get<std::string>(name + ".model")));
39 - model.position.x = pt.get<F32>(name + ".position.<xmlattr>.x");
40 - model.position.y = pt.get<F32>(name + ".position.<xmlattr>.y");
41 - model.position.z = pt.get<F32>(name + ".position.<xmlattr>.z");
42 - model.orientation.x = pt.get<F32>(name + ".orientation.<xmlattr>.x");
43 - model.orientation.y = pt.get<F32>(name + ".orientation.<xmlattr>.y");
44 - model.orientation.z = pt.get<F32>(name + ".orientation.<xmlattr>.z");
45 - model.scale.x = pt.get<F32>(name + ".scale.<xmlattr>.x");
46 - model.scale.y = pt.get<F32>(name + ".scale.<xmlattr>.y");
47 - model.scale.z = pt.get<F32>(name + ".scale.<xmlattr>.z");
48 - model.type = MESH;
49 - model.version = pt.get<F32>(name + ".version");
50 - Patch::getInstance().addGeometry(model);
51 - }
52 - for (it = pt.get_child("vegetation").begin(); it != pt.get_child("vegetation").end(); ++it )
53 - {
54 - std::string name(it->second.data());
55 - std::string format(it->first.data());
56 - if (format.find("<xmlcomment>") != stringImpl::npos) {
39 + model.position.x = pt.get<F32>(name + ".position.<xmlattr>.x");
40 + model.position.y = pt.get<F32>(name + ".position.<xmlattr>.y");
41 + model.position.z = pt.get<F32>(name + ".position.<xmlattr>.z");
42 + model.orientation.x = pt.get<F32>(name + ".orientation.<xmlattr>.x");
43 + model.orientation.y = pt.get<F32>(name + ".orientation.<xmlattr>.y");
44 + model.orientation.z = pt.get<F32>(name + ".orientation.<xmlattr>.z");
45 + model.scale.x = pt.get<F32>(name + ".scale.<xmlattr>.x");
46 + model.scale.y = pt.get<F32>(name + ".scale.<xmlattr>.y");
47 + model.scale.z = pt.get<F32>(name + ".scale.<xmlattr>.z");
48 + model.type = MESH;
49 + model.version = pt.get<F32>(name + ".version");
50 + Patch::getInstance().addGeometry(model);
51 + }
52 + for (it = pt.get_child("vegetation").begin(); it != pt.get_child("vegetation").end(); ++it )
53 + {
54 + std::string name(it->second.data());
55 + std::string format(it->first.data());
56 + if (format.find("<xmlcomment>") != stringImpl::npos) {
57 57 continue;
58 58 }
59 - FileData model;
60 - model.ItemName = stringAlg::toBase(name);
61 - model.ModelName = "Assets/";
59 + FileData model;
60 + model.ItemName = stringAlg::toBase(name);
61 + model.ModelName = "Assets/";
62 62 model.ModelName.append(stringAlg::toBase(pt.get<std::string>(name + ".model")));
63 - model.position.x = pt.get<F32>(name + ".position.<xmlattr>.x");
64 - model.position.y = pt.get<F32>(name + ".position.<xmlattr>.y");
65 - model.position.z = pt.get<F32>(name + ".position.<xmlattr>.z");
66 - model.orientation.x = pt.get<F32>(name + ".orientation.<xmlattr>.x");
67 - model.orientation.y = pt.get<F32>(name + ".orientation.<xmlattr>.y");
68 - model.orientation.z = pt.get<F32>(name + ".orientation.<xmlattr>.z");
69 - model.scale.x = pt.get<F32>(name + ".scale.<xmlattr>.x");
70 - model.scale.y = pt.get<F32>(name + ".scale.<xmlattr>.y");
71 - model.scale.z = pt.get<F32>(name + ".scale.<xmlattr>.z");
72 - model.type = VEGETATION;
73 - model.version = pt.get<F32>(name + ".version");
74 - Patch::getInstance().addGeometry(model);
75 - }
76 -
77 - if(boost::optional<ptree &> primitives = pt.get_child_optional("primitives"))
78 - for (it = pt.get_child("primitives").begin(); it != pt.get_child("primitives").end(); ++it )
79 - {
80 - std::string name(it->second.data());
81 - std::string format(it->first.data());
82 - if(format.find("<xmlcomment>") != stringImpl::npos) continue;
83 -
84 - FileData model;
85 - model.ItemName = stringAlg::toBase(name);
86 - model.ModelName = stringAlg::toBase(pt.get<std::string>(name + ".model"));
87 - model.position.x = pt.get<F32>(name + ".position.<xmlattr>.x");
88 - model.position.y = pt.get<F32>(name + ".position.<xmlattr>.y");
89 - model.position.z = pt.get<F32>(name + ".position.<xmlattr>.z");
90 - model.orientation.x = pt.get<F32>(name + ".orientation.<xmlattr>.x");
91 - model.orientation.y = pt.get<F32>(name + ".orientation.<xmlattr>.y");
92 - model.orientation.z = pt.get<F32>(name + ".orientation.<xmlattr>.z");
93 - model.scale.x = pt.get<F32>(name + ".scale.<xmlattr>.x");
94 - model.scale.y = pt.get<F32>(name + ".scale.<xmlattr>.y");
95 - model.scale.z = pt.get<F32>(name + ".scale.<xmlattr>.z");
96 - /*Primitives don't use materials yet so we can define colors*/
97 - model.color.r = pt.get<F32>(name + ".color.<xmlattr>.r");
98 - model.color.g = pt.get<F32>(name + ".color.<xmlattr>.g");
99 - model.color.b = pt.get<F32>(name + ".color.<xmlattr>.b");
100 - /*The data variable stores a float variable (not void*) that can represent anything you want*/
101 - /*For Text3D, it's the line width and for Box3D it's the edge length*/
102 - if(model.ModelName.compare("Text3D") == 0)
103 - {
104 - model.data = pt.get<F32>(name + ".lineWidth");
105 - model.data2 = stringAlg::toBase(pt.get<std::string>(name + ".text"));
106 - }
107 - else if(model.ModelName.compare("Box3D") == 0)
108 - model.data = pt.get<F32>(name + ".size");
109 -
110 - else if(model.ModelName.compare("Sphere3D") == 0)
111 - model.data = pt.get<F32>(name + ".radius");
112 - else
113 - model.data = 0;
114 -
115 - model.type = PRIMITIVE;
116 - model.version = pt.get<F32>(name + ".version");
117 - Patch::getInstance().addGeometry(model);
118 - }
119 - }
63 + model.position.x = pt.get<F32>(name + ".position.<xmlattr>.x");
64 + model.position.y = pt.get<F32>(name + ".position.<xmlattr>.y");
65 + model.position.z = pt.get<F32>(name + ".position.<xmlattr>.z");
66 + model.orientation.x = pt.get<F32>(name + ".orientation.<xmlattr>.x");
67 + model.orientation.y = pt.get<F32>(name + ".orientation.<xmlattr>.y");
68 + model.orientation.z = pt.get<F32>(name + ".orientation.<xmlattr>.z");
69 + model.scale.x = pt.get<F32>(name + ".scale.<xmlattr>.x");
70 + model.scale.y = pt.get<F32>(name + ".scale.<xmlattr>.y");
71 + model.scale.z = pt.get<F32>(name + ".scale.<xmlattr>.z");
72 + model.type = VEGETATION;
73 + model.version = pt.get<F32>(name + ".version");
74 + Patch::getInstance().addGeometry(model);
75 + }
76 +
77 + if(boost::optional<ptree &> primitives = pt.get_child_optional("primitives"))
78 + for (it = pt.get_child("primitives").begin(); it != pt.get_child("primitives").end(); ++it )
79 + {
80 + std::string name(it->second.data());
81 + std::string format(it->first.data());
82 + if(format.find("<xmlcomment>") != stringImpl::npos) continue;
83 +
84 + FileData model;
85 + model.ItemName = stringAlg::toBase(name);
86 + model.ModelName = stringAlg::toBase(pt.get<std::string>(name + ".model"));
87 + model.position.x = pt.get<F32>(name + ".position.<xmlattr>.x");
88 + model.position.y = pt.get<F32>(name + ".position.<xmlattr>.y");
89 + model.position.z = pt.get<F32>(name + ".position.<xmlattr>.z");
90 + model.orientation.x = pt.get<F32>(name + ".orientation.<xmlattr>.x");
91 + model.orientation.y = pt.get<F32>(name + ".orientation.<xmlattr>.y");
92 + model.orientation.z = pt.get<F32>(name + ".orientation.<xmlattr>.z");
93 + model.scale.x = pt.get<F32>(name + ".scale.<xmlattr>.x");
94 + model.scale.y = pt.get<F32>(name + ".scale.<xmlattr>.y");
95 + model.scale.z = pt.get<F32>(name + ".scale.<xmlattr>.z");
96 + /*Primitives don't use materials yet so we can define colors*/
97 + model.color.r = pt.get<F32>(name + ".color.<xmlattr>.r");
98 + model.color.g = pt.get<F32>(name + ".color.<xmlattr>.g");
99 + model.color.b = pt.get<F32>(name + ".color.<xmlattr>.b");
100 + /*The data variable stores a float variable (not void*) that can represent anything you want*/
101 + /*For Text3D, it's the line width and for Box3D it's the edge length*/
102 + if(model.ModelName.compare("Text3D") == 0)
103 + {
104 + model.data = pt.get<F32>(name + ".lineWidth");
105 + model.data2 = stringAlg::toBase(pt.get<std::string>(name + ".text"));
106 + }
107 + else if(model.ModelName.compare("Box3D") == 0)
108 + model.data = pt.get<F32>(name + ".size");
109 +
110 + else if(model.ModelName.compare("Sphere3D") == 0)
111 + model.data = pt.get<F32>(name + ".radius");
112 + else
113 + model.data = 0;
114 +
115 + model.type = PRIMITIVE;
116 + model.version = pt.get<F32>(name + ".version");
117 + Patch::getInstance().addGeometry(model);
118 + }
119 + }
120 120 }
121 121
122 122 }; //namespace Divide