source: nanovis/trunk/ParticleRenderer.h @ 4587

Last change on this file since 4587 was 3631, checked in by ldelgass, 7 years ago

Refactor names in particle renderer to match other classes

  • Property svn:eol-style set to native
File size: 2.5 KB
Line 
1/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2/*
3 *  Copyright (c) 2004-2013  HUBzero Foundation, LLC
4 *
5 *  Authors:
6 *    Wei Qiao <qiaow@purdue.edu>
7 */
8#ifndef NV_PARTICLE_RENDERER_H
9#define NV_PARTICLE_RENDERER_H
10
11#include <GL/glew.h>
12
13#include <vrmath/Vector3f.h>
14#include <vrmath/Color4f.h>
15
16#include "FlowTypes.h"
17#include "Volume.h"
18#include "ParticleAdvectionShader.h"
19#include "RenderVertexArray.h"
20
21namespace nv {
22
23struct Particle {
24    float x;
25    float y;
26    float z;
27    float life;
28
29    Particle()
30    {}
31
32    Particle(float _x, float _y, float _z, float _life) :
33        x(_x),
34        y(_y),
35        z(_z),
36        life(_life)
37    {}
38};
39
40class ParticleRenderer
41{
42public:
43    ParticleRenderer(int w, int h);
44
45    ~ParticleRenderer();
46
47    void setVectorField(Volume *volume);
48
49    void initialize();
50
51    void advect();
52
53    void reset();
54
55    void render();
56
57    bool active() const
58    {
59        return _activate;
60    }
61
62    void active(bool state)
63    {
64        _activate = state;
65    }
66
67    void setColor(const vrmath::Color4f& color)
68    {
69        _color = color;
70    }
71
72    void setSliceAxis(FlowSliceAxis axis);
73
74    FlowSliceAxis getSliceAxis() const
75    {
76        return _sliceAxis;
77    }
78
79    void setSlicePosition(float pos);
80
81    float getSlicePosition() const
82    {
83        return _slicePos;
84    }
85
86    void particleSize(float size)
87    {
88        _particleSize = size;
89    }
90
91    float particleSize() const
92    {
93        return _particleSize;
94    }
95
96private:
97    void initializeDataArray();
98
99    void updateVertexBuffer();
100
101    ParticleAdvectionShader *_advectionShader;
102
103    /// frame buffer objects: two are defined, flip them as input output every step
104    GLuint _psysFbo[2];
105
106    /// color textures attached to frame buffer objects
107    GLuint _psysTex[2];
108    GLuint _initPosTex;
109    Particle *_data;
110
111    /// Count the frame number of particle system iteration
112    unsigned int _psysFrame;
113
114    /// Reinitiate particles
115    bool _reborn;
116
117    /// flip the source and destination render targets
118    bool _flip;
119
120    float _maxLife;
121
122    /// Size of the particle: default is 1.2
123    float _particleSize;
124
125    /// vertex array for display particles
126    RenderVertexArray *_vertexArray;
127
128    /// scale of flow data
129    vrmath::Vector3f _scale;
130
131    vrmath::Vector3f _origin;
132
133    bool _activate;
134
135    float _slicePos;
136    FlowSliceAxis _sliceAxis;
137
138    vrmath::Color4f _color;
139
140    //the storage of particles is implemented as a 2D array.
141    int _psysWidth;
142    int _psysHeight;
143};
144
145}
146
147#endif
Note: See TracBrowser for help on using the repository browser.