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