00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "ParticleSysComponent.h"
00018 #include "../../core/GameManager.h"
00019
00020
00021
00022
00023 ParticleSysComponent::ParticleSysComponent(Entity *parent, const vector3df &scale)
00024 : SceneComponent(parent, true)
00025 {
00026
00027 ISceneManager *pSceneMgr = GameManager::Instance()->getSceneManager();
00028
00029
00030 mParticleSystemSN = pSceneMgr->addParticleSystemSceneNode(true, 0, parent->getID(),
00031 parent->getAbsolutePosition(),
00032 parent->getAbsoluteRotation(),
00033 scale);
00034 mSceneNode = mParticleSystemSN;
00035
00036
00037 mTriSelector = NULL;
00038 mMetaSelector = pSceneMgr->createMetaTriangleSelector();
00039 }
00040
00041
00042 ParticleSysComponent::~ParticleSysComponent()
00043 {
00044 mParticleSystemSN->remove();
00045 mSceneNode = NULL;
00046 }
00047
00048
00049 IParticleSystemSceneNode* ParticleSysComponent::getParticleSystemSceneNode()
00050 {
00051 return mParticleSystemSN;
00052 }
00053
00054
00055 void ParticleSysComponent::addAffector(IParticleAffector *affector)
00056 {
00057 mParticleSystemSN->addAffector(affector);
00058 }
00059
00060
00061 void ParticleSysComponent::addAttractionAffector(const vector3df &point, f32 speed, bool attract,
00062 bool affectX, bool affectY, bool affectZ)
00063 {
00064 IParticleAffector *affector = mParticleSystemSN->createAttractionAffector(point, speed, attract,
00065 affectX, affectY, affectZ);
00066 mParticleSystemSN->addAffector(affector);
00067 affector->drop();
00068 }
00069
00070
00071 void ParticleSysComponent::addFadeOutParticleAffector(const SColor &targetColor,
00072 u32 timeNeededToFadeOut)
00073 {
00074 IParticleAffector *affector = mParticleSystemSN->createFadeOutParticleAffector(targetColor,
00075 timeNeededToFadeOut);
00076 mParticleSystemSN->addAffector(affector);
00077 affector->drop();
00078 }
00079
00080
00081 void ParticleSysComponent::addGravityAffector(const vector3df &gravity, u32 timeForceLost)
00082 {
00083 IParticleAffector *affector = mParticleSystemSN->createGravityAffector(gravity, timeForceLost);
00084 mParticleSystemSN->addAffector(affector);
00085 affector->drop();
00086 }
00087
00088
00089 void ParticleSysComponent::addRotationAffector(const vector3df &speed, const vector3df &pivotPoint)
00090 {
00091 IParticleAffector *affector = mParticleSystemSN->createRotationAffector(speed, pivotPoint);
00092 mParticleSystemSN->addAffector(affector);
00093 affector->drop();
00094 }
00095
00096
00097 void ParticleSysComponent::addScaleParticleAffector(const dimension2df &scaleTo)
00098 {
00099 IParticleAffector *affector = mParticleSystemSN->createScaleParticleAffector(scaleTo);
00100 mParticleSystemSN->addAffector(affector);
00101 affector->drop();
00102 }
00103
00104
00105 void ParticleSysComponent::removeAffectors()
00106 {
00107 mParticleSystemSN->removeAllAffectors();
00108 }
00109
00110
00111 IParticleEmitter* ParticleSysComponent::getEmitter()
00112 {
00113 return mParticleSystemSN->getEmitter();
00114 }
00115
00116
00117 void ParticleSysComponent::setAnimatedMeshSceneNodeEmitter(IAnimatedMeshSceneNode *node,
00118 bool useNormalDirection,
00119 const vector3df &direction,
00120 f32 normalDirectionModifier,
00121 bool everyMeshVertex,
00122 u32 minParticlesPerSecond,
00123 u32 maxParticlesPerSecond,
00124 const SColor &minStartColor,
00125 const SColor &maxStartColor,
00126 u32 lifeTimeMin, u32 lifeTimeMax,
00127 s32 maxAngleDegrees,
00128 const dimension2df &minStartSize,
00129 const dimension2df &maxStartSize)
00130 {
00131 IParticleEmitter *emitter = mParticleSystemSN->createAnimatedMeshSceneNodeEmitter(node,
00132 useNormalDirection, direction, normalDirectionModifier, -1,
00133 everyMeshVertex, minParticlesPerSecond, maxParticlesPerSecond,
00134 minStartColor, maxStartColor, lifeTimeMin, lifeTimeMax,
00135 maxAngleDegrees, minStartSize, maxStartSize);
00136 mParticleSystemSN->setEmitter(emitter);
00137 emitter->drop();
00138 }
00139
00140
00141 void ParticleSysComponent::setBoxEmitter(const aabbox3df &box, const vector3df &direction,
00142 u32 minParticlesPerSecond, u32 maxParticlesPerSecond,
00143 const SColor &minStartColor, const SColor &maxStartColor,
00144 u32 lifeTimeMin, u32 lifeTimeMax, s32 maxAngleDegrees,
00145 const dimension2df &minStartSize,
00146 const dimension2df &maxStartSize)
00147 {
00148 IParticleEmitter *emitter = mParticleSystemSN->createBoxEmitter(box, direction,
00149 minParticlesPerSecond, maxParticlesPerSecond, minStartColor,
00150 maxStartColor, lifeTimeMin, lifeTimeMax, maxAngleDegrees,
00151 minStartSize, maxStartSize);
00152 mParticleSystemSN->setEmitter(emitter);
00153 emitter->drop();
00154 }
00155
00156
00157 void ParticleSysComponent::setCylinderEmitter(const vector3df ¢er, f32 radius,
00158 const vector3df &normal, f32 length,
00159 bool outlineOnly, const vector3df &direction,
00160 u32 minParticlesPerSecond, u32 maxParticlesPerSecond,
00161 const SColor &minStartColor,
00162 const SColor &maxStartColor,
00163 u32 lifeTimeMin, u32 lifeTimeMax, s32 maxAngleDegrees,
00164 const dimension2df &minStartSize,
00165 const dimension2df &maxStartSize)
00166 {
00167 IParticleEmitter *emitter = mParticleSystemSN->createCylinderEmitter(center, radius, normal,
00168 length, outlineOnly, direction, minParticlesPerSecond,
00169 maxParticlesPerSecond, minStartColor, maxStartColor, lifeTimeMin,
00170 lifeTimeMax, maxAngleDegrees, minStartSize, maxStartSize);
00171 mParticleSystemSN->setEmitter(emitter);
00172 emitter->drop();
00173 }
00174
00175
00176 void ParticleSysComponent::setEmitter(IParticleEmitter *emitter)
00177 {
00178 mParticleSystemSN->setEmitter(emitter);
00179 }
00180
00181
00182 void ParticleSysComponent::setMeshEmitter(const std::string &fileName, bool useNormalDirection,
00183 const vector3df &direction, f32 normalDirectionModifier,
00184 bool everyMeshVertex, u32 minParticlesPerSecond,
00185 u32 maxParticlesPerSecond, const SColor &minStartColor,
00186 const SColor &maxStartColor, u32 lifeTimeMin,
00187 u32 lifeTimeMax, s32 maxAngleDegrees,
00188 const dimension2df &minStartSize,
00189 const dimension2df &maxStartSize)
00190 {
00191 IMesh *mesh = GameManager::Instance()->getSceneManager()->getMesh(fileName.c_str());
00192
00193 if(mesh)
00194 {
00195 IParticleEmitter *emitter = mParticleSystemSN->createMeshEmitter(mesh, useNormalDirection,
00196 direction, normalDirectionModifier, -1, everyMeshVertex,
00197 minParticlesPerSecond, maxParticlesPerSecond,
00198 minStartColor, maxStartColor, lifeTimeMin, lifeTimeMax,
00199 maxAngleDegrees, minStartSize, maxStartSize);
00200 mParticleSystemSN->setEmitter(emitter);
00201 emitter->drop();
00202 }
00203 }
00204
00205
00206 void ParticleSysComponent::setMeshEmitter(IMesh *mesh, bool useNormalDirection,
00207 const vector3df &direction,
00208 f32 normalDirectionModifier, bool everyMeshVertex,
00209 u32 minParticlesPerSecond, u32 maxParticlesPerSecond,
00210 const SColor &minStartColor, const SColor &maxStartColor,
00211 u32 lifeTimeMin, u32 lifeTimeMax, s32 maxAngleDegrees,
00212 const dimension2df &minStartSize,
00213 const dimension2df &maxStartSize)
00214 {
00215 IParticleEmitter *emitter = mParticleSystemSN->createMeshEmitter(mesh, useNormalDirection,
00216 direction, normalDirectionModifier, -1, everyMeshVertex,
00217 minParticlesPerSecond, maxParticlesPerSecond,
00218 minStartColor, maxStartColor, lifeTimeMin, lifeTimeMax,
00219 maxAngleDegrees, minStartSize, maxStartSize);
00220 mParticleSystemSN->setEmitter(emitter);
00221 emitter->drop();
00222 }
00223
00224
00225 void ParticleSysComponent::setPointEmitter(const vector3df &direction,
00226 u32 minParticlesPerSecond, u32 maxParticlesPerSecond,
00227 const SColor &minStartColor, const SColor &maxStartColor,
00228 u32 lifeTimeMin, u32 lifeTimeMax, s32 maxAngleDegrees,
00229 const dimension2df &minStartSize,
00230 const dimension2df &maxStartSize)
00231 {
00232 IParticleEmitter *emitter = mParticleSystemSN->createPointEmitter(direction,
00233 minParticlesPerSecond, maxParticlesPerSecond, minStartColor,
00234 maxStartColor, lifeTimeMin, lifeTimeMax, maxAngleDegrees,
00235 minStartSize, maxStartSize);
00236 mParticleSystemSN->setEmitter(emitter);
00237 emitter->drop();
00238 }
00239
00240
00241 void ParticleSysComponent::setRingEmitter(const vector3df ¢er, f32 radius,
00242 f32 ringThickness, const vector3df &direction,
00243 u32 minParticlesPerSecond, u32 maxParticlesPerSecond,
00244 const SColor &minStartColor, const SColor &maxStartColor,
00245 u32 lifeTimeMin, u32 lifeTimeMax, s32 maxAngleDegrees,
00246 const dimension2df &minStartSize,
00247 const dimension2df &maxStartSize)
00248 {
00249 IParticleEmitter *emitter = mParticleSystemSN->createRingEmitter(center, radius, ringThickness,
00250 direction, minParticlesPerSecond, maxParticlesPerSecond,
00251 minStartColor, maxStartColor, lifeTimeMin, lifeTimeMax,
00252 maxAngleDegrees, minStartSize, maxStartSize);
00253 mParticleSystemSN->setEmitter(emitter);
00254 emitter->drop();
00255 }
00256
00257
00258 void ParticleSysComponent::setSphereEmitter(const vector3df ¢er, f32 radius,
00259 const vector3df &direction,
00260 u32 minParticlesPerSecond, u32 maxParticlesPerSecond,
00261 const SColor &minStartColor,
00262 const SColor &maxStartColor,
00263 u32 lifeTimeMin, u32 lifeTimeMax, s32 maxAngleDegrees,
00264 const dimension2df &minStartSize,
00265 const dimension2df &maxStartSize)
00266 {
00267 IParticleEmitter *emitter = mParticleSystemSN->createSphereEmitter(center, radius, direction,
00268 minParticlesPerSecond, maxParticlesPerSecond, minStartColor,
00269 maxStartColor, lifeTimeMin, lifeTimeMax, maxAngleDegrees,
00270 minStartSize, maxStartSize);
00271 mParticleSystemSN->setEmitter(emitter);
00272 emitter->drop();
00273 }
00274
00275
00276 void ParticleSysComponent::setParticlesAreGlobal(bool value)
00277 {
00278 mParticleSystemSN->setParticlesAreGlobal(value);
00279 }
00280
00281
00282 void ParticleSysComponent::setParticleSize(const dimension2df &size)
00283 {
00284 mParticleSystemSN->setParticleSize(size);
00285 }
00286
00287
00288 bool ParticleSysComponent::parseXML(IXMLReader *file, Entity *entity)
00289 {
00290
00291 ParticleSysComponent *component = NULL;
00292
00293
00294 if(file->getNodeType() == io::EXN_ELEMENT)
00295 {
00296 if(stringw("ParticleSysComponent") == file->getNodeName())
00297 {
00298
00299 component = new ParticleSysComponent(entity);
00300 }
00301 }
00302
00303 if(component == NULL)
00304 return false;
00305
00306
00307 while(file->read())
00308 {
00309 switch(file->getNodeType())
00310 {
00311 case io::EXN_ELEMENT:
00312
00313
00314 if(stringw("AttractionAffector") == file->getNodeName())
00315 {
00316
00317 vector3df point;
00318 f32 speed = 1.0f;
00319 bool attract = true;
00320 bool affectX = true;
00321 bool affectY = true;
00322 bool affectZ = true;
00323
00324 bool doneParsing = false;
00325
00326 while(file->read() && !doneParsing)
00327 {
00328 switch(file->getNodeType())
00329 {
00330 case io::EXN_ELEMENT:
00331
00332
00333 if(stringw("point") == file->getNodeName())
00334 {
00335 point = vector3df( file->getAttributeValueAsFloat(L"x"),
00336 file->getAttributeValueAsFloat(L"y"),
00337 file->getAttributeValueAsFloat(L"z") );
00338 }
00339
00340
00341 else if(stringw("speed") == file->getNodeName())
00342 speed = file->getAttributeValueAsFloat(L"value");
00343
00344
00345 else if(stringw("attract") == file->getNodeName())
00346 {
00347 stringc value = file->getAttributeValue(L"value");
00348 attract = (value == "true") ? true : false ;
00349 }
00350
00351
00352 else if(stringw("affectX") == file->getNodeName())
00353 {
00354 stringc value = file->getAttributeValue(L"value");
00355 affectX = (value == "true") ? true : false ;
00356 }
00357
00358
00359 else if(stringw("affectY") == file->getNodeName())
00360 {
00361 stringc value = file->getAttributeValue(L"value");
00362 affectY = (value == "true") ? true : false ;
00363 }
00364
00365
00366 else if(stringw("affectZ") == file->getNodeName())
00367 {
00368 stringc value = file->getAttributeValue(L"value");
00369 affectZ = (value == "true") ? true : false ;
00370 }
00371
00372 break;
00373
00374 case io::EXN_ELEMENT_END:
00375
00376
00377 if(stringw("AttractionAffector") == file->getNodeName())
00378 doneParsing = true;
00379
00380 break;
00381
00382 default:
00383
00384 break;
00385 }
00386 }
00387
00388
00389 component->addAttractionAffector(point, speed, attract, affectX, affectY, affectZ);
00390 }
00391
00392
00393 else if(stringw("FadeOutParticleAffector") == file->getNodeName())
00394 {
00395
00396 SColor targetColor = SColor(0, 0, 0, 0);
00397 u32 timeNeededToFadeOut = 1000;
00398
00399 bool doneParsing = false;
00400
00401 while(file->read() && !doneParsing)
00402 {
00403 switch(file->getNodeType())
00404 {
00405 case io::EXN_ELEMENT:
00406
00407
00408 if(stringw("targetColor") == file->getNodeName())
00409 {
00410 targetColor = SColor( file->getAttributeValueAsInt(L"a"),
00411 file->getAttributeValueAsInt(L"r"),
00412 file->getAttributeValueAsInt(L"g"),
00413 file->getAttributeValueAsInt(L"b") );
00414 }
00415
00416 else if(stringw("timeNeededToFadeOut") == file->getNodeName())
00417 timeNeededToFadeOut = file->getAttributeValueAsInt(L"value");
00418
00419 break;
00420
00421 case io::EXN_ELEMENT_END:
00422
00423
00424 if(stringw("FadeOutParticleAffector") == file->getNodeName())
00425 doneParsing = true;
00426
00427 break;
00428
00429 default:
00430
00431 break;
00432 }
00433 }
00434
00435
00436 component->addFadeOutParticleAffector(targetColor, timeNeededToFadeOut);
00437 }
00438
00439
00440 else if(stringw("GravityAffector") == file->getNodeName())
00441 {
00442
00443 vector3df gravity = vector3df(0.0f,-0.03f, 0.0f);
00444 u32 timeForceLost = 1000;
00445
00446 bool doneParsing = false;
00447
00448 while(file->read() && !doneParsing)
00449 {
00450 switch(file->getNodeType())
00451 {
00452 case io::EXN_ELEMENT:
00453
00454
00455 if(stringw("gravity") == file->getNodeName())
00456 {
00457 gravity = vector3df( file->getAttributeValueAsFloat(L"x"),
00458 file->getAttributeValueAsFloat(L"y"),
00459 file->getAttributeValueAsFloat(L"z") );
00460 }
00461
00462 else if(stringw("timeForceLost") == file->getNodeName())
00463 timeForceLost = file->getAttributeValueAsInt(L"value");
00464
00465 break;
00466
00467 case io::EXN_ELEMENT_END:
00468
00469
00470 if(stringw("GravityAffector") == file->getNodeName())
00471 doneParsing = true;
00472
00473 break;
00474
00475 default:
00476
00477 break;
00478 }
00479 }
00480
00481
00482 component->addGravityAffector(gravity, timeForceLost);
00483 }
00484
00485
00486 else if(stringw("RotationAffector") == file->getNodeName())
00487 {
00488
00489 vector3df speed = vector3df(5.0f, 5.0f, 5.0f);
00490 vector3df pivotPoint = vector3df(0.0f, 0.0f, 0.0f);
00491
00492 bool doneParsing = false;
00493
00494 while(file->read() && !doneParsing)
00495 {
00496 switch(file->getNodeType())
00497 {
00498 case io::EXN_ELEMENT:
00499
00500
00501 if(stringw("speed") == file->getNodeName())
00502 {
00503 speed = vector3df( file->getAttributeValueAsFloat(L"x"),
00504 file->getAttributeValueAsFloat(L"y"),
00505 file->getAttributeValueAsFloat(L"z") );
00506 }
00507
00508
00509 else if(stringw("pivotPoint") == file->getNodeName())
00510 {
00511 pivotPoint = vector3df( file->getAttributeValueAsFloat(L"x"),
00512 file->getAttributeValueAsFloat(L"y"),
00513 file->getAttributeValueAsFloat(L"z") );
00514 }
00515
00516 break;
00517
00518 case io::EXN_ELEMENT_END:
00519
00520
00521 if(stringw("RotationAffector") == file->getNodeName())
00522 doneParsing = true;
00523
00524 break;
00525
00526 default:
00527
00528 break;
00529 }
00530 }
00531
00532
00533 component->addRotationAffector(speed, pivotPoint);
00534 }
00535
00536
00537 else if(stringw("ScaleParticleAffector") == file->getNodeName())
00538 {
00539
00540 dimension2df scaleTo = dimension2df(1.0f, 1.0f);
00541
00542 bool doneParsing = false;
00543
00544 while(file->read() && !doneParsing)
00545 {
00546 switch(file->getNodeType())
00547 {
00548 case io::EXN_ELEMENT:
00549
00550
00551 if(stringw("scaleTo") == file->getNodeName())
00552 {
00553 scaleTo = dimension2df( file->getAttributeValueAsFloat(L"width"),
00554 file->getAttributeValueAsFloat(L"height") );
00555 }
00556
00557 break;
00558
00559 case io::EXN_ELEMENT_END:
00560
00561
00562 if(stringw("ScaleParticleAffector") == file->getNodeName())
00563 doneParsing = true;
00564
00565 break;
00566
00567 default:
00568
00569 break;
00570 }
00571 }
00572
00573
00574 component->addScaleParticleAffector(scaleTo);
00575 }
00576
00577
00578 else if(stringw("MeshEmitter") == file->getNodeName())
00579 {
00580
00581 std::string fileName;
00582 bool useNormalDirection = true;
00583 vector3df direction = vector3df(0.0f, 0.03f, 0.0f);
00584 f32 normalDirectionModifier = 100.0f;
00585 bool everyMeshVertex = false;
00586 u32 minParticlesPerSecond = 5;
00587 u32 maxParticlesPerSecond = 10;
00588 SColor minStartColor = SColor(255, 0, 0, 0);
00589 SColor maxStartColor = SColor(255, 255, 255, 255);
00590 u32 lifeTimeMin = 2000;
00591 u32 lifeTimeMax = 4000;
00592 s32 maxAngleDegrees = 0;
00593 dimension2df minStartSize = dimension2df(5.0f, 5.0f);
00594 dimension2df maxStartSize = dimension2df(5.0f, 5.0f);
00595
00596 bool doneParsing = false;
00597
00598 while(file->read() && !doneParsing)
00599 {
00600 switch(file->getNodeType())
00601 {
00602 case io::EXN_ELEMENT:
00603
00604
00605 if(stringw("fileName") == file->getNodeName())
00606 {
00607 stringc value = file->getAttributeValue(L"value");
00608 fileName = value.c_str();
00609 }
00610
00611
00612 else if(stringw("useNormalDirection") == file->getNodeName())
00613 {
00614 stringc value = file->getAttributeValue(L"value");
00615 useNormalDirection = (value == "true") ? true : false ;
00616 }
00617
00618
00619 else if(stringw("direction") == file->getNodeName())
00620 {
00621 direction = vector3df( file->getAttributeValueAsFloat(L"x"),
00622 file->getAttributeValueAsFloat(L"y"),
00623 file->getAttributeValueAsFloat(L"z") );
00624 }
00625
00626
00627 else if(stringw("normalDirectionModifier") == file->getNodeName())
00628 normalDirectionModifier = file->getAttributeValueAsFloat(L"value");
00629
00630
00631 else if(stringw("everyMeshVertex") == file->getNodeName())
00632 {
00633 stringc value = file->getAttributeValue(L"value");
00634 everyMeshVertex = (value == "true") ? true : false ;
00635 }
00636
00637
00638 else if(stringw("minParticlesPerSecond") == file->getNodeName())
00639 minParticlesPerSecond = file->getAttributeValueAsInt(L"value");
00640
00641
00642 else if(stringw("maxParticlesPerSecond") == file->getNodeName())
00643 maxParticlesPerSecond = file->getAttributeValueAsInt(L"value");
00644
00645
00646 else if(stringw("minStartColor") == file->getNodeName())
00647 {
00648 minStartColor = SColor( file->getAttributeValueAsInt(L"a"),
00649 file->getAttributeValueAsInt(L"r"),
00650 file->getAttributeValueAsInt(L"g"),
00651 file->getAttributeValueAsInt(L"b") );
00652 }
00653
00654
00655 else if(stringw("maxStartColor") == file->getNodeName())
00656 {
00657 maxStartColor = SColor( file->getAttributeValueAsInt(L"a"),
00658 file->getAttributeValueAsInt(L"r"),
00659 file->getAttributeValueAsInt(L"g"),
00660 file->getAttributeValueAsInt(L"b") );
00661 }
00662
00663
00664 else if(stringw("lifeTimeMin") == file->getNodeName())
00665 lifeTimeMin = file->getAttributeValueAsInt(L"value");
00666
00667
00668 else if(stringw("lifeTimeMax") == file->getNodeName())
00669 lifeTimeMax = file->getAttributeValueAsInt(L"value");
00670
00671
00672 else if(stringw("maxAngleDegrees") == file->getNodeName())
00673 maxAngleDegrees = file->getAttributeValueAsInt(L"value");
00674
00675
00676 else if(stringw("minStartSize") == file->getNodeName())
00677 {
00678 minStartSize = dimension2df( file->getAttributeValueAsFloat(L"width"),
00679 file->getAttributeValueAsFloat(L"height"));
00680 }
00681
00682
00683 else if(stringw("maxStartSize") == file->getNodeName())
00684 {
00685 maxStartSize = dimension2df( file->getAttributeValueAsFloat(L"width"),
00686 file->getAttributeValueAsFloat(L"height"));
00687 }
00688
00689 break;
00690
00691 case io::EXN_ELEMENT_END:
00692
00693
00694 if(stringw("MeshEmitter") == file->getNodeName())
00695 doneParsing = true;
00696
00697 break;
00698
00699 default:
00700
00701 break;
00702 }
00703 }
00704
00705
00706 component->setMeshEmitter(fileName, useNormalDirection, direction,
00707 normalDirectionModifier, everyMeshVertex, minParticlesPerSecond,
00708 maxParticlesPerSecond, minStartColor, maxStartColor, lifeTimeMin,
00709 lifeTimeMax, maxAngleDegrees, minStartSize, maxStartSize);
00710 }
00711
00712
00713 else if(stringw("BoxEmitter") == file->getNodeName())
00714 {
00715
00716 aabbox3df box = aabbox3df(-10, 28,-10, 10, 30, 10);
00717 vector3df direction = vector3df(0.0f, 0.03f, 0.0f);
00718 u32 minParticlesPerSecond = 5;
00719 u32 maxParticlesPerSecond = 10;
00720 SColor minStartColor = SColor(255, 0, 0, 0);
00721 SColor maxStartColor = SColor(255, 255, 255, 255);
00722 u32 lifeTimeMin = 2000;
00723 u32 lifeTimeMax = 4000;
00724 s32 maxAngleDegrees = 0;
00725 dimension2df minStartSize = dimension2df(5.0f, 5.0f);
00726 dimension2df maxStartSize = dimension2df(5.0f, 5.0f);
00727
00728 bool doneParsing = false;
00729
00730 while(file->read() && !doneParsing)
00731 {
00732 switch(file->getNodeType())
00733 {
00734 case io::EXN_ELEMENT:
00735
00736
00737 if(stringw("scaleTo") == file->getNodeName())
00738 {
00739 box = aabbox3df( file->getAttributeValueAsFloat(L"minX"),
00740 file->getAttributeValueAsFloat(L"minY"),
00741 file->getAttributeValueAsFloat(L"minZ"),
00742 file->getAttributeValueAsFloat(L"maxX"),
00743 file->getAttributeValueAsFloat(L"maxY"),
00744 file->getAttributeValueAsFloat(L"maxZ") );
00745 }
00746
00747
00748 else if(stringw("direction") == file->getNodeName())
00749 {
00750 direction = vector3df( file->getAttributeValueAsFloat(L"x"),
00751 file->getAttributeValueAsFloat(L"y"),
00752 file->getAttributeValueAsFloat(L"z") );
00753 }
00754
00755
00756 else if(stringw("minParticlesPerSecond") == file->getNodeName())
00757 minParticlesPerSecond = file->getAttributeValueAsInt(L"value");
00758
00759
00760 else if(stringw("maxParticlesPerSecond") == file->getNodeName())
00761 maxParticlesPerSecond = file->getAttributeValueAsInt(L"value");
00762
00763
00764 else if(stringw("minStartColor") == file->getNodeName())
00765 {
00766 minStartColor = SColor( file->getAttributeValueAsInt(L"a"),
00767 file->getAttributeValueAsInt(L"r"),
00768 file->getAttributeValueAsInt(L"g"),
00769 file->getAttributeValueAsInt(L"b") );
00770 }
00771
00772
00773 else if(stringw("maxStartColor") == file->getNodeName())
00774 {
00775 maxStartColor = SColor( file->getAttributeValueAsInt(L"a"),
00776 file->getAttributeValueAsInt(L"r"),
00777 file->getAttributeValueAsInt(L"g"),
00778 file->getAttributeValueAsInt(L"b") );
00779 }
00780
00781
00782 else if(stringw("lifeTimeMin") == file->getNodeName())
00783 lifeTimeMin = file->getAttributeValueAsInt(L"value");
00784
00785
00786 else if(stringw("lifeTimeMax") == file->getNodeName())
00787 lifeTimeMax = file->getAttributeValueAsInt(L"value");
00788
00789
00790 else if(stringw("maxAngleDegrees") == file->getNodeName())
00791 maxAngleDegrees = file->getAttributeValueAsInt(L"value");
00792
00793
00794 else if(stringw("minStartSize") == file->getNodeName())
00795 {
00796 minStartSize = dimension2df( file->getAttributeValueAsFloat(L"width"),
00797 file->getAttributeValueAsFloat(L"height"));
00798 }
00799
00800
00801 else if(stringw("maxStartSize") == file->getNodeName())
00802 {
00803 maxStartSize = dimension2df( file->getAttributeValueAsFloat(L"width"),
00804 file->getAttributeValueAsFloat(L"height"));
00805 }
00806
00807 break;
00808
00809 case io::EXN_ELEMENT_END:
00810
00811
00812 if(stringw("BoxEmitter") == file->getNodeName())
00813 doneParsing = true;
00814
00815 break;
00816
00817 default:
00818
00819 break;
00820 }
00821 }
00822
00823
00824 component->setBoxEmitter(box, direction, minParticlesPerSecond,
00825 maxParticlesPerSecond, minStartColor, maxStartColor, lifeTimeMin,
00826 lifeTimeMax, maxAngleDegrees, minStartSize, maxStartSize);
00827 }
00828
00829
00830 else if(stringw("CylinderEmitter") == file->getNodeName())
00831 {
00832
00833 vector3df center;
00834 f32 radius;
00835 vector3df normal;
00836 f32 length;
00837 bool outlineOnly = false;
00838 vector3df direction = vector3df(0.0f, 0.03f, 0.0f);
00839 u32 minParticlesPerSecond = 5;
00840 u32 maxParticlesPerSecond = 10;
00841 SColor minStartColor = SColor(255, 0, 0, 0);
00842 SColor maxStartColor = SColor(255, 255, 255, 255);
00843 u32 lifeTimeMin = 2000;
00844 u32 lifeTimeMax = 4000;
00845 s32 maxAngleDegrees = 0;
00846 dimension2df minStartSize = dimension2df(5.0f, 5.0f);
00847 dimension2df maxStartSize = dimension2df(5.0f, 5.0f);
00848
00849 bool doneParsing = false;
00850
00851 while(file->read() && !doneParsing)
00852 {
00853 switch(file->getNodeType())
00854 {
00855 case io::EXN_ELEMENT:
00856
00857
00858 if(stringw("center") == file->getNodeName())
00859 {
00860 center = vector3df( file->getAttributeValueAsFloat(L"x"),
00861 file->getAttributeValueAsFloat(L"y"),
00862 file->getAttributeValueAsFloat(L"z") );
00863 }
00864
00865
00866 else if(stringw("radius") == file->getNodeName())
00867 radius = file->getAttributeValueAsFloat(L"value");
00868
00869
00870 else if(stringw("normal") == file->getNodeName())
00871 {
00872 normal = vector3df( file->getAttributeValueAsFloat(L"x"),
00873 file->getAttributeValueAsFloat(L"y"),
00874 file->getAttributeValueAsFloat(L"z") );
00875 }
00876
00877
00878 else if(stringw("length") == file->getNodeName())
00879 length = file->getAttributeValueAsFloat(L"value");
00880
00881
00882 else if(stringw("outlineOnly") == file->getNodeName())
00883 {
00884 stringc value = file->getAttributeValue(L"value");
00885 outlineOnly = (value == "true") ? true : false ;
00886 }
00887
00888
00889 else if(stringw("direction") == file->getNodeName())
00890 {
00891 direction = vector3df( file->getAttributeValueAsFloat(L"x"),
00892 file->getAttributeValueAsFloat(L"y"),
00893 file->getAttributeValueAsFloat(L"z") );
00894 }
00895
00896
00897 else if(stringw("minParticlesPerSecond") == file->getNodeName())
00898 minParticlesPerSecond = file->getAttributeValueAsInt(L"value");
00899
00900
00901 else if(stringw("maxParticlesPerSecond") == file->getNodeName())
00902 maxParticlesPerSecond = file->getAttributeValueAsInt(L"value");
00903
00904
00905 else if(stringw("minStartColor") == file->getNodeName())
00906 {
00907 minStartColor = SColor( file->getAttributeValueAsInt(L"a"),
00908 file->getAttributeValueAsInt(L"r"),
00909 file->getAttributeValueAsInt(L"g"),
00910 file->getAttributeValueAsInt(L"b") );
00911 }
00912
00913
00914 else if(stringw("maxStartColor") == file->getNodeName())
00915 {
00916 maxStartColor = SColor( file->getAttributeValueAsInt(L"a"),
00917 file->getAttributeValueAsInt(L"r"),
00918 file->getAttributeValueAsInt(L"g"),
00919 file->getAttributeValueAsInt(L"b") );
00920 }
00921
00922
00923 else if(stringw("lifeTimeMin") == file->getNodeName())
00924 lifeTimeMin = file->getAttributeValueAsInt(L"value");
00925
00926
00927 else if(stringw("lifeTimeMax") == file->getNodeName())
00928 lifeTimeMax = file->getAttributeValueAsInt(L"value");
00929
00930
00931 else if(stringw("maxAngleDegrees") == file->getNodeName())
00932 maxAngleDegrees = file->getAttributeValueAsInt(L"value");
00933
00934
00935 else if(stringw("minStartSize") == file->getNodeName())
00936 {
00937 minStartSize = dimension2df( file->getAttributeValueAsFloat(L"width"),
00938 file->getAttributeValueAsFloat(L"height"));
00939 }
00940
00941
00942 else if(stringw("maxStartSize") == file->getNodeName())
00943 {
00944 maxStartSize = dimension2df( file->getAttributeValueAsFloat(L"width"),
00945 file->getAttributeValueAsFloat(L"height"));
00946 }
00947
00948 break;
00949
00950 case io::EXN_ELEMENT_END:
00951
00952
00953 if(stringw("CylinderEmitter") == file->getNodeName())
00954 doneParsing = true;
00955
00956 break;
00957
00958 default:
00959
00960 break;
00961 }
00962 }
00963
00964
00965 component->setCylinderEmitter(center, radius, normal, length, outlineOnly,
00966 direction, minParticlesPerSecond, maxParticlesPerSecond, minStartColor,
00967 maxStartColor, lifeTimeMin, lifeTimeMax, maxAngleDegrees,
00968 minStartSize, maxStartSize);
00969 }
00970
00971
00972 else if(stringw("PointEmitter") == file->getNodeName())
00973 {
00974
00975 vector3df direction = vector3df(0.0f, 0.03f, 0.0f);
00976 u32 minParticlesPerSecond = 5;
00977 u32 maxParticlesPerSecond = 10;
00978 SColor minStartColor = SColor(255, 0, 0, 0);
00979 SColor maxStartColor = SColor(255, 255, 255, 255);
00980 u32 lifeTimeMin = 2000;
00981 u32 lifeTimeMax = 4000;
00982 s32 maxAngleDegrees = 0;
00983 dimension2df minStartSize = dimension2df(5.0f, 5.0f);
00984 dimension2df maxStartSize = dimension2df(5.0f, 5.0f);
00985
00986 bool doneParsing = false;
00987
00988 while(file->read() && !doneParsing)
00989 {
00990 switch(file->getNodeType())
00991 {
00992 case io::EXN_ELEMENT:
00993
00994
00995 if(stringw("direction") == file->getNodeName())
00996 {
00997 direction = vector3df( file->getAttributeValueAsFloat(L"x"),
00998 file->getAttributeValueAsFloat(L"y"),
00999 file->getAttributeValueAsFloat(L"z") );
01000 }
01001
01002
01003 else if(stringw("minParticlesPerSecond") == file->getNodeName())
01004 minParticlesPerSecond = file->getAttributeValueAsInt(L"value");
01005
01006
01007 else if(stringw("maxParticlesPerSecond") == file->getNodeName())
01008 maxParticlesPerSecond = file->getAttributeValueAsInt(L"value");
01009
01010
01011 else if(stringw("minStartColor") == file->getNodeName())
01012 {
01013 minStartColor = SColor( file->getAttributeValueAsInt(L"a"),
01014 file->getAttributeValueAsInt(L"r"),
01015 file->getAttributeValueAsInt(L"g"),
01016 file->getAttributeValueAsInt(L"b") );
01017 }
01018
01019
01020 else if(stringw("maxStartColor") == file->getNodeName())
01021 {
01022 maxStartColor = SColor( file->getAttributeValueAsInt(L"a"),
01023 file->getAttributeValueAsInt(L"r"),
01024 file->getAttributeValueAsInt(L"g"),
01025 file->getAttributeValueAsInt(L"b") );
01026 }
01027
01028
01029 else if(stringw("lifeTimeMin") == file->getNodeName())
01030 lifeTimeMin = file->getAttributeValueAsInt(L"value");
01031
01032
01033 else if(stringw("lifeTimeMax") == file->getNodeName())
01034 lifeTimeMax = file->getAttributeValueAsInt(L"value");
01035
01036
01037 else if(stringw("maxAngleDegrees") == file->getNodeName())
01038 maxAngleDegrees = file->getAttributeValueAsInt(L"value");
01039
01040
01041 else if(stringw("minStartSize") == file->getNodeName())
01042 {
01043 minStartSize = dimension2df( file->getAttributeValueAsFloat(L"width"),
01044 file->getAttributeValueAsFloat(L"height"));
01045 }
01046
01047
01048 else if(stringw("maxStartSize") == file->getNodeName())
01049 {
01050 maxStartSize = dimension2df( file->getAttributeValueAsFloat(L"width"),
01051 file->getAttributeValueAsFloat(L"height"));
01052 }
01053
01054 break;
01055
01056 case io::EXN_ELEMENT_END:
01057
01058
01059 if(stringw("PointEmitter") == file->getNodeName())
01060 doneParsing = true;
01061
01062 break;
01063
01064 default:
01065
01066 break;
01067 }
01068 }
01069
01070
01071 component->setPointEmitter(direction, minParticlesPerSecond, maxParticlesPerSecond,
01072 minStartColor, maxStartColor, lifeTimeMin, lifeTimeMax,
01073 maxAngleDegrees, minStartSize, maxStartSize);
01074 }
01075
01076
01077 else if(stringw("RingEmitter") == file->getNodeName())
01078 {
01079
01080 vector3df center;
01081 f32 radius;
01082 f32 ringThickness;
01083 vector3df direction = vector3df(0.0f, 0.03f, 0.0f);
01084 u32 minParticlesPerSecond = 5;
01085 u32 maxParticlesPerSecond = 10;
01086 SColor minStartColor = SColor(255, 0, 0, 0);
01087 SColor maxStartColor = SColor(255, 255, 255, 255);
01088 u32 lifeTimeMin = 2000;
01089 u32 lifeTimeMax = 4000;
01090 s32 maxAngleDegrees = 0;
01091 dimension2df minStartSize = dimension2df(5.0f, 5.0f);
01092 dimension2df maxStartSize = dimension2df(5.0f, 5.0f);
01093
01094 bool doneParsing = false;
01095
01096 while(file->read() && !doneParsing)
01097 {
01098 switch(file->getNodeType())
01099 {
01100 case io::EXN_ELEMENT:
01101
01102
01103 if(stringw("center") == file->getNodeName())
01104 {
01105 center = vector3df( file->getAttributeValueAsFloat(L"x"),
01106 file->getAttributeValueAsFloat(L"y"),
01107 file->getAttributeValueAsFloat(L"z") );
01108 }
01109
01110
01111 else if(stringw("radius") == file->getNodeName())
01112 radius = file->getAttributeValueAsFloat(L"value");
01113
01114
01115 else if(stringw("ringThickness") == file->getNodeName())
01116 ringThickness = file->getAttributeValueAsFloat(L"value");
01117
01118
01119 else if(stringw("direction") == file->getNodeName())
01120 {
01121 direction = vector3df( file->getAttributeValueAsFloat(L"x"),
01122 file->getAttributeValueAsFloat(L"y"),
01123 file->getAttributeValueAsFloat(L"z") );
01124 }
01125
01126
01127 else if(stringw("minParticlesPerSecond") == file->getNodeName())
01128 minParticlesPerSecond = file->getAttributeValueAsInt(L"value");
01129
01130
01131 else if(stringw("maxParticlesPerSecond") == file->getNodeName())
01132 maxParticlesPerSecond = file->getAttributeValueAsInt(L"value");
01133
01134
01135 else if(stringw("minStartColor") == file->getNodeName())
01136 {
01137 minStartColor = SColor( file->getAttributeValueAsInt(L"a"),
01138 file->getAttributeValueAsInt(L"r"),
01139 file->getAttributeValueAsInt(L"g"),
01140 file->getAttributeValueAsInt(L"b") );
01141 }
01142
01143
01144 else if(stringw("maxStartColor") == file->getNodeName())
01145 {
01146 maxStartColor = SColor( file->getAttributeValueAsInt(L"a"),
01147 file->getAttributeValueAsInt(L"r"),
01148 file->getAttributeValueAsInt(L"g"),
01149 file->getAttributeValueAsInt(L"b") );
01150 }
01151
01152
01153 else if(stringw("lifeTimeMin") == file->getNodeName())
01154 lifeTimeMin = file->getAttributeValueAsInt(L"value");
01155
01156
01157 else if(stringw("lifeTimeMax") == file->getNodeName())
01158 lifeTimeMax = file->getAttributeValueAsInt(L"value");
01159
01160
01161 else if(stringw("maxAngleDegrees") == file->getNodeName())
01162 maxAngleDegrees = file->getAttributeValueAsInt(L"value");
01163
01164
01165 else if(stringw("minStartSize") == file->getNodeName())
01166 {
01167 minStartSize = dimension2df( file->getAttributeValueAsFloat(L"width"),
01168 file->getAttributeValueAsFloat(L"height"));
01169 }
01170
01171
01172 else if(stringw("maxStartSize") == file->getNodeName())
01173 {
01174 maxStartSize = dimension2df( file->getAttributeValueAsFloat(L"width"),
01175 file->getAttributeValueAsFloat(L"height"));
01176 }
01177
01178 break;
01179
01180 case io::EXN_ELEMENT_END:
01181
01182
01183 if(stringw("RingEmitter") == file->getNodeName())
01184 doneParsing = true;
01185
01186 break;
01187
01188 default:
01189
01190 break;
01191 }
01192 }
01193
01194
01195 component->setRingEmitter(center, radius, ringThickness, direction,
01196 minParticlesPerSecond, maxParticlesPerSecond, minStartColor,
01197 maxStartColor, lifeTimeMin, lifeTimeMax, maxAngleDegrees,
01198 minStartSize, maxStartSize);
01199 }
01200
01201
01202 else if(stringw("SphereEmitter") == file->getNodeName())
01203 {
01204
01205 vector3df center;
01206 f32 radius;
01207 vector3df direction = vector3df(0.0f, 0.03f, 0.0f);
01208 u32 minParticlesPerSecond = 5;
01209 u32 maxParticlesPerSecond = 10;
01210 SColor minStartColor = SColor(255, 0, 0, 0);
01211 SColor maxStartColor = SColor(255, 255, 255, 255);
01212 u32 lifeTimeMin = 2000;
01213 u32 lifeTimeMax = 4000;
01214 s32 maxAngleDegrees = 0;
01215 dimension2df minStartSize = dimension2df(5.0f, 5.0f);
01216 dimension2df maxStartSize = dimension2df(5.0f, 5.0f);
01217
01218 bool doneParsing = false;
01219
01220 while(file->read() && !doneParsing)
01221 {
01222 switch(file->getNodeType())
01223 {
01224 case io::EXN_ELEMENT:
01225
01226
01227 if(stringw("center") == file->getNodeName())
01228 {
01229 center = vector3df( file->getAttributeValueAsFloat(L"x"),
01230 file->getAttributeValueAsFloat(L"y"),
01231 file->getAttributeValueAsFloat(L"z") );
01232 }
01233
01234
01235 else if(stringw("radius") == file->getNodeName())
01236 radius = file->getAttributeValueAsFloat(L"value");
01237
01238
01239 else if(stringw("direction") == file->getNodeName())
01240 {
01241 direction = vector3df( file->getAttributeValueAsFloat(L"x"),
01242 file->getAttributeValueAsFloat(L"y"),
01243 file->getAttributeValueAsFloat(L"z") );
01244 }
01245
01246
01247 else if(stringw("minParticlesPerSecond") == file->getNodeName())
01248 minParticlesPerSecond = file->getAttributeValueAsInt(L"value");
01249
01250
01251 else if(stringw("maxParticlesPerSecond") == file->getNodeName())
01252 maxParticlesPerSecond = file->getAttributeValueAsInt(L"value");
01253
01254
01255 else if(stringw("minStartColor") == file->getNodeName())
01256 {
01257 minStartColor = SColor( file->getAttributeValueAsInt(L"a"),
01258 file->getAttributeValueAsInt(L"r"),
01259 file->getAttributeValueAsInt(L"g"),
01260 file->getAttributeValueAsInt(L"b") );
01261 }
01262
01263
01264 else if(stringw("maxStartColor") == file->getNodeName())
01265 {
01266 maxStartColor = SColor( file->getAttributeValueAsInt(L"a"),
01267 file->getAttributeValueAsInt(L"r"),
01268 file->getAttributeValueAsInt(L"g"),
01269 file->getAttributeValueAsInt(L"b") );
01270 }
01271
01272
01273 else if(stringw("lifeTimeMin") == file->getNodeName())
01274 lifeTimeMin = file->getAttributeValueAsInt(L"value");
01275
01276
01277 else if(stringw("lifeTimeMax") == file->getNodeName())
01278 lifeTimeMax = file->getAttributeValueAsInt(L"value");
01279
01280
01281 else if(stringw("maxAngleDegrees") == file->getNodeName())
01282 maxAngleDegrees = file->getAttributeValueAsInt(L"value");
01283
01284
01285 else if(stringw("minStartSize") == file->getNodeName())
01286 {
01287 minStartSize = dimension2df( file->getAttributeValueAsFloat(L"width"),
01288 file->getAttributeValueAsFloat(L"height"));
01289 }
01290
01291
01292 else if(stringw("maxStartSize") == file->getNodeName())
01293 {
01294 maxStartSize = dimension2df( file->getAttributeValueAsFloat(L"width"),
01295 file->getAttributeValueAsFloat(L"height"));
01296 }
01297
01298 break;
01299
01300 case io::EXN_ELEMENT_END:
01301
01302
01303 if(stringw("SphereEmitter") == file->getNodeName())
01304 doneParsing = true;
01305
01306 break;
01307
01308 default:
01309
01310 break;
01311 }
01312 }
01313
01314
01315 component->setSphereEmitter(center, radius, direction, minParticlesPerSecond,
01316 maxParticlesPerSecond, minStartColor, maxStartColor, lifeTimeMin,
01317 lifeTimeMax, maxAngleDegrees, minStartSize, maxStartSize);
01318 }
01319
01320
01321 else SceneComponent::parseBaseXML(file, component);
01322
01323 break;
01324
01325 case io::EXN_ELEMENT_END:
01326
01327
01328 if(stringw("ParticleSysComponent") == file->getNodeName())
01329 return true;
01330
01331 break;
01332
01333 default:
01334
01335 break;
01336 }
01337
01338 }
01339
01340
01341 return false;
01342 }
01343
01344