Simulant  21.12-194
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 TypedDestroyableObject<Skybox, SkyManager>,
37  public generic::Identifiable<SkyID>,
38  public ContainerNode,
39  public ChainNameable<Skybox> {
40 
41 public:
42  constexpr static float DEFAULT_SIZE = 128.0f;
43 
44  Skybox(SkyManager* manager);
45 
46  bool init() override;
47  void clean_up() override;
48 
49  void set_size(float size) { width_ = size; }
50  float size() const { return width_; }
51 
52  void generate(
53  const Path& up,
54  const Path& down,
55  const Path& left,
56  const Path& right,
57  const Path& front,
58  const Path& back,
59  const TextureFlags& flags
60  );
61 
62  void destroy() override;
63  void destroy_immediately() override;
64 
65  const AABB& aabb() const override;
66 
67  void update(float step) override {
68  _S_UNUSED(step);
69  }
70 
71 private:
72  friend class SkyManager;
73 
74  SkyManager* manager_ = nullptr;
75 
76  CameraID follow_camera_;
77 
78  ActorPtr actor_ = nullptr;
79  MeshID mesh_id_;
80 
81  MaterialID materials_[SKYBOX_FACE_MAX];
82 
83  float width_;
84 };
85 
86 }
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:285
smlt::UniqueID< CameraPtr >
smlt::TypedDestroyableObject
Definition: manual_object.h:33
smlt::Path
Definition: path.h:7
smlt::ChainNameable
Definition: nameable.h:34
smlt::AABB
Definition: aabb.h:22
smlt::Skybox
Definition: skybox.h:39
smlt::SkyManager
Definition: skybox_manager.h:39
smlt::default_init_ptr< Actor >
smlt::SkyboxImageNotFoundError
Definition: skybox.h:21