ShishGL  1.0
A simple modular cross-platform graphics library
SphereCast.hpp
Go to the documentation of this file.
1 /*============================================================================*/
2 #ifndef RAY_CASTING_SPHERE_CAST_HPP
3 #define RAY_CASTING_SPHERE_CAST_HPP
4 /*============================================================================*/
5 
6 #include "UICanvas.hpp"
7 #include "DefaultBehavior.hpp"
8 #include "Vector3.hpp"
9 
10 /*============================================================================*/
11 
12 class SphereCanvas : public Sh::UICanvas {
13 public:
14 
15  SphereCanvas(const Sh::Frame& frame,
16  const int64_t& radius,
17  const Sh::Color& sphere_color,
18  const Sh::Color& floor_color,
19  const Sh::Color& light_color);
20 
21  ~SphereCanvas() override = default;
22 
23 private:
24 
25  friend class CanvasBehavior;
26 
27  void update();
28 
29  Sh::Vector3<double> camera_position{0, 0, 1000};
30  Sh::Vector3<double> light_source_position{400, 0, -400};
31 
32  static constexpr double ANGLE_STEP = 0.05;
33  static constexpr uint8_t BG_LIGHT_INTENSITY = 40;
34 
35  const double SOURCE_RADIUS = light_source_position.x;
36  double source_angle = 0;
37 
38  const int64_t sphere_radius;
39 
40  Sh::Color sphere_color,
41  floor_color,
42  light_color;
43 
44  void onRender() override;
45 
46  Sh::Color dot_color(double x, double y,
47  const Sh::Vector3<double>& light_source_pos);
48 
49 };
50 
51 /*----------------------------------------------------------------------------*/
52 
54 public:
55 
57 
58  bool onTimer(Sh::TimerEvent& event) override;
59 
60 };
61 
62 /*============================================================================*/
63 #endif //RAY_CASTING_SPHERE_CAST_HPP
64 /*============================================================================*/
Sh::DefaultBehavior
Definition: DefaultBehavior.hpp:14
SphereCanvas::~SphereCanvas
~SphereCanvas() override=default
Vector3.hpp
Sh::Frame
Definition: Frame.hpp:9
CanvasBehavior::CanvasBehavior
CanvasBehavior(Sh::UIWindow *target)
Definition: SphereCast.cpp:104
CanvasBehavior
Definition: SphereCast.hpp:53
Sh::Behavior::target
SomeWindow * target() const
Definition: Behavior.hpp:17
Sh::UICanvas
Definition: UICanvas.hpp:10
Sh::Vector3< double >
Sh::UIWindow
Definition: UIWindow.hpp:16
DefaultBehavior.hpp
Sh::TimerEvent
Definition: TimerEvent.hpp:11
CanvasBehavior::onTimer
bool onTimer(Sh::TimerEvent &event) override
Definition: SphereCast.cpp:112
Sh::Color
Definition: Color.hpp:9
UICanvas.hpp
Sh::Vector3::x
T x
Definition: Vector3.hpp:15
SphereCanvas
Definition: SphereCast.hpp:12
SphereCanvas::SphereCanvas
SphereCanvas(const Sh::Frame &frame, const int64_t &radius, const Sh::Color &sphere_color, const Sh::Color &floor_color, const Sh::Color &light_color)
Definition: SphereCast.cpp:11