Build the castle.
Given the position, this method will start building the castle from that position. For now it will get data of the castle from xml file in media/Castle
29 irr::io::IXMLReader* xml = this->
device->getFileSystem()->createXMLReader(
"media/castle/castle.xml");
33 const stringw sideTag(L
"side");
34 core::stringw currentSection;
35 const stringw blockTag(L
"block");
36 core::stringc
position, lastposition;
37 float width, height, distance = 0.f;
39 f32 offsets[4]={0,0,0,0};
42 core::aabbox3d<f32> box;
43 core::matrix4 transformer;
44 std::multimap<char, scene::IMeshSceneNode*>::iterator first, last;
46 log1(
"Reading XML castle file and building castle");
50 switch (xml->getNodeType()){
52 case irr::io::EXN_ELEMENT:{
55 if (currentSection.empty() && sideTag.equals_ignore_case(xml->getNodeName()))
57 currentSection = sideTag;
58 position = xml->getAttributeValueSafe(L
"position");
59 distance = xml->getAttributeValueAsFloat(L
"distance");
63 if(!this->
nodes.empty() && position[0]){
70 }
else if (currentSection.equals_ignore_case(sideTag) && blockTag.equals_ignore_case(xml->getNodeName())){
72 core::vector3df scale = core::vector3df(1.f,1.f,1.f);
73 width = xml->getAttributeValueAsFloat(L
"width");
74 height = xml->getAttributeValueAsFloat(L
"height");
75 scale = core::vector3df(width,height,1);
79 pos = core::vector3df(
80 center.X + offsets[0] +scale.X/2, scale.Y/2 , center.Z );
85 pos = core::vector3df(
86 center.X+scale.X/2, scale.Y/2 , scale.X/2+center.Z+offsets[1]);
91 pos = core::vector3df(
92 center.X+scale.X/2+offsets[2], scale.Y/2,
102 pos = core::vector3df(
103 center.X+distance-
getMeshSize(this->
node)[2], scale.Y/2 , scale.X/2+center.Z+offsets[3]);
111 if(!this->
nodes.empty()){
112 first = this->
nodes.begin();
113 last = this->
nodes.end();
122 case irr::io::EXN_ELEMENT_END:
123 if(currentSection.equals_ignore_case(xml->getNodeName())) {
position =
""; currentSection =
""; };
const f32 BLOCKS_OFFSET
Definition: castle.h:13
video::SColor COLOR_DARK
Definition: castle.h:47
video::SColor COLOR_LIGHT
Definition: castle.h:46
#define log1(_Message)
Log message of 1 level verbosity.
Definition: Logger.h:28
void createBlock(core::vector3df position, core::vector3df scale, core::vector3df rotation, char side, video::SColor color=randomColor())
Create the block of the castle at a specified position, rotation and scaling.
Definition: castle.cpp:140
IrrlichtDevice * device
Definition: castle.h:23
f32 * getMeshSize(scene::ISceneNode *mesh)
Get a size of a 3D Irrlicth mesh.
Definition: bullethelper.cpp:47
std::multimap< char, scene::IMeshSceneNode * > nodes
Associative array for blocks.
Definition: castle.h:26
scene::IMeshSceneNode * node
Last node used.
Definition: castle.h:22
core::vector3df position
Definition: castle.h:20