/* orxonox - the future of 3D-vertical-scrollers Copyright (C) 2004 orx This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. ### File Specific: main-programmer: Benjamin Grauer co-programmer: Patrick Boenzli */ #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_GRAPHICS #include "emitter_node.h" #include "particle_system.h" #include "util/loading/load_param.h" #include "debug.h" ObjectListDefinition(EmitterNode); /** * standard constructor */ EmitterNode::EmitterNode( float lifetime) { this->registerObject(this, EmitterNode::_objectList); this->system = NULL; this->emitter = NULL; this->lifeCycle = 0.0; this->lifeSpan = lifetime; } /** * standard destructor removes the EmitterSystem from the ParticleEngine */ EmitterNode::~EmitterNode () { this->emitter->setSystem(NULL); delete this->emitter; } /** * loads a EmitterNode from a XML-element * @param root the XML-element to load from */ void EmitterNode::loadParams(const TiXmlElement* root) { PNode::loadParams(root); LoadParam(root, "life-time", this, EmitterNode, setLifetime) .describe("Amount of time this emitter node shall remain"); } void EmitterNode::start() { this->started = true; } void EmitterNode::tick(float dt) { if( !this->started) return; this->lifeCycle += dt/this->lifeSpan; if (unlikely(this->lifeCycle >= 1)) { this->removeNode(); } this->setAbsCoor(this->getAbsCoor() + (this->velocity * dt)); }