1 | /*
|
---|
2 | * ----------------------------------------------------------------------
|
---|
3 | * ParticleSystem.h: particle system class
|
---|
4 | *
|
---|
5 | * ======================================================================
|
---|
6 | * AUTHOR: Wei Qiao <qiaow@purdue.edu>
|
---|
7 | * Purdue Rendering and Perceptualization Lab (PURPL)
|
---|
8 | *
|
---|
9 | * Copyright (c) 2004-2006 Purdue Research Foundation
|
---|
10 | *
|
---|
11 | * See the file "license.terms" for information on usage and
|
---|
12 | * redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
---|
13 | * ======================================================================
|
---|
14 | */
|
---|
15 |
|
---|
16 |
|
---|
17 | #ifndef _PARTICLE_SYSTEM_H_
|
---|
18 | #define _PARTICLE_SYSTEM_H_
|
---|
19 |
|
---|
20 | #include "GL/glew.h"
|
---|
21 | #include "Cg/cgGL.h"
|
---|
22 |
|
---|
23 | #include "define.h"
|
---|
24 | #include "config.h"
|
---|
25 | #include "global.h"
|
---|
26 |
|
---|
27 | #include "RenderVertexArray.h"
|
---|
28 |
|
---|
29 | typedef struct Particle{
|
---|
30 | float x;
|
---|
31 | float y;
|
---|
32 | float z;
|
---|
33 | float aux;
|
---|
34 |
|
---|
35 | Particle(){};
|
---|
36 | Particle(float _x, float _y, float _z, float _life) :
|
---|
37 | x(_x), y(_y), z(_z), aux(_life){}
|
---|
38 | };
|
---|
39 |
|
---|
40 |
|
---|
41 | class ParticleSystem{
|
---|
42 |
|
---|
43 | NVISid psys_fbo[2]; //frame buffer objects: two are defined, flip them as input output every step
|
---|
44 | NVISid psys_tex[2]; //color textures attached to frame buffer objects
|
---|
45 |
|
---|
46 | Particle* data;
|
---|
47 |
|
---|
48 | int psys_frame; //count the frame number of particle system iteration
|
---|
49 | bool reborn; //reinitiate particles
|
---|
50 | bool flip; //flip the source and destination render targets
|
---|
51 | float max_life;
|
---|
52 |
|
---|
53 | RenderVertexArray* m_vertex_array; //vertex array for display particles
|
---|
54 |
|
---|
55 | //Nvidia CG shaders and their parameters
|
---|
56 | CGcontext m_g_context;
|
---|
57 | CGprogram m_pos_fprog;
|
---|
58 | CGparameter m_vel_tex_param, m_pos_tex_param, m_scale_param;
|
---|
59 | CGparameter m_pos_timestep_param, m_pos_spherePos_param;
|
---|
60 |
|
---|
61 | public:
|
---|
62 | int psys_width; //the storage of particles is implemented as a 2D array.
|
---|
63 | int psys_height;
|
---|
64 |
|
---|
65 | ParticleSystem(int w, int h, CGcontext context, NVISid vector_field,
|
---|
66 | float scalex, float scaley, float scalez);
|
---|
67 | ~ParticleSystem();
|
---|
68 | void initialize(Particle* data);
|
---|
69 | void advect();
|
---|
70 | void update_vertex_buffer();
|
---|
71 | void display_vertices();
|
---|
72 | void reset();
|
---|
73 |
|
---|
74 | };
|
---|
75 |
|
---|
76 |
|
---|
77 | #endif
|
---|