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