[1378] | 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 |
|
---|
| 23 | GameSceneLoader::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 |
|
---|
| 37 | GameSceneLoader::~GameSceneLoader(void)
|
---|
| 38 | {
|
---|
| 39 | }
|
---|
| 40 |
|
---|
| 41 | bool 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 |
|
---|
| 159 | void 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 |
|
---|
| 174 | Vector 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 |
|
---|
| 193 | void 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 |
|
---|
| 268 | void 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 |
|
---|
| 363 | void 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 |
|
---|
| 416 | void 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 |
|
---|
| 475 | void 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 |
|
---|
| 552 | void 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 |
|
---|
| 582 | void 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 |
|
---|
| 629 | void 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 |
|
---|
| 662 | void 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 |
|
---|
| 747 | void 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 |
|
---|
| 825 | void 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 |
|
---|
| 901 | void 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 |
|
---|
| 982 | void 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 |
|
---|
| 1025 | void 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 |
|
---|
| 1063 | void 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 |
|
---|
| 1092 | void 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;
|
---|
[1383] | 1104 |
|
---|
[1385] | 1105 | #if(0)
|
---|
[1383] | 1106 | int nbIteration = 10;
|
---|
| 1107 | #else
|
---|
| 1108 | int nbIteration = 3; // MG
|
---|
| 1109 | #endif
|
---|
[1378] | 1110 |
|
---|
| 1111 | for (MSXML::IXMLDOMNodePtr pChild = rendererNode->firstChild;NULL != pChild;pChild = pChild->nextSibling) {
|
---|
| 1112 | if(pChild->nodeType == MSXML::NODE_ELEMENT) {
|
---|
| 1113 | if(pChild->nodeName == tmpFresnel) {
|
---|
| 1114 | fresnel = (FLOAT)atof(pChild->firstChild->text);
|
---|
| 1115 | } else if(pChild->nodeName == tmpRefraction) {
|
---|
| 1116 | refraction = (FLOAT)atof(pChild->firstChild->text);
|
---|
| 1117 | } else if(pChild->nodeName == tmpIteration) {
|
---|
| 1118 | nbIteration = atoi(pChild->firstChild->text);
|
---|
| 1119 | }
|
---|
| 1120 | }
|
---|
| 1121 | }
|
---|
| 1122 |
|
---|
| 1123 | SPTR<Renderer> renderer(new RaytraceRenderer);
|
---|
| 1124 | RaytraceRenderer *r = (RaytraceRenderer*) renderer.get();
|
---|
| 1125 | r->setFresnelFactor(fresnel);
|
---|
| 1126 | r->setRefractionIndex(refraction);
|
---|
| 1127 | r->setNumberOfIterations(nbIteration);
|
---|
| 1128 | this->scene->connectNodeAndRenderer(node, renderer);
|
---|
| 1129 | }
|
---|
| 1130 |
|
---|
| 1131 | ParticleEmitter* GameSceneLoader::traceParticleEmitter(MSXML::IXMLDOMNodePtr emitterNode) {
|
---|
| 1132 | /*<position>
|
---|
| 1133 | <x>1000</x>
|
---|
| 1134 | <y>200</y>
|
---|
| 1135 | <z>1000);</z>
|
---|
| 1136 | </position>
|
---|
| 1137 | <rotation>
|
---|
| 1138 | <x>-90</x>
|
---|
| 1139 | <y>0</y>
|
---|
| 1140 | <z>0</z>
|
---|
| 1141 | </rotation>
|
---|
| 1142 | <dimension>
|
---|
| 1143 | <x>-20</x>
|
---|
| 1144 | <y>20</y>
|
---|
| 1145 | <z>0</z>
|
---|
| 1146 | </dimension>
|
---|
| 1147 | <velocity>600</velocity>
|
---|
| 1148 | <duration>10</duration>
|
---|
| 1149 | <horizontalDegree>0.2</horizontalDegree>
|
---|
| 1150 | <verticalDegree>0.2</verticalDegree>
|
---|
| 1151 | <rotationalDegree>
|
---|
| 1152 | <x>0</x>
|
---|
| 1153 | <y>0</y>
|
---|
| 1154 | <z>10</z>
|
---|
| 1155 | </rotationalDegree>
|
---|
| 1156 | <birthRate>100</birthRate>*/
|
---|
| 1157 |
|
---|
| 1158 | _bstr_t tmpPosition("position");
|
---|
| 1159 | _bstr_t tmpRotation("rotation");
|
---|
| 1160 | _bstr_t tmpDimension("dimension");
|
---|
| 1161 | _bstr_t tmpVelocity("velocity");
|
---|
| 1162 | _bstr_t tmpDuration("duration");
|
---|
| 1163 | _bstr_t tmpHDegree("horizontalDegree");
|
---|
| 1164 | _bstr_t tmpVDegree("verticalDegree");
|
---|
| 1165 | _bstr_t tmpRDegree("rotationalDegree");
|
---|
| 1166 | _bstr_t tmpBirthRate("birthRate");
|
---|
| 1167 | _bstr_t tmpSprite("sprite");
|
---|
| 1168 | _bstr_t tmpEnvObject("envObject");
|
---|
| 1169 | _bstr_t tmpTimeToLive("timetolive");
|
---|
| 1170 | _bstr_t tmpColGroup("colGroup");
|
---|
| 1171 | _bstr_t tmpRenderer("renderer");
|
---|
| 1172 | _bstr_t tmpHeatHaze("heathaze");
|
---|
| 1173 | _bstr_t tmpSound("sound");
|
---|
| 1174 | _bstr_t tmpGravity("gravity");
|
---|
| 1175 |
|
---|
| 1176 | bool usingSprites = true;
|
---|
| 1177 | bool addRenderer = false;
|
---|
| 1178 | bool useGravity = true;
|
---|
| 1179 | MSXML::IXMLDOMNodePtr renderNode;
|
---|
| 1180 |
|
---|
| 1181 | float velocity;
|
---|
| 1182 | float duration;
|
---|
| 1183 | float horizontalDegree;
|
---|
| 1184 | float verticalDegree;
|
---|
| 1185 | float birthRate;
|
---|
| 1186 | float timetolive;
|
---|
| 1187 | int colGroup;
|
---|
| 1188 | int heathaze = 0;
|
---|
| 1189 | SoundNode* sound = NULL;
|
---|
| 1190 |
|
---|
| 1191 | Vector position;
|
---|
| 1192 | Vector rotation;
|
---|
| 1193 | Vector dimension;
|
---|
| 1194 | Vector rotationalDegree;
|
---|
| 1195 |
|
---|
| 1196 |
|
---|
| 1197 | std::vector<Object3d*> objectVector;
|
---|
| 1198 | std::vector<Sprite*> spriteVector;
|
---|
| 1199 |
|
---|
| 1200 | for (MSXML::IXMLDOMNodePtr pChild = emitterNode->firstChild;NULL != pChild;pChild = pChild->nextSibling) {
|
---|
| 1201 | if(pChild->nodeType == MSXML::NODE_ELEMENT) {
|
---|
| 1202 | if(pChild->nodeName == tmpPosition) {
|
---|
| 1203 | position = tracePosition(pChild);
|
---|
| 1204 | } else if(pChild->nodeName == tmpRotation) {
|
---|
| 1205 | rotation = tracePosition(pChild);
|
---|
| 1206 | } else if(pChild->nodeName == tmpDimension) {
|
---|
| 1207 | dimension = tracePosition(pChild);
|
---|
| 1208 | } else if(pChild->nodeName == tmpVelocity) {
|
---|
| 1209 | velocity = (FLOAT)atof(pChild->firstChild->text);
|
---|
| 1210 | } else if(pChild->nodeName == tmpDuration) {
|
---|
| 1211 | duration = (FLOAT)atof(pChild->firstChild->text);
|
---|
| 1212 | } else if(pChild->nodeName == tmpTimeToLive) {
|
---|
| 1213 | timetolive = (FLOAT)atof(pChild->firstChild->text);
|
---|
| 1214 | } else if(pChild->nodeName == tmpHDegree) {
|
---|
| 1215 | horizontalDegree = (FLOAT)atof(pChild->firstChild->text);
|
---|
| 1216 | } else if(pChild->nodeName == tmpVDegree) {
|
---|
| 1217 | verticalDegree = (FLOAT)atof(pChild->firstChild->text);
|
---|
| 1218 | } else if(pChild->nodeName == tmpRDegree) {
|
---|
| 1219 | rotationalDegree = tracePosition(pChild);
|
---|
| 1220 | } else if(pChild->nodeName == tmpBirthRate) {
|
---|
| 1221 | birthRate = (FLOAT)atof(pChild->firstChild->text);
|
---|
| 1222 | } else if(pChild->nodeName == tmpSprite) {
|
---|
| 1223 | Sprite* sprite = traceSprite(pChild);
|
---|
| 1224 | sprite->generatePhysicMesh(Object3d::COL_CONVEX);
|
---|
| 1225 | usingSprites = true;
|
---|
| 1226 | spriteVector.push_back(sprite);
|
---|
| 1227 | //pe->addRefNode(*sprite);
|
---|
| 1228 | } else if(pChild->nodeName == tmpEnvObject) {
|
---|
| 1229 | Object3d* obj = this->traceEnvironmentObject(pChild);
|
---|
| 1230 | usingSprites = false;
|
---|
| 1231 | objectVector.push_back(obj);
|
---|
| 1232 | //pe->addRefNode(*obj);
|
---|
| 1233 | } else if(pChild->nodeName == tmpColGroup) {
|
---|
| 1234 | colGroup = atoi(pChild->firstChild->text);
|
---|
| 1235 | } else if(pChild->nodeName == tmpRenderer) {
|
---|
| 1236 | //this->traceRenderer(pChild, *pg);//pChild->firstChild->text);
|
---|
| 1237 | renderNode = pChild;
|
---|
| 1238 | addRenderer = true;
|
---|
| 1239 | } else if(pChild->nodeName == tmpHeatHaze) {
|
---|
| 1240 | heathaze = atoi(pChild->firstChild->text);
|
---|
| 1241 | } else if(pChild->nodeName == tmpSound) {
|
---|
| 1242 | sound = this->traceSound(pChild->firstChild);
|
---|
| 1243 | } else if(pChild->nodeName == tmpGravity) {
|
---|
| 1244 | useGravity = (atoi(pChild->firstChild->text)==1);
|
---|
| 1245 | }
|
---|
| 1246 | }
|
---|
| 1247 | }
|
---|
| 1248 |
|
---|
| 1249 | ParticleEmitter *pe = (ParticleEmitter*) this->scene->createNode(GameScene::NODE_PARTICLEEMITTER);
|
---|
| 1250 | ParticleGroup *pg;
|
---|
| 1251 | pg = (ParticleGroup*) this->scene->createNode(Scene::NODE_PARTICLEGROUP, usingSprites);
|
---|
| 1252 | SPTR<Node> spe = this->scene->getSmartPointer(pe);
|
---|
| 1253 |
|
---|
| 1254 | if(addRenderer) {
|
---|
| 1255 | this->traceRenderer(renderNode, *pg);
|
---|
| 1256 | }/* else if(!usingSprites) { //Standardmaessig haben Object3ds eh einen renderer
|
---|
| 1257 | SPTR<Renderer> renderer(new SimpleMeshRenderer);
|
---|
| 1258 | this->scene->connectNodeAndRenderer(node, renderer);
|
---|
| 1259 | }*/
|
---|
| 1260 |
|
---|
| 1261 | if(sound) {
|
---|
| 1262 | pe->addEmittingSound(sound);
|
---|
| 1263 | }
|
---|
| 1264 |
|
---|
| 1265 | if(usingSprites) {
|
---|
| 1266 | for(UINT i=0;i<spriteVector.size();i++) {
|
---|
| 1267 | pe->addRefNode(*spriteVector.at(i));
|
---|
| 1268 | }
|
---|
| 1269 | } else {
|
---|
| 1270 | for(UINT i=0;i<objectVector.size();i++) {
|
---|
| 1271 | pe->addRefNode(*objectVector.at(i));
|
---|
| 1272 | }
|
---|
| 1273 | }
|
---|
| 1274 | rotation = rotation*D3DX_PI/180;
|
---|
| 1275 | horizontalDegree*=(D3DX_PI/180);
|
---|
| 1276 | verticalDegree*=(D3DX_PI/180);
|
---|
| 1277 | //rotationalDegree = rotationalDegree*D3DX_PI/180;
|
---|
| 1278 | pe->setUseHeatHaze(heathaze==1);
|
---|
| 1279 | pe->setPosition(position);
|
---|
| 1280 | pe->setRotation(rotation);
|
---|
| 1281 | pe->setDimensions(dimension.x, dimension.y, dimension.z);
|
---|
| 1282 | pe->setEMParticleVelocity(velocity);
|
---|
| 1283 | pe->setEMEmissionDuration(duration);
|
---|
| 1284 | pe->setEMHorizontalDegree(horizontalDegree);
|
---|
| 1285 | pe->setEMVerticalDegree(verticalDegree);
|
---|
| 1286 | pe->setEMRotationalDegree(rotationalDegree.x, rotationalDegree.y, rotationalDegree.z);
|
---|
| 1287 | pe->setEMBirthRate(birthRate);
|
---|
| 1288 | pe->setEMParticleLifeTime(timetolive);
|
---|
| 1289 | pe->setColDetGroup(colGroup);
|
---|
| 1290 | pg->useGravity(useGravity);
|
---|
| 1291 | pg->addParticleEmitter(spe);
|
---|
| 1292 |
|
---|
| 1293 | return pe;
|
---|
| 1294 | }
|
---|
| 1295 |
|
---|
| 1296 | Object3d* GameSceneLoader::traceEnvironmentObject(MSXML::IXMLDOMNodePtr envNode) {
|
---|
| 1297 | /*<envObject>
|
---|
| 1298 | <position>...</position>
|
---|
| 1299 | <rotation>...</rotation>
|
---|
| 1300 | <xfile>asdf.x</xfile
|
---|
| 1301 | <pactor>...</pactor>
|
---|
| 1302 | <arrivaltime>10</arrivaltime>
|
---|
| 1303 | <timevariation>5</timevariation>
|
---|
| 1304 | <renderer>...</renderer>
|
---|
| 1305 | </envObject>*/
|
---|
| 1306 | _bstr_t tmpPosition("position");
|
---|
| 1307 | _bstr_t tmpRotation("rotation");
|
---|
| 1308 | _bstr_t tmpArrivaltime("arrivaltime");
|
---|
| 1309 | _bstr_t tmpVariation("timevariation");
|
---|
| 1310 | _bstr_t tmpPhysic("pactor");
|
---|
| 1311 | _bstr_t tmpRenderer("renderer");
|
---|
| 1312 | _bstr_t tmpXFile("xfile");
|
---|
| 1313 | _bstr_t tmpSoftKill("softkill");
|
---|
| 1314 |
|
---|
| 1315 | Vector position;
|
---|
| 1316 | Vector rotation;
|
---|
| 1317 | float arrivalTime = 0;
|
---|
| 1318 | float arrivalVariation = 0;
|
---|
| 1319 | float softKill=0;
|
---|
| 1320 | MSXML::IXMLDOMNodePtr physicChild;
|
---|
| 1321 | bool hasPActor = false;
|
---|
| 1322 | MSXML::IXMLDOMNodePtr rendererChild;
|
---|
| 1323 | bool hasRenderer = false;
|
---|
| 1324 | std::string xfile = "";
|
---|
| 1325 | for (MSXML::IXMLDOMNodePtr pChild = envNode->firstChild;NULL != pChild;pChild = pChild->nextSibling) {
|
---|
| 1326 | if(pChild->nodeType == MSXML::NODE_ELEMENT) {
|
---|
| 1327 | if(pChild->nodeName == tmpPosition) {
|
---|
| 1328 | position = tracePosition(pChild);
|
---|
| 1329 | } else if(pChild->nodeName == tmpRotation) {
|
---|
| 1330 | rotation = tracePosition(pChild);
|
---|
| 1331 | }else if(pChild->nodeName == tmpArrivaltime) {
|
---|
| 1332 | arrivalTime = (FLOAT)atof(pChild->firstChild->text);
|
---|
| 1333 | } else if(pChild->nodeName == tmpVariation) {
|
---|
| 1334 | arrivalVariation = (FLOAT)atof(pChild->firstChild->text);
|
---|
| 1335 | } else if(pChild->nodeName == tmpPhysic) {
|
---|
| 1336 | physicChild = pChild;
|
---|
| 1337 | hasPActor = true;
|
---|
| 1338 | } else if(pChild->nodeName == tmpRenderer) {
|
---|
| 1339 | rendererChild = pChild;
|
---|
| 1340 | hasRenderer = true;
|
---|
| 1341 | } else if(pChild->nodeName == tmpXFile) {
|
---|
| 1342 | xfile = pChild->firstChild->text;
|
---|
| 1343 | } else if(pChild->nodeName == tmpSoftKill) {
|
---|
| 1344 | softKill = (FLOAT)atof(pChild->firstChild->text);
|
---|
| 1345 | }
|
---|
| 1346 | }
|
---|
| 1347 | }
|
---|
| 1348 | rotation = rotation*D3DX_PI/180;
|
---|
| 1349 |
|
---|
| 1350 | Object3d* obj = (Object3d*) this->scene->createNode(GameScene::NODE_OBJECT3D, !hasRenderer);
|
---|
| 1351 | if(hasRenderer) {
|
---|
| 1352 | this->traceRenderer(rendererChild, *obj);
|
---|
| 1353 | }
|
---|
| 1354 | obj->setPosition(position);
|
---|
| 1355 | obj->setRotation(rotation);
|
---|
| 1356 | obj->loadMeshFromFile(xfile);
|
---|
| 1357 | if(softKill!=0) {
|
---|
| 1358 | obj->setSoftKill(true, softKill);
|
---|
| 1359 | }
|
---|
| 1360 | if(hasPActor) {
|
---|
| 1361 | this->tracePActor(physicChild, *obj);
|
---|
| 1362 | }
|
---|
| 1363 | if(arrivalTime!=0 /*&& arrivalVariation!=0*/) {
|
---|
| 1364 | obj->setStandBy(true);
|
---|
| 1365 | this->scene->setTrigger(GameScene::TRIGGER_UNSETSTANDBY, obj, this->scene->getRandomTime(arrivalTime, arrivalVariation));
|
---|
| 1366 | }
|
---|
| 1367 | return obj;
|
---|
| 1368 | }
|
---|
| 1369 |
|
---|
| 1370 | Sprite* GameSceneLoader::traceSprite(MSXML::IXMLDOMNodePtr spriteNode) {
|
---|
| 1371 | /*<particleFlaeche>
|
---|
| 1372 | <dimension>
|
---|
| 1373 | <x>-50</x>
|
---|
| 1374 | <y>50</y>
|
---|
| 1375 | <z>0</z>
|
---|
| 1376 | </dimension>
|
---|
| 1377 | <texture0>./media/textures/explosion1.bmp</texture0>
|
---|
| 1378 | <lookAtCamera>1</lookAtCamera> <!-- 0 = FALSE, 1 = TRUE -->
|
---|
| 1379 | </particleFlaeche>*/
|
---|
| 1380 |
|
---|
| 1381 | _bstr_t tmpDimension("dimension");
|
---|
| 1382 | _bstr_t tmpTexture0("texture0");
|
---|
| 1383 | _bstr_t tmpLookAtCamera("lookAtCamera");
|
---|
| 1384 | _bstr_t tmpAnimation("animation");
|
---|
| 1385 | _bstr_t tmpFps("fps");
|
---|
| 1386 | _bstr_t tmpFrameCount("framecount");
|
---|
| 1387 | _bstr_t tmpRowcount("rowcount");
|
---|
| 1388 | _bstr_t tmpColumncount("columncount");
|
---|
| 1389 | _bstr_t tmpLoopanimation("loopanimation");
|
---|
| 1390 | _bstr_t tmpKey1("key_start");
|
---|
| 1391 | _bstr_t tmpKey2("key_middle");
|
---|
| 1392 | _bstr_t tmpKey3("key_end");
|
---|
| 1393 | _bstr_t tmpAlpha("alpha");
|
---|
| 1394 | _bstr_t tmpRed("red");
|
---|
| 1395 | _bstr_t tmpGreen("green");
|
---|
| 1396 | _bstr_t tmpBlue("blue");
|
---|
| 1397 | _bstr_t tmpWidth("width");
|
---|
| 1398 | _bstr_t tmpHeight("height");
|
---|
| 1399 | _bstr_t tmpTime("time");
|
---|
| 1400 |
|
---|
| 1401 | std::string texture0;
|
---|
| 1402 | int lookAtCamera;
|
---|
| 1403 | Vector dimension;
|
---|
| 1404 |
|
---|
| 1405 | bool hasAnimation = false;
|
---|
| 1406 | int FPS = 1;
|
---|
| 1407 | int FrameCount = 1;
|
---|
| 1408 | int RowCount = 1;
|
---|
| 1409 | int ColumnCount = 1;
|
---|
| 1410 | bool loop = true;
|
---|
| 1411 |
|
---|
| 1412 | bool hasKey1 = false;
|
---|
| 1413 | bool hasKey2 = false;
|
---|
| 1414 | bool hasKey3 = false;
|
---|
| 1415 |
|
---|
| 1416 | float alpha[3] = {0.0f, 0.0f, 0.0f};
|
---|
| 1417 | float red[3] = {0.0f, 0.0f, 0.0f};
|
---|
| 1418 | float green[3] = {0.0f, 0.0f, 0.0f};
|
---|
| 1419 | float blue[3] = {0.0f, 0.0f, 0.0f};
|
---|
| 1420 | float width[3] = {0.0f, 0.0f, 0.0f};
|
---|
| 1421 | float height[3] = {0.0f, 0.0f, 0.0f};
|
---|
| 1422 | float time[3] = {0.0f, 0.0f, 1.0f};
|
---|
| 1423 |
|
---|
| 1424 | Sprite* sp = (Sprite*) this->scene->createNode(GameScene::NODE_SPRITE);
|
---|
| 1425 |
|
---|
| 1426 | for (MSXML::IXMLDOMNodePtr pChild = spriteNode->firstChild;NULL != pChild;pChild = pChild->nextSibling) {
|
---|
| 1427 | if(pChild->nodeType == MSXML::NODE_ELEMENT) {
|
---|
| 1428 | if(pChild->nodeName == tmpDimension) {
|
---|
| 1429 | dimension = tracePosition(pChild);
|
---|
| 1430 | } else if(pChild->nodeName == tmpTexture0) {
|
---|
| 1431 | texture0 = pChild->firstChild->text;
|
---|
| 1432 | } else if(pChild->nodeName == tmpLookAtCamera) {
|
---|
| 1433 | lookAtCamera = atoi(pChild->firstChild->text);
|
---|
| 1434 | } else if(pChild->nodeName == tmpAnimation) {
|
---|
| 1435 | hasAnimation = true;
|
---|
| 1436 | for (MSXML::IXMLDOMNodePtr pChildAnimation = pChild->firstChild;NULL != pChildAnimation;pChildAnimation = pChildAnimation->nextSibling) {
|
---|
| 1437 | if(pChildAnimation->nodeName == tmpFps) {
|
---|
| 1438 | FPS = atoi(pChildAnimation->firstChild->text);
|
---|
| 1439 | } else if(pChildAnimation->nodeName == tmpFrameCount) {
|
---|
| 1440 | FrameCount = atoi(pChildAnimation->firstChild->text);
|
---|
| 1441 | } else if(pChildAnimation->nodeName == tmpRowcount) {
|
---|
| 1442 | RowCount = atoi(pChildAnimation->firstChild->text);
|
---|
| 1443 | } else if(pChildAnimation->nodeName == tmpColumncount) {
|
---|
| 1444 | ColumnCount = atoi(pChildAnimation->firstChild->text);
|
---|
| 1445 | } else if(pChildAnimation->nodeName == tmpFrameCount) {
|
---|
| 1446 | FrameCount = atoi(pChildAnimation->firstChild->text);
|
---|
| 1447 | } else if(pChildAnimation->nodeName == tmpLoopanimation) {
|
---|
| 1448 | if(atoi(pChildAnimation->firstChild->text) != 1) {
|
---|
| 1449 | loop = false;
|
---|
| 1450 | }
|
---|
| 1451 | }
|
---|
| 1452 | }
|
---|
| 1453 | } else if(pChild->nodeName == tmpKey1) {
|
---|
| 1454 | hasKey1 = true;
|
---|
| 1455 | for (MSXML::IXMLDOMNodePtr pChildAnimation = pChild->firstChild;NULL != pChildAnimation;pChildAnimation = pChildAnimation->nextSibling) {
|
---|
| 1456 | if(pChildAnimation->nodeName == tmpAlpha) {
|
---|
| 1457 | alpha[0] = (FLOAT)atof(pChild->firstChild->text);
|
---|
| 1458 | } else if(pChildAnimation->nodeName == tmpRed) {
|
---|
| 1459 | red[0] = (FLOAT)atof(pChildAnimation->firstChild->text);
|
---|
| 1460 | } else if(pChildAnimation->nodeName == tmpGreen) {
|
---|
| 1461 | green[0] = (FLOAT)atof(pChildAnimation->firstChild->text);
|
---|
| 1462 | } else if(pChildAnimation->nodeName == tmpBlue) {
|
---|
| 1463 | blue[0] = (FLOAT)atof(pChildAnimation->firstChild->text);
|
---|
| 1464 | } else if(pChildAnimation->nodeName == tmpWidth) {
|
---|
| 1465 | width[0] = (FLOAT)atof(pChildAnimation->firstChild->text);
|
---|
| 1466 | } else if(pChildAnimation->nodeName == tmpHeight) {
|
---|
| 1467 | height[0] = (FLOAT)atof(pChildAnimation->firstChild->text);
|
---|
| 1468 | }
|
---|
| 1469 | }
|
---|
| 1470 | } else if(pChild->nodeName == tmpKey2) {
|
---|
| 1471 | hasKey2 = true;
|
---|
| 1472 | for (MSXML::IXMLDOMNodePtr pChildAnimation = pChild->firstChild;NULL != pChildAnimation;pChildAnimation = pChildAnimation->nextSibling) {
|
---|
| 1473 | if(pChildAnimation->nodeName == tmpAlpha) {
|
---|
| 1474 | alpha[1] = (FLOAT)atof(pChild->firstChild->text);
|
---|
| 1475 | } else if(pChildAnimation->nodeName == tmpRed) {
|
---|
| 1476 | red[1] = (FLOAT)atof(pChildAnimation->firstChild->text);
|
---|
| 1477 | } else if(pChildAnimation->nodeName == tmpGreen) {
|
---|
| 1478 | green[1] = (FLOAT)atof(pChildAnimation->firstChild->text);
|
---|
| 1479 | } else if(pChildAnimation->nodeName == tmpBlue) {
|
---|
| 1480 | blue[1] = (FLOAT)atof(pChildAnimation->firstChild->text);
|
---|
| 1481 | } else if(pChildAnimation->nodeName == tmpWidth) {
|
---|
| 1482 | width[1] = (FLOAT)atof(pChildAnimation->firstChild->text);
|
---|
| 1483 | } else if(pChildAnimation->nodeName == tmpHeight) {
|
---|
| 1484 | height[1] = (FLOAT)atof(pChildAnimation->firstChild->text);
|
---|
| 1485 | } else if(pChildAnimation->nodeName == tmpTime) {
|
---|
| 1486 | time[1] = (FLOAT)atof(pChildAnimation->firstChild->text);
|
---|
| 1487 | }
|
---|
| 1488 | }
|
---|
| 1489 | } else if(pChild->nodeName == tmpKey3) {
|
---|
| 1490 | hasKey3 = true;
|
---|
| 1491 | for (MSXML::IXMLDOMNodePtr pChildAnimation = pChild->firstChild;NULL != pChildAnimation;pChildAnimation = pChildAnimation->nextSibling) {
|
---|
| 1492 | if(pChildAnimation->nodeName == tmpAlpha) {
|
---|
| 1493 | alpha[2] = (FLOAT)atof(pChild->firstChild->text);
|
---|
| 1494 | } else if(pChildAnimation->nodeName == tmpRed) {
|
---|
| 1495 | red[2] = (FLOAT)atof(pChildAnimation->firstChild->text);
|
---|
| 1496 | } else if(pChildAnimation->nodeName == tmpGreen) {
|
---|
| 1497 | green[2] = (FLOAT)atof(pChildAnimation->firstChild->text);
|
---|
| 1498 | } else if(pChildAnimation->nodeName == tmpBlue) {
|
---|
| 1499 | blue[2] = (FLOAT)atof(pChildAnimation->firstChild->text);
|
---|
| 1500 | } else if(pChildAnimation->nodeName == tmpWidth) {
|
---|
| 1501 | width[2] = (FLOAT)atof(pChildAnimation->firstChild->text);
|
---|
| 1502 | } else if(pChildAnimation->nodeName == tmpHeight) {
|
---|
| 1503 | height[2] = (FLOAT)atof(pChildAnimation->firstChild->text);
|
---|
| 1504 | }
|
---|
| 1505 | }
|
---|
| 1506 | }
|
---|
| 1507 | }
|
---|
| 1508 | }
|
---|
| 1509 |
|
---|
| 1510 | sp->setDimension(dimension.x, dimension.y);
|
---|
| 1511 | sp->setTexture(texture0);
|
---|
| 1512 | sp->setLookAtCamera(lookAtCamera==1);
|
---|
| 1513 |
|
---|
| 1514 | if(hasAnimation) {
|
---|
| 1515 | sp->setFPS(FPS);
|
---|
| 1516 | sp->setFrameCount(FrameCount);
|
---|
| 1517 | sp->setRowColumnCount(RowCount, ColumnCount);
|
---|
| 1518 | sp->setLoopAnimation(true); // there's a bug if i set this to false
|
---|
| 1519 | }
|
---|
| 1520 |
|
---|
| 1521 | if(hasKey1 && hasKey2 && hasKey3) {
|
---|
| 1522 | sp->setKeyFrame(Sprite::KEY_START, alpha[0], red[0], green[0], blue[0], width[0], height[0], time[0]);
|
---|
| 1523 | sp->setKeyFrame(Sprite::KEY_MIDDLE, alpha[1], red[1], green[1], blue[1], width[1], height[1], time[1]);
|
---|
| 1524 | sp->setKeyFrame(Sprite::KEY_END, alpha[2], red[2], green[2], blue[2], width[2], height[2], time[2]);
|
---|
| 1525 | }
|
---|
| 1526 |
|
---|
| 1527 | return sp;
|
---|
| 1528 | }
|
---|
| 1529 |
|
---|
| 1530 | SoundNode* GameSceneLoader::traceSound(MSXML::IXMLDOMNodePtr soundNode)
|
---|
| 1531 | {
|
---|
| 1532 | _bstr_t tmpPosition("position");
|
---|
| 1533 | _bstr_t tmpArrivaltime("arrivaltime");
|
---|
| 1534 | _bstr_t tmpVariation("timevariation");
|
---|
| 1535 | _bstr_t tmpSoundfile("soundfile");
|
---|
| 1536 | _bstr_t tmpSoundVolume("volume");
|
---|
| 1537 | _bstr_t tmpKillAfterPlayed("killafterplayed");
|
---|
| 1538 | _bstr_t tmpLoop("loop");
|
---|
| 1539 |
|
---|
| 1540 | Vector position;
|
---|
| 1541 | float arrivalTime = 0;
|
---|
| 1542 | float arrivalVariation = 0;
|
---|
| 1543 | std::string soundfile;
|
---|
| 1544 | float volume = 1;
|
---|
| 1545 | bool killAfterPlayed;
|
---|
| 1546 | bool loop;
|
---|
| 1547 |
|
---|
| 1548 | for (MSXML::IXMLDOMNodePtr pChild = soundNode->firstChild;NULL != pChild;pChild = pChild->nextSibling) {
|
---|
| 1549 | if(pChild->nodeType == MSXML::NODE_ELEMENT) {
|
---|
| 1550 | if(pChild->nodeName == tmpPosition) {
|
---|
| 1551 | position = tracePosition(pChild);
|
---|
| 1552 | } else if(pChild->nodeName == tmpArrivaltime) {
|
---|
| 1553 | arrivalTime = (FLOAT)atof(pChild->firstChild->text);
|
---|
| 1554 | } else if(pChild->nodeName == tmpVariation) {
|
---|
| 1555 | arrivalVariation = (FLOAT)atof(pChild->firstChild->text);
|
---|
| 1556 | } else if(pChild->nodeName == tmpSoundfile) {
|
---|
| 1557 | soundfile = pChild->firstChild->text;
|
---|
| 1558 | } else if(pChild->nodeName == tmpSoundVolume) {
|
---|
| 1559 | volume = (FLOAT) atof(pChild->firstChild->text);
|
---|
| 1560 | } else if(pChild->nodeName == tmpKillAfterPlayed) {
|
---|
| 1561 | killAfterPlayed = ((INT)atoi(pChild->firstChild->text)==1);
|
---|
| 1562 | } else if(pChild->nodeName == tmpLoop) {
|
---|
| 1563 | loop = ((INT)atoi(pChild->firstChild->text)==1);
|
---|
| 1564 | }
|
---|
| 1565 | }
|
---|
| 1566 | }
|
---|
| 1567 |
|
---|
| 1568 | SoundNode* sound;
|
---|
| 1569 | sound = (SoundNode*) this->scene->createNode(Scene::NODE_SOUND);
|
---|
| 1570 | sound->loadFile(soundfile, loop);
|
---|
| 1571 | sound->setVolume(volume);
|
---|
| 1572 | sound->setKillSoundNodeAfterPlayed(killAfterPlayed);
|
---|
| 1573 |
|
---|
| 1574 | if(arrivalTime!=0) {
|
---|
| 1575 | sound->setStandBy(true);
|
---|
| 1576 | this->scene->setTrigger(GameScene::TRIGGER_UNSETSTANDBY, sound, this->scene->getRandomTime(arrivalTime, arrivalVariation));
|
---|
| 1577 | } else {
|
---|
| 1578 | sound->play();
|
---|
| 1579 | }
|
---|
| 1580 |
|
---|
| 1581 | return sound;
|
---|
| 1582 | }
|
---|