source: trunk/packages/vizservers/nanovis/NvParticleRenderer.h @ 2825

Last change on this file since 2825 was 2798, checked in by ldelgass, 13 years ago

Add emacs mode magic line in preparation for indentation cleanup

  • Property svn:eol-style set to native
File size: 3.4 KB
Line 
1/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2/*
3 * ----------------------------------------------------------------------
4 * NvParticleRenderer.h: particle system class
5 *
6 * ======================================================================
7 *  AUTHOR:  Wei Qiao <qiaow@purdue.edu>
8 *           Purdue Rendering and Perceptualization Lab (PURPL)
9 *
10 *  Copyright (c) 2004-2006  Purdue Research Foundation
11 *
12 *  See the file "license.terms" for information on usage and
13 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
14 * ======================================================================
15 */
16
17
18#ifndef _NV_PARTICLE_SYSTEM_H_
19#define _NV_PARTICLE_SYSTEM_H_
20
21#include "GL/glew.h"
22#include "Cg/cgGL.h"
23
24#include "define.h"
25#include "config.h"
26#include "global.h"
27
28#include "Renderable.h"
29#include "RenderVertexArray.h"
30#include "Vector3.h"
31
32#include <vector>
33
34#include "NvParticleAdvectionShader.h"
35
36struct Particle {
37    float x;
38    float y;
39    float z;
40    float aux;
41
42    Particle(){};
43    Particle(float _x, float _y, float _z, float _life) :
44        x(_x), y(_y), z(_z), aux(_life){}
45};
46
47class NvParticleRenderer : public Renderable {
48public :
49    /**
50     * @brief frame buffer objects: two are defined, flip them as input output every step
51     */
52    GLuint psys_fbo[2];         
53
54    /**
55     * @brief color textures attached to frame buffer objects
56     */
57    GLuint psys_tex[2];
58    GLuint initPosTex; 
59    Particle* data;
60   
61    /**
62     *@brief Count the frame number of particle system iteration
63     */
64    int psys_frame;         
65   
66    /**
67     * @brief Reinitiate particles     
68     */
69    bool reborn;                       
70
71    /**
72     * @brief flip the source and destination render targets
73     */
74    bool flip;                 
75
76    float max_life;
77
78    float _particleSize;                // Size of the particle: default is 1.2
79
80    /**
81     * @brief vertex array for display particles
82     */
83    RenderVertexArray* m_vertex_array; 
84
85    //Nvidia CG shaders and their parameters
86    /*
87      CGcontext m_g_context;
88      CGprogram m_pos_fprog;
89      CGparameter m_vel_tex_param, m_pos_tex_param, m_scale_param;
90      CGparameter m_pos_timestep_param, m_pos_spherePos_param;
91    */
92    static NvParticleAdvectionShader* _advectionShader;
93
94    /**
95     * @brief scale of flow data
96     */
97    Vector3 scale;
98
99    Vector3 origin;
100
101    bool _activate;
102
103    float _slice_pos;
104    int _slice_axis;
105    Vector4 _color;
106
107public:
108    int psys_width;     //the storage of particles is implemented as a 2D array.
109    int psys_height;
110
111    NvParticleRenderer(int w, int h, CGcontext context);
112    ~NvParticleRenderer();
113    void setVectorField(unsigned int texID, const Vector3& ori, float scaleX, float scaleY, float scaleZ, float max);
114    void initialize();
115    void advect();
116    void update_vertex_buffer();
117    void display_vertices();
118    void reset();
119    void render();
120
121    bool active(void) {
122        return _activate;
123    }
124    void active(bool state) {
125        _activate = state;
126    }
127    void setColor(const Vector4& color) {
128        _color = color;
129    }
130    void setAxis(int axis);
131    void setPos(float pos);
132    void draw_bounding_box(float x0, float y0, float z0,
133                           float x1, float y1, float z1,
134                           float r, float g, float b, float line_width);
135    void initializeDataArray();
136    void particleSize(float size) {
137        _particleSize = size;
138    }
139    float particleSize(void) {
140        return _particleSize;
141    }
142};
143
144#endif
Note: See TracBrowser for help on using the repository browser.