Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/new_class_id/src/lib/particles/spark_particles.cc @ 9686

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

new_class_id: many more classes done

File size: 2.8 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_GRAPHICS
17
18#include "spark_particles.h"
19
20#include "util/loading/load_param.h"
21#include "util/loading/factory.h"
22#include "material.h"
23#include "state.h"
24#include "shell_command.h"
25
26#include "parser/tinyxml/tinyxml.h"
27#include <algorithm>
28
29
30
31
32
33CREATE_FACTORY(SparkParticles, CL_SPARK_PARTICLES);
34NewObjectListDefinitionID(SparkParticles, CL_SPARK_PARTICLES);
35
36/**
37 *  standard constructor
38 * @param maxCount the Count of particles in the System
39 * @param type The Type of the SparkParticles
40*/
41SparkParticles::SparkParticles (unsigned int maxCount)
42    : ParticleSystem(maxCount)
43{
44  this->init();
45}
46
47/**
48 * @brief creates a Particle System out of a XML-element
49 * @param root: the XML-element to load from
50 */
51SparkParticles::SparkParticles(const TiXmlElement* root)
52{
53  this->init();
54
55  if (root != NULL)
56    this->loadParams(root);
57}
58
59/**
60 *  standard deconstructor
61*/
62SparkParticles::~SparkParticles()
63{ }
64
65/**
66 * @brief initializes the SparkParticles with default values
67*/
68void SparkParticles::init()
69{
70  this->registerObject(this, SparkParticles::_objectList);
71}
72
73
74/**
75 * loads Parameters from a TiXmlElement
76 * @param root the XML-element to load from.
77 */
78void SparkParticles::loadParams(const TiXmlElement* root)
79{
80  ParticleSystem::loadParams(root);
81}
82
83/**
84 * @brief draws all the Particles of this System
85 *
86 * The Cases in this Function all do the same:
87 * Drawing all the particles with the appropriate Type.
88 * This is just the fastest Way to do this, but will most likely be changed in the future.
89 */
90void SparkParticles::draw() const
91{
92
93  Particle* drawPart = particles;
94
95  glDepthMask(GL_FALSE);
96  glPushAttrib(GL_ENABLE_BIT);
97
98  glDisable(GL_LIGHTING);
99  glDisable(GL_TEXTURE_2D);
100
101  glEnable(GL_LINE_SMOOTH);
102  glEnable(GL_BLEND);
103  glBlendFunc(GL_SRC_ALPHA, GL_DST_ALPHA);
104
105  glLineWidth(2.0);
106  glBegin(GL_LINES);
107  while (likely(drawPart != NULL))
108  {
109  //    printf("%f %f %f %f\n", drawPart->color[0], drawPart->color[1], drawPart->color[2], drawPart->color[3]);
110    glColor4fv(drawPart->color);
111    glVertex3f(drawPart->position.x, drawPart->position.y, drawPart->position.z);
112    glVertex3f(drawPart->position.x - drawPart->velocity.x * drawPart->radius,
113               drawPart->position.y - drawPart->velocity.y * drawPart->radius,
114               drawPart->position.z - drawPart->velocity.z * drawPart->radius);
115    drawPart = drawPart->next;
116  }
117  glEnd();
118
119  glDepthMask(GL_TRUE);
120  glPopAttrib();
121}
Note: See TracBrowser for help on using the repository browser.