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 <string>
8#include <vector>
9
10namespace Engine::Components
11{
12 class Scene;
13 class Mesh;
14} // namespace Engine::Components
15
16namespace Engine::Entities {
20 class Actor : public Entity {
21 friend class Scene;
22 public:
23 explicit Actor(std::shared_ptr<SceneNode> sceneNode, Scene* owningScene);
24 ~Actor() override = default;
25
29 virtual void beginPlay();
30
36 void tick(double deltaTime) override;
37 virtual void endPlay();
38
39 [[nodiscard]] virtual std::string getActorName() const;
40
45 glm::vec3 getActorLocation() const;
46
51 glm::vec3 getActorRotation() const;
52
57 glm::vec3 getActorScale() const;
58
63 void setActorLocation(glm::vec3 newLocation ) const;
68 void setActorRotation(glm::vec3 newRotation ) const;
69
76 void rotateActor(glm::vec3 deltaRotation ) const;
77
82 void setActorScale(glm::vec3 newScale ) const;
83
88 glm::mat4 getWorldTransform() const;
89
90 protected:
91 std::optional<std::shared_ptr<SceneNode>> sceneNode;
92
93 public:
99
104 std::shared_ptr<SceneNode> getSceneNode() const;
105 private:
106 Scene* owningScene_ = nullptr;
107 std::weak_ptr<Components::Scene> rootComponent_;
108 bool hasEndedPlay_ = false;
109 };
110
111}
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.
friend class Scene
Definition Actor.h:21
void setActorLocation(glm::vec3 newLocation) const
Set the new world location for this actor.
virtual void endPlay()
glm::vec3 getActorRotation() const
Gets the actors rotation in the world.
void setActorRotation(glm::vec3 newRotation) const
Sets the world rotation.
virtual void beginPlay()
Gets executed when the actor is spawned into the world.
glm::mat4 getWorldTransform() const
Gets the model matrix.
void rotateActor(glm::vec3 deltaRotation) const
Applies an incremental rotation to the actor using quaternion multiplication. Use this instead of get...
std::optional< std::shared_ptr< SceneNode > > sceneNode
Definition Actor.h:91
void setActorScale(glm::vec3 newScale) const
sets the world scale for this actor
glm::vec3 getActorScale() const
Scales the actor to world scale.
Scene * getOwningScene() const
Get the pointer to the scene this entity is a part of.
glm::vec3 getActorLocation() const
Gets the actors location in the world.
void tick(double deltaTime) override
Executed every frame.
~Actor() override=default
std::shared_ptr< SceneNode > getSceneNode() const
Getter for the scene graph node for this object.
std::weak_ptr< Components::Scene > rootComponent_
Definition Actor.h:107
Actor(std::shared_ptr< SceneNode > sceneNode, Scene *owningScene)
virtual std::string getActorName() const