1 | /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ |
---|
2 | /* |
---|
3 | * ---------------------------------------------------------------------- |
---|
4 | * NvLIC.h: line integral convolution class |
---|
5 | * |
---|
6 | * ====================================================================== |
---|
7 | * AUTHOR: Wei Qiao <qiaow@purdue.edu> |
---|
8 | * Purdue Rendering and Perceptualization Lab (PURPL) |
---|
9 | * |
---|
10 | * Copyright (c) 2004-2012 HUBzero Foundation, LLC |
---|
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 | */ |
---|
16 | #ifndef NV_LIC_H |
---|
17 | #define NV_LIC_H |
---|
18 | |
---|
19 | #include <GL/glew.h> |
---|
20 | |
---|
21 | #include "Vector3.h" |
---|
22 | #include "Volume.h" |
---|
23 | #include "NvShader.h" |
---|
24 | |
---|
25 | class NvLIC |
---|
26 | { |
---|
27 | public: |
---|
28 | NvLIC(int size, int width, int height, int axis, float offset); |
---|
29 | ~NvLIC(); |
---|
30 | |
---|
31 | /// project 3D vectors to a 2D slice for line integral convolution |
---|
32 | void convolve(); |
---|
33 | |
---|
34 | /// Display the convolution result |
---|
35 | void render(); |
---|
36 | |
---|
37 | void makePatterns(); |
---|
38 | |
---|
39 | void makeMagnitudes(); |
---|
40 | |
---|
41 | void getVelocity(float x, float y, float *px, float *py); |
---|
42 | |
---|
43 | void getSlice(); |
---|
44 | |
---|
45 | void setOffset(float offset); |
---|
46 | |
---|
47 | /** |
---|
48 | * @brief Specify the perpendicular axis |
---|
49 | * |
---|
50 | * 0 : x axis<br> |
---|
51 | * 1 : y axis<br> |
---|
52 | * 2 : z axis<br> |
---|
53 | */ |
---|
54 | void setAxis(int axis); |
---|
55 | |
---|
56 | void setVectorField(unsigned int texID, const Vector3& origin, |
---|
57 | float scaleX, float scaleY, float scaleZ, float max); |
---|
58 | |
---|
59 | void reset(); |
---|
60 | |
---|
61 | void visible(bool state) |
---|
62 | { |
---|
63 | _isHidden = !state; |
---|
64 | } |
---|
65 | |
---|
66 | bool visible() const |
---|
67 | { |
---|
68 | return (!_isHidden); |
---|
69 | } |
---|
70 | |
---|
71 | void active(bool state) |
---|
72 | { |
---|
73 | _activate = state; |
---|
74 | } |
---|
75 | |
---|
76 | bool active() const |
---|
77 | { |
---|
78 | return _activate; |
---|
79 | } |
---|
80 | |
---|
81 | private: |
---|
82 | /** |
---|
83 | * @brief the normal vector of the NvLIC plane, |
---|
84 | * the inherited Vector3 location is its center |
---|
85 | */ |
---|
86 | Vector3 _normal; |
---|
87 | |
---|
88 | int _width, _height; |
---|
89 | int _size; /**< The lic is a square of size, it can |
---|
90 | be stretched */ |
---|
91 | float *_sliceVector; /**< Storage for the per slice vectors |
---|
92 | driving the flow */ |
---|
93 | Vector3 _scale; /**< Scaling factor stretching the lic |
---|
94 | plane to fit the actual dimensions */ |
---|
95 | Vector3 _origin; |
---|
96 | float _offset; ///< [0,1] offset of slice plane |
---|
97 | int _axis; ///< Axis normal to slice plane |
---|
98 | |
---|
99 | //some convolve variables. They can pretty much stay fixed |
---|
100 | int _iframe; |
---|
101 | int _Npat; |
---|
102 | int _alpha; |
---|
103 | float _sa; |
---|
104 | float _tmax; |
---|
105 | float _dmax; |
---|
106 | float _max; |
---|
107 | |
---|
108 | GLuint _disListID; |
---|
109 | |
---|
110 | NvShader *_renderVelShader; |
---|
111 | |
---|
112 | GLuint _colorTex, _patternTex, _magTex; |
---|
113 | GLuint _fbo, _velFbo, _sliceVectorTex; // For projecting 3d vector to 2d |
---|
114 | // vector on a plane. |
---|
115 | GLuint _vectorFieldId; |
---|
116 | |
---|
117 | Volume *_vectorField; |
---|
118 | /** |
---|
119 | * flag for rendering |
---|
120 | */ |
---|
121 | bool _activate; |
---|
122 | bool _isHidden; // Indicates if LIC plane is displayed. |
---|
123 | }; |
---|
124 | |
---|
125 | #endif |
---|