Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 6941 was 6826, checked in by bensch, 19 years ago

orxonox/trunk: ok, the Cube Emitter works

File size: 3.6 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 "box_emitter.h"
26#include "spark_particles.h"
27
28
29using namespace std;
30
31CREATE_FAST_FACTORY_STATIC(Hyperblast, CL_HYPERBLAST);
32
33/**
34 *  standard constructor
35*/
36Hyperblast::Hyperblast () : Projectile()
37{
38  this->setClassID(CL_HYPERBLAST, "Hyperblast");
39
40  float modelSize = .3;
41  this->loadModel("models/projectiles/hyperblast.obj", 5);
42
43  this->setMinEnergy(1);
44  this->setHealthMax(10);
45  this->lifeSpan = 1;
46  this->size = 4.0;
47
48  this->emitter = new BoxEmitter(Vector(400, 2, 2), 100, 5, M_2_PI);
49  this->emitter->setRelCoor(200,0,0);
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  glTranslatef (this->getAbsCoor ().x,
144                this->getAbsCoor ().y,
145                this->getAbsCoor ().z);
146  Vector tmpRot = this->getAbsDir().getSpacialAxis();
147  glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
148
149//  glScalef(2.0, this->size, this->size);
150//  this->getModel()->draw();
151
152  glPopMatrix();
153}
154
Note: See TracBrowser for help on using the repository browser.