Changeset 4726 in orxonox.OLD for orxonox/trunk/src/lib
- Timestamp:
- Jun 28, 2005, 10:33:14 PM (19 years ago)
- Location:
- orxonox/trunk/src/lib/particles
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/lib/particles/particle_emitter.cc
r4725 r4726 30 30 CREATE_FACTORY(ParticleEmitter); 31 31 32 33 32 /** 34 33 \brief standard constructor … … 37 36 float velocity) 38 37 { 39 this->setClassID(CL_PARTICLE_EMITTER, "ParticleEmitter"); 40 this->type = EMITTER_DOT; 41 this->emitterSize = 1.0; 38 this->init(); 39 42 40 this->direction = direction; 43 this->setInheritSpeed(0);44 41 this->setSpread(angle); 45 42 this->setEmissionRate(emissionRate); … … 55 52 ParticleEmitter::ParticleEmitter(const TiXmlElement* root) 56 53 { 57 this->setClassID(CL_PARTICLE_EMITTER, "ParticleEmitter"); 58 59 this->saveTime = 0.0; 54 this->init(); 60 55 61 56 if (root) … … 76 71 77 72 /** 73 \brief initializes default values of a ParitcleEmitter 74 */ 75 void ParticleEmitter::init() 76 { 77 this->setClassID(CL_PARTICLE_EMITTER, "ParticleEmitter"); 78 79 this->type = PARTICLE_EMITTER_DEFAULT_TYPE; 80 this->emitterSize = PARTICLE_EMITTER_DEFAULT_SIZE; 81 this->setInheritSpeed(PARTICLE_EMITTER_DEFAULT_INHERIT_SPEED); 82 this->setEmissionRate(PARTICLE_EMITTER_DEFAULT_EMISSION_RATE); 83 this->setSize(PARTICLE_EMITTER_DEFAULT_SIZE); 84 85 this->saveTime = 0.0; 86 } 87 88 /** 78 89 \brief loads a ParticleEmitter from a XML-element 79 90 \param root the XML-element to load from … … 103 114 LoadParam<ParticleEmitter>(root, "spread", this, &ParticleEmitter::setSpread) 104 115 .describe("The angle the particles are emitted from (angle, deviation)"); 116 117 118 LoadParam<ParticleEmitter>(root, "emission-direction", this, &ParticleEmitter::setDirection); 105 119 } 106 120 -
orxonox/trunk/src/lib/particles/particle_emitter.h
r4690 r4726 12 12 class ParticleSystem; 13 13 class TiXmlElement; 14 15 // Default values 16 #define PARTICLE_EMITTER_DEFAULT_SIZE 1.0 17 #define PARTICLE_EMITTER_DEFAULT_EMISSION_RATE 50 18 #define PARTICLE_EMITTER_DEFAULT_TYPE EMITTER_DOT 19 #define PARTICLE_EMITTER_DEFAULT_INHERIT_SPEED 0.0 20 #define PARTICLE_EMITTER_DEFAULT_SPREAD M_PI 14 21 15 22 //! The form of the Emitter to emit from … … 31 38 virtual ~ParticleEmitter(void); 32 39 40 void init(); 33 41 void loadParams(const TiXmlElement* root); 34 42 … … 47 55 void setEmissionVelocity(float velocity, float randomVelocity = 0.0); 48 56 void setEmissionMomentum(float momentum, float randomMomentum = 0.0); 57 58 void setDirection(float x, float y, float z) { this->direction = Vector(x,y,z); }; //!< todo this should be done via PNODE 49 59 50 60 /** \returns the type of the emitter */ -
orxonox/trunk/src/lib/particles/particle_engine.cc
r4639 r4726 24 24 #include "debug.h" 25 25 #include "stdlibincl.h" 26 #include "load_param.h" 26 27 27 28 using namespace std; … … 82 83 83 84 /** 85 \brief loads the ParticleEngines settings and connections between particles and emitters 86 \param root the XML-element to load this from. 87 */ 88 void ParticleEngine::loadParams(const TiXmlElement* root) 89 { 90 const TiXmlElement* element = root->FirstChildElement(); 91 while( element != NULL) 92 { 93 LoadParam<ParticleEngine>(element, "connect", this, &ParticleEngine::addConnection, true) 94 .describe("connects an Emitter to a System (emitterName, systemName)"); 95 element = element->NextSiblingElement(); 96 } 97 } 98 99 100 101 /** 84 102 \brief Adds a System to the System list. 85 103 … … 99 117 { 100 118 this->emitterList->add(emitter); 119 } 120 121 /** 122 \brief Connects a ParticleSystem to a ParticleSystem thus emitting Particles. 123 \param emitter the Emitter to connect to the System 124 \param system the System to connect to the Emitter 125 */ 126 void ParticleEngine::addConnection(const char* emitter, const char* system) 127 { 128 ParticleEmitter* tmpEmit = this->getEmitterByName(emitter); 129 ParticleSystem* tmpSys = this->getSystemByName(system); 130 131 if (tmpEmit != NULL && tmpSys != NULL) 132 this->addConnection(tmpEmit, tmpSys); 133 else 134 { 135 if (tmpEmit == NULL) 136 PRINTF(2)("Emitter %s not found in the List of emitters, not connecting to %s\n", emitter, system); 137 if (tmpEmit == NULL) 138 PRINTF(2)("System %s not found in the List of emitters, not connecting to %s\n", system, emitter); 139 } 101 140 } 102 141 -
orxonox/trunk/src/lib/particles/particle_engine.h
r4677 r4726 8 8 9 9 #include "base_object.h" 10 10 11 #include "particle_system.h" 11 12 #include "particle_emitter.h" 13 14 #include "tinyxml.h" 12 15 13 16 // FORWARD DEFINITION … … 34 37 inline static ParticleEngine* getInstance(void) { if (!singletonRef) singletonRef = new ParticleEngine(); return singletonRef; }; 35 38 39 void loadParams(const TiXmlElement* root); 40 36 41 void tick(float dt); 37 42 void draw(void) const; … … 40 45 void addEmitter(ParticleEmitter* emitter); 41 46 void addConnection(ParticleEmitter* emitter, ParticleSystem* system); 47 void addConnection(const char* emitter, const char* system); 48 42 49 43 50 bool removeSystem(ParticleSystem* system); -
orxonox/trunk/src/lib/particles/particle_system.cc
r4725 r4726 127 127 128 128 LoadParam<ParticleSystem>(root, "type", this, &ParticleSystem::setType) 129 .describe("sets the type of the Particles, (DOT, SPARK, SPRITE or MODEL)"); 130 131 LoadParam<ParticleSystem>(root, "model", this, &ParticleSystem::setModel) 132 .describe("sets a model to be loaded on top of this System (also sets type to Model)"); 129 .describe("sets the type of the Particles, (dot, spark, sprite or model)"); 133 130 134 131 // PER-PARTICLE-ATTRIBUTES: … … 149 146 void ParticleSystem::setType(const char* particleType) 150 147 { 151 if ( strcmp(particleType, "DOTS"))148 if (!strcmp(particleType, "dot")) 152 149 this->setType(PARTICLE_DOT); 153 else if (strcmp(particleType, "SPARKS"))150 else if(!strcmp(particleType, "spark")) 154 151 this->setType(PARTICLE_SPARK); 155 else if (strcmp(particleType, "MODELS"))152 else if(!strcmp(particleType, "model")) 156 153 this->setType(PARTICLE_MODEL); 157 154 else // if (strcmp(particleType, "SPRITE")) … … 187 184 // material->setTransparency(.5); 188 185 break; 189 case PARTICLE_MODEL: 190 if (!this->model) 191 { 192 PRINTF(2)("Model not loaded yet, please do this through ParticleSystem::loadModel()"); 193 this->setType(PARTICLE_SPRITE); 194 } 195 break; 196 } 186 } 197 187 } 198 188 … … 207 197 { 208 198 this->material = material; 209 }210 211 /**212 * sets a Model to the Particles213 * @param modelName the Name of the Model to load214 */215 void ParticleSystem::setModel(const char* modelName)216 {217 if (this->model)218 ResourceManager::getInstance()->unload(this->model);219 if (modelName)220 {221 this->model = (Model*)ResourceManager::getInstance()->load(modelName, OBJ, RP_LEVEL);222 this->setType(PARTICLE_MODEL);223 }224 else225 {226 this->model = NULL;227 this->setType(PARTICLE_SPRITE);228 }229 199 } 230 200 … … 505 475 drawPart = drawPart->next; 506 476 } 477 else 478 printf("no model loaded onto ParticleSystem-%s\n", this->getName()); 507 479 } 508 480 break; … … 595 567 void ParticleSystem::debug(void) const 596 568 { 597 PRINT(0)(" ParticleSystem %s\n", this->getName()); 569 PRINT(0)(" ParticleSystem %s, type: ", this->getName()); 570 { 571 if (this->particleType == PARTICLE_MODEL) 572 PRINT(0)("model"); 573 else if (this->particleType == PARTICLE_SPRITE) 574 PRINT(0)("sprite"); 575 else if (this->particleType == PARTICLE_DOT) 576 PRINT(0)("dot"); 577 else if (this->particleType == PARTICLE_SPARK) 578 PRINT(0)("spark"); 579 580 PRINT(0)("\n"); 581 } 582 598 583 PRINT(0)(" ParticleCount: %d, maximumCount: %d :: filled %d%%\n", this->count, this->maxCount, 100*this->count/this->maxCount); 599 584 if (deadList)
Note: See TracChangeset
for help on using the changeset viewer.