source: trunk/packages/vizservers/nanovis/NvLIC.h @ 1970

Last change on this file since 1970 was 1515, checked in by gah, 15 years ago
File size: 3.4 KB
Line 
1/*
2 * ----------------------------------------------------------------------
3 * NvLIC.h: line integral convolution class
4 *
5 * ======================================================================
6 *  AUTHOR:  Wei Qiao <qiaow@purdue.edu>
7 *           Purdue Rendering and Perceptualization Lab (PURPL)
8 *
9 *  Copyright (c) 2004-2006  Purdue Research Foundation
10 *
11 *  See the file "license.terms" for information on usage and
12 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
13 * ======================================================================
14 */
15
16
17#ifndef _NV_LIC_H_
18#define _NV_LIC_H_
19
20#include "GL/glew.h"
21#include "Cg/cgGL.h"
22
23#include "define.h"
24#include "config.h"
25#include "global.h"
26
27#include "Renderable.h"
28#include "Vector3.h"
29#include "Volume.h"
30
31#define NPN 256   //resolution of background pattern
32#define NMESH 256 //resolution of flow mesh
33#define DM ((float) (1.0/(NMESH-1.0))) //distance in world coords between mesh lines
34#define NPIX  512 //display size 
35#define SCALE 3.0 //scale for background pattern. small value -> fine texture
36
37class NvLIC : public Renderable {
38
39private:
40    GLuint disListID;
41
42    int width, height;
43    int size;                           // The lic is a square of size, it can
44                                        // be stretched
45    float* slice_vector;                // Storage for the per slice vectors
46                                        // driving the follow.
47    Vector3 scale;                      // Scaling factor stretching the lic
48                                        // plane to fit the actual dimensions
49    Vector3 origin;
50    Vector3 offset;                     // [0,1] offset could be x, y, or z
51                                        // direction
52    int axis;
53
54    //some convolve variables. They can pretty much stay fixed
55    int iframe;
56    int Npat;
57    int alpha;
58    float sa;
59    float tmax;
60    float dmax;
61    float max;
62   
63    //CG shader parameters
64    CGcontext m_g_context;
65    CGparameter m_vel_tex_param;
66    CGparameter m_vel_tex_param_render_vel, m_plane_normal_param_render_vel;
67    CGprogram m_render_vel_fprog;
68    CGparameter m_max_param;
69   
70    GLuint color_tex, pattern_tex, mag_tex;
71    GLuint fbo, vel_fbo, slice_vector_tex;  // For projecting 3d vector to 2d
72                                            // vector on a plane.
73    GLuint _vectorFieldId;
74
75    Volume* _vectorField;
76    /**
77     * flag for rendering
78     */
79    bool _activate;
80    bool _isHidden;                     // Indicates if LIC plane is displayed.
81public:
82    Vector3 normal; //the normal vector of the NvLIC plane,
83    //the inherited Vector3 location is its center
84    NvLIC(int _size, int _width, int _height, int axis,
85          const Vector3& _offset, CGcontext _context);
86    ~NvLIC();
87
88    /**
89     * @brief project 3D vectors to a 2D slice for line integral convolution
90     */
91    void convolve();
92
93    void display(void);                 // Display the convolution result
94    void render(void);
95    void make_patterns();
96    void make_magnitudes();
97    void get_velocity(float x, float y, float* px, float* py);
98    void get_slice();
99    void set_offset(float v);
100    /**
101     * @brief Specify the perdicular axis
102     * @brief 0 : x axis
103     * @brief 1 : y axis
104     * @brief 2 : z axis
105     */
106    void set_axis(int axis);
107
108    void setVectorField(unsigned int texID, const Vector3& ori, float scaleX, float scaleY, float scaleZ, float max);
109
110    void reset(void);
111    void visible(bool state) {
112        _isHidden = !state;
113    }
114    bool visible(void) {
115        return (!_isHidden);
116    }
117    void active(bool state) {
118        _activate = state;
119    }
120    bool active(void) {
121        return _activate;
122    }
123};
124
125
126#endif
Note: See TracBrowser for help on using the repository browser.