My Project: openb3dlib.mod/openb3d/src/particle.h Source File

My Project

particle.h
Go to the documentation of this file.
1 #ifndef PARTICLE_H
2 #define PARTICLE_H
3
4 #include "mesh.h"
5 #include "global.h"
6 #include "surface.h"
7 #include "texture.h"
8
9 #include <iostream>
10 using namespace std;
11
12 /*class Particle : public Mesh{
13 public:
14
15 void Render();
16
17 };*/
18
19
20
21 class ParticleBatch: public Mesh{
22
23 public:
24
25 static list<ParticleBatch*> particle_batch_list;
26
27 int trail;
28
29 void Render();
30
31
32 ParticleBatch(){
33 no_surfs=1;
34
35 c_col_tree=NULL;
36 reset_col_tree=0;
37
38 reset_bounds=true;
39
40 trail=1;
41
42 min_x=-999999999;;min_y=-999999999;;min_z=-999999999;;max_x=999999999;;max_y=999999999;;max_z=999999999;;
43 };
44
45 static ParticleBatch* GetParticleBatch(Texture* tex,int blend,int order){
46
47 ParticleBatch* particle_batch=NULL;
48
49 // check if particle batch already exists for specified texture, if so return it
50 list<ParticleBatch*>::iterator it;
51 for(it=particle_batch_list.begin();it!=particle_batch_list.end();it++){
52 particle_batch=*it;
53 if(particle_batch->brush.tex[0]==tex && particle_batch->brush.blend==blend && particle_batch->order==order){
54 return particle_batch; //*particle_batch->surf_list.begin();
55 }
56 }
57
58 // if no particle batch surface exists, create new particle batch with new surface
59 particle_batch=new ParticleBatch;
60 Surface* surf=new Surface;
61 surf->vbo_enabled=false;
62 surf->ShaderMat=Global::ambient_shader;
63 particle_batch->surf_list.push_back(surf);
64 particle_batch->hide=false;
65 entity_list.push_back(particle_batch);
66 Global::root_ent->child_list.push_back(particle_batch);
67
68
69 particle_batch->brush.tex[0]=tex;
70 particle_batch->brush.blend=blend;
71 particle_batch->order=order;
72 particle_batch_list.push_back(particle_batch);
73 return particle_batch;
74
75 }
76
77
78
79 };
80
81 class ParticleEmitter: public Entity{
82
83 private:
84 int rate_counter;
85
86 struct ParticleData{
87 Entity* ent;
88 int particleLife;
89 float vx,vy,vz;
90 };
91
92 list<ParticleData> particles;
93
94 public:
95 static list<ParticleEmitter*> emitter_list;
96
97 Entity* particle_base;
98
99
100 int rate;
101 int lifetime;
102
103 float gx,gy,gz; //Gravity
104 float variance;
105 float particleSpeed;
106
107 void (*UpdateParticle)(Entity* ent, int life);
108
109 void Update();
110
111 ParticleEmitter(){
112 rate=1;
113 particleSpeed=1;
114 rate_counter=0;
115 lifetime=0;
116 gx=0;gy=0;gz=0;
117 variance=0;
118 UpdateParticle=0;
119 }
120
121 ParticleEmitter* CopyEntity(Entity* parent_ent=NULL);
122 static ParticleEmitter* CreateParticleEmitter(Entity* particle, Entity* parent_ent=NULL);
123 void FreeEntity(void);
124
125 void EmitterVector(float x, float y, float z);
126 void EmitterRate (float r);
127 void EmitterVariance (float v);
128 void EmitterParticleLife (int l);
129 void EmitterParticleSpeed (float s);
130 void EmitterParticleFunction(void (*EmitterFunction)(Entity*, int));
131
132
133 };
134
135 #endif
ParticleBatch::ParticleBatch
ParticleBatch()
Definition: particle.h:32
Mesh
Definition: mesh.h:34
Global::ambient_shader
static Shader * ambient_shader
Definition: global.h:24
Surface
Definition: surface.h:19
ParticleEmitter::lifetime
int lifetime
Definition: particle.h:101
EmitterParticleSpeed
void EmitterParticleSpeed(ParticleEmitter *emit, float s)
Definition: functions.cpp:623
EmitterVector
void EmitterVector(ParticleEmitter *emit, float x, float y, float z)
Definition: functions.cpp:606
ParticleBatch::particle_batch_list
static list< ParticleBatch * > particle_batch_list
Definition: particle.h:25
ParticleEmitter::particle_base
Entity * particle_base
Definition: particle.h:97
CopyEntity
Entity * CopyEntity(Entity *ent, Entity *parent)
Definition: functions.cpp:421
mesh.h
std
Brush::blend
int blend
Definition: brush.h:29
global.h
texture.h
EmitterParticleFunction
void EmitterParticleFunction(ParticleEmitter *emit, void(*EmitterFunction)(Entity *, int))
Definition: functions.cpp:618
FreeEntity
void FreeEntity(Entity *ent)
Definition: functions.cpp:882
ParticleEmitter::gz
float gz
Definition: particle.h:103
Entity
Definition: entity.h:27
Surface::vbo_enabled
int vbo_enabled
Definition: surface.h:65
ParticleEmitter::ParticleEmitter
ParticleEmitter()
Definition: particle.h:111
Entity::hide
int hide
Definition: entity.h:54
ParticleBatch
Definition: particle.h:21
EmitterVariance
void EmitterVariance(ParticleEmitter *emit, float v)
Definition: functions.cpp:627
CreateParticleEmitter
ParticleEmitter * CreateParticleEmitter(Entity *particle, Entity *parent_ent=0)
Definition: functions.cpp:1959
Entity::brush
Brush brush
Definition: entity.h:49
Texture
Definition: texture.h:23
ParticleEmitter::emitter_list
static list< ParticleEmitter * > emitter_list
Definition: particle.h:95
Global::root_ent
static Pivot * root_ent
Definition: global.h:35
surface.h
ParticleEmitter::variance
float variance
Definition: particle.h:104
Entity::child_list
list< Entity * > child_list
Definition: entity.h:37
Surface::ShaderMat
Shader * ShaderMat
Definition: surface.h:51
Brush::tex
Texture * tex[8]
Definition: brush.h:31
EmitterRate
void EmitterRate(ParticleEmitter *emit, float r)
Definition: functions.cpp:610
Mesh::surf_list
list< Surface * > surf_list
Definition: mesh.h:40
Entity::order
int order
Definition: entity.h:52
ParticleBatch::trail
int trail
Definition: particle.h:27
ParticleEmitter
Definition: particle.h:81
ParticleEmitter::rate
int rate
Definition: particle.h:100
NULL
#define NULL
Definition: tree.cpp:4
EmitterParticleLife
void EmitterParticleLife(ParticleEmitter *emit, int l)
Definition: functions.cpp:614
ParticleEmitter::particleSpeed
float particleSpeed
Definition: particle.h:105
ParticleBatch::GetParticleBatch
static ParticleBatch * GetParticleBatch(Texture *tex, int blend, int order)
Definition: particle.h:45