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