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

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

Convert NvLIC to use new NvShader? parameter API. Also fixes for LIC when plane
is not XY plane. Remove unused/incomplete Renderable base class (source files
remain for now, but it is not part of default build).

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