[4597] | 1 | /* |
---|
[1853] | 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. |
---|
[1855] | 10 | |
---|
| 11 | ### File Specific: |
---|
[3925] | 12 | main-programmer: Benjamin Grauer |
---|
[1855] | 13 | co-programmer: ... |
---|
[1853] | 14 | */ |
---|
| 15 | |
---|
[5357] | 16 | #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_GRAPHICS |
---|
[1853] | 17 | |
---|
[6652] | 18 | #include "dot_particles.h" |
---|
[1853] | 19 | |
---|
[7193] | 20 | #include "util/loading/load_param.h" |
---|
| 21 | #include "util/loading/factory.h" |
---|
[3942] | 22 | #include "material.h" |
---|
[4338] | 23 | #include "state.h" |
---|
[5446] | 24 | #include "shell_command.h" |
---|
[3930] | 25 | |
---|
[5944] | 26 | #include "parser/tinyxml/tinyxml.h" |
---|
[6612] | 27 | #include <algorithm> |
---|
[4338] | 28 | |
---|
[6612] | 29 | |
---|
[6653] | 30 | CREATE_FACTORY(DotParticles, CL_DOT_PARTICLES); |
---|
[9686] | 31 | NewObjectListDefinitionID(DotParticles, CL_DOT_PARTICLES); |
---|
[6621] | 32 | |
---|
[6652] | 33 | SHELL_COMMAND(texture, DotParticles, setMaterialTexture) |
---|
[7198] | 34 | ->defaultValues("maps/evil-flower.png"); |
---|
[4725] | 35 | |
---|
[1853] | 36 | |
---|
[9406] | 37 | |
---|
[3245] | 38 | /** |
---|
[4836] | 39 | * standard constructor |
---|
| 40 | * @param maxCount the Count of particles in the System |
---|
[6652] | 41 | * @param type The Type of the DotParticles |
---|
[3245] | 42 | */ |
---|
[6652] | 43 | DotParticles::DotParticles (unsigned int maxCount) |
---|
[6621] | 44 | : ParticleSystem(maxCount) |
---|
[3365] | 45 | { |
---|
[4602] | 46 | this->init(); |
---|
[3365] | 47 | } |
---|
[1853] | 48 | |
---|
[4677] | 49 | /** |
---|
[5445] | 50 | * @brief creates a Particle System out of a XML-element |
---|
| 51 | * @param root: the XML-element to load from |
---|
[4677] | 52 | */ |
---|
[6652] | 53 | DotParticles::DotParticles(const TiXmlElement* root) |
---|
[4602] | 54 | { |
---|
| 55 | this->init(); |
---|
[6623] | 56 | if (root != NULL) |
---|
| 57 | this->loadParams(root); |
---|
[4602] | 58 | } |
---|
[1853] | 59 | |
---|
[3245] | 60 | /** |
---|
[4836] | 61 | * standard deconstructor |
---|
[3245] | 62 | */ |
---|
[6652] | 63 | DotParticles::~DotParticles() |
---|
[6653] | 64 | { } |
---|
[4123] | 65 | |
---|
[3945] | 66 | /** |
---|
[6652] | 67 | * @brief initializes the DotParticles with default values |
---|
[4602] | 68 | */ |
---|
[6652] | 69 | void DotParticles::init() |
---|
[4602] | 70 | { |
---|
[9686] | 71 | this->registerObject(this, DotParticles::_objectList); |
---|
[4602] | 72 | |
---|
[6626] | 73 | this->material.setDiffuseMap("maps/radial-trans-noise.png"); |
---|
[4602] | 74 | } |
---|
| 75 | |
---|
| 76 | |
---|
| 77 | /** |
---|
| 78 | * loads Parameters from a TiXmlElement |
---|
| 79 | * @param root the XML-element to load from. |
---|
| 80 | */ |
---|
[6652] | 81 | void DotParticles::loadParams(const TiXmlElement* root) |
---|
[4602] | 82 | { |
---|
[6623] | 83 | ParticleSystem::loadParams(root); |
---|
[4602] | 84 | |
---|
[6652] | 85 | LoadParam(root, "texture", this, DotParticles, setMaterialTexture); |
---|
[4602] | 86 | } |
---|
[4727] | 87 | |
---|
[4478] | 88 | /** |
---|
[6621] | 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. |
---|
[4338] | 94 | */ |
---|
[6652] | 95 | void DotParticles::draw() const |
---|
[4338] | 96 | { |
---|
[4176] | 97 | glPushAttrib(GL_ENABLE_BIT); |
---|
[4338] | 98 | |
---|
[6628] | 99 | GLboolean checkLight = false; |
---|
| 100 | glGetBooleanv(GL_LIGHTING, &checkLight); |
---|
[6653] | 101 | if (checkLight == GL_TRUE) |
---|
| 102 | glDisable(GL_LIGHTING); |
---|
| 103 | |
---|
[6621] | 104 | glMatrixMode(GL_MODELVIEW); |
---|
| 105 | glBlendFunc(GL_SRC_ALPHA, GL_DST_ALPHA); |
---|
[4863] | 106 | |
---|
[6652] | 107 | Particle* drawPart = particles; |
---|
[6621] | 108 | //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_ENV_MODE, GL_MODULATE); |
---|
[4338] | 109 | |
---|
[6652] | 110 | glBegin(GL_POINTS); |
---|
[6621] | 111 | while (likely(drawPart != NULL)) |
---|
| 112 | { |
---|
| 113 | glColor4fv(drawPart->color); |
---|
[6652] | 114 | glVertex3f(drawPart->position.x, drawPart->position.y, drawPart->position.z); |
---|
[4338] | 115 | |
---|
[6621] | 116 | drawPart = drawPart->next; |
---|
[4663] | 117 | } |
---|
[6652] | 118 | glEnd(); |
---|
[4176] | 119 | glPopAttrib(); |
---|
[3932] | 120 | } |
---|