Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/world_entities/particles/spark_particles.cc @ 9869

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

orxonox/trunk: merged the new_class_id branche back to the trunk.
merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/new_class_id trunk -r9683:HEAD
no conflicts… puh..

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