Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 10086 was 10078, checked in by marcscha, 18 years ago

Update in swarm launcher, swarm missile, mbolt

File size: 1.8 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 "debug.h"
24
25ObjectListDefinition(EmitterNode);
26
27/**
28 *  standard constructor
29*/
30EmitterNode::EmitterNode( float lifetime)
31{
32  this->registerObject(this, EmitterNode::_objectList);
33
34  this->system = NULL;
35  this->emitter = NULL;
36  this->lifeCycle = 0.0;
37  this->lifeSpan = lifetime;
38}
39
40/**
41 *  standard destructor
42
43   removes the EmitterSystem from the ParticleEngine
44*/
45EmitterNode::~EmitterNode ()
46{
47  this->emitter->setSystem(NULL);
48  this->removeNode();
49}
50
51/**
52 *  loads a EmitterNode from a XML-element
53 * @param root the XML-element to load from
54*/
55void EmitterNode::loadParams(const TiXmlElement* root)
56{
57  PNode::loadParams(root);
58
59  LoadParam(root, "life-time", this, EmitterNode, setLifetime)
60    .describe("Amount of time this emitter node shall remain");
61}
62
63bool EmitterNode::start()
64{
65  this->started  = true;
66  return this->started;
67}
68
69void EmitterNode::tick(float dt)
70{
71  if( !this->started)
72    return;
73
74  this->lifeCycle += dt/this->lifeSpan;
75  if  (unlikely(this->lifeCycle >= 1))
76  {
77    this->removeNode();
78  }
79  PRINTF(0)("Coordinate Update EmitterNode: (%f,%f,%f) -> (%f,%f,%f)\n",this->getAbsCoor().x,this->getAbsCoor().y,this->getAbsCoor().z,this->velocity.x,this->velocity.y,this->velocity.z);
80  this->setAbsCoor(this->getAbsCoor() + (this->velocity * dt));
81}
Note: See TracBrowser for help on using the repository browser.