Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/playability/src/world_entities/particles/emitter_node.cc @ 10107

Last change on this file since 10107 was 10107, checked in by marcscha, 17 years ago

many additions, several fixes

File size: 1.9 KB
RevLine 
[10077]1/*
2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2004 orx
5
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
10
11   ### File Specific:
12   main-programmer: Benjamin Grauer
13   co-programmer: Patrick Boenzli
14*/
15
16#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_GRAPHICS
17
18#include "emitter_node.h"
19
20#include "particle_system.h"
21
22#include "util/loading/load_param.h"
[10107]23#include "util/loading/factory.h"
[10077]24#include "debug.h"
25
26ObjectListDefinition(EmitterNode);
[10107]27//CREATE_FAST_FACTORY(EmitterNode);
[10077]28
29/**
30 *  standard constructor
31*/
32EmitterNode::EmitterNode( float lifetime)
33{
34  this->registerObject(this, EmitterNode::_objectList);
35
[10107]36  this->toList(OM_DEAD_TICK);
37
[10077]38  this->system = NULL;
39  this->emitter = NULL;
40  this->lifeCycle = 0.0;
41  this->lifeSpan = lifetime;
[10107]42
43  this->setParent( PNode::getNullParent());
[10077]44}
45
46/**
47 *  standard destructor
48
49   removes the EmitterSystem from the ParticleEngine
50*/
51EmitterNode::~EmitterNode ()
52{
53  this->emitter->setSystem(NULL);
[10078]54  this->removeNode();
[10077]55}
56
57/**
58 *  loads a EmitterNode from a XML-element
59 * @param root the XML-element to load from
60*/
61void EmitterNode::loadParams(const TiXmlElement* root)
62{
63  PNode::loadParams(root);
64
65  LoadParam(root, "life-time", this, EmitterNode, setLifetime)
66    .describe("Amount of time this emitter node shall remain");
67}
68
[10078]69bool EmitterNode::start()
[10077]70{
[10078]71  this->started  = true;
[10107]72
73  this->emitter->start();
74  this->emitter->setSystem( this->system);
75
[10078]76  return this->started;
[10077]77}
78
79void EmitterNode::tick(float dt)
80{
[10107]81
[10077]82  if( !this->started)
83    return;
84
85  this->lifeCycle += dt/this->lifeSpan;
[10107]86
87  if( this->lifeCycle >= 1.0f)
[10077]88  {
89    this->removeNode();
[10098]90    this->emitter->stop();
91    this->emitter->setSystem(NULL);
92    this->started = false;
[10107]93
94    this->destroy( NULL );
[10077]95  }
[10107]96  this->shiftCoor(this->velocity * dt);
[10078]97}
Note: See TracBrowser for help on using the repository browser.