Changeset 6623 in orxonox.OLD for trunk/src/lib/particles/spark_particles.cc
- Timestamp:
- Jan 20, 2006, 12:54:20 AM (18 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/particles/spark_particles.cc
r6622 r6623 16 16 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_GRAPHICS 17 17 18 #include "sp rite_particles.h"18 #include "spark_particles.h" 19 19 20 20 #include "load_param.h" … … 28 28 29 29 30 CREATE_FACTORY(SpriteParticles, CL_SPRITE_PARTICLES); 31 32 SHELL_COMMAND(texture, SpriteParticles, setMaterialTexture) 33 ->defaultValues(1, "maps/evil-flower.png"); 30 CREATE_FACTORY(SparkParticles, CL_SPARK_PARTICLES); 34 31 35 32 using namespace std; … … 38 35 * standard constructor 39 36 * @param maxCount the Count of particles in the System 40 * @param type The Type of the Sp riteParticles37 * @param type The Type of the SparkParticles 41 38 */ 42 Sp riteParticles::SpriteParticles (unsigned int maxCount)43 : ParticleSystem(maxCount)39 SparkParticles::SparkParticles (unsigned int maxCount) 40 : ParticleSystem(maxCount) 44 41 { 45 42 this->init(); … … 50 47 * @param root: the XML-element to load from 51 48 */ 52 Sp riteParticles::SpriteParticles(const TiXmlElement* root)49 SparkParticles::SparkParticles(const TiXmlElement* root) 53 50 { 54 51 this->init(); 55 52 56 this->loadParams(root); 53 if (root != NULL) 54 this->loadParams(root); 57 55 } 58 56 … … 60 58 * standard deconstructor 61 59 */ 62 Sp riteParticles::~SpriteParticles()60 SparkParticles::~SparkParticles() 63 61 { 64 62 // deleting all the living Particles … … 80 78 81 79 /** 82 * @brief initializes the Sp riteParticles with default values80 * @brief initializes the SparkParticles with default values 83 81 */ 84 void Sp riteParticles::init()82 void SparkParticles::init() 85 83 { 86 this->setClassID(CL_SP RITE_PARTICLES, "SpriteParticles");84 this->setClassID(CL_SPARK_PARTICLES, "SparkParticles"); 87 85 88 86 this->material = NULL; … … 94 92 * @param root the XML-element to load from. 95 93 */ 96 void Sp riteParticles::loadParams(const TiXmlElement* root)94 void SparkParticles::loadParams(const TiXmlElement* root) 97 95 { 98 SpriteParticles::loadParams(root); 99 100 LoadParam(root, "texture", this, SpriteParticles, setMaterialTexture); 101 } 102 103 // setting properties 104 /** 105 * @brief sets the material to an external material 106 * @param material: the material to set this material to. 107 * 108 * !! important if the extern material gets deleted it MUST be unregistered here or segfault !! 109 */ 110 void SpriteParticles::setMaterial(Material* material) 111 { 112 this->material = *material; 113 } 114 115 void SpriteParticles::setMaterialTexture(const char* textureFile) 116 { 117 this->material.setDiffuseMap(textureFile); 96 ParticleSystem::loadParams(root); 118 97 } 119 98 … … 125 104 * This is just the fastest Way to do this, but will most likely be changed in the future. 126 105 */ 127 void Sp riteParticles::draw() const106 void SparkParticles::draw() const 128 107 { 129 108 glPushAttrib(GL_ENABLE_BIT); … … 131 110 Particle* drawPart = particles; 132 111 133 glDisable(GL_LIGHTING);134 glMatrixMode(GL_MODELVIEW);135 112 glDepthMask(GL_FALSE); 136 113 137 material.select(); 138 glBlendFunc(GL_SRC_ALPHA, GL_DST_ALPHA); 114 glDisable(GL_LIGHTING); 115 glEnable(GL_LINE_SMOOTH); 116 glEnable(GL_BLEND); 139 117 140 //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_ENV_MODE, GL_MODULATE); 141 142 118 glBegin(GL_LINES); 143 119 while (likely(drawPart != NULL)) 144 120 { 145 121 glColor4fv(drawPart->color); 146 //! @todo implement a faster code for the look-at Camera algorithm. 147 148 const PNode* camera = State::getCamera(); //!< @todo MUST be different 149 Vector cameraPos = camera->getAbsCoor(); 150 Vector cameraTargetPos = State::getCameraTarget()->getAbsCoor(); 151 Vector view = cameraTargetPos - cameraPos; 152 Vector up = Vector(0, 1, 0); 153 up = camera->getAbsDir().apply(up); 154 Vector h = up.cross(view); 155 Vector v = h.cross(view); 156 h.normalize(); 157 v.normalize(); 158 v *= .5 * drawPart->radius; 159 h *= .5 * drawPart->radius; 160 161 glBegin(GL_TRIANGLE_STRIP); 162 glTexCoord2i(1, 1); 163 glVertex3f(drawPart->position.x - h.x - v.x, 164 drawPart->position.y - h.y - v.y, 165 drawPart->position.z - h.z - v.z); 166 glTexCoord2i(0, 1); 167 glVertex3f(drawPart->position.x - h.x + v.x, 168 drawPart->position.y - h.y + v.y, 169 drawPart->position.z - h.z + v.z); 170 glTexCoord2i(1, 0); 171 glVertex3f(drawPart->position.x + h.x - v.x, 172 drawPart->position.y + h.y - v.y, 173 drawPart->position.z + h.z - v.z); 174 glTexCoord2i(0, 0); 175 glVertex3f(drawPart->position.x + h.x + v.x, 176 drawPart->position.y + h.y + v.y, 177 drawPart->position.z + h.z + v.z); 178 179 glEnd(); 180 122 glVertex3f(drawPart->position.x, drawPart->position.y, drawPart->position.z); 123 glVertex3f(drawPart->position.x - drawPart->velocity.x * drawPart->radius, 124 drawPart->position.y - drawPart->velocity.y * drawPart->radius, 125 drawPart->position.z - drawPart->velocity.z * drawPart->radius); 181 126 drawPart = drawPart->next; 182 127 } 128 glEnd(); 129 183 130 glDepthMask(GL_TRUE); 184 131 glPopAttrib();
Note: See TracChangeset
for help on using the changeset viewer.