Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/particles/spark_particles.cc @ 6631

Last change on this file since 6631 was 6629, checked in by bensch, 19 years ago

trunk: particles: precache and ModelParticles

File size: 3.0 KB
RevLine 
[4597]1/*
[1853]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.
[1855]10
11   ### File Specific:
[3925]12   main-programmer: Benjamin Grauer
[1855]13   co-programmer: ...
[1853]14*/
15
[5357]16#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_GRAPHICS
[1853]17
[6623]18#include "spark_particles.h"
[1853]19
[5155]20#include "load_param.h"
[5652]21#include "factory.h"
[3942]22#include "material.h"
[4338]23#include "state.h"
[5446]24#include "shell_command.h"
[3930]25
[5944]26#include "parser/tinyxml/tinyxml.h"
[6612]27#include <algorithm>
[4338]28
[6612]29
[6621]30
[1856]31using namespace std;
[1853]32
[6626]33CREATE_FACTORY(SparkParticles, CL_SPARK_PARTICLES);
34
[3245]35/**
[4836]36 *  standard constructor
37 * @param maxCount the Count of particles in the System
[6623]38 * @param type The Type of the SparkParticles
[3245]39*/
[6623]40SparkParticles::SparkParticles (unsigned int maxCount)
41    : ParticleSystem(maxCount)
[3365]42{
[4602]43  this->init();
[3365]44}
[1853]45
[4677]46/**
[5445]47 * @brief creates a Particle System out of a XML-element
48 * @param root: the XML-element to load from
[4677]49 */
[6623]50SparkParticles::SparkParticles(const TiXmlElement* root)
[4602]51{
52  this->init();
[4725]53
[6623]54  if (root != NULL)
55    this->loadParams(root);
[4602]56}
[1853]57
[3245]58/**
[4836]59 *  standard deconstructor
[3245]60*/
[6623]61SparkParticles::~SparkParticles()
[3543]62{
[6621]63  // deleting all the living Particles
64  while (this->particles)
65  {
66    Particle* tmpDelPart = this->particles;
67    this->particles = this->particles->next;
68    delete tmpDelPart;
69  }
[4123]70
[6621]71  // deleting all the dead particles
72  while (this->deadList)
73  {
74    Particle* tmpDelPart = this->deadList;
75    this->deadList = this->deadList->next;
76    delete tmpDelPart;
77  }
[3543]78}
[1853]79
[3945]80/**
[6623]81 * @brief initializes the SparkParticles with default values
[4602]82*/
[6623]83void SparkParticles::init()
[4602]84{
[6623]85  this->setClassID(CL_SPARK_PARTICLES, "SparkParticles");
[4602]86
87  this->material = NULL;
88}
89
90
91/**
92 * loads Parameters from a TiXmlElement
93 * @param root the XML-element to load from.
94 */
[6623]95void SparkParticles::loadParams(const TiXmlElement* root)
[4602]96{
[6623]97  ParticleSystem::loadParams(root);
[4602]98}
[4727]99
[4478]100/**
[6621]101 * @brief draws all the Particles of this System
102 *
103 * The Cases in this Function all do the same:
104 * Drawing all the particles with the appropriate Type.
105 * This is just the fastest Way to do this, but will most likely be changed in the future.
[4338]106 */
[6623]107void SparkParticles::draw() const
[4338]108{
[4176]109  glPushAttrib(GL_ENABLE_BIT);
[4338]110
[4176]111  Particle* drawPart = particles;
[4597]112
[6621]113  glDepthMask(GL_FALSE);
[4338]114
[6623]115  glDisable(GL_LIGHTING);
116  glEnable(GL_LINE_SMOOTH);
117  glEnable(GL_BLEND);
[6626]118  glBlendFunc(GL_SRC_ALPHA, GL_DST_ALPHA);
[4863]119
[6623]120  glBegin(GL_LINES);
[6621]121  while (likely(drawPart != NULL))
122  {
123    glColor4fv(drawPart->color);
[6623]124    glVertex3f(drawPart->position.x, drawPart->position.y, drawPart->position.z);
125    glVertex3f(drawPart->position.x - drawPart->velocity.x * drawPart->radius,
126               drawPart->position.y - drawPart->velocity.y * drawPart->radius,
127               drawPart->position.z - drawPart->velocity.z * drawPart->radius);
[6621]128    drawPart = drawPart->next;
[4663]129  }
[6623]130  glEnd();
131
[6621]132  glDepthMask(GL_TRUE);
[4176]133  glPopAttrib();
[3932]134}
Note: See TracBrowser for help on using the repository browser.