#include <particle.h>
Inheritance diagram for Bouncy:
Public Methods | |
Bouncy () | |
~Bouncy () | |
void | Update () |
void | Render (int nodeid) |
void | SetShape (PARTICLE *Particle) |
void | SetDefaults (PARTICLE *Particle) |
|
Definition at line 141 of file particle.h.
00141 {}; |
|
Definition at line 142 of file particle.h.
00142 {}; |
|
Reimplemented from ParticleSystem. Definition at line 608 of file particle.cpp. References ParticleInfo::Alive, 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.
00609 { 00610 MATRIX mat; 00611 VECTOR up; 00612 VECTOR right; 00613 PARTICLE* tempParticle; 00614 00615 glGetFloatv(GL_MODELVIEW_MATRIX, mat.Element); 00616 00617 glEnable(GL_BLEND); 00618 glDepthMask(0); 00619 glBlendFunc(GL_SRC_ALPHA, GL_ONE); 00620 glDisable(GL_LIGHTING); 00621 glBindTexture(GL_TEXTURE_2D, SysInfo.TexID); 00622 00623 for (int loop = 1; loop <= SysInfo.numParticles; loop++) 00624 { 00625 tempParticle = ParticleList.Get(loop); 00626 00627 if (tempParticle->PartInfo.Leaf == nodeid) 00628 { 00629 if (tempParticle->PartInfo.Alive) 00630 { 00631 right.x = mat.Element[0]; 00632 right.y = mat.Element[4]; 00633 right.z = mat.Element[8]; 00634 right.Normalize(); 00635 right.x *= tempParticle->PartInfo.SizeX / 2; 00636 right.y *= tempParticle->PartInfo.SizeX / 2; 00637 right.z *= tempParticle->PartInfo.SizeX / 2; 00638 00639 up.x = mat.Element[1]; 00640 up.y = mat.Element[5]; 00641 up.z = mat.Element[9]; 00642 up.Normalize(); 00643 up.x *= tempParticle->PartInfo.SizeY / 2; 00644 up.y *= tempParticle->PartInfo.SizeY / 2; 00645 up.z *= tempParticle->PartInfo.SizeY / 2; 00646 00647 glColor4f(0.0, 1.0, 0.0, 1.0); 00648 glBegin(GL_QUADS); 00649 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)); 00650 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)); 00651 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)); 00652 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)); 00653 glEnd(); 00654 } 00655 } 00656 } 00657 00658 glEnable(GL_LIGHTING); 00659 glDepthMask(1); 00660 glDisable(GL_BLEND); 00661 } |
|
Reimplemented from ParticleSystem. Definition at line 663 of file particle.cpp. References ParticleInfo::Alive, 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.
00664 { 00665 Particle->PartInfo.Alive = true; 00666 Particle->PartInfo.Pos = SysInfo.Pos; 00667 Particle->PartInfo.OldPos = SysInfo.Pos; 00668 Particle->PartInfo.OrigPos = SysInfo.Pos; 00669 00670 VECTOR Velocity = SysInfo.Normal; 00671 00672 float x; 00673 x = (float)rand()/(float)RAND_MAX; 00674 Particle->PartInfo.Velocity.x = Velocity.x + (x - 0.5) / 5; 00675 Particle->PartInfo.Velocity.x /= 4.0; 00676 x = (float)rand()/(float)RAND_MAX; 00677 Particle->PartInfo.Velocity.y = Velocity.y + (x - 0.5); 00678 Particle->PartInfo.Velocity.y /= 4.0; 00679 x = (float)rand()/(float)RAND_MAX; 00680 Particle->PartInfo.Velocity.z = Velocity.z + (x - 0.5) / 5; 00681 Particle->PartInfo.Velocity.z /= 4.0; 00682 00683 Particle->PartInfo.Energy = 1.0; 00684 Particle->PartInfo.SizeX = 3.0; 00685 Particle->PartInfo.SizeY = 3.0; 00686 } |
|
Reimplemented from ParticleSystem. Definition at line 688 of file particle.cpp.
00689 { 00690 } |
|
Reimplemented from ParticleSystem. Definition at line 572 of file particle.cpp. References CheckForParticleCollision(), VECTOR::dot(), LinkedList< PARTICLE >::Get(), SystemInfo::numParticles, ParticleInfo::OldPos, ParticleSystem::ParticleList, PARTICLE::PartInfo, ParticleInfo::Pos, ParticleSystem::SysInfo, ParticleInfo::Velocity, VECTOR::x, VECTOR::y, and VECTOR::z.
00573 { 00574 bool CollisionFlag; 00575 VECTOR VelocityVector, normal, pos, oldpos, temppos; 00576 PARTICLE* tempParticle; 00577 00578 for (int loop = 1; loop <= SysInfo.numParticles; loop++) 00579 { 00580 tempParticle = ParticleList.Get(loop); 00581 tempParticle->PartInfo.OldPos = tempParticle->PartInfo.Pos; 00582 oldpos = tempParticle->PartInfo.Pos; 00583 pos = tempParticle->PartInfo.Pos + tempParticle->PartInfo.Velocity; 00584 temppos = pos; 00585 CollisionFlag = CheckForParticleCollision(tempParticle, oldpos, &temppos, &normal); 00586 00587 if (CollisionFlag) 00588 { 00589 VECTOR vn = normal * (normal.dot(tempParticle->PartInfo.Velocity)); 00590 VECTOR vt = tempParticle->PartInfo.Velocity - vn; 00591 VECTOR vel = (vt - vn); 00592 tempParticle->PartInfo.Pos.x += vel.x; 00593 tempParticle->PartInfo.Pos.y += vel.y; 00594 tempParticle->PartInfo.Pos.z += vel.z; 00595 tempParticle->PartInfo.Velocity.x = vel.x; 00596 tempParticle->PartInfo.Velocity.y = vel.y; 00597 tempParticle->PartInfo.Velocity.z = vel.z; 00598 } 00599 else 00600 { 00601 tempParticle->PartInfo.Pos.x += tempParticle->PartInfo.Velocity.x; 00602 tempParticle->PartInfo.Pos.y += tempParticle->PartInfo.Velocity.y; 00603 tempParticle->PartInfo.Pos.z += tempParticle->PartInfo.Velocity.z; 00604 } 00605 } 00606 } |