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

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

Cleanups, no functional changes

  • Property svn:eol-style set to native
File size: 3.0 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
[2837]19#include <vector>
[1333]20
[2837]21#include <GL/glew.h>
22#include <Cg/cgGL.h>
[1333]23
24#include "define.h"
25#include "config.h"
26#include "global.h"
27
28#include "Renderable.h"
29#include "RenderVertexArray.h"
30#include "Vector3.h"
31#include "NvParticleAdvectionShader.h"
32
33struct Particle {
[1497]34    float x;
35    float y;
36    float z;
37    float aux;
[1333]38
[2837]39    Particle()
40    {}
41
[1497]42    Particle(float _x, float _y, float _z, float _life) :
[2837]43        x(_x), y(_y), z(_z), aux(_life)
44    {}
[1333]45};
46
[2837]47class NvParticleRenderer : public Renderable
48{
49public:
50    NvParticleRenderer(int w, int h, CGcontext context);
[1333]51
[2837]52    ~NvParticleRenderer();
[1333]53
[2837]54    void setVectorField(unsigned int texID, const Vector3& ori,
55                        float scaleX, float scaleY, float scaleZ, float max);
[1333]56
[2837]57    void initialize();
[1333]58
[2837]59    void advect();
[1497]60
[2837]61    void update_vertex_buffer();
[1333]62
[2837]63    void display_vertices();
[1333]64
[2837]65    void reset();
[1333]66
67    void render();
68
[2837]69    bool active() const
70    {
[1431]71        return _activate;
72    }
[2837]73
74    void active(bool state)
75    {
[1431]76        _activate = state;
77    }
[2837]78
79    void setColor(const Vector4& color)
80    {
[1431]81        _color = color;
82    }
[2837]83
[1370]84    void setAxis(int axis);
[2837]85
[1370]86    void setPos(float pos);
[2837]87
[1431]88    void draw_bounding_box(float x0, float y0, float z0,
89                           float x1, float y1, float z1,
90                           float r, float g, float b, float line_width);
[2837]91
[1370]92    void initializeDataArray();
[2837]93
94    void particleSize(float size)
95    {
[1497]96        _particleSize = size;
97    }
[2837]98
99    float particleSize() const
100    {
[1497]101        return _particleSize;
102    }
[2837]103
104   static NvParticleAdvectionShader *_advectionShader;
105
106private:
107    /// frame buffer objects: two are defined, flip them as input output every step
108    GLuint psys_fbo[2];         
109
110    /// color textures attached to frame buffer objects
111    GLuint psys_tex[2];
112    GLuint initPosTex; 
113    Particle *data;
114
115    /// Count the frame number of particle system iteration
116    int psys_frame;         
117
118    /// Reinitiate particles
119    bool reborn;                       
120
121    /// flip the source and destination render targets
122    bool flip;                 
123
124    float max_life;
125
126    /// Size of the particle: default is 1.2
127    float _particleSize;
128
129    /// vertex array for display particles
130    RenderVertexArray *_vertex_array;   
131
132    /// scale of flow data
133    Vector3 scale;
134
135    Vector3 origin;
136
137    bool _activate;
138
139    float _slice_pos;
140    int _slice_axis;
141
142    Vector4 _color;
143
144    //the storage of particles is implemented as a 2D array.
145    int psys_width;
146    int psys_height;
[1333]147};
148
149#endif
Note: See TracBrowser for help on using the repository browser.