1 | /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ |
---|
2 | #ifndef VELOCITY_ARROW_SLICE_H |
---|
3 | #define VELOCITY_ARROW_SLICE_H |
---|
4 | |
---|
5 | #include <vector> |
---|
6 | |
---|
7 | #include <Cg/cg.h> |
---|
8 | #include <Cg/cgGL.h> |
---|
9 | |
---|
10 | #include "Texture2D.h" |
---|
11 | #include "Vector3.h" |
---|
12 | |
---|
13 | class VelocityArrowsSlice |
---|
14 | { |
---|
15 | public: |
---|
16 | enum RenderMode { |
---|
17 | LINES, |
---|
18 | GLYPHS, |
---|
19 | }; |
---|
20 | |
---|
21 | VelocityArrowsSlice(); |
---|
22 | |
---|
23 | ~VelocityArrowsSlice(); |
---|
24 | |
---|
25 | void vectorField(unsigned int vfGraphicsID, float xScale, float yScale, float zScale); |
---|
26 | |
---|
27 | void axis(int axis); |
---|
28 | |
---|
29 | int axis() const |
---|
30 | { |
---|
31 | return _axis; |
---|
32 | } |
---|
33 | |
---|
34 | void slicePos(float pos) |
---|
35 | { |
---|
36 | _slicePos = pos; |
---|
37 | _dirty = true; |
---|
38 | } |
---|
39 | |
---|
40 | float slicePos() const |
---|
41 | { |
---|
42 | return _slicePos; |
---|
43 | } |
---|
44 | |
---|
45 | void queryVelocity(); |
---|
46 | |
---|
47 | void render(); |
---|
48 | |
---|
49 | void enabled(bool enabled) |
---|
50 | { |
---|
51 | _enabled = enabled; |
---|
52 | } |
---|
53 | |
---|
54 | bool enabled() const |
---|
55 | { |
---|
56 | return _enabled; |
---|
57 | } |
---|
58 | |
---|
59 | void tickCountForMinSizeAxis(int tickCount) |
---|
60 | { |
---|
61 | _tickCountForMinSizeAxis = tickCount; |
---|
62 | } |
---|
63 | |
---|
64 | int tickCountForMinSizeAxis() const |
---|
65 | { |
---|
66 | return _tickCountForMinSizeAxis; |
---|
67 | } |
---|
68 | |
---|
69 | void arrowColor(const Vector3& color) |
---|
70 | { |
---|
71 | _arrowColor = color; |
---|
72 | } |
---|
73 | |
---|
74 | void renderMode(RenderMode mode) |
---|
75 | { |
---|
76 | _renderMode = mode; |
---|
77 | _dirty = true; |
---|
78 | } |
---|
79 | |
---|
80 | RenderMode renderMode() const |
---|
81 | { |
---|
82 | return _renderMode; |
---|
83 | } |
---|
84 | |
---|
85 | private: |
---|
86 | unsigned int _vectorFieldGraphicsID; |
---|
87 | float _vfXscale; |
---|
88 | float _vfYscale; |
---|
89 | float _vfZscale; |
---|
90 | float _slicePos; |
---|
91 | int _axis; |
---|
92 | |
---|
93 | unsigned int _fbo; |
---|
94 | unsigned int _tex; |
---|
95 | |
---|
96 | CGcontext _context; |
---|
97 | CGprogram _queryVelocityFP; |
---|
98 | CGparameter _qvVectorFieldParam; |
---|
99 | |
---|
100 | int _renderTargetWidth; |
---|
101 | int _renderTargetHeight; |
---|
102 | Vector3 *_velocities; |
---|
103 | std::vector<Vector3> _samplingPositions; |
---|
104 | Vector3 _projectionVector; |
---|
105 | |
---|
106 | int _tickCountForMinSizeAxis; |
---|
107 | int _tickCountX; |
---|
108 | int _tickCountY; |
---|
109 | int _tickCountZ; |
---|
110 | |
---|
111 | int _pointCount; |
---|
112 | |
---|
113 | Vector3 _maxVelocityScale; |
---|
114 | Vector3 _arrowColor; |
---|
115 | |
---|
116 | bool _enabled; |
---|
117 | bool _dirty; |
---|
118 | bool _dirtySamplingPosition; |
---|
119 | bool _dirtyRenderTarget; |
---|
120 | |
---|
121 | unsigned int _vertexBufferGraphicsID; |
---|
122 | |
---|
123 | CGprogram _particleVP; |
---|
124 | CGparameter _mvpParticleParam; |
---|
125 | CGparameter _mvParticleParam; |
---|
126 | CGparameter _mvTanHalfFOVParam; |
---|
127 | CGparameter _mvCurrentTimeParam; |
---|
128 | |
---|
129 | CGprogram _particleFP; |
---|
130 | CGparameter _vectorParticleParam; |
---|
131 | |
---|
132 | Texture2D *_arrowsTex; |
---|
133 | |
---|
134 | RenderMode _renderMode; |
---|
135 | |
---|
136 | void createRenderTarget(); |
---|
137 | |
---|
138 | void computeSamplingTicks(); |
---|
139 | }; |
---|
140 | |
---|
141 | #endif |
---|