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