Virtual Testbed
Ship dynamics simulator for extreme conditions
WavySurfaceObject.hh
1 #ifndef VTESTBED_GRAPHICS_WAVYSURFACEOBJECT_HH
2 #define VTESTBED_GRAPHICS_WAVYSURFACEOBJECT_HH
3 
4 #include <blitz/array.h>
5 
6 #include <vtestbed/core/types.hh>
7 #include <vtestbed/graphics/AxisSurface.hh>
8 #include <vtestbed/graphics/GerstnerSurface.hh>
9 #include <vtestbed/graphics/WavySurface.hh>
10 #include <vtestbed/graphics/WavySurfaceSlice.hh>
11 #include <vtestbed/graphics/types.hh>
12 
13 namespace vtb {
14 
15  namespace graphics {
16 
17  template <class T>
18  class WavySurfaceObject: public Object3D, public Drawable3D {
19 
20  public:
21  using array2 = vtb::core::Array2<T>;
22  using array3 = vtb::core::Array3<T>;
23  using array4 = vtb::core::Array4<T>;
27  using int2 = vtb::core::int2;
28  using vec2 = vtb::core::Vector2<T>;
29  using vec3 = vtb::core::Vector3<T>;
30  using gerstner_type = vtb::core::Array2<vec3>;
32 
33  private:
34  DrawableGroup3D _drawables;
35  AxisSurface _axis;
36  WavySurface<T> _regularSurface;
37  GerstnerSurface<T> _irregularSurface;
38  WavySurfaceSlice<T> _sliceXZ{0}, _sliceYZ{1};
39  bool _show = true;
40  bool _showSurface = true;
41  bool _irregular = true;
42 
43  public:
44 
46 
47  void draw(const Matrix4& m, Camera3D& camera) override;
48  void step(const testbed_type& testbed);
49  void step_irregular(const testbed_type& testbed);
50  void step_regular(const testbed_type& testbed);
51  void init(const testbed_type& testbed);
52 
53  inline void show(bool b) { this->_show = b; }
54  inline void showAxes(bool b) { _axis.show(b); }
55 
56  inline void
57  showWavySurface(bool b) {
58  if (_irregular) {
59  this->_irregularSurface.show(b);
60  } else {
61  this->_regularSurface.show(b);
62  }
63  }
64 
65  inline void
66  showVelocityPotential(bool b) {
67  if (_irregular) {
68  this->_irregularSurface.showSlice(b);
69  } else {
70  this->_regularSurface.showSlice(b);
71  }
72  this->_sliceXZ.show(b);
73  this->_sliceYZ.show(b);
74  }
75 
76  };
77 
78  }
79 
80 }
81 
82 #endif // vim:filetype=cpp
Main namespace.
Definition: convert.hh:9