Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4176 in orxonox.OLD


Ignore:
Timestamp:
May 13, 2005, 11:09:20 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the particleSystem into the Trunk

Location:
orxonox/trunk/src
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/defs/globals.h

    r4119 r4176  
    4646#define CONFIG_NAME_TEXTURE_DETAIL "Texture-Detail"
    4747#define CONFIG_NAME_MODEL_DETAIL "Model-Detail"
     48#define CONFIG_NAME_PARTICLES_ENABLED "Particles Enabled"
    4849#define CONFIG_NAME_ANTI_ALIASING "Anti-Aliasing"
    4950#define CONFIG_NAME_FILTER_METHOD "Filtering-Method"
  • orxonox/trunk/src/lib/graphics/particles/particle_emitter.cc

    r4017 r4176  
    137137            randDir = (this->getAbsDir()*Quaternion(angle + randomAngle *((float)rand()/RAND_MAX -.5), randDir)).apply(this->direction);
    138138            Vector velocityV = randDir.getNormalized()*this->velocity + inheritVelocity;
    139            
    140             system->addParticle(this->getAbsCoor(), velocityV);
     139
     140            // this should spread the Particles evenly. if the Emitter is moved around quickly
     141            Vector equalSpread = this->getVelocity() * random()/RAND_MAX * dt;
     142
     143            system->addParticle(this->getAbsCoor() - equalSpread, velocityV);
    141144          }
    142145      }
  • orxonox/trunk/src/lib/graphics/particles/particle_emitter.h

    r3966 r4176  
    2222
    2323 public:
    24   ParticleEmitter(const Vector& direction, float angle = .5, float emissionRate = 1.0,
    25                   float velocity = 1.0);
     24  ParticleEmitter(const Vector& direction, float angle = .5,
     25                  float emissionRate = 1.0, float velocity = 1.0);
    2626  virtual ~ParticleEmitter(void);
    2727
  • orxonox/trunk/src/lib/graphics/particles/particle_engine.cc

    r3966 r4176  
    228228void ParticleEngine::tick(float dt)
    229229{
    230   // add new Particles to each System connected to an Emitter.
    231   tIterator<ParticleConnection>* tmpConIt = connectionList->getIterator();
    232   ParticleConnection* tmpConnection = tmpConIt->nextElement();
    233   while(tmpConnection)
    234     {
    235       tmpConnection->emitter->tick(dt, tmpConnection->system);
    236       tmpConnection = tmpConIt->nextElement();
    237     }
    238   delete tmpConIt;
    239  
    240 
    241230  // ticks all the ParticleSystems
    242231  tIterator<ParticleSystem>* tmpIt = systemList->getIterator();
     
    248237    }
    249238  delete tmpIt;
     239
     240  // add new Particles to each System connected to an Emitter.
     241  tIterator<ParticleConnection>* tmpConIt = connectionList->getIterator();
     242  ParticleConnection* tmpConnection = tmpConIt->nextElement();
     243  while(tmpConnection)
     244    {
     245      tmpConnection->emitter->tick(dt, tmpConnection->system);
     246      tmpConnection = tmpConIt->nextElement();
     247    }
     248  delete tmpConIt;
    250249}
    251250
    252251/**
    253252   \brief draws all the systems and their Particles.
    254 */
    255 void ParticleEngine::draw(void)
     253   \param dt the time passed in seconds (since the last Frame)
     254*/
     255void ParticleEngine::draw(float dt)
    256256{
    257257  tIterator<ParticleSystem>* tmpIt = systemList->getIterator();
     
    259259  while(tmpSys)
    260260    {
    261       tmpSys->draw();
     261      tmpSys->draw(dt);
    262262      tmpSys = tmpIt->nextElement();
    263263    }
  • orxonox/trunk/src/lib/graphics/particles/particle_engine.h

    r3966 r4176  
    88
    99#include "base_object.h"
     10#include "particle_system.h"
     11#include "particle_emitter.h"
    1012
    1113// FORWARD DEFINITION
     
    2830
    2931  void tick(float dt);
    30   void draw(void);
     32  void draw(float dt);
    3133
    3234  void addSystem(ParticleSystem* system);
  • orxonox/trunk/src/lib/graphics/particles/particle_system.cc

    r4123 r4176  
    3535{
    3636   this->setClassName ("ParticleSystem");
     37   this->material = NULL;
    3738   this->name = NULL;
    3839   this->maxCount = maxCount;
    3940   this->count = 0;
    40    this->particleType = type;
    4141   this->particles = NULL;
    4242   this->deadList = NULL;
    43    this->setConserve(.8);
    44    this->setLifeSpan(.1);
     43   this->setConserve(1);
     44   this->setLifeSpan(1);
    4545   this->setInheritSpeed(0);
    4646   this->glID = NULL;
    4747   this->setRadius(1.0, 1.0, 0.0);
    48    this->setType(PARTICLE_SPRITE, 1);
     48   this->setType(type, 1);
    4949   ParticleEngine::getInstance()->addSystem(this);
    5050}
     
    5454   \brief standard deconstructor
    5555*/
    56 ParticleSystem::~ParticleSystem() 
     56ParticleSystem::~ParticleSystem()
    5757{
    5858  // delete what has to be deleted here
     
    7474       delete tmpDelPart;
    7575     }
     76
     77   if (this->material)
     78     delete this->material;
    7679}
    7780
     
    240243/**
    241244   \brief draws all the Particles of this System
    242 */
    243 void ParticleSystem::draw(void)
    244 {
     245   \param the time passed in seconds (since the last draw)
     246*/
     247void ParticleSystem::draw(float dt)
     248{
     249  glPushAttrib(GL_ENABLE_BIT);
    245250  //  material->select();
    246 
    247 
    248   glMatrixMode(GL_MODELVIEW);
    249   //  glDisable(GL_LIGHTING);
    250   material->select();
    251   glDisable(GL_DEPTH_TEST);
    252  Particle* drawPart = particles;
    253   if (likely(drawPart != NULL))
     251  Particle* drawPart = particles;
     252
     253  switch (this->particleType)
    254254    {
    255       //draw in DOT mode
    256       //      glBegin(GL_POINTS);
     255    case PARTICLE_SPRITE:
     256      glMatrixMode(GL_MODELVIEW);
     257      //  glDisable(GL_LIGHTING);
     258      material->select();
     259      glDisable(GL_DEPTH_TEST);
    257260      while (likely(drawPart != NULL))
    258261        {
     
    267270        }
    268271      //      glEnd();
     272     
     273      //  glEnable(GL_LIGHTING);
     274     
     275      glEnable(GL_DEPTH_TEST);
     276      break;
     277    default:
     278
     279    case PARTICLE_SPARK:
     280      glEnable(GL_LINE_SMOOTH);
     281      glBegin(GL_LINES);
     282      while (likely(drawPart != NULL))
     283        {
     284          glVertex3f(drawPart->position.x, drawPart->position.y, drawPart->position.z);
     285          glVertex3f(drawPart->position.x - drawPart->velocity.x,
     286                     drawPart->position.y - drawPart->velocity.y,
     287                     drawPart->position.z - drawPart->velocity.z);
     288          drawPart = drawPart->next;
     289        }
     290      glEnd();
     291      break;
     292     
     293    case PARTICLE_DOT:
     294      glBegin(GL_POINTS);
     295      while (likely(drawPart != NULL))
     296        {
     297          glLineWidth(drawPart->radius);
     298
     299          glVertex3f(drawPart->position.x, drawPart->position.y, drawPart->position.z);
     300          drawPart = drawPart->next;
     301        }
     302      glEnd();
     303      break;
    269304    }
    270   //  glEnable(GL_LIGHTING);
    271   glEnable(GL_DEPTH_TEST);
     305  glPopAttrib();
    272306}
    273307
     
    291325            }
    292326          else
    293             this->particles = new Particle;
     327            {
     328              PRINTF(5)("Generating new Particle\n");
     329              this->particles = new Particle;
     330            }
    294331          this->particles->next = NULL;
    295332        }
     
    304341            }
    305342          else
    306             tmpPart = new Particle;
     343            {
     344              PRINTF(5)("Generating new Particle\n");
     345              tmpPart = new Particle;
     346            }
    307347          tmpPart->next = this->particles;
    308348          this->particles = tmpPart;
  • orxonox/trunk/src/lib/graphics/particles/particle_system.h

    r4123 r4176  
    5454
    5555 public:
    56   ParticleSystem(unsigned int maxCount = PARTICLE_DEFAULT_MAX_COUNT, PARTICLE_TYPE type = PARTICLE_DEFAULT_TYPE);
     56  ParticleSystem(unsigned int maxCount = PARTICLE_DEFAULT_MAX_COUNT,
     57                 PARTICLE_TYPE type = PARTICLE_DEFAULT_TYPE);
    5758  virtual ~ParticleSystem();
    5859  void setName(const char* name);
     
    6364  void setInheritSpeed(float value);
    6465  void setLifeSpan(float lifeSpan, float randomLifeSpan = 0.0);
    65   void setRadius(float startRadius, float endRadius, float randomStartRadius = 0.0, float randomEndRadius = 0.0);
     66  void setRadius(float startRadius, float endRadius,
     67                 float randomStartRadius = 0.0, float randomEndRadius = 0.0);
    6668  void setConserve(float conserve);
    6769  void setMass(float mass, float randomMass);
    6870
    6971  void tick(float dt);
    70   void draw(void);
     72  void draw(float dt);
    7173
    7274  void debug(void);
  • orxonox/trunk/src/lib/gui/gui/gui_video.cc

    r4132 r4176  
    107107      Label* modelDetailLabel;  //!< Label for model-detail.
    108108      Menu* modelDetail;        //!< model-detail.
     109      CheckButton* particles;   //!< If the Particles should be enabled
    109110      Label* antiAliasingLabel; //!< Label for the anti-aliasing mode.
    110111      Menu* antiAliasing;       //!< Menu for the Antialiasing-mode.
     
    142143      advancedBox->fill(modelDetail);
    143144     
     145      particles = new CheckButton(CONFIG_NAME_PARTICLES_ENABLED);
     146      particles->saveability();
     147      particles->setDefaultValue(1);
     148      advancedBox->fill(particles);
     149
    144150      antiAliasingLabel = new Label("Anti-Aliasing-depth:");
    145151      advancedBox->fill(antiAliasingLabel);
     
    155161      filterMethod->saveability();
    156162      advancedBox->fill(filterMethod);
     163
     164
    157165 
    158166      closeButton = new Button("close");
  • orxonox/trunk/src/story_entities/world.cc

    r4145 r4176  
    4040#include "garbage_collector.h"
    4141#include "animation_player.h"
     42#include "particle_engine.h"
    4243
    4344#include "command_node.h"
     
    203204  delete this->lightMan;
    204205  delete this->trackManager;
     206  delete this->particleEngine;
    205207  TextEngine::getInstance()->flush();
    206208
     
    246248  this->garbageCollector = GarbageCollector::getInstance();
    247249
     250  this->particleEngine = ParticleEngine::getInstance();
    248251  this->trackManager = TrackManager::getInstance();
    249252  this->lightMan = LightManager::getInstance();
     
    484487  this->spawn(terrain);
    485488
     489
     490  ParticleSystem* system = new ParticleSystem(1000, PARTICLE_SPRITE);
     491  system->setLifeSpan(.5);
     492  system->setConserve(.99);
     493  system->setRadius(2, 0, 2, 0);
     494
     495  ParticleEmitter* emitter = new ParticleEmitter(Vector(-1, 0, 0), M_PI_4, 100, .05);
     496  emitter->setParent(this->localPlayer);
     497 
     498  particleEngine->addConnection(emitter, system);
    486499}
    487500
     
    945958
    946959  TextEngine::getInstance()->draw();
     960  particleEngine->draw(this->dtS); //!< \todo should be dts like in the Trunk;
     961
    947962  lightMan->draw(); // must be at the end of the drawing procedure, otherwise Light cannot be handled as PNodes //
    948963}
     
    11301145
    11311146      AnimationPlayer::getInstance()->tick(this->dtS);
     1147      particleEngine->tick(this->dtS);
    11321148    }
    11331149  this->lastFrame = currentFrame;
  • orxonox/trunk/src/story_entities/world.h

    r4145 r4176  
    2020class GLMenuImageScreen;
    2121class LightManager;
     22class ParticleEngine;
    2223class Terrain;
    2324class GarbageCollector;
     
    108109  PNode* nullParent;                  //!< The zero-point, that everything has as its parent.
    109110  TrackManager* trackManager;         //!< The reference of the TrackManager that handles the course through the Level.
     111  ParticleEngine* particleEngine;     //!< The ParticleEngine of the World.
    110112  Camera* localCamera;                //!< The current Camera
    111113  WorldEntity* sky;                   //!< The Environmental Heaven of orxonox \todo insert this to environment insted
Note: See TracChangeset for help on using the changeset viewer.