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 | |
---|
25 | #include "class_id_DEPRECATED.h" |
---|
26 | |
---|
27 | ObjectListDefinitionID(DotParticles, CL_DOT_PARTICLES); |
---|
28 | CREATE_FACTORY(DotParticles); |
---|
29 | |
---|
30 | |
---|
31 | /** |
---|
32 | * standard constructor |
---|
33 | * @param maxCount the Count of particles in the System |
---|
34 | * @param type The Type of the DotParticles |
---|
35 | */ |
---|
36 | DotParticles::DotParticles (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 | */ |
---|
46 | DotParticles::DotParticles(const TiXmlElement* root) |
---|
47 | { |
---|
48 | this->init(); |
---|
49 | if (root != NULL) |
---|
50 | this->loadParams(root); |
---|
51 | } |
---|
52 | |
---|
53 | /** |
---|
54 | * standard deconstructor |
---|
55 | */ |
---|
56 | DotParticles::~DotParticles() |
---|
57 | { } |
---|
58 | |
---|
59 | /** |
---|
60 | * @brief initializes the DotParticles with default values |
---|
61 | */ |
---|
62 | void DotParticles::init() |
---|
63 | { |
---|
64 | this->registerObject(this, DotParticles::_objectList); |
---|
65 | |
---|
66 | this->material.setDiffuseMap("maps/radial-trans-noise.png"); |
---|
67 | } |
---|
68 | |
---|
69 | |
---|
70 | /** |
---|
71 | * loads Parameters from a TiXmlElement |
---|
72 | * @param root the XML-element to load from. |
---|
73 | */ |
---|
74 | void DotParticles::loadParams(const TiXmlElement* root) |
---|
75 | { |
---|
76 | ParticleSystem::loadParams(root); |
---|
77 | } |
---|
78 | |
---|
79 | /** |
---|
80 | * @brief draws all the Particles of this System |
---|
81 | * |
---|
82 | * The Cases in this Function all do the same: |
---|
83 | * Drawing all the particles with the appropriate Type. |
---|
84 | * This is just the fastest Way to do this, but will most likely be changed in the future. |
---|
85 | */ |
---|
86 | void DotParticles::draw() const |
---|
87 | { |
---|
88 | glPushAttrib(GL_ENABLE_BIT); |
---|
89 | |
---|
90 | GLboolean checkLight = false; |
---|
91 | glGetBooleanv(GL_LIGHTING, &checkLight); |
---|
92 | if (checkLight == GL_TRUE) |
---|
93 | glDisable(GL_LIGHTING); |
---|
94 | |
---|
95 | glMatrixMode(GL_MODELVIEW); |
---|
96 | glBlendFunc(GL_SRC_ALPHA, GL_DST_ALPHA); |
---|
97 | |
---|
98 | Particle* drawPart = particles; |
---|
99 | //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_ENV_MODE, GL_MODULATE); |
---|
100 | |
---|
101 | glBegin(GL_POINTS); |
---|
102 | while (likely(drawPart != NULL)) |
---|
103 | { |
---|
104 | glColor4fv(drawPart->color); |
---|
105 | glVertex3f(drawPart->position.x, drawPart->position.y, drawPart->position.z); |
---|
106 | |
---|
107 | drawPart = drawPart->next; |
---|
108 | } |
---|
109 | glEnd(); |
---|
110 | glPopAttrib(); |
---|
111 | } |
---|