Changeset 7300 in orxonox.OLD for trunk/src/lib
- Timestamp:
- Apr 16, 2006, 7:30:56 PM (19 years ago)
- Location:
- trunk/src/lib
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/particles/particle_system.cc
r7221 r7300 14 14 */ 15 15 16 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_GRAPHICS16 #define DEBUG_SPECIAL_MODULE 5 //DEBUG_MODULE_GRAPHICS 17 17 18 18 #include "particle_system.h" … … 40 40 ParticleSystem::ParticleSystem (unsigned int maxCount) 41 41 { 42 this->init();43 44 this->setMaxCount(maxCount);45 }46 47 /**48 * standard deconstructor49 */50 ParticleSystem::~ParticleSystem()51 {52 // deleting all the living Particles53 while (this->particles)54 {55 Particle* tmpDelPart = this->particles;56 this->particles = this->particles->next;57 delete tmpDelPart;58 }59 60 // deleting all the dead particles61 while (this->deadList)62 {63 Particle* tmpDelPart = this->deadList;64 this->deadList = this->deadList->next;65 delete tmpDelPart;66 }67 68 while(!this->emitters.empty())69 {70 this->removeEmitter(this->emitters.front());71 }72 73 }74 75 /**76 * @brief initializes the ParticleSystem with default values77 */78 void ParticleSystem::init()79 {80 42 this->setClassID(CL_PARTICLE_SYSTEM, "ParticleSystem"); 81 43 … … 84 46 this->particles = NULL; 85 47 this->deadList = NULL; 86 this-> setConserve(1);87 this-> setLifeSpan(1);48 this->conserve = 1.0; 49 this->lifeSpan = 1.0; this->randomLifeSpan = 0.0; 88 50 89 51 this->toList(OM_ENVIRON); 52 53 this->maxCount = maxCount; 54 } 55 56 /** 57 * standard deconstructor 58 */ 59 ParticleSystem::~ParticleSystem() 60 { 61 // deleting all the living Particles 62 while (this->particles) 63 { 64 Particle* tmpDelPart = this->particles; 65 this->particles = this->particles->next; 66 delete tmpDelPart; 67 } 68 69 // deleting all the dead particles 70 while (this->deadList) 71 { 72 Particle* tmpDelPart = this->deadList; 73 this->deadList = this->deadList->next; 74 delete tmpDelPart; 75 } 76 77 while(!this->emitters.empty()) 78 { 79 this->removeEmitter(this->emitters.front()); 80 } 81 90 82 } 91 83 … … 127 119 128 120 LoadParam(root, "precache", this, ParticleSystem, precache) 129 130 121 .describe("Precaches the ParticleSystem for %1 seconds, %2 times per Second") 122 .defaultValues(1.0, 25.0); 131 123 } 132 124 … … 160 152 161 153 /** 162 * @param maxCount the maximum count of particles that can be emitted163 */ 164 void ParticleSystem::setMaxCount( int maxCount)154 * @param maxCount the maximum count of particles that can be emitted 155 */ 156 void ParticleSystem::setMaxCount(unsigned int maxCount) 165 157 { 166 158 this->maxCount = maxCount; 159 PRINTF(4)("MAXCOUNT of %s::%s is %d\n", this->getClassName(), this->getName(),maxCount); 167 160 } 168 161 169 162 // setting properties 170 163 /** 171 * Sets the lifespan of newly created particles 164 * @brief Sets the lifespan of newly created particles 165 * @param lifeSpan the LifeSpan of each particle in the System 166 * @param randomLifeSpan the Deviation from lifeSpan (random Value). 172 167 */ 173 168 void ParticleSystem::setLifeSpan(float lifeSpan, float randomLifeSpan) … … 175 170 this->lifeSpan = lifeSpan; 176 171 this->randomLifeSpan = randomLifeSpan; 177 } 178 179 /** 180 * sets the conserve Factor of newly created particles 181 */ 172 PRINTF(4)("LifeTime of %s::%s is %f\n", this->getClassName(), this->getName(), lifeSpan); 173 } 174 175 /** 176 * @brief sets the conserve Factor of newly created particles 177 * @param conserve sets the conserve factor of each particle. 178 * Conserve is the ammount of energy a particle takes from the last Frame into the next. 179 * A Value of 1 means, that all energy is conserved, a Value of 0 means infinit friction. 180 */ 182 181 void ParticleSystem::setConserve(float conserve) 183 182 { … … 188 187 else 189 188 this->conserve = conserve; 189 190 PRINTF(4)("Conserve of %s::%s is %f\n", this->getClassName(), this->getName(),conserve); 190 191 } 191 192 … … 194 195 ///////////////////////////// 195 196 /** 196 * sets a key in the radius-animation on a per-particle basis197 * @brief sets a key in the radius-animation on a per-particle basis 197 198 * @param lifeCycleTime the time (partilceLifeTime/particleAge) [0-1] 198 199 * @param radius the radius at this position … … 203 204 this->radiusAnim.changeEntry(lifeCycleTime, radius); 204 205 this->randRadiusAnim.changeEntry(lifeCycleTime, randRadius); 205 } 206 207 /** 208 * sets a key in the mass-animation on a per-particle basis 206 207 PRINTF(4)("Radius of %s::%s at timeSlice %f is %f with a Random of %f\n", 208 this->getClassName(), this->getName(),lifeCycleTime, radius, randRadius); 209 } 210 211 /** 212 * @brief sets a key in the mass-animation on a per-particle basis 209 213 * @param lifeCycleTime the time (partilceLifeTime/particleAge) [0-1] 210 214 * @param mass the mass at this position … … 218 222 219 223 /** 220 * sets a key in the color-animation on a per-particle basis224 * @brief sets a key in the color-animation on a per-particle basis 221 225 * @param lifeCycleTime: the time (partilceLifeTime/particleAge) [0-1] 222 226 * @param red: red … … 231 235 this->colorAnim[2].changeEntry(lifeCycleTime, blue); 232 236 this->colorAnim[3].changeEntry(lifeCycleTime, alpha); 237 238 PRINTF(4)("Color of %s::%s on timeslice %f is r:%f g:%f b:%f a:%f\n", 239 this->getClassName(), this->getName(), lifeCycleTime, red, green, blue, alpha); 233 240 } 234 241 … … 267 274 void ParticleSystem::precache(unsigned int seconds, unsigned int ticksPerSecond) 268 275 { 269 270 276 std::list<ParticleEmitter*>::iterator emitter; 271 277 for (emitter = this->emitters.begin(); emitter != this->emitters.end(); emitter++) … … 280 286 281 287 /** 282 * ticks the system.288 * @brief ticks the system. 283 289 * @param dt the time to tick all the Particles of the System 284 290 … … 357 363 * @param field the Field to apply. 358 364 */ 359 void ParticleSystem::applyField( Field* field)365 void ParticleSystem::applyField(const Field* field) 360 366 { 361 367 Particle* tickPart = particles; … … 376 382 } 377 383 378 379 /** 380 * draws all the Particles of this System 381 382 The Cases in this Function all do the same: 383 Drawing all the particles with the appropriate Type. 384 This is just the fastest Way to do this, but will most likely be changed in the future. 385 */ 386 // void ParticleSystem::draw() const 387 // { 388 // glPushAttrib(GL_ENABLE_BIT); 389 // 390 // Particle* drawPart = particles; 391 // 392 // switch (this->particleType) 393 // { 394 // 395 // case PARTICLE_MODEL: 396 // { 397 // } 398 // break; 399 // 400 // case PARTICLE_DOT: 401 // glDisable(GL_LIGHTING); 402 // glBegin(GL_POINTS); 403 // while (likely(drawPart != NULL)) 404 // { 405 // glColor4fv(drawPart->color); 406 // 407 // glLineWidth(drawPart->radius); 408 // 409 // glVertex3f(drawPart->position.x, drawPart->position.y, drawPart->position.z); 410 // drawPart = drawPart->next; 411 // } 412 // glEnd(); 413 // break; 414 // } 415 // glPopAttrib(); 416 // } 417 418 /** 419 * adds a new Particle to the System 384 /** 385 * @brief adds a new Particle to the System 420 386 * @param position the initial position, where the particle gets emitted. 421 387 * @param velocity the initial velocity of the particle. … … 477 443 } 478 444 else 479 PRINTF( 5)("maximum count of particles reached not adding any more\n");445 PRINTF(4)("maximum count of particles reached not adding any more\n"); 480 446 } 481 447 … … 485 451 void ParticleSystem::debug() const 486 452 { 487 PRINT(0)(" ParticleCount: %d emitters: %d, maximumCount: %d :: filled %d%%\n", this->count, this->emitters.size(), this->maxCount, ((this->maxCount!=0)?100*this->count/this->maxCount:0)); 488 if (deadList) 453 PRINT(0)(" ParticleCount: %d emitters: %d, maximumCount: %d :: filled %d%%\n", 454 this->count, 455 this->emitters.size(), 456 this->maxCount, 457 ((this->maxCount!=0)?100*this->count/this->maxCount:0)); 458 if (this->deadList) 489 459 { 490 460 PRINT(0)(" - ParticleDeadList is used: "); -
trunk/src/lib/particles/particle_system.h
r7027 r7300 60 60 virtual ~ParticleSystem(); 61 61 62 void init();63 62 virtual void loadParams(const TiXmlElement* root); 64 63 void loadEmitters(const TiXmlElement* root); … … 66 65 void setLifeSpan(float lifeSpan, float randomLifeSpan = 0.0); 67 66 void setConserve(float conserve); 68 void setMaxCount( int maxCount);67 void setMaxCount(unsigned int maxCount); 69 68 70 69 /* Per-Particle-Attributes */ … … 94 93 void removeEmitter(ParticleEmitter* emitter); 95 94 96 virtual void applyField( Field* field);95 virtual void applyField(const Field* field); 97 96 /** @brief this is an empty function, because the Physics are implemented in tick @param dt: useless here */ 98 97 virtual void tickPhys(float dt) {}; … … 114 113 float randomInitialMass; //!< The random initial Mass of the Particle 115 114 116 intmaxCount; //!< The maximum count of Particles.117 intcount; //!< The current count of Particles.115 unsigned int maxCount; //!< The maximum count of Particles. 116 unsigned int count; //!< The current count of Particles. 118 117 Particle* particles; //!< A list of particles of this System. 119 118 Particle* deadList; //!< A list of dead Particles in the System. -
trunk/src/lib/util/executor/executor.cc
r7221 r7300 53 53 54 54 this->paramCount = 0; 55 for (unsigned int i = 0; i < FUNCTOR_MAX_ARGUMENTS; i++)55 for (unsigned int i = 0; i <= FUNCTOR_MAX_ARGUMENTS; i++) 56 56 { 57 if (this->defaultValue[i] == MT_NULL )57 if (this->defaultValue[i] == MT_NULL || i == FUNCTOR_MAX_ARGUMENTS) 58 58 { 59 59 this->paramCount = i; -
trunk/src/lib/util/executor/executor.h
r7221 r7300 121 121 122 122 #define ExecutorFunctionPoiter5(t1, t2, t3, t4, t5) \ 123 void EXECUTORINCLASS(*functionPointer_5_##t1##_##t2##_##t3##_##t4##_##t5)(t1##_TYPE, t2##_TYPE, t3##_TYPE, t4##_TYPE, t5##_TYPE); \123 void EXECUTORINCLASS(*functionPointer_5_##t1##_##t2##_##t3##_##t4##_##t5)(t1##_TYPE, t2##_TYPE, t3##_TYPE, t4##_TYPE, t5##_TYPE); 124 124 125 125 … … 218 218 219 219 220 221 //////////\////////// 220 ///////////////////// 222 221 // DYNAMIC FUNCTOR // 223 /////////// \/////////222 ///////////////////// 224 223 #ifdef FUNCTOR_LIST 225 224 #undef FUNCTOR_LIST -
trunk/src/lib/util/substring.h
r7221 r7300 31 31 unsigned int split(const std::string& string, const std::string& splitters, char escapeChar ='\\', char safemode_char = '"', char comment_char = '\0'); 32 32 33 33 inline unsigned int getCount() { return this->strings.size(); }; 34 const std::string& getString(unsigned int i) { return (i < this->strings.size()) ? this->strings[i] : emptyString; }; // safety-precaution 34 35 const std::string& operator[](unsigned int i) { return this->getString(i); }; 35 36 inline unsigned int getCount() { return this->strings.size(); };37 const std::string& getString(unsigned int i) { return (i < this->strings.size()) ? this->strings[i] : emptyString; };38 36 unsigned int getOffset(unsigned int i); 39 37
Note: See TracChangeset
for help on using the changeset viewer.