Vulkan Schnee 0.0.1
High-performance rendering engine
Loading...
Searching...
No Matches
Actor.h
Go to the documentation of this file.
1#pragma once
5#include <memory>
6#include <optional>
7#include <vector>
8
9namespace EngineCore {
10 class SceneManager;
11 class MeshComponent;
12 class World;
13 class SceneComponent;
14 class Scene;
15}
16
17namespace EngineCore {
24 class Actor : public Entity {
25 friend class Scene;
26 public:
27 explicit Actor(std::shared_ptr<SceneNode> sceneNode, Scene* owningScene);
28 ~Actor();
29
36 virtual void beginPlay();
37
46 void tick(double deltaTime) override;
47 virtual void endPlay();
48
57 glm::vec3 getActorLocation() const;
58
67 glm::vec3 getActorRotation() const;
68
76 glm::vec3 getActorScale() const;
77
85 void setActorLocation(glm::vec3 newLocation);
93 void setActorRotation(glm::vec3 newRotation);
94
104 void rotateActor(glm::vec3 deltaRotation);
105
113 void setActorScale(glm::vec3 newScale);
114
122 glm::mat4 getWorldTransform() const;
123
124
126 void unregisterMeshComponent(MeshComponent * meshComponent);
127 std::vector<MeshComponent*> getMeshComponents() const;
128 std::vector<MeshComponent*> meshComponents;
129
130 protected:
131 std::optional<std::shared_ptr<SceneNode>> sceneNode;
132
133 public:
138 Scene * getOwningScene() const;
139
144 std::shared_ptr<SceneNode> getSceneNode() const;
145 private:
147 bool isTransformDirty = true;
148
149 Scene* owningScene = nullptr;
150
151 void initComponents();
152 void cleanupComponents();
153
154 std::weak_ptr<SceneComponent> rootComponent;
155
156 bool doesEverTick = false;
157
158 std::shared_ptr<World> world;
159
160 };
161
162}
friend class Scene
Definition Actor.h:25
std::vector< MeshComponent * > meshComponents
Definition Actor.h:128
void cleanupComponents()
Definition Actor.cpp:123
std::vector< MeshComponent * > getMeshComponents() const
Definition Actor.cpp:115
Actor(std::shared_ptr< SceneNode > sceneNode, Scene *owningScene)
Definition Actor.cpp:13
bool isTransformDirty
Definition Actor.h:147
void setActorLocation(glm::vec3 newLocation)
Set the new world location for this actor.
Definition Actor.cpp:72
Scene * getOwningScene() const
Get the pointer to the scene this entity is a part of.
Definition Actor.cpp:131
virtual void beginPlay()
Gets executed when the actor is spawned into the world.
Definition Actor.cpp:20
MeshComponent * registerMeshComponent(MeshComponent *meshComponent)
Definition Actor.cpp:103
void tick(double deltaTime) override
Executed every frame.
Definition Actor.cpp:28
void setActorScale(glm::vec3 newScale)
sets the world scale for this actor
Definition Actor.cpp:90
void initComponents()
Definition Actor.cpp:119
void setActorRotation(glm::vec3 newRotation)
Sets the world rotation.
Definition Actor.cpp:78
Scene * owningScene
Definition Actor.h:149
Transform worldTransform
Definition Actor.h:146
glm::vec3 getActorScale() const
Scales the actor to world scale.
Definition Actor.cpp:65
glm::mat4 getWorldTransform() const
Gets the model matrix.
Definition Actor.cpp:96
std::weak_ptr< SceneComponent > rootComponent
Definition Actor.h:154
glm::vec3 getActorLocation() const
Gets the actors location in the world.
Definition Actor.cpp:50
std::shared_ptr< World > world
Definition Actor.h:158
virtual void endPlay()
Definition Actor.cpp:39
glm::vec3 getActorRotation() const
Gets the actors rotation in the world.
Definition Actor.cpp:58
std::shared_ptr< SceneNode > getSceneNode() const
Getter for the scene graph node for this object.
Definition Actor.cpp:135
std::optional< std::shared_ptr< SceneNode > > sceneNode
Definition Actor.h:131
bool doesEverTick
Definition Actor.h:156
void rotateActor(glm::vec3 deltaRotation)
Applies an incremental rotation to the actor using quaternion multiplication. Use this instead of get...
Definition Actor.cpp:84
void unregisterMeshComponent(MeshComponent *meshComponent)
Definition Actor.cpp:109
A component which can be attached as many times to an actor as one wants. It makes it possible to ren...
A scene component has a transform.
Manages game objects within a scene, handling registration, ID allocation, and GPU buffer synchroniza...
A scene is the overarching structure which can spawn actors.
Definition Scene.h:17
Log category system implementation.