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< BSP_nodeLeafList
LinkedList< BSP_nodePartitionList
BSP_nodelistnode


Function Documentation

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

Definition at line 758 of file particle.cpp.

References CheckPointInTriangle(), ClassifyPoint(), VERTEX::coords, FindCurrentLeaf(), LinkedList< T >::Get(), POLYGON::GetNormal(), line_plane_collision(), BSP_node::nodepolylist, VERTEX::normal, VECTOR::normalize(), BSP_node::numpolys, and POLYGON::Vertex.

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

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

void CreateBouncy VECTOR    Pos
 

Definition at line 739 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.

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

void CreateRomanCandle VECTOR    Pos
 

Definition at line 716 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.

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

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

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<BSP_node> LeafList
 

Definition at line 21 of file particle.cpp.

BSP_node* listnode
 

Definition at line 23 of file particle.cpp.

LinkedList<BSP_node> 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:15:50 2005 for Constructive Solid Geometry by doxygen1.2.15