Changeset 4663 in orxonox.OLD for orxonox/trunk
- Timestamp:
- Jun 23, 2005, 1:49:25 PM (19 years ago)
- Location:
- orxonox/trunk/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/lib/graphics/graphics_engine.cc
r4619 r4663 93 93 94 94 // setting up the Resolution 95 this->setResolution( 800, 600, 16);95 this->setResolution(1000, 800, 16); 96 96 97 97 -
orxonox/trunk/src/lib/particles/particle_system.cc
r4655 r4663 26 26 #include "material.h" 27 27 #include "state.h" 28 #include "objModel.h" 28 29 29 30 #include "tinyxml.h" … … 86 87 87 88 this->material = NULL; 89 this->model = NULL; 88 90 this->maxCount = PARTICLE_DEFAULT_MAX_COUNT; 89 91 this->count = 0; … … 141 143 this->material = NULL; 142 144 143 if (this->particleType == PARTICLE_SPRITE)145 switch (this->particleType) 144 146 { 145 this->material = new Material("transperencyMap"); 146 this->material->setDiffuseMap("pictures/radialTransparency.png"); 147 case PARTICLE_SPRITE: 148 this->material = new Material("transperencyMap"); 149 this->material->setDiffuseMap("pictures/radialTransparency.png"); 147 150 // material->setTransparency(.5); 151 break; 152 case PARTICLE_MODEL: 153 if (!this->model) 154 { 155 PRINTF(2)("Model not loaded yet, please do this through ParticleSystem::loadModel()"); 156 this->setType(PARTICLE_SPRITE); 157 } 158 break; 148 159 } 149 160 } … … 159 170 { 160 171 this->material = material; 172 } 173 174 175 176 /** 177 * sets a Model to the Particles 178 * @param modelName the Name of the Model to load 179 */ 180 void ParticleSystem::setModel(const char* modelName) 181 { 182 if (this->model) 183 delete this->model; 184 if (modelName) 185 this->model = new OBJModel(modelName); 186 this->setType(PARTICLE_MODEL); 161 187 } 162 188 … … 312 338 Drawing all the particles with the appropriate Type. 313 339 This is just the fastest Way to do this, but will most likely be changed in the future. 314 */340 */ 315 341 void ParticleSystem::draw(void) const 316 342 { … … 321 347 322 348 switch (this->particleType) 323 349 { 324 350 default: 325 351 case PARTICLE_SPRITE: … … 332 358 333 359 while (likely(drawPart != NULL)) 334 335 360 { 361 glColor4fv(drawPart->color); 336 362 //! \todo implement a faster code for the look-at Camera algorithm. 337 363 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 364 const PNode* camera = State::getInstance()->getCamera(); //!< \todo MUST be different 365 Vector cameraPos = camera->getAbsCoor(); 366 Vector cameraTargetPos = State::getInstance()->getCameraTarget()->getAbsCoor(); 367 Vector view = cameraTargetPos - cameraPos; 368 Vector up = Vector(0, 1, 0); 369 up = camera->getAbsDir().apply(up); 370 Vector h = up.cross(view); 371 Vector v = h.cross(view); 372 h.normalize(); 373 v.normalize(); 374 v *= .5 * drawPart->radius; 375 h *= .5 * drawPart->radius; 376 377 glBegin(GL_TRIANGLE_STRIP); 378 glTexCoord2i(1, 1); 379 glVertex3f(drawPart->position.x - h.x - v.x, 380 drawPart->position.y - h.y - v.y, 381 drawPart->position.z - h.z - v.z); 382 glTexCoord2i(0, 1); 383 glVertex3f(drawPart->position.x - h.x + v.x, 384 drawPart->position.y - h.y + v.y, 385 drawPart->position.z - h.z + v.z); 386 glTexCoord2i(1, 0); 387 glVertex3f(drawPart->position.x + h.x - v.x, 388 drawPart->position.y + h.y - v.y, 389 drawPart->position.z + h.z - v.z); 390 glTexCoord2i(0, 0); 391 glVertex3f(drawPart->position.x + h.x + v.x, 392 drawPart->position.y + h.y + v.y, 393 drawPart->position.z + h.z + v.z); 394 395 glEnd(); 396 397 drawPart = drawPart->next; 398 } 373 399 glDepthMask(GL_TRUE); 374 400 break; … … 378 404 glBegin(GL_LINES); 379 405 while (likely(drawPart != NULL)) 380 381 382 383 384 385 386 387 406 { 407 glColor4fv(drawPart->color); 408 glVertex3f(drawPart->position.x, drawPart->position.y, drawPart->position.z); 409 glVertex3f(drawPart->position.x - drawPart->velocity.x, 410 drawPart->position.y - drawPart->velocity.y, 411 drawPart->position.z - drawPart->velocity.z); 412 drawPart = drawPart->next; 413 } 388 414 glEnd(); 415 break; 416 417 case PARTICLE_MODEL: 418 if (likely(this->model != NULL)) 419 while (likely(drawPart != NULL)) 420 { 421 glPushMatrix(); 422 glMatrixMode(GL_MODELVIEW); 423 424 glTranslatef(drawPart->position.x, drawPart->position.y, drawPart->position.z); 425 glScalef(drawPart->radius, drawPart->radius, drawPart->radius); 426 427 this->model->draw(); 428 429 glPopMatrix(); 430 drawPart = drawPart->next; 431 } 389 432 break; 390 433 … … 392 435 glBegin(GL_POINTS); 393 436 while (likely(drawPart != NULL)) 394 395 396 397 398 399 400 401 437 { 438 glColor4fv(drawPart->color); 439 440 glLineWidth(drawPart->radius); 441 442 glVertex3f(drawPart->position.x, drawPart->position.y, drawPart->position.z); 443 drawPart = drawPart->next; 444 } 402 445 glEnd(); 403 446 break; 404 447 } 405 448 glPopAttrib(); 406 449 } -
orxonox/trunk/src/lib/particles/particle_system.h
r4602 r4663 77 77 void setType(PARTICLE_TYPE particleType, int count = 0); 78 78 void setMaterial(Material* material); 79 void setModel(const char* modelName = NULL); 79 80 void setLifeSpan(float lifeSpan, float randomLifeSpan = 0.0); 80 81 void setConserve(float conserve); … … 122 123 PARTICLE_TYPE particleType; //!< A type for all the Particles 123 124 Material* material; //!< A Material for all the Particles. 125 Model* model; //!< A Model to be displayed (PARTICLE_MODEL) 124 126 Particle* particles; //!< A list of particles of this System. 125 127 Particle* deadList; //!< A list of dead Particles in the System. -
orxonox/trunk/src/story_entities/world.cc
r4654 r4663 483 483 system->setRadius(1.0, 0.0, .0); 484 484 system->setMass (0.0, 1.0); 485 system->setModel(ResourceManager::getFullName("models/orx-rocket.obj")); 485 486 486 487 system->setColor(0, .5, 0, 0, 1); … … 490 491 491 492 // Creating a Test Particle Emitter 492 ParticleEmitter* emitter = new ParticleEmitter(Vector(-1, 0, 0), M_PI_4, 40 0, .5);493 ParticleEmitter* emitter = new ParticleEmitter(Vector(-1, 0, 0), M_PI_4, 40, .5); 493 494 emitter->setType(EMITTER_DOT); 494 495 emitter->setSize(20);
Note: See TracChangeset
for help on using the changeset viewer.