Brenta Engine 1.2
Loading...
Searching...
No Matches
scene.hpp
1// SPDX-License-Identifier: MIT
2// Author: Giovanni Santini
3// Mail: giovanni.santini@proton.me
4// Github: @San7o
5
6#pragma once
7
8#include <brenta/renderer/camera.hpp>
9
10#include <tenno/memory.hpp>
11
12#include <filesystem>
13
14namespace brenta
15{
16
17class Node;
18class NodeComponent;
19class Skybox;
20
21class RenderPipeline;
22
23//
24// Scene
25// -----
26//
27// The scene contains the root node of the node-graph and it is used
28// to manage the rest of the graph, like creating new nodes or adding
29// scripts.
30//
31// When the scene is updated, all the nodes are updated top to bottom,
32// same with drawing.
33//
34class Scene
35{
36public:
37
38 class Builder;
39
40 Scene(Camera&& camera);
41 Scene(tenno::shared_ptr<Camera> camera);
42 Scene(Camera::Builder& camera);
43
44 void set_skybox(tenno::shared_ptr<Skybox> skybox);
45 void set_skybox(const tenno::vector<std::filesystem::path>& faces);
46
47 tenno::shared_ptr<Node> get_root() const;
48 tenno::shared_ptr<Camera> get_camera() const;
49
50 static void add_component(tenno::shared_ptr<Node> owner,
51 tenno::shared_ptr<NodeComponent> component);
52 static tenno::shared_ptr<Node> create_child(tenno::shared_ptr<Node> parent);
53
54 static void set_script(tenno::weak_ptr<Node> node, const std::filesystem::path &path);
55
56 static void set_script(tenno::weak_ptr<Node> node, const std::string &source);
57
58 void update(float delta_time);
59 void draw(tenno::shared_ptr<RenderPipeline> pipeline,
60 int width, int height);
61
62private:
63
64 tenno::shared_ptr<Node> root;
65 tenno::shared_ptr<Camera> active_camera;
66 std::optional<tenno::shared_ptr<Skybox>> skybox;
67
68};
69
71{
72public:
73
74 Builder &camera(tenno::shared_ptr<Camera> camera);
75 Builder &camera(Camera&& camera);
76 Builder &camera(Camera::Builder& camera);
77
78 Scene build();
79
80private:
81
82 tenno::shared_ptr<Camera> _camera;
83
84};
85
86} // namespace brenta