#include <particle.h>
Inheritance diagram for Roman:
Public Methods | |
Roman () | |
~Roman () | |
void | Update () |
void | Render (int nodeid) |
void | SetShape (PARTICLE *Particle) |
void | SetDefaults (PARTICLE *Particle) |
|
Definition at line 128 of file particle.h.
00128 {}; |
|
Definition at line 129 of file particle.h.
00129 {}; |
|
Reimplemented from ParticleSystem. Definition at line 482 of file particle.cpp. References ParticleInfo::Alive, ParticleInfo::Color, MATRIX::Element, LinkedList< PARTICLE >::Get(), ParticleInfo::Leaf, VECTOR::Normalize(), SystemInfo::numParticles, ParticleSystem::ParticleList, PARTICLE::PartInfo, ParticleInfo::Pos, ParticleInfo::SizeX, ParticleInfo::SizeY, ParticleSystem::SysInfo, SystemInfo::TexID, VECTOR::x, VECTOR::y, and VECTOR::z.
00483 { 00484 MATRIX mat; 00485 VECTOR up; 00486 VECTOR right; 00487 PARTICLE* tempParticle; 00488 00489 glGetFloatv(GL_MODELVIEW_MATRIX, mat.Element); 00490 00491 glEnable(GL_BLEND); 00492 glDepthMask(0); 00493 glBlendFunc(GL_SRC_ALPHA, GL_ONE); 00494 glDisable(GL_LIGHTING); 00495 glBindTexture(GL_TEXTURE_2D, SysInfo.TexID); 00496 00497 for (int loop = 1; loop <= SysInfo.numParticles; loop++) 00498 { 00499 tempParticle = ParticleList.Get(loop); 00500 00501 if (tempParticle->PartInfo.Leaf == nodeid) 00502 { 00503 if (tempParticle->PartInfo.Alive) 00504 { 00505 right.x = mat.Element[0]; 00506 right.y = mat.Element[4]; 00507 right.z = mat.Element[8]; 00508 right.Normalize(); 00509 right.x *= tempParticle->PartInfo.SizeX / 2; 00510 right.y *= tempParticle->PartInfo.SizeX / 2; 00511 right.z *= tempParticle->PartInfo.SizeX / 2; 00512 00513 up.x = mat.Element[1]; 00514 up.y = mat.Element[5]; 00515 up.z = mat.Element[9]; 00516 up.Normalize(); 00517 up.x *= tempParticle->PartInfo.SizeY / 2; 00518 up.y *= tempParticle->PartInfo.SizeY / 2; 00519 up.z *= tempParticle->PartInfo.SizeY / 2; 00520 00521 glColor4f(tempParticle->PartInfo.Color[0], tempParticle->PartInfo.Color[1], tempParticle->PartInfo.Color[2], tempParticle->PartInfo.Color[3]); 00522 glBegin(GL_QUADS); 00523 glTexCoord2f(0.0f, 0.0f); glVertex3f(tempParticle->PartInfo.Pos.x + (-right.x - up.x), tempParticle->PartInfo.Pos.y + (-right.y - up.y), tempParticle->PartInfo.Pos.z + (-right.z - up.z)); 00524 glTexCoord2f(1.0f, 0.0f); glVertex3f(tempParticle->PartInfo.Pos.x + (right.x - up.x), tempParticle->PartInfo.Pos.y + (right.y - up.y), tempParticle->PartInfo.Pos.z + (right.z - up.z)); 00525 glTexCoord2f(1.0f, 1.0f); glVertex3f(tempParticle->PartInfo.Pos.x + (right.x + up.x), tempParticle->PartInfo.Pos.y + (right.y + up.y), tempParticle->PartInfo.Pos.z + (right.z + up.z)); 00526 glTexCoord2f(0.0f, 1.0f); glVertex3f(tempParticle->PartInfo.Pos.x + (up.x - right.x), tempParticle->PartInfo.Pos.y + (up.y - right.y), tempParticle->PartInfo.Pos.z + (up.z - right.z)); 00527 glEnd(); 00528 } 00529 } 00530 } 00531 00532 glEnable(GL_LIGHTING); 00533 glDepthMask(1); 00534 glDisable(GL_BLEND); 00535 } |
|
Reimplemented from ParticleSystem. Definition at line 537 of file particle.cpp. References ParticleInfo::Alive, SystemInfo::Color, ParticleInfo::Color, ParticleInfo::Energy, SystemInfo::Normal, ParticleInfo::OldPos, ParticleInfo::OrigPos, PARTICLE::PartInfo, SystemInfo::Pos, ParticleInfo::Pos, ParticleInfo::SizeX, ParticleInfo::SizeY, ParticleSystem::SysInfo, ParticleInfo::Velocity, VECTOR::x, VECTOR::y, and VECTOR::z. Referenced by Update().
00538 { 00539 Particle->PartInfo.Alive = true; 00540 Particle->PartInfo.Pos = SysInfo.Pos; 00541 Particle->PartInfo.OldPos = SysInfo.Pos; 00542 Particle->PartInfo.OrigPos = SysInfo.Pos; 00543 00544 VECTOR Velocity = SysInfo.Normal; 00545 00546 float x; 00547 x = (float)rand()/(float)RAND_MAX; 00548 Particle->PartInfo.Velocity.x = Velocity.x + (x - 0.5) / 5; 00549 Particle->PartInfo.Velocity.x /= 4.0; 00550 x = (float)rand()/(float)RAND_MAX; 00551 Particle->PartInfo.Velocity.y = Velocity.y + (x - 0.5); 00552 Particle->PartInfo.Velocity.y /= 4.0; 00553 x = (float)rand()/(float)RAND_MAX; 00554 Particle->PartInfo.Velocity.z = Velocity.z + (x - 0.5) / 5; 00555 Particle->PartInfo.Velocity.z /= 4.0; 00556 00557 Particle->PartInfo.Color[0] = SysInfo.Color[0]; 00558 Particle->PartInfo.Color[1] = SysInfo.Color[1]; 00559 Particle->PartInfo.Color[2] = SysInfo.Color[2]; 00560 Particle->PartInfo.Color[3] = 1.0; 00561 00562 Particle->PartInfo.Energy = 1.0; 00563 Particle->PartInfo.SizeX = 3.0; 00564 Particle->PartInfo.SizeY = 3.0; 00565 } |
|
Reimplemented from ParticleSystem. Definition at line 567 of file particle.cpp.
00568 { 00569 } |
|
Reimplemented from ParticleSystem. Definition at line 422 of file particle.cpp. References CheckForParticleCollision(), ParticleInfo::Color, VECTOR::DotProduct(), ParticleInfo::Energy, LinkedList< PARTICLE >::Get(), SystemInfo::numParticles, ParticleInfo::OldPos, ParticleSystem::ParticleList, PARTICLE::PartInfo, ParticleInfo::Pos, SetDefaults(), ParticleSystem::SysInfo, ParticleInfo::Velocity, VECTOR::x, VECTOR::y, and VECTOR::z.
00423 { 00424 VECTOR normal, pos, oldpos, temppos; 00425 PARTICLE* tempParticle; 00426 00427 for (int loop = 1; loop <= SysInfo.numParticles; loop++) 00428 { 00429 tempParticle = ParticleList.Get(loop); 00430 tempParticle->PartInfo.OldPos = tempParticle->PartInfo.Pos; 00431 tempParticle->PartInfo.Velocity.x += 0.0; 00432 tempParticle->PartInfo.Velocity.y += -0.003; 00433 tempParticle->PartInfo.Velocity.z += 0.0; 00434 if (tempParticle->PartInfo.Energy > 0.0) 00435 { 00436 tempParticle->PartInfo.Color[3] = tempParticle->PartInfo.Energy; 00437 tempParticle->PartInfo.Energy -= 0.003; 00438 oldpos = tempParticle->PartInfo.Pos; 00439 pos = tempParticle->PartInfo.Pos + tempParticle->PartInfo.Velocity; 00440 temppos = pos; 00441 bool CollisionFlag = CheckForParticleCollision(tempParticle, oldpos, &temppos, &normal); 00442 00443 VECTOR VelocityVector; 00444 00445 if (CollisionFlag) 00446 { 00447 VECTOR vn = normal * (normal.DotProduct(tempParticle->PartInfo.Velocity)); 00448 VECTOR vt = tempParticle->PartInfo.Velocity - vn; 00449 VECTOR vel = (vt - vn); 00450 tempParticle->PartInfo.Pos.x += vel.x; 00451 tempParticle->PartInfo.Pos.y += vel.y; 00452 tempParticle->PartInfo.Pos.z += vel.z; 00453 tempParticle->PartInfo.Velocity.x = vel.x / 3.0; 00454 tempParticle->PartInfo.Velocity.y = vel.y / 3.0; 00455 tempParticle->PartInfo.Velocity.z = vel.z / 3.0; 00456 tempParticle->PartInfo.Energy -= 0.3; 00457 } 00458 else 00459 { 00460 tempParticle->PartInfo.Pos.x += tempParticle->PartInfo.Velocity.x; 00461 tempParticle->PartInfo.Pos.y += tempParticle->PartInfo.Velocity.y; 00462 tempParticle->PartInfo.Pos.z += tempParticle->PartInfo.Velocity.z; 00463 } 00464 } 00465 else 00466 { 00467 SetDefaults(tempParticle); 00468 } 00469 00470 tempParticle->PartInfo.Color[0] += 0.006; 00471 if (tempParticle->PartInfo.Color[0] > 1.0) 00472 tempParticle->PartInfo.Color[0] = 1.0; 00473 tempParticle->PartInfo.Color[1] += 0.006; 00474 if (tempParticle->PartInfo.Color[1] > 1.0) 00475 tempParticle->PartInfo.Color[1] = 1.0; 00476 tempParticle->PartInfo.Color[2] += 0.006; 00477 if (tempParticle->PartInfo.Color[2] > 1.0) 00478 tempParticle->PartInfo.Color[2] = 1.0; 00479 } 00480 } |