source: trunk/gui/vizservers/nanovis/ParticleSystem.h @ 587

Last change on this file since 587 was 587, checked in by vrinside, 18 years ago
File size: 2.3 KB
Line 
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 "Renderable.h"
28#include "RenderVertexArray.h"
29#include "Vector3.h"
30
31#include "NvParticleAdvectionShader.h"
32
33typedef struct Particle {
34  float x;
35  float y;
36  float z;
37  float aux;
38
39  Particle(){};
40  Particle(float _x, float _y, float _z, float _life) :
41   x(_x), y(_y), z(_z), aux(_life){}
42};
43
44
45class ParticleSystem : public Renderable {
46
47  NVISid psys_fbo[2];   //frame buffer objects: two are defined, flip them as input output every step
48  NVISid psys_tex[2];   //color textures attached to frame buffer objects
49
50  Particle* data;
51
52  int psys_frame;               //count the frame number of particle system iteration
53  bool reborn;                  //reinitiate particles
54  bool flip;                    //flip the source and destination render targets
55  float max_life;
56
57  RenderVertexArray* m_vertex_array;    //vertex array for display particles
58
59  //Nvidia CG shaders and their parameters
60  /*
61  CGcontext m_g_context;
62  CGprogram m_pos_fprog;
63  CGparameter m_vel_tex_param, m_pos_tex_param, m_scale_param;
64  CGparameter m_pos_timestep_param, m_pos_spherePos_param;
65  */
66  NvParticleAdvectionShader* _advectionShader;
67
68  Vector3 scale;
69
70public:
71  int psys_width;       //the storage of particles is implemented as a 2D array.
72  int psys_height;
73
74  ParticleSystem(int w, int h, CGcontext context, NVISid vector_field,
75                  float scalex, float scaley, float scalez);
76  ~ParticleSystem();
77  void initialize(Particle* data);
78  void advect();
79  void update_vertex_buffer();
80  void display_vertices();
81  void reset();
82  void render();
83};
84
85
86#endif
Note: See TracBrowser for help on using the repository browser.