Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 8854 was 7221, checked in by bensch, 19 years ago

orxonox/trunk: merged the std-branche back, it runs on windows and Linux

svn merge https://svn.orxonox.net/orxonox/branches/std . -r7202:HEAD

File size: 2.8 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
[7193]20#include "util/loading/load_param.h"
21#include "util/loading/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()
[6653]62{ }
[4123]63
[3945]64/**
[6623]65 * @brief initializes the SparkParticles with default values
[4602]66*/
[6623]67void SparkParticles::init()
[4602]68{
[6623]69  this->setClassID(CL_SPARK_PARTICLES, "SparkParticles");
[4602]70}
71
72
73/**
74 * loads Parameters from a TiXmlElement
75 * @param root the XML-element to load from.
76 */
[6623]77void SparkParticles::loadParams(const TiXmlElement* root)
[4602]78{
[6623]79  ParticleSystem::loadParams(root);
[4602]80}
[4727]81
[4478]82/**
[6621]83 * @brief draws all the Particles of this System
84 *
85 * The Cases in this Function all do the same:
86 * Drawing all the particles with the appropriate Type.
87 * This is just the fastest Way to do this, but will most likely be changed in the future.
[4338]88 */
[6623]89void SparkParticles::draw() const
[4338]90{
91
[4176]92  Particle* drawPart = particles;
[4597]93
[6621]94  glDepthMask(GL_FALSE);
[6821]95  glPushAttrib(GL_ENABLE_BIT);
[4338]96
[6623]97  glDisable(GL_LIGHTING);
[6821]98  glDisable(GL_TEXTURE_2D);
99
[6623]100  glEnable(GL_LINE_SMOOTH);
101  glEnable(GL_BLEND);
[6626]102  glBlendFunc(GL_SRC_ALPHA, GL_DST_ALPHA);
[4863]103
[6821]104  glLineWidth(2.0);
[6623]105  glBegin(GL_LINES);
[6621]106  while (likely(drawPart != NULL))
107  {
[6821]108  //    printf("%f %f %f %f\n", drawPart->color[0], drawPart->color[1], drawPart->color[2], drawPart->color[3]);
[6621]109    glColor4fv(drawPart->color);
[6623]110    glVertex3f(drawPart->position.x, drawPart->position.y, drawPart->position.z);
111    glVertex3f(drawPart->position.x - drawPart->velocity.x * drawPart->radius,
112               drawPart->position.y - drawPart->velocity.y * drawPart->radius,
113               drawPart->position.z - drawPart->velocity.z * drawPart->radius);
[6621]114    drawPart = drawPart->next;
[4663]115  }
[6623]116  glEnd();
117
[6621]118  glDepthMask(GL_TRUE);
[4176]119  glPopAttrib();
[3932]120}
Note: See TracBrowser for help on using the repository browser.