Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

particle.cpp File Reference

#include "particle.h"
#include "matrix.h"
#include "texture.h"
#include "listnode.h"
#include "collision.h"
#include "general.h"
#include "bsp.h"
#include "locmath.h"
#include "mmgr.h"

Go to the source code of this file.

Functions

void RenderParticles (int nodeid)
void CreateSparks (VECTOR OldPos, VECTOR Pos, VECTOR Normal)
void CreateRomanCandle (VECTOR Pos)
void CreateBouncy (VECTOR Pos)
bool CheckForParticleCollision (PARTICLE *Particle, VECTOR OldPos, VECTOR *Pos, VECTOR *Norm)

Variables

BSP_noderoot
ParticleManager PManager
TEXTUREtexture
LinkedList< ListNodeLeafList
LinkedList< ListNodePartitionList
ListNodelistnode


Function Documentation

bool CheckForParticleCollision PARTICLE   Particle,
VECTOR    OldPos,
VECTOR   Pos,
VECTOR   Norm
 

Definition at line 757 of file particle.cpp.

References CheckPointInTriangle(), ClassifyPoint(), FindCurrentLeaf(), LinkedList< T >::Get(), POLYGON::GetNormal(), line_plane_collision(), ListNode::node, BSP_node::nodepolylist, VECTOR::normalize(), BSP_node::numpolys, VERTEX::nx, VERTEX::ny, VERTEX::nz, POLYGON::Vertex, VECTOR::x, VERTEX::x, VECTOR::y, VERTEX::y, VECTOR::z, and VERTEX::z.

Referenced by Spark::Update(), Roman::Update(), and Bouncy::Update().

00758 {
00759     int CollisionPoly, ParticleLeaf;
00760     POLYGON Polygon;
00761     ListNode* tempnode;
00762     VECTOR CollisionPoint, p0, pN, a, b, c;
00763     bool CollisionFlag = false;
00764 
00765     ParticleLeaf = FindCurrentLeaf(OldPos, root);
00766     tempnode = LeafList.Get(ParticleLeaf);
00767 
00768     // Loop through all polygons in leaf
00769     for (CollisionPoly = 0; CollisionPoly < tempnode->node->numpolys; CollisionPoly++)
00770     {
00771         Polygon = tempnode->node->nodepolylist[CollisionPoly];
00772         // Get a point on the polygon
00773         p0.x = Polygon.Vertex[0].x;
00774         p0.y = Polygon.Vertex[0].y;
00775         p0.z = Polygon.Vertex[0].z;
00776         // Get the polygon normal
00777         pN.x = Polygon.Vertex[0].nx;
00778         pN.y = Polygon.Vertex[0].ny;
00779         pN.z = Polygon.Vertex[0].nz;
00780         // If the position isn't in front of or on the polygon then continue
00781         if (ClassifyPoint(*Pos, p0, pN) == 1 || ClassifyPoint(*Pos, p0, pN) == 0)
00782             continue;
00783         // Find collision point on the plane
00784         CollisionPoint = line_plane_collision(&OldPos, Pos, &Polygon);
00785         // If collision point is within the polygon
00786         a.x = Polygon.Vertex[0].x;
00787         a.y = Polygon.Vertex[0].y;
00788         a.z = Polygon.Vertex[0].z;
00789         b.x = Polygon.Vertex[1].x;
00790         b.y = Polygon.Vertex[1].y;
00791         b.z = Polygon.Vertex[1].z;
00792         c.x = Polygon.Vertex[2].x;
00793         c.y = Polygon.Vertex[2].y;
00794         c.z = Polygon.Vertex[2].z;
00795         if (CheckPointInTriangle(CollisionPoint, a, b, c))
00796         {
00797             CollisionFlag = true;
00798             VECTOR Normal = Polygon.GetNormal();
00799             Pos->x = CollisionPoint.x;
00800             Pos->y = CollisionPoint.y;
00801             Pos->z = CollisionPoint.z;
00802 
00803             Normal.normalize();
00804             Norm->x = Normal.x;
00805             Norm->y = Normal.y;
00806             Norm->z = Normal.z;
00807             break;
00808         }
00809     }
00810     return CollisionFlag;
00811 }

