24 #include "generic/object_manager.h"
25 #include "generic/managed.h"
26 #include "generic/generic_tree.h"
27 #include "generic/data_carrier.h"
28 #include "threads/atomic.h"
30 #include "managers/window_holder.h"
32 #include "nodes/skies/skybox_manager.h"
33 #include "nodes/sprites/sprite_manager.h"
34 #include "nodes/actor.h"
35 #include "nodes/geom.h"
36 #include "nodes/particle_system.h"
37 #include "nodes/stage_node.h"
38 #include "nodes/light.h"
39 #include "nodes/mesh_instancer.h"
40 #include "nodes/stage_node_manager.h"
43 #include "asset_manager.h"
46 #include "stage_manager.h"
59 typedef StageNodeManager<StageNodePool, ActorID, Actor> ActorManager;
60 typedef StageNodeManager<StageNodePool, GeomID, Geom> GeomManager;
61 typedef StageNodeManager<StageNodePool, LightID, Light> LightManager;
62 typedef StageNodeManager<StageNodePool, ParticleSystemID, ParticleSystem> ParticleSystemManager;
63 typedef StageNodeManager<StageNodePool, CameraID, Camera> CameraManager;
64 typedef StageNodeManager<StageNodePool, MeshInstancerID, MeshInstancer> MeshInstancerManager;
66 typedef sig::signal<void (StageNode*, StageNodeType)> StageNodeCreatedSignal;
67 typedef sig::signal<void (StageNode*, StageNodeType)> StageNodeDestroyedSignal;
69 typedef sig::signal<void (CameraID, Viewport)> StagePreRenderSignal;
70 typedef sig::signal<void (CameraID, Viewport)> StagePostRenderSignal;
72 extern const Colour DEFAULT_LIGHT_COLOUR;
95 AvailablePartitioner partitioner
101 ActorPtr new_actor_with_name(
const std::string& name);
104 ActorPtr new_actor_with_name_and_mesh(
const std::string& name,
MeshID mid);
111 bool has_actor(
ActorID e)
const;
113 std::size_t actor_count()
const;
151 CameraPtr new_camera_with_orthographic_projection(
double left=0,
double right=0,
double bottom=0,
double top=0,
double near=-1.0,
double far=1.0);
156 uint32_t camera_count()
const;
158 void destroy_all_cameras();
161 GeomPtr new_geom_with_mesh_at_position(
168 bool has_geom(
GeomID geom_id)
const;
169 void destroy_geom(
GeomID geom_id);
170 std::size_t geom_count()
const;
177 std::size_t particle_system_count()
const;
183 void destroy_light(
LightID light_id);
184 std::size_t light_count()
const;
186 smlt::Colour ambient_light()
const {
return ambient_light_; }
187 void set_ambient_light(
const smlt::Colour& c) { ambient_light_ = c; }
189 void move(
float x,
float y,
float z) {
194 throw std::logic_error(
"You cannot move the stage");
197 bool init()
override;
198 void clean_up()
override;
201 void update(
float dt)
override;
203 const AABB& aabb()
const override {
return aabb_; }
204 const AABB transformed_aabb()
const override {
return aabb_; }
207 Debug* enable_debug(
bool v=
true);
210 void destroy_object(
Actor*
object);
211 void destroy_object(
Light*
object);
212 void destroy_object(
Camera*
object);
213 void destroy_object(
Geom*
object);
217 void destroy_object_immediately(
Actor*
object);
218 void destroy_object_immediately(
Light*
object);
219 void destroy_object_immediately(
Camera*
object);
220 void destroy_object_immediately(
Geom*
object);
224 bool is_part_of_active_pipeline()
const {
225 return active_pipeline_count_ > 0;
229 UniqueIDKey make_key()
const override {
230 return make_unique_id_key(
id());
237 std::shared_ptr<Partitioner> partitioner_;
239 void set_partitioner(AvailablePartitioner partitioner);
241 std::shared_ptr<Debug> debug_;
245 std::shared_ptr<AssetManager> asset_manager_;
246 std::unique_ptr<ui::UIManager> ui_;
252 std::unique_ptr<GeomManager> geom_manager_;
253 std::unique_ptr<SkyManager> sky_manager_;
254 std::unique_ptr<SpriteManager> sprite_manager_;
255 std::unique_ptr<MeshInstancerManager> mesh_instancer_manager_;
256 std::unique_ptr<ActorManager> actor_manager_;
257 std::unique_ptr<ParticleSystemManager> particle_system_manager_;
258 std::unique_ptr<LightManager> light_manager_;
259 std::unique_ptr<CameraManager> camera_manager_;
269 void on_actor_created(
ActorID actor_id);
270 void on_actor_destroyed(
ActorID actor_id);
272 void clean_up_dead_objects();
275 Property<decltype(&Stage::debug_)> debug = {
this, &Stage::debug_};
276 Property<decltype(&Stage::partitioner_)> partitioner = {
this, &Stage::partitioner_};
277 Property<decltype(&Stage::asset_manager_)> assets = {
this, &Stage::asset_manager_};
278 Property<decltype(&Stage::data_)> data = {
this, &Stage::data_};
279 Property<decltype(&Stage::ui_)> ui = {
this, &Stage::ui_};
280 Property<decltype(&Stage::sky_manager_)> skies = {
this, &Stage::sky_manager_};
281 Property<decltype(&Stage::sprite_manager_)> sprites = {
this, &Stage::sprite_manager_};