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

Last change on this file since 401 was 401, checked in by qiaow, 18 years ago

Added Renderable class, the superclass of every class that can be drawn.

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