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

Last change on this file since 2849 was 2844, checked in by ldelgass, 12 years ago

Cleanups, no functional changes

  • Property svn:eol-style set to native
File size: 3.0 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#ifndef NVPARTICLERENDERER_H
17#define NVPARTICLERENDERER_H
18
19#include <vector>
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#include "NvParticleAdvectionShader.h"
32
33struct Particle {
34    float x;
35    float y;
36    float z;
37    float aux;
38
39    Particle()
40    {}
41
42    Particle(float _x, float _y, float _z, float _life) :
43        x(_x), y(_y), z(_z), aux(_life)
44    {}
45};
46
47class NvParticleRenderer : public Renderable
48{
49public:
50    NvParticleRenderer(int w, int h, CGcontext context);
51
52    ~NvParticleRenderer();
53
54    void setVectorField(unsigned int texID, const Vector3& ori,
55                        float scaleX, float scaleY, float scaleZ, float max);
56
57    void initialize();
58
59    void advect();
60
61    void update_vertex_buffer();
62
63    void display_vertices();
64
65    void reset();
66
67    void render();
68
69    bool active() const
70    {
71        return _activate;
72    }
73
74    void active(bool state)
75    {
76        _activate = state;
77    }
78
79    void setColor(const Vector4& color)
80    {
81        _color = color;
82    }
83
84    void setAxis(int axis);
85
86    void setPos(float pos);
87
88    void draw_bounding_box(float x0, float y0, float z0,
89                           float x1, float y1, float z1,
90                           float r, float g, float b, float line_width);
91
92    void initializeDataArray();
93
94    void particleSize(float size)
95    {
96        _particleSize = size;
97    }
98
99    float particleSize() const
100    {
101        return _particleSize;
102    }
103
104   static NvParticleAdvectionShader *_advectionShader;
105
106private:
107    /// frame buffer objects: two are defined, flip them as input output every step
108    GLuint psys_fbo[2];         
109
110    /// color textures attached to frame buffer objects
111    GLuint psys_tex[2];
112    GLuint initPosTex; 
113    Particle *data;
114
115    /// Count the frame number of particle system iteration
116    int psys_frame;         
117
118    /// Reinitiate particles
119    bool reborn;                       
120
121    /// flip the source and destination render targets
122    bool flip;                 
123
124    float max_life;
125
126    /// Size of the particle: default is 1.2
127    float _particleSize;
128
129    /// vertex array for display particles
130    RenderVertexArray *_vertex_array;   
131
132    /// scale of flow data
133    Vector3 scale;
134
135    Vector3 origin;
136
137    bool _activate;
138
139    float _slice_pos;
140    int _slice_axis;
141
142    Vector4 _color;
143
144    //the storage of particles is implemented as a 2D array.
145    int psys_width;
146    int psys_height;
147};
148
149#endif
Note: See TracBrowser for help on using the repository browser.