source: trunk/vizservers/nanovis/NvParticleRenderer.h @ 884

Last change on this file since 884 was 850, checked in by vrinside, 16 years ago

Activated Particle System.

File size: 3.0 KB
Line 
1/*
2 * ----------------------------------------------------------------------
3 * NvParticleRenderer.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 _NV_PARTICLE_SYSTEM_H_
18#define _NV_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 NvParticleRenderer : public Renderable {
46public :
47    /**
48     * @brief frame buffer objects: two are defined, flip them as input output every step
49     */
50    NVISid psys_fbo[2];         
51
52    /**
53     * @brief color textures attached to frame buffer objects
54     */
55    NVISid psys_tex[2];
56
57    Particle* data;
58
59    /**
60     *@brief Count the frame number of particle system iteration
61     */
62    int psys_frame;         
63   
64    /**
65     * @brief Reinitiate particles     
66     */
67    bool reborn;                       
68
69    /**
70     * @brief flip the source and destination render targets
71     */
72    bool flip;                 
73
74    float max_life;
75
76    /**
77     * @brief vertex array for display particles
78     */
79    RenderVertexArray* m_vertex_array; 
80
81  //Nvidia CG shaders and their parameters
82  /*
83  CGcontext m_g_context;
84  CGprogram m_pos_fprog;
85  CGparameter m_vel_tex_param, m_pos_tex_param, m_scale_param;
86  CGparameter m_pos_timestep_param, m_pos_spherePos_param;
87  */
88    NvParticleAdvectionShader* _advectionShader;
89
90    /**
91     * @brief scale of flow data
92     */
93    Vector3 scale;
94
95    bool _activate;
96public:
97    int psys_width;     //the storage of particles is implemented as a 2D array.
98    int psys_height;
99
100    NvParticleRenderer(int w, int h, CGcontext context);
101    ~NvParticleRenderer();
102    void setVectorField(unsigned int texID, float scaleX, float scaleY, float scaleZ, float max);
103    void initialize(Particle* data);
104    void advect();
105    void update_vertex_buffer();
106    void display_vertices();
107    void reset();
108    void render();
109
110    void activate();
111    void deactivate();
112    bool isActivated() const;
113};
114
115inline void NvParticleRenderer::activate()
116{
117    _activate = true;
118}
119
120inline void NvParticleRenderer::deactivate()
121{
122    _activate = false;
123}
124
125inline bool NvParticleRenderer::isActivated() const
126{
127    return _activate;
128}
129
130#endif
Note: See TracBrowser for help on using the repository browser.