void CreateBouncy VECTOR    Pos
 

Definition at line 738 of file particle.cpp.

References ParticleManager::Add(), bouncy, SystemInfo::Id, SystemInfo::Normal, SystemInfo::numParticles, SystemInfo::Pos, roman, VECTOR::Set(), ParticleSystem::SysInfo, SystemInfo::TexID, TEXTURE::TexID, SystemInfo::Type, and SystemInfo::Visibility.

Referenced by InitGL().

00739 {
00740 
00741     SystemInfo SI;
00742     ZeroMemory(&SI, sizeof(SI));
00743     SI.Visibility = true;
00744     SI.numParticles = 20;
00745     SI.Type = roman;
00746     SI.TexID = texture[9].TexID;
00747     SI.Id = 2;
00748     SI.Pos = Pos;
00749     SI.Normal.Set(0.0, 1.0, 0.0);
00750 
00751     ParticleSystem* bouncy = new Bouncy;
00752     bouncy->SysInfo = SI;
00753     PManager.Add(bouncy);
00754 }

void CreateRomanCandle VECTOR    Pos
 

Definition at line 715 of file particle.cpp.

References ParticleManager::Add(), SystemInfo::Color, SystemInfo::Id, SystemInfo::Normal, SystemInfo::numParticles, SystemInfo::Pos, roman, VECTOR::Set(), ParticleSystem::SysInfo, SystemInfo::TexID, TEXTURE::TexID, SystemInfo::Type, and SystemInfo::Visibility.

Referenced by InitGL().

00716 {
00717 
00718     SystemInfo SI;
00719     ZeroMemory(&SI, sizeof(SI));
00720     SI.Visibility = true;
00721     SI.numParticles = 80;
00722     SI.Type = roman;
00723     SI.TexID = texture[9].TexID;
00724     SI.Id = 2;
00725     SI.Pos = Pos;
00726     SI.Normal.Set(0.0, 1.0, 0.0);
00727 
00728     SI.Color[0] = 1.0;
00729     SI.Color[1] = 0.0;
00730     SI.Color[2] = 0.0;
00731     SI.Color[3] = 1.0;
00732 
00733     ParticleSystem* romancandle = new Roman;
00734     romancandle->SysInfo = SI;
00735     PManager.Add(romancandle);
00736 }

void CreateSparks VECTOR    OldPos,
VECTOR    Pos,
VECTOR    Normal
 

Definition at line 697 of file particle.cpp.

References ParticleManager::Add(), SystemInfo::Id, SystemInfo::InitialVelocity, SystemInfo::Normal, SystemInfo::numParticles, SystemInfo::Pos, spark, ParticleSystem::SysInfo, SystemInfo::TexID, TEXTURE::TexID, SystemInfo::Type, and SystemInfo::Visibility.

Referenced by UpdateBullets().

00698 {
00699     SystemInfo SI;
00700     ZeroMemory(&SI, sizeof(SI));
00701     SI.Visibility = true;
00702     SI.numParticles = rand()%6 + 2;
00703     SI.Type = spark;
00704     SI.TexID = texture[8].TexID;
00705     SI.Id = 1;
00706     SI.Pos = Pos;
00707     SI.Normal = Normal;
00708     SI.InitialVelocity = Pos - OldPos;
00709 
00710     ParticleSystem* sparky = new Spark;
00711     sparky->SysInfo = SI;
00712     PManager.Add(sparky);
00713 }

void RenderParticles int    nodeid
 

Definition at line 692 of file particle.cpp.

References ParticleManager::Render().

Referenced by RenderBSP().

00693 {
00694     PManager.Render(nodeid);
00695 }


Variable Documentation

LinkedList<ListNode> LeafList
 

Definition at line 21 of file particle.cpp.

ListNode* listnode
 

Definition at line 23 of file particle.cpp.

LinkedList<ListNode> PartitionList
 

Definition at line 22 of file particle.cpp.

ParticleManager PManager
 

Definition at line 19 of file particle.cpp.

BSP_node* root
 

Definition at line 18 of file particle.cpp.

TEXTURE* texture
 

Definition at line 20 of file particle.cpp.


Generated on Fri Dec 23 05:19:58 2005 for Particles by doxygen1.2.15