Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/new_class_id/src/lib/particles/dot_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.7 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 "dot_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
30CREATE_FACTORY(DotParticles, CL_DOT_PARTICLES);
31NewObjectListDefinitionID(DotParticles, CL_DOT_PARTICLES);
32
33SHELL_COMMAND(texture, DotParticles, setMaterialTexture)
34    ->defaultValues("maps/evil-flower.png");
35
36
37
38/**
39 *  standard constructor
40 * @param maxCount the Count of particles in the System
41 * @param type The Type of the DotParticles
42*/
43DotParticles::DotParticles (unsigned int maxCount)
44  : ParticleSystem(maxCount)
45{
46  this->init();
47}
48
49/**
50 * @brief creates a Particle System out of a XML-element
51 * @param root: the XML-element to load from
52 */
53DotParticles::DotParticles(const TiXmlElement* root)
54{
55  this->init();
56  if (root != NULL)
57    this->loadParams(root);
58}
59
60/**
61 *  standard deconstructor
62*/
63DotParticles::~DotParticles()
64{ }
65
66/**
67 * @brief initializes the DotParticles with default values
68*/
69void DotParticles::init()
70{
71  this->registerObject(this, DotParticles::_objectList);
72
73  this->material.setDiffuseMap("maps/radial-trans-noise.png");
74}
75
76
77/**
78 * loads Parameters from a TiXmlElement
79 * @param root the XML-element to load from.
80 */
81void DotParticles::loadParams(const TiXmlElement* root)
82{
83  ParticleSystem::loadParams(root);
84
85  LoadParam(root, "texture", this, DotParticles, setMaterialTexture);
86}
87
88/**
89 * @brief draws all the Particles of this System
90 *
91 * The Cases in this Function all do the same:
92 * Drawing all the particles with the appropriate Type.
93 * This is just the fastest Way to do this, but will most likely be changed in the future.
94 */
95void DotParticles::draw() const
96{
97  glPushAttrib(GL_ENABLE_BIT);
98
99  GLboolean checkLight = false;
100  glGetBooleanv(GL_LIGHTING, &checkLight);
101  if (checkLight == GL_TRUE)
102    glDisable(GL_LIGHTING);
103
104  glMatrixMode(GL_MODELVIEW);
105  glBlendFunc(GL_SRC_ALPHA, GL_DST_ALPHA);
106
107  Particle* drawPart = particles;
108  //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_ENV_MODE, GL_MODULATE);
109
110  glBegin(GL_POINTS);
111  while (likely(drawPart != NULL))
112  {
113    glColor4fv(drawPart->color);
114    glVertex3f(drawPart->position.x, drawPart->position.y, drawPart->position.z);
115
116    drawPart = drawPart->next;
117  }
118  glEnd();
119  glPopAttrib();
120}
Note: See TracBrowser for help on using the repository browser.