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 (
const ActorID&)> ActorCreatedSignal;
67 typedef sig::signal<void (
const ActorID&)> ActorDestroyedSignal;
69 typedef sig::signal<void (GeomID)> GeomCreatedSignal;
70 typedef sig::signal<void (GeomID)> GeomDestroyedSignal;
72 typedef sig::signal<void (ParticleSystemID)> ParticleSystemCreatedSignal;
73 typedef sig::signal<void (ParticleSystemID)> ParticleSystemDestroyedSignal;
75 typedef sig::signal<void (CameraID)> CameraCreatedSignal;
76 typedef sig::signal<void (CameraID)> CameraDestroyedSignal;
78 typedef sig::signal<void (CameraID, Viewport)> StagePreRenderSignal;
79 typedef sig::signal<void (CameraID, Viewport)> StagePostRenderSignal;
81 typedef sig::signal<void (MeshInstancerID)> MeshInstancerCreatedSignal;
82 typedef sig::signal<void (MeshInstancerID)> MeshInstancerDestroyedSignal;
84 extern const Colour DEFAULT_LIGHT_COLOUR;
110 AvailablePartitioner partitioner
116 ActorPtr new_actor_with_name(
const std::string& name);
119 ActorPtr new_actor_with_name_and_mesh(
const std::string& name,
MeshID mid);
126 bool has_actor(
ActorID e)
const;
128 std::size_t actor_count()
const;
166 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);
171 uint32_t camera_count()
const;
173 void destroy_all_cameras();
176 GeomPtr new_geom_with_mesh_at_position(
183 bool has_geom(
GeomID geom_id)
const;
184 void destroy_geom(
GeomID geom_id);
185 std::size_t geom_count()
const;
192 std::size_t particle_system_count()
const;
198 void destroy_light(
LightID light_id);
199 std::size_t light_count()
const;
201 smlt::Colour ambient_light()
const {
return ambient_light_; }
202 void set_ambient_light(
const smlt::Colour& c) { ambient_light_ = c; }
204 void move(
float x,
float y,
float z) {
209 throw std::logic_error(
"You cannot move the stage");
212 bool init()
override;
213 void clean_up()
override;
216 void update(
float dt)
override;
228 sig::signal<void (
LightID)>& signal_light_destroyed() {
return signal_light_destroyed_; }
230 const AABB& aabb()
const override {
return aabb_; }
231 const AABB transformed_aabb()
const override {
return aabb_; }
234 Debug* enable_debug(
bool v=
true);
237 void destroy_object(
Actor*
object);
238 void destroy_object(
Light*
object);
239 void destroy_object(
Camera*
object);
240 void destroy_object(
Geom*
object);
244 void destroy_object_immediately(
Actor*
object);
245 void destroy_object_immediately(
Light*
object);
246 void destroy_object_immediately(
Camera*
object);
247 void destroy_object_immediately(
Geom*
object);
251 bool is_part_of_active_pipeline()
const {
252 return active_pipeline_count_ > 0;
275 std::shared_ptr<Partitioner> partitioner_;
277 void set_partitioner(AvailablePartitioner partitioner);
279 std::shared_ptr<Debug> debug_;
283 std::shared_ptr<AssetManager> asset_manager_;
284 std::unique_ptr<ui::UIManager> ui_;
290 std::unique_ptr<GeomManager> geom_manager_;
291 std::unique_ptr<SkyManager> sky_manager_;
292 std::unique_ptr<SpriteManager> sprite_manager_;
293 std::unique_ptr<MeshInstancerManager> mesh_instancer_manager_;
294 std::unique_ptr<ActorManager> actor_manager_;
295 std::unique_ptr<ParticleSystemManager> particle_system_manager_;
296 std::unique_ptr<LightManager> light_manager_;
297 std::unique_ptr<CameraManager> camera_manager_;
307 void on_actor_created(
ActorID actor_id);
308 void on_actor_destroyed(
ActorID actor_id);
310 void clean_up_dead_objects();
313 Property<decltype(&Stage::debug_)> debug = {
this, &Stage::debug_};
314 Property<decltype(&Stage::partitioner_)> partitioner = {
this, &Stage::partitioner_};
315 Property<decltype(&Stage::asset_manager_)> assets = {
this, &Stage::asset_manager_};
316 Property<decltype(&Stage::data_)> data = {
this, &Stage::data_};
317 Property<decltype(&Stage::ui_)> ui = {
this, &Stage::ui_};
318 Property<decltype(&Stage::sky_manager_)> skies = {
this, &Stage::sky_manager_};
319 Property<decltype(&Stage::sprite_manager_)> sprites = {
this, &Stage::sprite_manager_};