Simulant  21.09-46
A portable game engine for Windows, OSX, Linux, Dreamcast, and PSP
skybox.h
1 #pragma once
2 
3 #include <stdexcept>
4 #include "../stage_node.h"
5 #include "../../generic/identifiable.h"
6 #include "../../path.h"
7 #include "../../asset_manager.h"
8 
9 namespace smlt {
10 
11 enum SkyboxFace {
12  SKYBOX_FACE_TOP,
13  SKYBOX_FACE_BOTTOM,
14  SKYBOX_FACE_LEFT,
15  SKYBOX_FACE_RIGHT,
16  SKYBOX_FACE_FRONT,
17  SKYBOX_FACE_BACK,
18  SKYBOX_FACE_MAX
19 };
20 
21 class SkyboxImageNotFoundError : public std::runtime_error {
22 public:
23  SkyboxImageNotFoundError(const std::string& what):
24  std::runtime_error(what) {}
25 };
26 
27 class SkyboxImageDuplicateError : public std::runtime_error {
28 public:
29  SkyboxImageDuplicateError(const std::string& what):
30  std::runtime_error(what) {}
31 };
32 
33 class SkyManager;
34 
35 class Skybox :
36  public generic::Identifiable<SkyID>,
37  public ContainerNode,
38  public ChainNameable<Skybox> {
39 
40 public:
41  constexpr static float DEFAULT_SIZE = 128.0f;
42 
43  Skybox(SkyManager* manager);
44 
45  bool init() override;
46  void clean_up() override;
47 
48  void set_size(float size) { width_ = size; }
49  float size() const { return width_; }
50 
51  void generate(
52  const Path& up,
53  const Path& down,
54  const Path& left,
55  const Path& right,
56  const Path& front,
57  const Path& back,
58  const TextureFlags& flags
59  );
60 
61  void destroy() override;
62  void destroy_immediately() override;
63 
64  const AABB& aabb() const override;
65 
66  void update(float step) override {
67  _S_UNUSED(step);
68  }
69 
70 private:
71  friend class SkyManager;
72 
73  SkyManager* manager_ = nullptr;
74 
75  CameraID follow_camera_;
76 
77  ActorPtr actor_ = nullptr;
78  MeshID mesh_id_;
79 
80  MaterialID materials_[SKYBOX_FACE_MAX];
81 
82  float width_;
83 };
84 
85 }
smlt::TextureFlags
Definition: asset_manager.h:47
smlt::SkyboxImageDuplicateError
Definition: skybox.h:27
smlt
Definition: animation.cpp:25
smlt::generic::Identifiable
Definition: identifiable.h:26
smlt::ContainerNode
Definition: stage_node.h:284
smlt::UniqueID< CameraPtr >
smlt::Path
Definition: path.h:7
smlt::ChainNameable
Definition: nameable.h:34
smlt::AABB
Definition: aabb.h:22
smlt::Skybox
Definition: skybox.h:38
smlt::SkyManager
Definition: skybox_manager.h:39
smlt::default_init_ptr< Actor >
smlt::SkyboxImageNotFoundError
Definition: skybox.h:21