Changeset 6652 in orxonox.OLD for trunk/src/lib/particles
- Timestamp:
- Jan 22, 2006, 4:33:43 PM (19 years ago)
- Location:
- trunk/src/lib/particles
- Files:
-
- 1 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/particles/Makefile.am
r6629 r6652 11 11 spark_particles.cc \ 12 12 model_particles.cc \ 13 dot_particles.cc \ 13 14 \ 14 15 quick_animation.cc … … 22 23 spark_particles.h \ 23 24 model_particles.h \ 25 dot_particles.h \ 24 26 \ 25 27 quick_animation.h -
trunk/src/lib/particles/dot_particles.cc
r6651 r6652 16 16 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_GRAPHICS 17 17 18 #include " sprite_particles.h"18 #include "dot_particles.h" 19 19 20 20 #include "load_param.h" … … 28 28 29 29 30 CREATE_FACTORY( SpriteParticles, CL_SPRITE_PARTICLES);30 CREATE_FACTORY(DotParticles, CL_SPRITE_PARTICLES); 31 31 32 SHELL_COMMAND(texture, SpriteParticles, setMaterialTexture)32 SHELL_COMMAND(texture, DotParticles, setMaterialTexture) 33 33 ->defaultValues(1, "maps/evil-flower.png"); 34 34 … … 38 38 * standard constructor 39 39 * @param maxCount the Count of particles in the System 40 * @param type The Type of the SpriteParticles40 * @param type The Type of the DotParticles 41 41 */ 42 SpriteParticles::SpriteParticles (unsigned int maxCount)42 DotParticles::DotParticles (unsigned int maxCount) 43 43 : ParticleSystem(maxCount) 44 44 { … … 50 50 * @param root: the XML-element to load from 51 51 */ 52 SpriteParticles::SpriteParticles(const TiXmlElement* root)52 DotParticles::DotParticles(const TiXmlElement* root) 53 53 { 54 54 this->init(); … … 60 60 * standard deconstructor 61 61 */ 62 SpriteParticles::~SpriteParticles()62 DotParticles::~DotParticles() 63 63 { 64 64 // deleting all the living Particles … … 80 80 81 81 /** 82 * @brief initializes the SpriteParticles with default values82 * @brief initializes the DotParticles with default values 83 83 */ 84 void SpriteParticles::init()84 void DotParticles::init() 85 85 { 86 this->setClassID(CL_SPRITE_PARTICLES, " SpriteParticles");86 this->setClassID(CL_SPRITE_PARTICLES, "DotParticles"); 87 87 88 88 this->material.setDiffuseMap("maps/radial-trans-noise.png"); … … 94 94 * @param root the XML-element to load from. 95 95 */ 96 void SpriteParticles::loadParams(const TiXmlElement* root)96 void DotParticles::loadParams(const TiXmlElement* root) 97 97 { 98 98 ParticleSystem::loadParams(root); 99 99 100 LoadParam(root, "texture", this, SpriteParticles, setMaterialTexture);100 LoadParam(root, "texture", this, DotParticles, setMaterialTexture); 101 101 } 102 102 103 103 /** 104 104 * @brief sets the Texutre that is placed onto the particles 105 * @param textureFile the Texture to load onto these SpriteParticles105 * @param textureFile the Texture to load onto these DotParticles 106 106 */ 107 void SpriteParticles::setMaterialTexture(const char* textureFile)107 void DotParticles::setMaterialTexture(const char* textureFile) 108 108 { 109 109 this->material.setDiffuseMap(textureFile); … … 117 117 * This is just the fastest Way to do this, but will most likely be changed in the future. 118 118 */ 119 void SpriteParticles::draw() const119 void DotParticles::draw() const 120 120 { 121 121 glPushAttrib(GL_ENABLE_BIT); 122 122 123 Particle* drawPart = particles;124 123 125 124 GLboolean checkLight = false; … … 133 132 glBlendFunc(GL_SRC_ALPHA, GL_DST_ALPHA); 134 133 134 Particle* drawPart = particles; 135 135 //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_ENV_MODE, GL_MODULATE); 136 136 137 137 glBegin(GL_POINTS); 138 138 while (likely(drawPart != NULL)) 139 139 { 140 140 glColor4fv(drawPart->color); 141 //! @todo implement a faster code for the look-at Camera algorithm. 142 143 const PNode* camera = State::getCamera(); //!< @todo MUST be different 144 Vector cameraPos = camera->getAbsCoor(); 145 Vector cameraTargetPos = State::getCameraTarget()->getAbsCoor(); 146 Vector view = cameraTargetPos - cameraPos; 147 Vector up = Vector(0, 1, 0); 148 up = camera->getAbsDir().apply(up); 149 Vector h = up.cross(view); 150 Vector v = h.cross(view); 151 h.normalize(); 152 v.normalize(); 153 v *= .5 * drawPart->radius; 154 h *= .5 * drawPart->radius; 155 156 glBegin(GL_TRIANGLE_STRIP); 157 glTexCoord2i(1, 1); 158 glVertex3f(drawPart->position.x - h.x - v.x, 159 drawPart->position.y - h.y - v.y, 160 drawPart->position.z - h.z - v.z); 161 glTexCoord2i(0, 1); 162 glVertex3f(drawPart->position.x - h.x + v.x, 163 drawPart->position.y - h.y + v.y, 164 drawPart->position.z - h.z + v.z); 165 glTexCoord2i(1, 0); 166 glVertex3f(drawPart->position.x + h.x - v.x, 167 drawPart->position.y + h.y - v.y, 168 drawPart->position.z + h.z - v.z); 169 glTexCoord2i(0, 0); 170 glVertex3f(drawPart->position.x + h.x + v.x, 171 drawPart->position.y + h.y + v.y, 172 drawPart->position.z + h.z + v.z); 173 174 glEnd(); 141 glVertex3f(drawPart->position.x, drawPart->position.y, drawPart->position.z); 175 142 176 143 drawPart = drawPart->next; 177 144 } 145 glEnd(); 178 146 glDepthMask(GL_TRUE); 179 147 glPopAttrib(); -
trunk/src/lib/particles/dot_particles.h
r6651 r6652 1 1 /*! 2 * @file sprite_particles.h2 * @file dot_particles.h 3 3 4 4 */ 5 5 6 #ifndef _ SPRITE_PARTICLE_SYSTEM_H7 #define _ SPRITE_PARTICLE_SYSTEM_H6 #ifndef _DOT_PARTICLE_SYSTEM_H 7 #define _DOT_PARTICLE_SYSTEM_H 8 8 9 9 #include "particle_system.h" … … 11 11 12 12 //! A class to handle ParticleSystems 13 class SpriteParticles : public ParticleSystem13 class DotParticles : public ParticleSystem 14 14 { 15 15 16 16 public: 17 SpriteParticles(unsigned int maxCount = PARTICLE_DEFAULT_MAX_COUNT);18 SpriteParticles(const TiXmlElement* root);19 virtual ~ SpriteParticles();17 DotParticles(unsigned int maxCount = PARTICLE_DEFAULT_MAX_COUNT); 18 DotParticles(const TiXmlElement* root); 19 virtual ~DotParticles(); 20 20 21 21 virtual void loadParams(const TiXmlElement* root); … … 35 35 }; 36 36 37 #endif /* _ SPRITE_PARTICLE_SYSTEM_H */37 #endif /* _DOT_PARTICLE_SYSTEM_H */
Note: See TracChangeset
for help on using the changeset viewer.