1 | /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ |
---|
2 | #ifndef NV_VECTOR_FIELD_H |
---|
3 | #define NV_VECTOR_FIELD_H |
---|
4 | |
---|
5 | #include <string> |
---|
6 | #include <map> |
---|
7 | |
---|
8 | #include <vrmath/Vector3f.h> |
---|
9 | #include <vrmath/Vector4f.h> |
---|
10 | |
---|
11 | #include "Volume.h" |
---|
12 | #include "NvParticleRenderer.h" |
---|
13 | |
---|
14 | class NvDeviceShape |
---|
15 | { |
---|
16 | public: |
---|
17 | NvDeviceShape() : |
---|
18 | visible(true) |
---|
19 | { |
---|
20 | } |
---|
21 | |
---|
22 | vrmath::Vector3f min; |
---|
23 | vrmath::Vector3f max; |
---|
24 | vrmath::Vector4f color; |
---|
25 | bool visible; |
---|
26 | }; |
---|
27 | |
---|
28 | class NvVectorField |
---|
29 | { |
---|
30 | public : |
---|
31 | NvVectorField(); |
---|
32 | |
---|
33 | ~NvVectorField(); |
---|
34 | |
---|
35 | void setVectorField(Volume *vol, const vrmath::Vector3f& origin, |
---|
36 | float scaleX, float scaleY, float scaleZ, float max); |
---|
37 | |
---|
38 | bool active() |
---|
39 | { |
---|
40 | return _activated; |
---|
41 | } |
---|
42 | |
---|
43 | void active(bool state) |
---|
44 | { |
---|
45 | _activated = state; |
---|
46 | } |
---|
47 | |
---|
48 | void activateDeviceShape() |
---|
49 | { |
---|
50 | _deviceVisible = true; |
---|
51 | } |
---|
52 | |
---|
53 | void deactivateDeviceShape() |
---|
54 | { |
---|
55 | _deviceVisible = false; |
---|
56 | } |
---|
57 | |
---|
58 | void addDeviceShape(const std::string& name, const NvDeviceShape& shape); |
---|
59 | |
---|
60 | void removeDeviceShape(const std::string& name); |
---|
61 | |
---|
62 | void activateDeviceShape(const std::string& name); |
---|
63 | |
---|
64 | void deactivateDeviceShape(const std::string& name); |
---|
65 | |
---|
66 | void initialize(); |
---|
67 | |
---|
68 | void reset(); |
---|
69 | |
---|
70 | void addPlane(const std::string& name); |
---|
71 | |
---|
72 | void removePlane(const std::string& name); |
---|
73 | |
---|
74 | void advect(); |
---|
75 | |
---|
76 | void render(); |
---|
77 | |
---|
78 | void drawDeviceShape(); |
---|
79 | |
---|
80 | void activatePlane(const std::string& name); |
---|
81 | |
---|
82 | void deactivatePlane(const std::string& name); |
---|
83 | |
---|
84 | void setPlaneAxis(const std::string& name, int axis); |
---|
85 | |
---|
86 | void setPlanePos(const std::string& name, float pos); |
---|
87 | |
---|
88 | void setParticleColor(const std::string& name, float r, float g, float b, float a); |
---|
89 | |
---|
90 | void setParticleColor(const std::string& name, const vrmath::Vector4f& color); |
---|
91 | |
---|
92 | private: |
---|
93 | GLuint _vectorFieldId; |
---|
94 | Volume *_volPtr; |
---|
95 | std::map<std::string, NvParticleRenderer *> _particleRendererMap; |
---|
96 | std::map<std::string, NvDeviceShape> _shapeMap; |
---|
97 | |
---|
98 | /** |
---|
99 | * @brief Specify the visibility |
---|
100 | */ |
---|
101 | bool _activated; |
---|
102 | |
---|
103 | vrmath::Vector3f _origin; |
---|
104 | float _scaleX; |
---|
105 | float _scaleY; |
---|
106 | float _scaleZ; |
---|
107 | float _max; |
---|
108 | |
---|
109 | bool _deviceVisible; |
---|
110 | }; |
---|
111 | |
---|
112 | #endif |
---|