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

Last change on this file since 3596 was 3502, checked in by ldelgass, 12 years ago

Add basic VTK structured points reader to nanovis, update copyright dates.

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