source: GTP/trunk/App/Games/Jungle_Rumble/src/GameSceneLoader.cpp @ 1378

Revision 1378, 54.9 KB checked in by giegl, 18 years ago (diff)

GTPD - Jungle Rumble - integrate into GTP SVN structure

Line 
1#include "dxstdafx.h"
2#include ".\gamesceneloader.h"
3#include "GameManager.h"
4#include "UserPlayer.h"
5#include "Weapon.h"
6#include "SimpleWeapon.h"
7#include "SimpleBullet.h"
8#include "Terrain.h"
9#include "HUD.h"
10#include "Ocean.h"
11#include "SkyBox.h"
12#include "Object3d.h"
13#include "NxActorDesc.h"
14#include "NxMaterialDesc.h"
15#include "NxMaterial.h"
16#include "Goodie.h"
17#include "UserContactReport.h"
18#include "UniversalWeapon.h"
19#include "ParticleEmitter.h"
20#include "ParticleGroup.h"
21#include "Sprite.h"
22
23GameSceneLoader::GameSceneLoader(void)
24{
25       
26        //XML Stuff
27        ::CoInitialize(NULL);
28
29        HRESULT hr = sceneDomDocument.CreateInstance(MSXML::CLSID_DOMDocument);
30        if (FAILED(hr)) {
31                //MessageBox(NULL,"Unable to create XML instance!", "Wuermer DEBUG",MB_OK|MB_ICONQUESTION);
32                this->scene->manager->printToConsole("Unable to create XML instance!");
33                exit(0);
34        }
35}
36
37GameSceneLoader::~GameSceneLoader(void)
38{
39}
40
41bool GameSceneLoader::loadGameScene(GameScene &_scene, std::string filename, GameManager *_manager) {
42        this->scene = &_scene;
43        // specify xml file name
44        variant_t vResult;
45       
46        vResult = sceneDomDocument->load(filename.c_str());
47        if (((bool)vResult) == TRUE) {
48                sceneDocRoot = sceneDomDocument->documentElement;
49        } else {
50                this->scene->manager->printToConsole(filename);
51                this->scene->manager->printToConsole("Loading GameScene failed!");
52                MessageBox(NULL, L"Maybe the file is not a valid xml!", L"Error loading .xml file!", MB_ICONERROR);
53                return false;
54        }
55       
56        //Clear existing gamescene
57        /*if (this->loadAgain) {
58        this->scene->clearScene();
59        } else {
60                this->loadAgain = true;
61        }*/
62
63        //BuildGame
64        _bstr_t tmpName("name");
65        _bstr_t tmpMode("mode");
66        _bstr_t tmpTime("time");
67        _bstr_t tmpSun("sun");
68        _bstr_t tmpDimension("dimension");
69        _bstr_t tmpTerrain("terrain");
70        _bstr_t tmpOcean("ocean");
71        _bstr_t tmpSkyBox("skybox");
72        _bstr_t tmpBullet("bullet");
73        _bstr_t tmpWeapon("weapon");
74        _bstr_t tmpPlayer("player");
75        _bstr_t tmpGoodies("goodies");
76        _bstr_t tmpPMaterial("pmaterial");
77        _bstr_t tmpHud("hud");
78        _bstr_t tmpParticleEmitter("particleEmitter");
79        _bstr_t tmpSoundFile("soundfile");
80        _bstr_t tmpSoundVolume("soundvolume");
81        _bstr_t tmpEnvObject("envObject");
82        _bstr_t tmpDescription("description");
83        _bstr_t tmpDescriptionDuration("descduration");
84        _bstr_t tmpMaxEnemyCount("maxenemycount");
85        std::string description;
86        bool descSet = false;
87        float descTime = 3;
88        int maxEnemyCount = 1;
89        Vector dimension;
90
91        //NOTE: this is a hack to ensure that the scene has constant size (==>watermap!)
92        dimension.addXYZ(320, 40, 320);
93        this->scene->setWidth(dimension.x);
94        this->scene->setHeight(dimension.y);
95        this->scene->setDepth(dimension.z);
96
97        for (MSXML::IXMLDOMNodePtr pChild = sceneDocRoot->firstChild;NULL != pChild;pChild = pChild->nextSibling) {
98                if(pChild->nodeType == MSXML::NODE_ELEMENT) {
99                        if(pChild->nodeName == tmpName) {
100                                this->scene->gameName = pChild->firstChild->text;                       //GameScene Name
101                        } else if(pChild->nodeName == tmpMode) {
102                                this->scene->gameMode = atoi(pChild->firstChild->text);         //Game Mode
103                        } else if(pChild->nodeName == tmpTime) {
104                                this->scene->gameDuration = (float)atoi(pChild->firstChild->text);      //Game Time
105                        } /*else if (pChild->nodeName == tmpDimension) {
106                                dimension = this->tracePosition(pChild);                                        //Dimension of level
107                                this->scene->setWidth(dimension.x);
108                                this->scene->setHeight(dimension.y);
109                                this->scene->setDepth(dimension.z);
110                        }*/ else if(pChild->nodeName == tmpTerrain) {
111                                this->traceTerrain(pChild);                                                                     //Terrain
112                        } else if(pChild->nodeName == tmpOcean) {
113                                this->traceOcean(pChild);                                                                       //Ocean  //TODO EINFUEGEN!!!
114                                this->scene->manager->printToConsole("Uncomment this->traceOcean(...) in GameSceneLoader!!");
115                        } else if(pChild->nodeName == tmpSkyBox) {
116                                this->traceSkyBox(pChild);                                                                      //SkyBox
117                        } else if(pChild->nodeName == tmpBullet) {
118                                this->traceBullet(pChild);                                                                      //Bullet
119                        } else if(pChild->nodeName == tmpWeapon) {
120                                this->traceWeapon(pChild);                                                                      //Weapon
121                        } else if(pChild->nodeName == tmpPlayer) {
122                                this->tracePlayer(pChild);                                                                      //Player
123                        } else if(pChild->nodeName == tmpGoodies) {
124                                this->traceGoodies(pChild);                                                                     //Goodies
125                        } else if(pChild->nodeName == tmpSun) {
126                                this->traceSun(pChild);                                                                         //Sun
127                        } else if(pChild->nodeName == tmpHud) {
128                                this->traceHud(pChild);                                                                         //HUD
129                        } else if(pChild->nodeName == tmpParticleEmitter) {
130                                this->traceParticleEmitter(pChild);                                                     //ParticleEmitter
131                        } else if(pChild->nodeName == tmpSoundFile) {
132                                std::string soundFile = pChild->firstChild->text;
133                                this->scene->setBackgroundSound(soundFile);                                     //BackgroundSound
134                        } else if(pChild->nodeName == tmpSoundVolume) {
135                                this->scene->setBackgroundSoundVolume((FLOAT)atof(pChild->firstChild->text));   //SoundVolume
136                        } else if(pChild->nodeName == tmpEnvObject) {
137                                this->traceEnvironmentObject(pChild);                                           //Environment Object
138                        } else if(pChild->nodeName == tmpPMaterial) {
139                                this->tracePMaterial(pChild);
140                        } else if(pChild->nodeName == tmpDescription) {
141                                description = pChild->firstChild->text;
142                                descSet = true;
143                        } else if(pChild->nodeName == tmpDescriptionDuration) {
144                                descTime = (FLOAT) atof(pChild->firstChild->text);
145                        } else if(pChild->nodeName == tmpMaxEnemyCount) {
146                                maxEnemyCount = (INT) atoi(pChild->firstChild->text);
147                                this->scene->setMaxEnemyCount(maxEnemyCount);
148                        }
149                }
150        }
151
152        if(descSet) {
153                this->scene->setChallengeDescription(description, descTime);
154        }
155
156        return true;
157}
158
159void GameSceneLoader::traceSun(MSXML::IXMLDOMNodePtr sunNode) {
160        Vector direction;
161        _bstr_t tmpDirection("direction");
162
163        for (MSXML::IXMLDOMNodePtr pChild = sunNode->firstChild;NULL != pChild;pChild = pChild->nextSibling) {
164                if(pChild->nodeType == MSXML::NODE_ELEMENT) {
165                        if(pChild->nodeName == tmpDirection) {
166                                direction = tracePosition(pChild);
167                        }
168                }
169        }
170        direction = direction*(-1); //Use direction vector
171        this->scene->setLight(direction);
172}
173
174Vector GameSceneLoader::tracePosition(MSXML::IXMLDOMNodePtr positionNode) {
175        _bstr_t tmpX("x");
176        _bstr_t tmpY("y");
177        _bstr_t tmpZ("z");
178        Vector position;
179        for (MSXML::IXMLDOMNodePtr pChild = positionNode->firstChild;NULL != pChild;pChild = pChild->nextSibling) {
180                if(pChild->nodeType == MSXML::NODE_ELEMENT) {
181                        if(pChild->nodeName == tmpX) {
182                                position.x = (FLOAT)atof(pChild->firstChild->text);
183                        } else if(pChild->nodeName == tmpY) {
184                                position.y = (FLOAT)atof(pChild->firstChild->text);
185                        } else if(pChild->nodeName == tmpZ) {
186                                position.z = (FLOAT)atof(pChild->firstChild->text);
187                        }
188                }
189        }
190        return position;
191}
192
193void GameSceneLoader::traceBullet(MSXML::IXMLDOMNodePtr bulletNode) {
194        /*<bullet>
195                <type>0</type>
196                <speed>4000</speed>
197                <impactForce>150000</impactForce>
198        </bullet>*/
199        _bstr_t tmpType("type");
200        _bstr_t tmpSpeed("speed");
201        _bstr_t tmpImpactForce("impactForce");
202        _bstr_t tmpXFile("xfile");
203        _bstr_t tmpFlySound("flySound");
204        _bstr_t tmpImpactSound("impactSound");
205        _bstr_t tmpParticleEmitter("particleEmitter");
206
207        //_bstr_t tmpPActor("pactor");
208        //MSXML::IXMLDOMNodePtr pActorNode;
209        //bool pActorInside = false;
210        int type=0;
211        float speed=0;
212        float impactForce=0;
213        std::string flySound = "";
214        std::string impactSound = "";
215        std::string xfile = "";
216        std::vector<ParticleEmitter *> partEmitt;
217        for (MSXML::IXMLDOMNodePtr pChild = bulletNode->firstChild;NULL != pChild;pChild = pChild->nextSibling) {
218                if(pChild->nodeType == MSXML::NODE_ELEMENT) {
219                        if(pChild->nodeName == tmpType) {
220                                type = atoi(pChild->firstChild->text);
221                        } else if(pChild->nodeName == tmpSpeed) {
222                                speed = (FLOAT)atof(pChild->firstChild->text);
223                        } else if(pChild->nodeName == tmpImpactForce) {
224                                impactForce = (FLOAT)atof(pChild->firstChild->text);  //float between 0...16!!
225                        } else if(pChild->nodeName == tmpXFile) {
226                                xfile = pChild->firstChild->text;
227                        } else if(pChild->nodeName == tmpFlySound) {
228                                flySound = pChild->firstChild->text;
229                        } else if(pChild->nodeName == tmpImpactSound) {
230                                impactSound = pChild->firstChild->text;
231                        } else if(pChild->nodeName == tmpParticleEmitter) { //Particle Emitter for Bullet!
232                                ParticleEmitter* tempEmitt = this->traceParticleEmitter(pChild);
233                                partEmitt.push_back(tempEmitt);
234                        }
235                        /*else if(pChild->nodeName == tmpPActor) {
236                                pActorNode = pChild;
237                                pActorInside = true;
238                        }*/
239                }
240        }
241        if(type<3) {
242                SimpleBullet *bullet = (SimpleBullet *) this->scene->createReferenceNode(this->scene->NODE_SIMPLEBULLET, true);
243                bullet->setBulletType(type);
244                if(speed!=0)
245                        bullet->setSpeed(speed);
246                if(impactForce!=0)
247                        bullet->setImpactForce(impactForce);
248                bullet->setXFile(xfile);
249                bullet->setFlySound(flySound);
250                bullet->setImpactSound(impactSound);
251                for(UINT i = 0; i<partEmitt.size(); i++) {
252                        if(partEmitt[i] == NULL) {
253                                this->scene->manager->printToConsole("ist nullllllllllllllllllllllllllllllllll!");
254                        }
255                        bullet->addParticleEmitter(partEmitt[i]);
256                }
257        } //else if...
258
259        /*Bullet *bullet = (Bullet *) this->scene->createReferenceNode(this->scene->NODE_BULLET, true);
260        bullet->setType(type);
261        bullet->setSpeed(speed);
262        bullet->setImpactForce(impactForce);
263        bullet->setFilename(mdlObject.c_str());
264        if(pActorInside)
265                this->tracePActor(pActorNode, *bullet);*/
266}
267
268void GameSceneLoader::traceWeapon(MSXML::IXMLDOMNodePtr weaponNode) {
269        /*      <weapon>
270                <type>0</type>
271                <bulletType>0</bulletType>
272                <reboundForce>500</reboundForce>
273                ..
274                ..
275                ..
276        </weapon>*/
277
278        _bstr_t tmpType("type");
279        _bstr_t tmpBulletType("bulletType");
280        _bstr_t tmpReboundForce("reboundForce");
281        _bstr_t tmpIdleSound("idleSound");
282        _bstr_t tmpPreloadTime("preloadTime");
283        _bstr_t tmpPreloadSound("preloadSound");
284        _bstr_t tmpFireTime("fireTime");
285        _bstr_t tmpFireSound("fireSound");
286        _bstr_t tmpPostloadTime("postloadTime");
287        _bstr_t tmpPostloadSound("postloadSound");
288        _bstr_t tmpEmptySound("emptySound");
289       
290        _bstr_t tmpXFile("xfile");
291
292        int type=0;
293        int bulletType=0;
294        float reboundForce=0;
295        std::string idleSound;
296        float preloadTime=0;
297        std::string preloadSound;
298        float fireTime=0;
299        std::string fireSound;
300        float postloadTime=0;
301        std::string postloadSound;
302        std::string emptySound;
303        std::string xfile;
304        for (MSXML::IXMLDOMNodePtr pChild = weaponNode->firstChild;NULL != pChild;pChild = pChild->nextSibling) {
305                if(pChild->nodeType == MSXML::NODE_ELEMENT) {
306                        if(pChild->nodeName == tmpType) {
307                                type = atoi(pChild->firstChild->text);                          //WeaponType
308                        } else if(pChild->nodeName == tmpBulletType) {
309                                bulletType = atoi(pChild->firstChild->text);            //BulletType
310                        } else if(pChild->nodeName == tmpReboundForce) {
311                                reboundForce = (FLOAT)atof(pChild->firstChild->text);           //ReboundForce
312                        } else if(pChild->nodeName == tmpIdleSound) {
313                                idleSound = pChild->firstChild->text;                           //IdleSound
314                        } else if(pChild->nodeName == tmpPreloadTime) {
315                                preloadTime = (FLOAT)atof(pChild->firstChild->text);            //PreloadTime
316                        } else if(pChild->nodeName == tmpPreloadSound) {       
317                                preloadSound = pChild->firstChild->text;                        //PreloadSound
318                        } else if(pChild->nodeName == tmpFireTime) {
319                                fireTime = (FLOAT)atof(pChild->firstChild->text);                       //FireTime
320                        } else if(pChild->nodeName == tmpFireSound) {
321                                fireSound = pChild->firstChild->text;                           //FireSound
322                        } else if(pChild->nodeName == tmpPostloadTime) {
323                                postloadTime = (FLOAT)atof(pChild->firstChild->text);           //PostloadTime
324                        } else if(pChild->nodeName == tmpPostloadSound) {
325                                postloadSound = pChild->firstChild->text;                       //PostloadSound
326                        } else if(pChild->nodeName == tmpEmptySound) {
327                                emptySound = pChild->firstChild->text;                          //EmptySound
328                        } else if(pChild->nodeName == tmpXFile) {
329                                xfile = pChild->firstChild->text;                                       //XFile
330                        }
331                }
332        }
333        if(type <= 4) { //All simpleWeapons
334                SimpleWeapon *weapon = (SimpleWeapon *) this->scene->createReferenceNode(this->scene->NODE_SIMPLEWEAPON, true);
335                weapon->setWeaponType(type);
336        } else {                //Yet, only these Types are supported!
337                UniversalWeapon *weapon = (UniversalWeapon*) this->scene->createReferenceNode(GameScene::NODE_UNIVERSALWEAPON, true);
338                weapon->setWeaponType(type);
339                weapon->setBulletType(bulletType);
340                weapon->setReboundForce(reboundForce);
341                weapon->setStateSound(Weapon::STATE_IDLE, idleSound);
342                weapon->setStateTime(Weapon::STATE_PRELOAD, preloadTime);
343                weapon->setStateSound(Weapon::STATE_PRELOAD, preloadSound);
344                weapon->setStateTime(Weapon::STATE_FIRE, fireTime);
345                weapon->setStateSound(Weapon::STATE_FIRE, fireSound);
346                weapon->setStateTime(Weapon::STATE_POSTLOAD, postloadTime);
347                weapon->setStateSound(Weapon::STATE_POSTLOAD, postloadSound);
348                weapon->setStateSound(Weapon::STATE_EMPTY, emptySound);
349                weapon->setXFile(xfile);
350                weapon->setStandBy(true);
351        }
352        //else if...
353        /*Weapon *weapon = (Weapon *) this->scene->createReferenceNode(this->scene->NODE_WEAPON, true);
354        weapon->setType(type);
355        weapon->setBulletType(bulletType);
356        weapon->setReboundForce(reboundForce);
357        weapon->setLeftWeapon(mdlObject.c_str());
358        weapon->setRightWeapon(mdlObject.c_str());
359        weapon->setReboundTime(reboundTime);
360        weapon->setReloadTime(reloadTime);*/
361}
362
363void GameSceneLoader::tracePlayer(MSXML::IXMLDOMNodePtr playerNode) {
364        Vector position;
365        int type;
366        int team = 0;
367        std::string avatar = "";
368
369        _bstr_t tmpType("type");
370        _bstr_t tmpPosition("position");
371        _bstr_t tmpWeapon("weapon");
372        _bstr_t tmpTeam("team");
373        _bstr_t tmpAvatar("xfile");
374
375        bool aiPlayer = false;
376
377        Player *player = NULL;
378        for (MSXML::IXMLDOMNodePtr pChild = playerNode->firstChild;NULL != pChild;pChild = pChild->nextSibling) {
379                if(pChild->nodeType == MSXML::NODE_ELEMENT) {
380                        if(pChild->nodeName == tmpType) {
381                                type = atoi(pChild->firstChild->text);
382                                switch(type) {
383                                        case 0:
384                                                this->scene->manager->printToConsole("Creating UserPlayer");
385                                                player = (Player *) this->scene->createNode(this->scene->NODE_USERPLAYER, false);
386                                                break;
387                                        case 1:
388                                                this->scene->manager->printToConsole("Creating AIPlayer");
389                                                player = (Player *) this->scene->createNode(this->scene->NODE_AIPLAYER, false);
390                                                aiPlayer = true;
391                        break;
392                                }
393                        } else if(pChild->nodeName == tmpPosition) {
394                                position = tracePosition(pChild);
395                                player->initPlayer(position.x, position.y, position.z);
396                        } else if(pChild->nodeName == tmpWeapon) {
397                this->addWeapon(pChild, *player);                               
398                        } else if(pChild->nodeName == tmpTeam) {
399                                team = atoi(pChild->firstChild->text);
400                        } else if(pChild->nodeName == tmpAvatar) {
401                                avatar = pChild->firstChild->text;
402                                player->setAvatareFileName(avatar);
403                        }
404                }
405        }
406
407        if(aiPlayer) {
408                this->scene->enemyModel = avatar;
409        }
410       
411        //player->initPlayer(position.x, position.y, position.z);
412        player->setTeam(team);
413        player->setActiveWeapon(0);
414}
415
416void GameSceneLoader::addWeapon(MSXML::IXMLDOMNodePtr playerWeaponNode, Player &player) {
417        //Addweapon and munition
418        /*<weapon>
419                <type>0</type>
420                <amount>100</amount>
421        </weapon>*/
422        _bstr_t tmpType("type");
423        _bstr_t tmpAmount("amount");
424
425        int type=0;
426        int amount=0;
427       
428        for (MSXML::IXMLDOMNodePtr pChild = playerWeaponNode->firstChild;NULL != pChild;pChild = pChild->nextSibling) {
429                if(pChild->nodeType == MSXML::NODE_ELEMENT) {
430                        if(pChild->nodeName == tmpType) {
431                                type = atoi(pChild->firstChild->text);
432                        } else if(pChild->nodeName == tmpAmount) {
433                                amount = atoi(pChild->firstChild->text);
434                        }
435                }
436        }
437        if(type<=4) {
438                //this->scene->manager->printToConsole("   adding Weapon Type<=3");
439                SimpleWeapon *weapon = (SimpleWeapon *) this->scene->createNode(this->scene->NODE_SIMPLEWEAPON, *player.schale, true);
440                weapon->setWeaponType(type);
441                weapon->addMunition(amount);
442                weapon->initWeapon();
443                player.addWeapon(*weapon);
444                return;
445        } else {
446                player.addWeapon(*this->scene->cloneWeaponFromReference(type));
447        }
448
449        /*Weapon *refWeapon = NULL;
450
451        //Find Reference Weapon
452        for(unsigned int i=0;i<this->scene->refWeaponList.size();i++) {
453                refWeapon = (Weapon *) this->scene->refWeaponList.at(i).get();
454                if(refWeapon->getWeaponType()==type)
455                        break;
456        }*/
457
458        //Add Weapon to Player
459        //Weapon *weapon = player.sMgr->createWeapon(*player.schale);
460        /*Weapon *weapon = (Weapon *) this->scene->createNode(this->scene->NODE_WEAPON, *player.schale, true);
461        weapon->setType(refWeapon->getType());
462        weapon->setBulletType(refWeapon->getBulletType());
463        weapon->setReboundForce(refWeapon->getReboundForceLength());
464        weapon->setLeftWeapon(refWeapon->getLeftWeaponFilename());
465        weapon->setRightWeapon(refWeapon->getRightWeaponFilename());
466        weapon->setReboundTime(refWeapon->getReboundTime());
467        weapon->setReloadTime(refWeapon->getReloadTime());
468        weapon->initWeapon();
469        player.addWeapon(*weapon);
470        player.addMunition(refWeapon->getBulletType(), amount);*/
471
472
473}
474
475void GameSceneLoader::traceSkyBox(MSXML::IXMLDOMNodePtr skyBoxNode) {
476        /*<skybox>
477                        <skyname>./media/sky.x</skyname>
478        </skybox>*/
479       
480        _bstr_t tmpCube("xfile");
481        /*_bstr_t tmpTexture0("skytexture0");
482        _bstr_t tmpTexture1("skytexture1");
483        _bstr_t tmpTexture2("skytexture2");
484        _bstr_t tmpTexture3("skytexture3");
485        _bstr_t tmpTexture4("skytexture4");
486        _bstr_t tmpTexture5("skytexture5");
487        _bstr_t tmpTexture6("skytexture6");
488        _bstr_t tmpTexture7("skytexture7");
489        _bstr_t tmpTexture8("skytexture8");*/
490
491        std::string skyname;
492        /*std::string texture0;
493        std::string texture1;
494        std::string texture2;
495        std::string texture3;
496        std::string texture4;
497        std::string texture5;
498        std::string texture6;
499        std::string texture7;
500        std::string texture8;*/
501       
502        std::string skyTexture;
503        for (MSXML::IXMLDOMNodePtr pChild = skyBoxNode->firstChild;NULL != pChild;pChild = pChild->nextSibling) {
504                if(pChild->nodeType == MSXML::NODE_ELEMENT) {
505                        if(pChild->nodeName == tmpCube) {
506                                skyname = pChild->firstChild->text;
507                        }
508                        /*if(pChild->nodeName == tmpTexture0) {
509                                texture0 = pChild->firstChild->text;
510                        } else if(pChild->nodeName == tmpTexture1) {
511                                texture1 = pChild->firstChild->text;
512                        } else if(pChild->nodeName == tmpTexture2) {
513                                texture2 = pChild->firstChild->text;
514                        } else if(pChild->nodeName == tmpTexture3) {
515                                texture3 = pChild->firstChild->text;
516                        } else if(pChild->nodeName == tmpTexture4) {
517                                texture4 = pChild->firstChild->text;
518                        } else if(pChild->nodeName == tmpTexture5) {
519                                texture5 = pChild->firstChild->text;
520                        } else if(pChild->nodeName == tmpTexture6) {
521                                texture6 = pChild->firstChild->text;
522                        } else if(pChild->nodeName == tmpTexture7) {
523                                texture7 = pChild->firstChild->text;
524                        } else if(pChild->nodeName == tmpTexture8) {
525                                texture8 = pChild->firstChild->text;
526                        }*/
527                }
528        }
529
530        //SkyBox erzeugen & entsprechende Texture laden
531        /*this->scene->createSkybox();*/
532
533        SkyBox *skybox = (SkyBox *) this->scene->createNode(this->scene->NODE_SKYBOX, *this->scene->getRoot(), false);
534        skybox->generateSkyBox(skyname);
535        //skybox->generateSkyBox("./media/models/skybox1.x");
536
537        /*this->scene->getSkybox()->setTexture0(texture0);
538        this->scene->getSkybox()->setTexture1(texture1);
539        this->scene->getSkybox()->setTexture2(texture2);
540        this->scene->getSkybox()->setTexture3(texture3);
541        this->scene->getSkybox()->setTexture4(texture4);
542        this->scene->getSkybox()->setTexture5(texture5);
543        this->scene->getSkybox()->setTexture6(texture6);
544        this->scene->getSkybox()->setTexture7(texture7);
545        this->scene->getSkybox()->setTexture8(texture8);
546
547
548        this->scene->getSkybox()->generateSkybox(this->scene->getSunDirecetion());
549        this->scene->getSkybox()->setSize(this->scene->getTerrain()->getSize());*/
550}
551
552void GameSceneLoader::traceTerrain(MSXML::IXMLDOMNodePtr terrainNode) {
553        _bstr_t tmpHeightMap("heightmap");
554        _bstr_t tmpTexture0("texture0");
555        _bstr_t tmpTexture1("texture1");
556        _bstr_t tmpTexture2("texture2");
557
558        std::string heightMap;
559        std::string texture0;
560        std::string texture1;
561        std::string texture2;
562        for (MSXML::IXMLDOMNodePtr pChild = terrainNode->firstChild;NULL != pChild;pChild = pChild->nextSibling) {
563                if(pChild->nodeType == MSXML::NODE_ELEMENT) {
564                        if(pChild->nodeName == tmpHeightMap) {
565                                heightMap = pChild->firstChild->text;
566                        } else if(pChild->nodeName == tmpTexture0) {
567                                texture0 = pChild->firstChild->text;
568                        } else if(pChild->nodeName == tmpTexture1) {
569                                texture1 = pChild->firstChild->text;
570                        } else if(pChild->nodeName == tmpTexture2) {
571                                texture2 = pChild->firstChild->text;
572                        }
573                }
574        }
575
576        Terrain *terrain = (Terrain *) this->scene->createNode(this->scene->NODE_TERRAIN, *this->scene->getRoot(), false);
577       
578        terrain->setTextures(texture0, texture1, texture2);
579        terrain->generateTerrain(heightMap, 129, 129);
580}
581
582void GameSceneLoader::traceOcean(MSXML::IXMLDOMNodePtr oceanNode) {
583        _bstr_t tmpTexture0("texture0");
584        _bstr_t tmpTexture1("texture1");
585        _bstr_t tmpWatermap("watermap");
586        _bstr_t tmpShallowColorR("shallowColorR");
587        _bstr_t tmpShallowColorG("shallowColorG");
588        _bstr_t tmpShallowColorB("shallowColorB");
589        _bstr_t tmpDeepColorR("deepColorR");
590        _bstr_t tmpDeepColorG("deepColorG");
591        _bstr_t tmpDeepColorB("deepColorB");
592       
593        std::string texture0;
594        std::string texture1;
595        std::string watermap;
596        float shallowColor [] = {0.0f, 0.0f, 0.0f, 0.0f};
597        float deepColor [] = {0.0f, 0.0f, 0.0f, 0.0f};
598       
599        for (MSXML::IXMLDOMNodePtr pChild = oceanNode->firstChild;NULL != pChild;pChild = pChild->nextSibling) {
600                if(pChild->nodeType == MSXML::NODE_ELEMENT) {
601                        if(pChild->nodeName == tmpTexture0) {
602                                texture0 = pChild->firstChild->text;
603                        } else if(pChild->nodeName == tmpTexture1) {
604                                texture1 = pChild->firstChild->text;
605                        } else if(pChild->nodeName == tmpShallowColorR) {
606                                shallowColor[0] = (FLOAT)atof(pChild->firstChild->text);
607                        } else if(pChild->nodeName == tmpShallowColorG) {
608                                shallowColor[1] = (FLOAT)atof(pChild->firstChild->text);
609                        } else if(pChild->nodeName == tmpShallowColorB) {
610                                shallowColor[2] = (FLOAT)atof(pChild->firstChild->text);
611                        } else if(pChild->nodeName == tmpDeepColorR) {
612                                deepColor[0] = (FLOAT)atof(pChild->firstChild->text);
613                        } else if(pChild->nodeName == tmpDeepColorG) {
614                                deepColor[1] = (FLOAT)atof(pChild->firstChild->text);
615                        } else if(pChild->nodeName == tmpDeepColorB) {
616                                deepColor[2] = (FLOAT)atof(pChild->firstChild->text);
617                        } else if(pChild->nodeName == tmpWatermap) {
618                                watermap = pChild->firstChild->text;
619                        }
620                }
621        }
622       
623        Ocean *ocean = (Ocean *) this->scene->createNode(this->scene->NODE_OCEAN, *this->scene->getRoot(), false);
624       
625        ocean->setTextures(texture0, texture1, watermap);
626        ocean->generateOcean(deepColor, shallowColor);
627}
628
629void GameSceneLoader::traceGoodies(MSXML::IXMLDOMNodePtr goodiesNode) {
630        /*<goodies>
631                <healthpackage>
632                </healthpackage>
633                <weaponpackage>
634                </weaponpackage>
635                <amopackage>
636                </amopackage>
637        </goodies>*/
638        _bstr_t tmpHealthPackage("healthpackage");
639        _bstr_t tmpWeapon("weaponpackage");
640        _bstr_t tmpAmo("amopackage");
641        //_bstr_t tmpPActor("pactor");
642        MSXML::IXMLDOMNodePtr pActorNode;
643        bool pActorInside = false;
644
645       
646        for (MSXML::IXMLDOMNodePtr pChild = goodiesNode->firstChild;NULL != pChild;pChild = pChild->nextSibling) {
647                if(pChild->nodeType == MSXML::NODE_ELEMENT) {
648                        if(pChild->nodeName == tmpHealthPackage) {
649                                traceHealthPackage(pChild);
650                        } else if(pChild->nodeName == tmpWeapon) {
651                                traceWeaponPackage(pChild);
652                        } else if(pChild->nodeName == tmpAmo) {
653                                traceAmoPackage(pChild);
654                        }/*  else if(pChild->nodeName == tmpAmo) {
655                                pActorNode = pChild;
656                                pActorInside = true;
657                        }*/
658                }
659        }
660}
661
662void GameSceneLoader::traceWeaponPackage(MSXML::IXMLDOMNodePtr weaponNode) {
663        /*<weaponpackage>
664                <position>
665                        <x>1200</x>
666                        <y>450</y>
667                        <z>1300</z>
668                </position>
669                <type>0</type>
670                <amount>1000</amount>
671                <arrivalTime>20000</arrivalTime>
672        </weaponpackage>*/
673        _bstr_t tmpPosition("position");
674        _bstr_t tmpType("type");
675        _bstr_t tmpAmount("amount");
676        _bstr_t tmpArrivalTime("arrivaltime");
677        _bstr_t tmpVariation("timevariation");
678        _bstr_t tmpPhysic("pactor");
679        _bstr_t tmpRenderer("renderer");
680        _bstr_t tmpXFile("xfile");
681
682        int type = 0;
683        int amo = 0;
684        float arrivalTime = 0;
685        float arrivalVariation = 0;
686        Vector position;
687        MSXML::IXMLDOMNodePtr physicChild;
688        bool hasPActor = false;
689        MSXML::IXMLDOMNodePtr rendererChild;
690        bool hasRenderer = false;
691        std::string xfile;
692        for (MSXML::IXMLDOMNodePtr pChild = weaponNode->firstChild;NULL != pChild;pChild = pChild->nextSibling) {
693                if(pChild->nodeType == MSXML::NODE_ELEMENT) {
694                        if(pChild->nodeName == tmpPosition) {
695                                position = tracePosition(pChild);
696                        } else if(pChild->nodeName == tmpType) {
697                                type = atoi(pChild->firstChild->text);
698                        } else if(pChild->nodeName == tmpAmount) {
699                                amo = atoi(pChild->firstChild->text);
700                        } else if(pChild->nodeName == tmpArrivalTime) {
701                                arrivalTime = (FLOAT)atof(pChild->firstChild->text);
702                        } else if(pChild->nodeName == tmpVariation) {
703                                arrivalVariation = (FLOAT)atof(pChild->firstChild->text);
704                        } else if(pChild->nodeName == tmpPhysic) {
705                                physicChild = pChild;
706                                hasPActor = true;
707                        } else if(pChild->nodeName == tmpRenderer) {
708                                rendererChild = pChild;
709                                hasRenderer = true;
710                        } else if(pChild->nodeName == tmpXFile) {
711                                xfile = pChild->firstChild->text;
712                        }
713                }
714        }
715        //TODO zufallssachen machen, goodie registrieren
716        /*if(position.x = 0 && position.y = 0 && position.z = 0) {
717                //Generate random coodinates
718                float w = this->scene->getWidth();
719                float y = this->scene->getHeight();
720
721        }*/
722        //Register WeaponPackage in ChallengeManager!!
723        //this->cMgr->registerWeaponPackage(position, type, amo, arrivalTime);
724        //this->scene->registerWeaponPackage(position, type, amo, arrivalTime, arrivalVariation);
725        Goodie* wp;
726        if(!hasRenderer) {
727                wp = (Goodie*) this->scene->createNode(this->scene->NODE_GOODIE, true);
728        } else {
729                wp = (Goodie*) this->scene->createNode(this->scene->NODE_GOODIE, false);
730                this->traceRenderer(rendererChild, *wp);
731        }
732        wp->setXFile(xfile);
733        wp->setPosition(position);
734        wp->setGoodieType(wp->GOODIE_WEAPON);
735        wp->setWeaponType(type);
736        wp->setArmorAmount(amo);
737        wp->setStandBy(true);
738        wp->loadGoodieMesh();
739        if(hasPActor) {
740                this->tracePActor(physicChild, *wp);
741                wp->setColDetGroup(UserContactReport::COLGROUP_GOODIE);
742        }
743        wp->init();
744        this->scene->setTrigger(this->scene->TRIGGER_UNSETSTANDBY, wp, this->scene->getRandomTime(arrivalTime, arrivalVariation));
745}
746
747void GameSceneLoader::traceHealthPackage(MSXML::IXMLDOMNodePtr healthNode) {
748        /*<healthpackage>
749                <position>
750                        <x>300</x>
751                        <y>450</y>
752                        <z>900</z>
753                </position>
754                <healthamount>100</healthamount>
755                <arrivalTime>20000</arrivalTime>
756        </healthpackage>*/
757        _bstr_t tmpPosition("position");
758        _bstr_t tmpHealth("healthamount");
759        _bstr_t tmpArrivaltime("arrivaltime");
760        _bstr_t tmpVariation("timevariation");
761        _bstr_t tmpPhysic("pactor");
762        _bstr_t tmpRenderer("renderer");
763        _bstr_t tmpXFile("xfile");
764
765        Vector position;
766        float health = 0;
767        float arrivalTime = 0;
768        float arrivalVariation = 0;
769        MSXML::IXMLDOMNodePtr physicChild;
770        bool hasPActor = false;
771        MSXML::IXMLDOMNodePtr rendererChild;
772        bool hasRenderer = false;
773        std::string xfile = "";
774        for (MSXML::IXMLDOMNodePtr pChild = healthNode->firstChild;NULL != pChild;pChild = pChild->nextSibling) {
775                if(pChild->nodeType == MSXML::NODE_ELEMENT) {
776                        if(pChild->nodeName == tmpPosition) {
777                                position = tracePosition(pChild);
778                        } else if(pChild->nodeName == tmpHealth) {
779                                health = (FLOAT)atof(pChild->firstChild->text);
780                        } else if(pChild->nodeName == tmpArrivaltime) {
781                                arrivalTime = (FLOAT)atof(pChild->firstChild->text);
782                        } else if(pChild->nodeName == tmpVariation) {
783                                arrivalVariation = (FLOAT)atof(pChild->firstChild->text);
784                        } else if(pChild->nodeName == tmpPhysic) {
785                                physicChild = pChild;
786                                hasPActor = true;
787                        } else if(pChild->nodeName == tmpRenderer) {
788                                rendererChild = pChild;
789                                hasRenderer = true;
790                        } else if(pChild->nodeName == tmpXFile) {
791                                xfile = pChild->firstChild->text;
792                        }
793                }
794        }
795
796        Goodie* hp;
797        if(!hasRenderer) {
798                hp = (Goodie*) this->scene->createNode(this->scene->NODE_GOODIE, true);
799        } else {
800                hp = (Goodie*) this->scene->createNode(this->scene->NODE_GOODIE, false);
801                this->traceRenderer(rendererChild, *hp);
802        }
803        hp->setXFile(xfile);
804        hp->setPosition(position);
805        hp->setGoodieType(hp->GOODIE_HEALTH);
806        hp->setHealthAmount(health);
807        hp->setStandBy(true);
808        hp->loadGoodieMesh();
809        if(hasPActor) {
810                this->tracePActor(physicChild, *hp);
811                hp->setColDetGroup(UserContactReport::COLGROUP_GOODIE);
812        }
813        //if use phyics
814        //hp->generatePhysicMesh(obj->COL_CONVEX);
815        //hp->setBehaveAs(obj->RIGIDBODY);
816        hp->init();
817        this->scene->setTrigger(this->scene->TRIGGER_UNSETSTANDBY, hp, this->scene->getRandomTime(arrivalTime, arrivalVariation));
818
819
820        //Register HealthPackage in ChallengeManager!!
821        //TODO this->cMgr->registerHealthPackage(position, health, arrivalTime);
822        //this->scene->registerHealthPackage(position, health, arrivalTime, arrivalVariation);
823}
824
825void GameSceneLoader::traceAmoPackage(MSXML::IXMLDOMNodePtr amoNode) {
826        /*<amopackage>
827                <position>
828                        <x>1300</x>
829                        <y>450</y>
830                        <z>1300</z>
831                </position>
832                <type>0</type>
833                <amount>1000</amount>
834                <arrivalTime>20000</arrivalTime>
835        </amopackage>*/
836        _bstr_t tmpPosition("position");
837        _bstr_t tmpType("type");
838        _bstr_t tmpAmount("amount");
839        _bstr_t tmpArrivalTime("arrivaltime");
840        _bstr_t tmpVariation("timevariation");
841        _bstr_t tmpPhysic("pactor");
842        _bstr_t tmpRenderer("renderer");
843        _bstr_t tmpXFile("xfile");
844
845        Vector position;
846        int type = 0;
847        int amount = 0;
848        float arrivalTime = 0;
849        float arrivalVariation = 0;
850        MSXML::IXMLDOMNodePtr physicChild;
851        bool hasPActor = false;
852        MSXML::IXMLDOMNodePtr rendererChild;
853        bool hasRenderer = false;
854        std::string xfile = "";
855        for (MSXML::IXMLDOMNodePtr pChild = amoNode->firstChild;NULL != pChild;pChild = pChild->nextSibling) {
856                if(pChild->nodeType == MSXML::NODE_ELEMENT) {
857                        if(pChild->nodeName == tmpPosition) {
858                                position = tracePosition(pChild);
859                        } else if(pChild->nodeName == tmpType) {
860                                type = atoi(pChild->firstChild->text);
861                        } else if(pChild->nodeName == tmpAmount) {
862                                amount = atoi(pChild->firstChild->text);
863                        } else if(pChild->nodeName == tmpArrivalTime) {
864                                arrivalTime = (FLOAT)atof(pChild->firstChild->text);
865                        } else if(pChild->nodeName == tmpVariation) {
866                                arrivalVariation = (FLOAT)atof(pChild->firstChild->text);
867                        } else if(pChild->nodeName == tmpPhysic) {
868                                physicChild = pChild;
869                                hasPActor = true;
870                        } else if(pChild->nodeName == tmpRenderer) {
871                                rendererChild = pChild;
872                                hasRenderer = true;
873                        } else if(pChild->nodeName == tmpXFile) {
874                                xfile = pChild->firstChild->text;
875                        }
876                }
877        }
878
879        Goodie* mp;
880        if(!hasRenderer) {
881                mp = (Goodie*) this->scene->createNode(this->scene->NODE_GOODIE, true);
882        } else {
883                mp = (Goodie*) this->scene->createNode(this->scene->NODE_GOODIE, false);
884                this->traceRenderer(rendererChild, *mp);
885        }
886        mp->setXFile(xfile);
887        mp->setPosition(position);
888        mp->setGoodieType(mp->GOODIE_AMO);
889        mp->setWeaponType(type);
890        mp->setArmorAmount(amount);
891        mp->setStandBy(true);
892        mp->loadGoodieMesh();
893        if(hasPActor) {
894                this->tracePActor(physicChild, *mp);
895                mp->setColDetGroup(UserContactReport::COLGROUP_GOODIE);
896        }
897        mp->init();
898        this->scene->setTrigger(this->scene->TRIGGER_UNSETSTANDBY, mp, this->scene->getRandomTime(arrivalTime, arrivalVariation));
899}
900
901void GameSceneLoader::traceHud(MSXML::IXMLDOMNodePtr terrainNode) {
902        _bstr_t tmpCrosshair("crosshair");
903        _bstr_t tmpCrosshairX("crosshairscaleX");
904        _bstr_t tmpCrosshairY("crosshairscaleY");
905        _bstr_t tmpRadar("radar");
906        _bstr_t tmpRadarX("radarscaleX");
907        _bstr_t tmpRadarY("radarscaleY");
908        _bstr_t tmpRadarOffsetX("radaroffsetX");
909        _bstr_t tmpRadarOffsetY("radaroffsetY");
910        _bstr_t tmpUserPlayer("userplayerscale");
911        _bstr_t tmpAIPlayer("aiplayerscale");
912        _bstr_t tmpTexture0("texture0");
913        _bstr_t tmpTexture1("texture1");
914        _bstr_t tmpTexture2("texture2");
915        _bstr_t tmpTexture3("texture3");
916        _bstr_t tmpTexture4("texture4");
917       
918       
919
920        std::string crosshair;
921        float CrosshairScaleX = 1.0f;
922        float CrosshairScaleY = 1.0f;
923        std::string radar;
924        float RadarScaleX = 1.0f;
925        float RadarScaleY = 1.0f;
926        float RadarOffsetX = 20.0f;
927        float RadarOffsetY = 20.0f;
928        float scaleUserPlayer = 1.0f;
929        float scaleAIPlayer = 1.0f;
930        std::string texture0;
931        std::string texture1;
932        std::string texture2;
933        std::string texture3;
934        std::string texture4;
935
936       
937        for (MSXML::IXMLDOMNodePtr pChild = terrainNode->firstChild;NULL != pChild;pChild = pChild->nextSibling) {
938                if(pChild->nodeType == MSXML::NODE_ELEMENT) {
939                        if(pChild->nodeName == tmpCrosshair) {
940                                crosshair = pChild->firstChild->text;
941                        } else if(pChild->nodeName == tmpCrosshairX) {
942                                CrosshairScaleX = (FLOAT)atof(pChild->firstChild->text);
943                        } else if(pChild->nodeName == tmpCrosshairY) {
944                                CrosshairScaleY = (FLOAT)atof(pChild->firstChild->text);
945                        } else if(pChild->nodeName == tmpRadar) {
946                                radar = pChild->firstChild->text;
947                        } else if(pChild->nodeName == tmpRadarX) {
948                                RadarScaleX = (FLOAT)atof(pChild->firstChild->text);
949                        } else if(pChild->nodeName == tmpRadarY) {
950                                RadarScaleY = (FLOAT)atof(pChild->firstChild->text);
951                        } else if(pChild->nodeName == tmpRadarOffsetX) {
952                                RadarOffsetX = (FLOAT)atof(pChild->firstChild->text);
953                        } else if(pChild->nodeName == tmpRadarOffsetY) {
954                                RadarOffsetY = (FLOAT)atof(pChild->firstChild->text);
955                        } else if(pChild->nodeName == tmpUserPlayer) {
956                                scaleUserPlayer = (FLOAT)atof(pChild->firstChild->text);
957                        } else if(pChild->nodeName == tmpAIPlayer) {
958                                scaleAIPlayer = (FLOAT)atof(pChild->firstChild->text);
959                        } else if(pChild->nodeName == tmpTexture0) {
960                                texture0 = pChild->firstChild->text;
961                        } else if(pChild->nodeName == tmpTexture1) {
962                                texture1 = pChild->firstChild->text;
963                        } else if(pChild->nodeName == tmpTexture2) {
964                                texture2 = pChild->firstChild->text;
965                        } else if(pChild->nodeName == tmpTexture3) {
966                                texture3 = pChild->firstChild->text;
967                        } else if(pChild->nodeName == tmpTexture4) {
968                                texture4 = pChild->firstChild->text;
969                        }
970                }
971        }
972
973        //instanciate hud
974        HUD *hud = (HUD*) this->scene->createNode(this->scene->NODE_HUD, *this->scene->getRoot(), false);
975       
976        hud->setCrosshair(crosshair, CrosshairScaleX, CrosshairScaleY);
977        hud->setRadar(radar, RadarScaleX, RadarScaleY, RadarOffsetX, RadarOffsetY);
978        hud->setTextures(texture0, texture1, texture2, texture3, texture4, scaleUserPlayer, scaleAIPlayer);
979        hud->generateHUD();
980}
981
982void GameSceneLoader::tracePActor(MSXML::IXMLDOMNodePtr actorNode, Object3d &obj) {
983        /*<pactor>
984                <behaveas>0</behaveas>          0 - NORMAL, 1 - STATIC, 2 - KINEMATIC, 3 - RIGIDBODY
985                <colmode>1</colmode>            0 - MESH, 1 - HEIGHTFIELD, 2 - CONVEX, 3 - PMAP
986                <density>10.2</density>
987                <material>index</material>
988         </pactor>*/
989        _bstr_t tmpColMode("colmode");
990        _bstr_t tmpBehaveAs("behaveas");
991        _bstr_t tmpDensity("density");
992        _bstr_t tmpMaterial("material");
993        _bstr_t tmpColGroup("colgroup");
994       
995        int colmode = 0;
996        int behaveas = 0;
997        float density = 10;
998        int material = 0;
999        int colgroup = UserContactReport::COLGROUP_OTHER;
1000
1001        for (MSXML::IXMLDOMNodePtr pChild = actorNode->firstChild;NULL != pChild;pChild = pChild->nextSibling) {
1002                if(pChild->nodeType == MSXML::NODE_ELEMENT) {
1003                        if(pChild->nodeName == tmpColMode) {
1004                                colmode = atoi(pChild->firstChild->text);
1005                        } else if(pChild->nodeName == tmpBehaveAs) {
1006                                behaveas = atoi(pChild->firstChild->text);
1007                        } else if(pChild->nodeName == tmpDensity) {
1008                                density = (FLOAT)atof(pChild->firstChild->text);
1009                        } else if(pChild->nodeName == tmpMaterial) {
1010                                material = atoi(pChild->firstChild->text);
1011                        } else if(pChild->nodeName == tmpColGroup) {
1012                                colgroup = atoi(pChild->firstChild->text);
1013                        }
1014                }
1015        }
1016        NxActorDesc* ad = obj.getActorDescriptor();
1017        ad->density = density;
1018        obj.getBodyDescriptor()->mass = 0;
1019        obj.generatePhysicMesh(colmode);
1020        obj.setBehaveAs(behaveas);
1021        obj.setColDetGroup(colgroup);
1022        obj.setPMaterial(this->scene->getPhysicMaterialId(material));
1023}
1024
1025void GameSceneLoader::tracePMaterial(MSXML::IXMLDOMNodePtr materialNode) {
1026        /*<pmaterial>
1027                <materialid>0<materialid>
1028                <restitution>0.7</restitution>
1029                <staticfriction>0.5</staticfriction>
1030                <dynamicfriction>0.5</dynamicfriction>
1031         </pmaterial>*/
1032        _bstr_t tmpMaterial("materialid");
1033        _bstr_t tmpRestitution("restitution");
1034        _bstr_t tmpStaticFriction("staticfriction");
1035        _bstr_t tmpDynamicFriction("dynamicfriction");
1036       
1037        int materialid = 0;
1038        float restitution = 0.7f;
1039        float staticFriction = 0.5f;
1040        float dynamicFriction = 0.5f;
1041
1042        for (MSXML::IXMLDOMNodePtr pChild = materialNode->firstChild;NULL != pChild;pChild = pChild->nextSibling) {
1043                if(pChild->nodeType == MSXML::NODE_ELEMENT) {
1044                        if(pChild->nodeName == tmpMaterial) {
1045                                materialid = atoi(pChild->firstChild->text);
1046                        } else if(pChild->nodeName == tmpRestitution) {
1047                                restitution = (FLOAT)atof(pChild->firstChild->text);
1048                        } else if(pChild->nodeName == tmpStaticFriction) {
1049                                staticFriction = (FLOAT)atof(pChild->firstChild->text);
1050                        } else if(pChild->nodeName == tmpDynamicFriction) {
1051                                dynamicFriction = (FLOAT)atof(pChild->firstChild->text);
1052                        }
1053                }
1054        }
1055        NxMaterialDesc md;
1056        md.restitution = restitution;
1057        md.staticFriction = staticFriction;
1058        md.dynamicFriction = dynamicFriction;
1059        NxMaterial* m = this->scene->pScene->createMaterial(md);
1060        this->scene->connectMaterialIds(m->getMaterialIndex(), materialid);
1061}
1062
1063void GameSceneLoader::traceRenderer(MSXML::IXMLDOMNodePtr rendererNode, Node &node)
1064{
1065        /*<renderer>
1066                <type>0</type>          0 - RAYTRACE
1067                ....other renderer parameter....
1068         </renderer>*/
1069        _bstr_t tmpType("type");
1070       
1071        int type = 0;
1072
1073        for (MSXML::IXMLDOMNodePtr pChild = rendererNode->firstChild;NULL != pChild;pChild = pChild->nextSibling) {
1074                if(pChild->nodeType == MSXML::NODE_ELEMENT) {
1075                        if(pChild->nodeName == tmpType) {
1076                                type = atoi(pChild->firstChild->text);
1077                        }
1078                }
1079        }
1080        switch(type) {
1081                case 0:         //RaytraceRenderer
1082                        this->traceRaytraceRenderer(rendererNode, node);
1083                        break;
1084                case 1:         //ParticleRenderer
1085                        SPTR<Renderer> renderer(new ParticleRenderer);
1086                        //ParticleRenderer *r = (ParticleRenderer*) renderer.get();
1087                        this->scene->connectNodeAndRenderer(node, renderer);
1088            break;
1089        }
1090}
1091
1092void GameSceneLoader::traceRaytraceRenderer(MSXML::IXMLDOMNodePtr rendererNode, Node &node)
1093{
1094        /*<renderer>
1095                <fresnel>1.0</fresnel>
1096                <refraction>0.95</refraction>
1097         </renderer>*/
1098        _bstr_t tmpFresnel("fresnel");
1099        _bstr_t tmpRefraction("refraction");
1100        _bstr_t tmpIteration("iterations");
1101       
1102        float fresnel = 0;
1103        float refraction = 0;
1104        int nbIteration = 10;
1105
1106        for (MSXML::IXMLDOMNodePtr pChild = rendererNode->firstChild;NULL != pChild;pChild = pChild->nextSibling) {
1107                if(pChild->nodeType == MSXML::NODE_ELEMENT) {
1108                        if(pChild->nodeName == tmpFresnel) {
1109                                fresnel = (FLOAT)atof(pChild->firstChild->text);
1110                        } else if(pChild->nodeName == tmpRefraction) {
1111                                refraction = (FLOAT)atof(pChild->firstChild->text);
1112                        } else if(pChild->nodeName == tmpIteration) {
1113                                nbIteration = atoi(pChild->firstChild->text);
1114                        }
1115                }
1116        }
1117
1118        SPTR<Renderer> renderer(new RaytraceRenderer);
1119        RaytraceRenderer *r = (RaytraceRenderer*) renderer.get();
1120        r->setFresnelFactor(fresnel);
1121        r->setRefractionIndex(refraction);
1122        r->setNumberOfIterations(nbIteration);
1123        this->scene->connectNodeAndRenderer(node, renderer);
1124}
1125
1126ParticleEmitter* GameSceneLoader::traceParticleEmitter(MSXML::IXMLDOMNodePtr emitterNode) {
1127        /*<position>
1128                <x>1000</x>
1129                <y>200</y>
1130                <z>1000);</z>
1131        </position>
1132        <rotation>
1133                <x>-90</x>
1134                <y>0</y>
1135                <z>0</z>
1136        </rotation>
1137        <dimension>
1138                <x>-20</x>
1139                <y>20</y>
1140                <z>0</z>
1141        </dimension>
1142        <velocity>600</velocity>
1143        <duration>10</duration>
1144        <horizontalDegree>0.2</horizontalDegree>
1145        <verticalDegree>0.2</verticalDegree>
1146        <rotationalDegree>
1147                <x>0</x>
1148                <y>0</y>
1149                <z>10</z>
1150        </rotationalDegree>
1151        <birthRate>100</birthRate>*/
1152
1153        _bstr_t tmpPosition("position");
1154        _bstr_t tmpRotation("rotation");
1155        _bstr_t tmpDimension("dimension");
1156        _bstr_t tmpVelocity("velocity");
1157        _bstr_t tmpDuration("duration");
1158        _bstr_t tmpHDegree("horizontalDegree");
1159        _bstr_t tmpVDegree("verticalDegree");
1160        _bstr_t tmpRDegree("rotationalDegree");
1161        _bstr_t tmpBirthRate("birthRate");
1162        _bstr_t tmpSprite("sprite");
1163        _bstr_t tmpEnvObject("envObject");
1164        _bstr_t tmpTimeToLive("timetolive");
1165        _bstr_t tmpColGroup("colGroup");
1166        _bstr_t tmpRenderer("renderer");
1167        _bstr_t tmpHeatHaze("heathaze");
1168        _bstr_t tmpSound("sound");
1169        _bstr_t tmpGravity("gravity");
1170
1171        bool usingSprites = true;
1172        bool addRenderer = false;
1173        bool useGravity = true;
1174        MSXML::IXMLDOMNodePtr renderNode;
1175
1176        float velocity;
1177        float duration;
1178        float horizontalDegree;
1179        float verticalDegree;
1180        float birthRate;
1181        float timetolive;
1182        int colGroup;
1183        int heathaze = 0;
1184        SoundNode* sound = NULL;
1185
1186        Vector position;
1187        Vector rotation;
1188        Vector dimension;
1189        Vector rotationalDegree;
1190
1191       
1192        std::vector<Object3d*> objectVector;
1193        std::vector<Sprite*> spriteVector;
1194
1195        for (MSXML::IXMLDOMNodePtr pChild = emitterNode->firstChild;NULL != pChild;pChild = pChild->nextSibling) {
1196                if(pChild->nodeType == MSXML::NODE_ELEMENT) {
1197                        if(pChild->nodeName == tmpPosition) {
1198                                position = tracePosition(pChild);
1199                        } else if(pChild->nodeName == tmpRotation) {
1200                                rotation = tracePosition(pChild);
1201                        } else if(pChild->nodeName == tmpDimension) {
1202                                dimension = tracePosition(pChild);
1203                        } else if(pChild->nodeName == tmpVelocity) {
1204                                velocity = (FLOAT)atof(pChild->firstChild->text);
1205                        } else if(pChild->nodeName == tmpDuration) {
1206                                duration = (FLOAT)atof(pChild->firstChild->text);
1207                        } else if(pChild->nodeName == tmpTimeToLive) {
1208                                timetolive = (FLOAT)atof(pChild->firstChild->text);
1209                        } else if(pChild->nodeName == tmpHDegree) {
1210                                horizontalDegree = (FLOAT)atof(pChild->firstChild->text);
1211                        } else if(pChild->nodeName == tmpVDegree) {
1212                                verticalDegree = (FLOAT)atof(pChild->firstChild->text);
1213                        } else if(pChild->nodeName == tmpRDegree) {
1214                                rotationalDegree = tracePosition(pChild);
1215                        } else if(pChild->nodeName == tmpBirthRate) {
1216                                birthRate = (FLOAT)atof(pChild->firstChild->text);
1217                        } else if(pChild->nodeName == tmpSprite) {
1218                                Sprite* sprite = traceSprite(pChild);
1219                                sprite->generatePhysicMesh(Object3d::COL_CONVEX);
1220                                usingSprites = true;
1221                                spriteVector.push_back(sprite);
1222                                //pe->addRefNode(*sprite);
1223                        } else if(pChild->nodeName == tmpEnvObject) {
1224                                Object3d* obj = this->traceEnvironmentObject(pChild);
1225                                usingSprites = false;
1226                                objectVector.push_back(obj);
1227                                //pe->addRefNode(*obj);
1228                        } else if(pChild->nodeName == tmpColGroup) {
1229                                colGroup = atoi(pChild->firstChild->text);
1230                        } else if(pChild->nodeName == tmpRenderer) {
1231                                //this->traceRenderer(pChild, *pg);//pChild->firstChild->text);
1232                                renderNode = pChild;
1233                                addRenderer = true;
1234                        } else if(pChild->nodeName == tmpHeatHaze) {
1235                                heathaze = atoi(pChild->firstChild->text);
1236                        } else if(pChild->nodeName == tmpSound) {
1237                                sound = this->traceSound(pChild->firstChild);
1238                        } else if(pChild->nodeName == tmpGravity) {
1239                                useGravity = (atoi(pChild->firstChild->text)==1);
1240                        }
1241                }
1242        }
1243
1244        ParticleEmitter *pe = (ParticleEmitter*) this->scene->createNode(GameScene::NODE_PARTICLEEMITTER);
1245        ParticleGroup *pg;
1246        pg = (ParticleGroup*) this->scene->createNode(Scene::NODE_PARTICLEGROUP, usingSprites);
1247        SPTR<Node> spe = this->scene->getSmartPointer(pe);
1248       
1249        if(addRenderer) {
1250                this->traceRenderer(renderNode, *pg);
1251        }/* else if(!usingSprites) {    //Standardmaessig haben Object3ds eh einen renderer
1252                SPTR<Renderer> renderer(new SimpleMeshRenderer);
1253                this->scene->connectNodeAndRenderer(node, renderer);
1254        }*/
1255
1256        if(sound) {
1257                pe->addEmittingSound(sound);
1258        }
1259
1260        if(usingSprites) {
1261                for(UINT i=0;i<spriteVector.size();i++) {
1262                        pe->addRefNode(*spriteVector.at(i));
1263                }
1264        } else {
1265                for(UINT i=0;i<objectVector.size();i++) {
1266                        pe->addRefNode(*objectVector.at(i));
1267                }
1268        }
1269        rotation = rotation*D3DX_PI/180;
1270        horizontalDegree*=(D3DX_PI/180);
1271        verticalDegree*=(D3DX_PI/180);
1272        //rotationalDegree = rotationalDegree*D3DX_PI/180;
1273        pe->setUseHeatHaze(heathaze==1);
1274        pe->setPosition(position);
1275        pe->setRotation(rotation);
1276        pe->setDimensions(dimension.x, dimension.y, dimension.z);
1277        pe->setEMParticleVelocity(velocity);
1278        pe->setEMEmissionDuration(duration);
1279        pe->setEMHorizontalDegree(horizontalDegree);
1280        pe->setEMVerticalDegree(verticalDegree);
1281        pe->setEMRotationalDegree(rotationalDegree.x, rotationalDegree.y, rotationalDegree.z);
1282        pe->setEMBirthRate(birthRate);
1283        pe->setEMParticleLifeTime(timetolive);
1284        pe->setColDetGroup(colGroup);
1285        pg->useGravity(useGravity);
1286        pg->addParticleEmitter(spe);
1287
1288        return pe;
1289}
1290
1291Object3d* GameSceneLoader::traceEnvironmentObject(MSXML::IXMLDOMNodePtr envNode) {
1292        /*<envObject>
1293                <position>...</position>
1294                <rotation>...</rotation>
1295                <xfile>asdf.x</xfile
1296                <pactor>...</pactor>
1297                <arrivaltime>10</arrivaltime>
1298                <timevariation>5</timevariation>
1299                <renderer>...</renderer>
1300        </envObject>*/
1301        _bstr_t tmpPosition("position");
1302        _bstr_t tmpRotation("rotation");
1303        _bstr_t tmpArrivaltime("arrivaltime");
1304        _bstr_t tmpVariation("timevariation");
1305        _bstr_t tmpPhysic("pactor");
1306        _bstr_t tmpRenderer("renderer");
1307        _bstr_t tmpXFile("xfile");
1308        _bstr_t tmpSoftKill("softkill");
1309
1310        Vector position;
1311        Vector rotation;
1312        float arrivalTime = 0;
1313        float arrivalVariation = 0;
1314        float softKill=0;
1315        MSXML::IXMLDOMNodePtr physicChild;
1316        bool hasPActor = false;
1317        MSXML::IXMLDOMNodePtr rendererChild;
1318        bool hasRenderer = false;
1319        std::string xfile = "";
1320        for (MSXML::IXMLDOMNodePtr pChild = envNode->firstChild;NULL != pChild;pChild = pChild->nextSibling) {
1321                if(pChild->nodeType == MSXML::NODE_ELEMENT) {
1322                        if(pChild->nodeName == tmpPosition) {
1323                                position = tracePosition(pChild);
1324                        } else if(pChild->nodeName == tmpRotation) {
1325                                rotation = tracePosition(pChild);
1326                        }else if(pChild->nodeName == tmpArrivaltime) {
1327                                arrivalTime = (FLOAT)atof(pChild->firstChild->text);
1328                        } else if(pChild->nodeName == tmpVariation) {
1329                                arrivalVariation = (FLOAT)atof(pChild->firstChild->text);
1330                        } else if(pChild->nodeName == tmpPhysic) {
1331                                physicChild = pChild;
1332                                hasPActor = true;
1333                        } else if(pChild->nodeName == tmpRenderer) {
1334                                rendererChild = pChild;
1335                                hasRenderer = true;
1336                        } else if(pChild->nodeName == tmpXFile) {
1337                                xfile = pChild->firstChild->text;
1338                        } else if(pChild->nodeName == tmpSoftKill) {
1339                                softKill = (FLOAT)atof(pChild->firstChild->text);
1340                        }
1341                }
1342        }
1343        rotation = rotation*D3DX_PI/180;
1344
1345        Object3d* obj = (Object3d*) this->scene->createNode(GameScene::NODE_OBJECT3D, !hasRenderer);
1346        if(hasRenderer) {
1347                this->traceRenderer(rendererChild, *obj);
1348        }
1349        obj->setPosition(position);
1350        obj->setRotation(rotation);
1351        obj->loadMeshFromFile(xfile);
1352        if(softKill!=0) {
1353                obj->setSoftKill(true, softKill);
1354        }
1355        if(hasPActor) {
1356                this->tracePActor(physicChild, *obj);
1357        }
1358        if(arrivalTime!=0 /*&& arrivalVariation!=0*/) {
1359                obj->setStandBy(true);
1360                this->scene->setTrigger(GameScene::TRIGGER_UNSETSTANDBY, obj, this->scene->getRandomTime(arrivalTime, arrivalVariation));
1361        }
1362        return obj;
1363}
1364
1365Sprite* GameSceneLoader::traceSprite(MSXML::IXMLDOMNodePtr spriteNode) {
1366        /*<particleFlaeche>
1367                <dimension>
1368                        <x>-50</x>
1369                        <y>50</y>
1370                        <z>0</z>
1371                </dimension>
1372                <texture0>./media/textures/explosion1.bmp</texture0>
1373                <lookAtCamera>1</lookAtCamera> <!-- 0 = FALSE, 1 = TRUE -->
1374        </particleFlaeche>*/
1375
1376        _bstr_t tmpDimension("dimension");
1377        _bstr_t tmpTexture0("texture0");
1378        _bstr_t tmpLookAtCamera("lookAtCamera");
1379        _bstr_t tmpAnimation("animation");
1380                _bstr_t tmpFps("fps");
1381                _bstr_t tmpFrameCount("framecount");
1382                _bstr_t tmpRowcount("rowcount");
1383                _bstr_t tmpColumncount("columncount");
1384                _bstr_t tmpLoopanimation("loopanimation");
1385        _bstr_t tmpKey1("key_start");
1386        _bstr_t tmpKey2("key_middle");
1387        _bstr_t tmpKey3("key_end");
1388                _bstr_t tmpAlpha("alpha");
1389                _bstr_t tmpRed("red");
1390                _bstr_t tmpGreen("green");
1391                _bstr_t tmpBlue("blue");
1392                _bstr_t tmpWidth("width");
1393                _bstr_t tmpHeight("height");
1394                _bstr_t tmpTime("time");
1395
1396        std::string texture0;
1397        int lookAtCamera;
1398    Vector dimension;
1399
1400        bool hasAnimation = false;
1401        int FPS = 1;
1402        int FrameCount = 1;
1403        int RowCount = 1;
1404        int ColumnCount = 1;
1405        bool loop = true;
1406
1407        bool hasKey1 = false;
1408        bool hasKey2 = false;
1409        bool hasKey3 = false;
1410
1411        float alpha[3] = {0.0f, 0.0f, 0.0f};
1412        float red[3] = {0.0f, 0.0f, 0.0f};
1413        float green[3] = {0.0f, 0.0f, 0.0f};
1414        float blue[3] = {0.0f, 0.0f, 0.0f};
1415        float width[3] = {0.0f, 0.0f, 0.0f};
1416        float height[3] = {0.0f, 0.0f, 0.0f};
1417        float time[3] = {0.0f, 0.0f, 1.0f};
1418
1419        Sprite* sp = (Sprite*) this->scene->createNode(GameScene::NODE_SPRITE);
1420
1421        for (MSXML::IXMLDOMNodePtr pChild = spriteNode->firstChild;NULL != pChild;pChild = pChild->nextSibling) {
1422                if(pChild->nodeType == MSXML::NODE_ELEMENT) {
1423                        if(pChild->nodeName == tmpDimension) {
1424                                dimension = tracePosition(pChild);
1425                        } else if(pChild->nodeName == tmpTexture0) {
1426                                texture0 = pChild->firstChild->text;
1427                        } else if(pChild->nodeName == tmpLookAtCamera) {
1428                                lookAtCamera = atoi(pChild->firstChild->text);
1429                        } else if(pChild->nodeName == tmpAnimation) {
1430                                hasAnimation = true;
1431                                for (MSXML::IXMLDOMNodePtr pChildAnimation = pChild->firstChild;NULL != pChildAnimation;pChildAnimation = pChildAnimation->nextSibling) {
1432                                        if(pChildAnimation->nodeName == tmpFps) {
1433                                                FPS = atoi(pChildAnimation->firstChild->text);
1434                                        } else if(pChildAnimation->nodeName == tmpFrameCount) {
1435                                                FrameCount = atoi(pChildAnimation->firstChild->text);
1436                                        } else if(pChildAnimation->nodeName == tmpRowcount) {
1437                                                RowCount = atoi(pChildAnimation->firstChild->text);
1438                                        } else if(pChildAnimation->nodeName == tmpColumncount) {
1439                                                ColumnCount = atoi(pChildAnimation->firstChild->text);
1440                                        } else if(pChildAnimation->nodeName == tmpFrameCount) {
1441                                                FrameCount = atoi(pChildAnimation->firstChild->text);
1442                                        } else if(pChildAnimation->nodeName == tmpLoopanimation) {
1443                                                if(atoi(pChildAnimation->firstChild->text) != 1) {
1444                                                        loop = false;
1445                                                }
1446                                        }
1447                                }
1448                        } else if(pChild->nodeName == tmpKey1) {
1449                                hasKey1 = true;
1450                                for (MSXML::IXMLDOMNodePtr pChildAnimation = pChild->firstChild;NULL != pChildAnimation;pChildAnimation = pChildAnimation->nextSibling) {
1451                                        if(pChildAnimation->nodeName == tmpAlpha) {
1452                                                alpha[0] = (FLOAT)atof(pChild->firstChild->text);
1453                                        } else if(pChildAnimation->nodeName == tmpRed) {
1454                                                red[0] = (FLOAT)atof(pChildAnimation->firstChild->text);
1455                                        } else if(pChildAnimation->nodeName == tmpGreen) {
1456                                                green[0] = (FLOAT)atof(pChildAnimation->firstChild->text);
1457                                        } else if(pChildAnimation->nodeName == tmpBlue) {
1458                                                blue[0] = (FLOAT)atof(pChildAnimation->firstChild->text);
1459                                        } else if(pChildAnimation->nodeName == tmpWidth) {
1460                                                width[0] = (FLOAT)atof(pChildAnimation->firstChild->text);
1461                                        } else if(pChildAnimation->nodeName == tmpHeight) {
1462                                                height[0] = (FLOAT)atof(pChildAnimation->firstChild->text);
1463                                        }
1464                                }
1465                        } else if(pChild->nodeName == tmpKey2) {
1466                                hasKey2 = true;
1467                                for (MSXML::IXMLDOMNodePtr pChildAnimation = pChild->firstChild;NULL != pChildAnimation;pChildAnimation = pChildAnimation->nextSibling) {
1468                                        if(pChildAnimation->nodeName == tmpAlpha) {
1469                                                alpha[1] = (FLOAT)atof(pChild->firstChild->text);
1470                                        } else if(pChildAnimation->nodeName == tmpRed) {
1471                                                red[1] = (FLOAT)atof(pChildAnimation->firstChild->text);
1472                                        } else if(pChildAnimation->nodeName == tmpGreen) {
1473                                                green[1] = (FLOAT)atof(pChildAnimation->firstChild->text);
1474                                        } else if(pChildAnimation->nodeName == tmpBlue) {
1475                                                blue[1] = (FLOAT)atof(pChildAnimation->firstChild->text);
1476                                        } else if(pChildAnimation->nodeName == tmpWidth) {
1477                                                width[1] = (FLOAT)atof(pChildAnimation->firstChild->text);
1478                                        } else if(pChildAnimation->nodeName == tmpHeight) {
1479                                                height[1] = (FLOAT)atof(pChildAnimation->firstChild->text);
1480                                        } else if(pChildAnimation->nodeName == tmpTime) {
1481                                                time[1] = (FLOAT)atof(pChildAnimation->firstChild->text);
1482                                        }
1483                                }
1484                        } else if(pChild->nodeName == tmpKey3) {
1485                                hasKey3 = true;
1486                                for (MSXML::IXMLDOMNodePtr pChildAnimation = pChild->firstChild;NULL != pChildAnimation;pChildAnimation = pChildAnimation->nextSibling) {
1487                                        if(pChildAnimation->nodeName == tmpAlpha) {
1488                                                alpha[2] = (FLOAT)atof(pChild->firstChild->text);
1489                                        } else if(pChildAnimation->nodeName == tmpRed) {
1490                                                red[2] = (FLOAT)atof(pChildAnimation->firstChild->text);
1491                                        } else if(pChildAnimation->nodeName == tmpGreen) {
1492                                                green[2] = (FLOAT)atof(pChildAnimation->firstChild->text);
1493                                        } else if(pChildAnimation->nodeName == tmpBlue) {
1494                                                blue[2] = (FLOAT)atof(pChildAnimation->firstChild->text);
1495                                        } else if(pChildAnimation->nodeName == tmpWidth) {
1496                                                width[2] = (FLOAT)atof(pChildAnimation->firstChild->text);
1497                                        } else if(pChildAnimation->nodeName == tmpHeight) {
1498                                                height[2] = (FLOAT)atof(pChildAnimation->firstChild->text);
1499                                        }
1500                                }
1501                        }
1502                }
1503        }
1504
1505        sp->setDimension(dimension.x, dimension.y);
1506        sp->setTexture(texture0);
1507        sp->setLookAtCamera(lookAtCamera==1);
1508       
1509        if(hasAnimation) {
1510                sp->setFPS(FPS);
1511                sp->setFrameCount(FrameCount);
1512                sp->setRowColumnCount(RowCount, ColumnCount);
1513                sp->setLoopAnimation(true); // there's a bug if i set this to false
1514        }
1515
1516        if(hasKey1 && hasKey2 && hasKey3) {
1517                sp->setKeyFrame(Sprite::KEY_START, alpha[0], red[0], green[0], blue[0], width[0], height[0], time[0]);
1518                sp->setKeyFrame(Sprite::KEY_MIDDLE, alpha[1], red[1], green[1], blue[1], width[1], height[1], time[1]);
1519                sp->setKeyFrame(Sprite::KEY_END, alpha[2], red[2], green[2], blue[2], width[2], height[2], time[2]);
1520        }
1521
1522        return sp;
1523}
1524
1525SoundNode* GameSceneLoader::traceSound(MSXML::IXMLDOMNodePtr soundNode)
1526{
1527        _bstr_t tmpPosition("position");
1528        _bstr_t tmpArrivaltime("arrivaltime");
1529        _bstr_t tmpVariation("timevariation");
1530        _bstr_t tmpSoundfile("soundfile");
1531        _bstr_t tmpSoundVolume("volume");
1532        _bstr_t tmpKillAfterPlayed("killafterplayed");
1533        _bstr_t tmpLoop("loop");
1534   
1535        Vector position;
1536        float arrivalTime = 0;
1537        float arrivalVariation = 0;
1538        std::string soundfile;
1539        float volume = 1;
1540        bool killAfterPlayed;
1541        bool loop;
1542       
1543        for (MSXML::IXMLDOMNodePtr pChild = soundNode->firstChild;NULL != pChild;pChild = pChild->nextSibling) {
1544                if(pChild->nodeType == MSXML::NODE_ELEMENT) {
1545                        if(pChild->nodeName == tmpPosition) {
1546                                position = tracePosition(pChild);
1547                        } else if(pChild->nodeName == tmpArrivaltime) {
1548                                arrivalTime = (FLOAT)atof(pChild->firstChild->text);
1549                        } else if(pChild->nodeName == tmpVariation) {
1550                                arrivalVariation = (FLOAT)atof(pChild->firstChild->text);
1551                        } else if(pChild->nodeName == tmpSoundfile) {
1552                                soundfile = pChild->firstChild->text;
1553                        } else if(pChild->nodeName == tmpSoundVolume) {
1554                                volume = (FLOAT) atof(pChild->firstChild->text);
1555                        } else if(pChild->nodeName == tmpKillAfterPlayed) {
1556                                killAfterPlayed = ((INT)atoi(pChild->firstChild->text)==1);
1557                        } else if(pChild->nodeName == tmpLoop) {
1558                                loop = ((INT)atoi(pChild->firstChild->text)==1);
1559                        }
1560                }
1561        }
1562
1563        SoundNode* sound;
1564        sound = (SoundNode*) this->scene->createNode(Scene::NODE_SOUND);
1565        sound->loadFile(soundfile, loop);
1566        sound->setVolume(volume);
1567        sound->setKillSoundNodeAfterPlayed(killAfterPlayed);
1568       
1569        if(arrivalTime!=0) {
1570                sound->setStandBy(true);
1571                this->scene->setTrigger(GameScene::TRIGGER_UNSETSTANDBY, sound, this->scene->getRandomTime(arrivalTime, arrivalVariation));
1572        } else {
1573                sound->play();
1574        }
1575
1576        return sound;
1577}
Note: See TracBrowser for help on using the repository browser.