Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/cleanup/src/world_entities/particles/emitter_node.cc @ 10642

Last change on this file since 10642 was 10368, checked in by patrick, 18 years ago

merged the branche playability into the trunk

File size: 2.0 KB
Line 
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"
23#include "util/loading/factory.h"
24#include "debug.h"
25
26ObjectListDefinition(EmitterNode);
27//CREATE_FAST_FACTORY(EmitterNode);
28
29/**
30 *  standard constructor
31*/
32EmitterNode::EmitterNode( float lifetime)
33{
34  this->registerObject(this, EmitterNode::_objectList);
35
36  this->toList(OM_ENVIRON);
37
38  this->system = NULL;
39  this->emitter = NULL;
40  this->lifeCycle = 0.0;
41  this->lifeSpan = lifetime;
42
43  this->setParent( PNode::getNullParent());
44}
45
46/**
47 *  standard destructor
48
49   removes the EmitterSystem from the ParticleEngine
50*/
51EmitterNode::~EmitterNode ()
52{
53  this->emitter->setSystem(NULL);
54  this->removeNode();
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
69bool EmitterNode::start()
70{
71  this->started  = true;
72
73  this->emitter->start();
74  this->emitter->setSystem( this->system);
75
76  return this->started;
77}
78
79void EmitterNode::tick(float dt)
80{
81
82  if( !this->started)
83    return;
84
85  this->lifeCycle += dt/this->lifeSpan;
86
87  if( this->lifeCycle >= 1.0f)
88  {
89//   this->removeNode();
90 //   this->emitter->stop();
91    this->emitter->setSystem(NULL);
92    this->started = false;
93    this->toList(OM_NULL);
94
95//    this->destroy( NULL );
96  }
97  this->shiftCoor(this->velocity * dt);
98}
Note: See TracBrowser for help on using the repository browser.