source: branches/nanovis2/packages/vizservers/nanovis/NvParticleRenderer.h @ 3351

Last change on this file since 3351 was 3305, checked in by ldelgass, 12 years ago

sync with trunk

  • Property svn:eol-style set to native
File size: 2.7 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-2012  HUBzero Foundation, LLC
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 <GL/glew.h>
20
21#include "NvParticleAdvectionShader.h"
22#include "RenderVertexArray.h"
23#include "Vector3.h"
24#include "Vector4.h"
25
26struct Particle {
27    float x;
28    float y;
29    float z;
30    float aux;
31
32    Particle()
33    {}
34
35    Particle(float _x, float _y, float _z, float _life) :
36        x(_x), y(_y), z(_z), aux(_life)
37    {}
38};
39
40class NvParticleRenderer
41{
42public:
43    NvParticleRenderer(int w, int h);
44
45    ~NvParticleRenderer();
46
47    void setVectorField(unsigned int texID, const Vector3& origin,
48                        float scaleX, float scaleY, float scaleZ, float max);
49
50    void initialize();
51
52    void advect();
53
54    void updateVertexBuffer();
55
56    void reset();
57
58    void render();
59
60    bool active() const
61    {
62        return _activate;
63    }
64
65    void active(bool state)
66    {
67        _activate = state;
68    }
69
70    void setColor(const Vector4& color)
71    {
72        _color = color;
73    }
74
75    void setAxis(int axis);
76
77    void setPos(float pos);
78
79    void initializeDataArray();
80
81    void particleSize(float size)
82    {
83        _particleSize = size;
84    }
85
86    float particleSize() const
87    {
88        return _particleSize;
89    }
90
91   static NvParticleAdvectionShader *_advectionShader;
92
93private:
94    /// frame buffer objects: two are defined, flip them as input output every step
95    GLuint _psysFbo[2];
96
97    /// color textures attached to frame buffer objects
98    GLuint _psysTex[2];
99    GLuint _initPosTex;
100    Particle *_data;
101
102    /// Count the frame number of particle system iteration
103    int _psysFrame;
104
105    /// Reinitiate particles
106    bool _reborn;
107
108    /// flip the source and destination render targets
109    bool _flip;
110
111    float _maxLife;
112
113    /// Size of the particle: default is 1.2
114    float _particleSize;
115
116    /// vertex array for display particles
117    RenderVertexArray *_vertexArray;
118
119    /// scale of flow data
120    Vector3 _scale;
121
122    Vector3 _origin;
123
124    bool _activate;
125
126    float _slicePos;
127    int _sliceAxis;
128
129    Vector4 _color;
130
131    //the storage of particles is implemented as a 2D array.
132    int _psysWidth;
133    int _psysHeight;
134};
135
136#endif
Note: See TracBrowser for help on using the repository browser.