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