Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/world_entities/projectiles/hyperblast.cc @ 6822

Last change on this file since 6822 was 6822, checked in by bensch, 18 years ago

trunk: ParticleEmitters now splitted into SubClasses.
Also fixed a little Boeg in the ClassID

File size: 3.5 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: ...
14
15*/
16#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WEAPON
17
18#include "hyperblast.h"
19
20#include "fast_factory.h"
21
22#include "state.h"
23#include "class_list.h"
24
25#include "dot_emitter.h"
26#include "sprite_particles.h"
27#include "spark_particles.h"
28
29
30using namespace std;
31
32CREATE_FAST_FACTORY_STATIC(Hyperblast, CL_HYPERBLAST);
33
34/**
35 *  standard constructor
36*/
37Hyperblast::Hyperblast () : Projectile()
38{
39  this->setClassID(CL_HYPERBLAST, "Hyperblast");
40
41  float modelSize = .3;
42  this->loadModel("models/projectiles/hyperblast.obj", 5);
43
44  this->setMinEnergy(1);
45  this->setHealthMax(10);
46  this->lifeSpan = 1;
47  this->size = 4.0;
48
49  this->emitter = new DotEmitter(Vector(0,1,0), M_2_PI, 100, 5);
50  this->emitter->setParent(this);
51  this->emitter->setSpread(M_PI, M_PI);
52}
53
54
55/**
56 *  standard deconstructor
57*/
58Hyperblast::~Hyperblast ()
59{
60  /* this is normaly done by World.cc by deleting the ParticleEngine */
61  if (Hyperblast::explosionParticles != NULL && ClassList::getList(CL_HYPERBLAST)->size() <= 1)
62  {
63    Hyperblast::explosionParticles = NULL;
64  }
65
66}
67
68SparkParticles* Hyperblast::explosionParticles = NULL;
69
70void Hyperblast::activate()
71{
72  if (unlikely(Hyperblast::explosionParticles == NULL))
73  {
74    Hyperblast::explosionParticles = new SparkParticles(2000);
75    Hyperblast::explosionParticles->setName("HyperblastExplosionParticles");
76    Hyperblast::explosionParticles->setLifeSpan(2, .3);
77    Hyperblast::explosionParticles->setRadius(0.1, .1);
78    Hyperblast::explosionParticles->setRadius(0.2, .2);
79    Hyperblast::explosionParticles->setRadius(1.0, .1);
80    Hyperblast::explosionParticles->setColor(0.0, 1.0, .6, 0 ,1);
81    Hyperblast::explosionParticles->setColor(0.5, .8,.1,0,.6);
82    Hyperblast::explosionParticles->setColor(0.8, .8,.2,.3,.3);
83    Hyperblast::explosionParticles->setColor(1.0, 1,1,1,.0);
84  }
85
86  this->emitter->setSystem(Hyperblast::explosionParticles);
87  this->size = 4.0;
88
89  Hyperblast::explosionParticles->debug();
90  this->updateNode(0);
91  this->emitter->setEmissionRate(5000.0);
92  this->emitter->setEmissionVelocity(50.0);
93}
94
95
96void Hyperblast::deactivate()
97{
98  this->emitter->setSystem(NULL);
99  this->lifeCycle = 0.0;
100  this->toList(OM_NULL);
101
102//  GarbageCollector::getInstance()->collect(this);
103  this->toList(OM_DEAD);
104  Hyperblast::fastFactory->kill(this);
105}
106
107
108void Hyperblast::collidesWith(WorldEntity* entity, const Vector& location)
109{
110}
111
112/**
113 *  signal tick, time dependent things will be handled here
114 * @param time since last tick
115*/
116void Hyperblast::tick (float dt)
117{
118  if(this->tickLifeCycle(dt))
119    this->deactivate();
120
121  this->size *=(1 - (5.0*dt));
122
123  if (this->lifeCycle > .1 && this->emitter->getEmissionRate() > 10.0)
124    this->emitter->setEmissionRate(0.0);
125}
126
127/**
128 *  the function gets called, when the projectile is destroyed
129*/
130void Hyperblast::destroy ()
131{
132  PRINTF(5)("DESTROY Hyperblast\n");
133
134
135}
136
137
138void Hyperblast::draw () const
139{
140  glMatrixMode(GL_MODELVIEW);
141  glPushMatrix();
142
143  float matrix[4][4];
144  glTranslatef (this->getAbsCoor ().x, this->getAbsCoor ().y, this->getAbsCoor ().z);
145  this->getAbsDir().matrix (matrix);
146  glMultMatrixf((float*)matrix);
147  glScalef(2.0, this->size, this->size);
148  this->getModel()->draw();
149
150  glPopMatrix();
151}
152
Note: See TracBrowser for help on using the repository browser.