Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

merged the presentation back

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