1 | #include <string> |
---|
2 | |
---|
3 | #include "Model.h" |
---|
4 | #include "../core/CoreIncludes.h" |
---|
5 | #include "../orxonox.h" |
---|
6 | #include "../../tinyxml/tinyxml.h" |
---|
7 | #include "../../misc/Tokenizer.h" |
---|
8 | #include "../../misc/String2Number.h" |
---|
9 | |
---|
10 | namespace orxonox |
---|
11 | { |
---|
12 | CreateFactory(Model); |
---|
13 | |
---|
14 | Model::Model() |
---|
15 | { |
---|
16 | RegisterObject(Model); |
---|
17 | } |
---|
18 | |
---|
19 | Model::~Model() |
---|
20 | { |
---|
21 | } |
---|
22 | |
---|
23 | void Model::loadParams(TiXmlElement* xmlElem) |
---|
24 | { |
---|
25 | std::cout << "1\n"; |
---|
26 | if (xmlElem->Attribute("position")) |
---|
27 | { |
---|
28 | std::cout << "2\n"; |
---|
29 | std::vector<std::string> pos = tokenize(xmlElem->Attribute("position"),","); |
---|
30 | float x, y, z; |
---|
31 | String2Number<float>(x, pos[0]); |
---|
32 | String2Number<float>(y, pos[1]); |
---|
33 | String2Number<float>(z, pos[2]); |
---|
34 | this->setPosition(x, y, z); |
---|
35 | } |
---|
36 | |
---|
37 | std::cout << "3\n"; |
---|
38 | if (xmlElem->Attribute("direction")) |
---|
39 | { |
---|
40 | std::cout << "4\n"; |
---|
41 | std::vector<std::string> pos = tokenize(xmlElem->Attribute("direction"),","); |
---|
42 | float x, y, z; |
---|
43 | String2Number<float>(x, pos[0]); |
---|
44 | String2Number<float>(y, pos[1]); |
---|
45 | String2Number<float>(z, pos[2]); |
---|
46 | this->setDirection(x, y, z); |
---|
47 | } |
---|
48 | |
---|
49 | std::cout << "5\n"; |
---|
50 | if (xmlElem->Attribute("mesh")) |
---|
51 | { |
---|
52 | std::cout << "6_1\n"; |
---|
53 | std::string src = xmlElem->Attribute("mesh"); |
---|
54 | std::cout << "6_2\n"; |
---|
55 | std::cout << this->mesh_.getEntity() << std::endl; |
---|
56 | this->mesh_ = Mesh(src); |
---|
57 | std::cout << "6_3\n"; |
---|
58 | std::cout << this->mesh_.getEntity() << std::endl; |
---|
59 | this->attachObject(this->mesh_.getEntity()); |
---|
60 | std::cout << "6_4\n"; |
---|
61 | } |
---|
62 | |
---|
63 | std::cout << "7\n"; |
---|
64 | if (xmlElem->Attribute("scale")) |
---|
65 | { |
---|
66 | std::cout << "8\n"; |
---|
67 | std::string scaleStr = xmlElem->Attribute("scale"); |
---|
68 | float scale; |
---|
69 | String2Number<float>(scale, scaleStr); |
---|
70 | this->setScale(scale); |
---|
71 | } |
---|
72 | std::cout << "9\n"; |
---|
73 | |
---|
74 | COUT(4) << "Loader: Created model" << std::endl; |
---|
75 | } |
---|
76 | } |
---|