source: nanovis/trunk/ParticleRenderer.h @ 5704

Last change on this file since 5704 was 5587, checked in by ldelgass, 5 years ago

Some fixes from release branch

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