KarmaEngine
Game Engine for practical learning and research purposes
Loading...
Searching...
No Matches
SceneComponent.h
Go to the documentation of this file.
1
10#pragma once
11
12#include "ActorComponent.h"
13#include "glm/glm.hpp"
14
15#include "Ganit/Transform.h"
16
17namespace Karma
18{
19 class FTransform;
20 class USceneComponent;
21
34
42 {
44
45 public:
52
54 //FTransform GetRelativeTransform() const;
55
56 private:
58 glm::vec3 m_RelativeLocation;
59
61 glm::vec3 m_RelativeRotation;
62
67 glm::vec3 m_RelativeScale3D;
68
70 std::shared_ptr<USceneComponent> m_AttachParent;
71
73 FTransform m_ComponentToWorld;
74
76 uint8_t m_bAbsoluteLocation : 1;
77
79 uint8_t m_bAbsoluteRotation : 1;
80
82 uint8_t m_bAbsoluteScale : 1;
83
84 public:
90
91 public:
93 //std::shared_ptr<USceneComponent> m_AttachParent;
94
96 std::string m_AttachSocketName;
97
99 std::vector<std::shared_ptr<USceneComponent>> m_AttachChildren;
100
111 const glm::vec3& GetRelativeRotation() const
112 {
113 return m_RelativeRotation;
114 }
115
126 const glm::vec3& GetRelativeLocation() const
127 {
128 return m_RelativeLocation;
129 }
130
141 const glm::vec3& GetRelativeScale3D() const
142 {
143 return m_RelativeScale3D;
144 }
145
146 public:
162 void SetWorldLocation(glm::vec3 newLocation);
163
178 virtual void SetWorldTransform(const FTransform& NewTransform/*, bool bSweep = false, FHitResult* OutSweepHitResult = nullptr, ETeleportType Teleport = ETeleportType::None*/);
179
185 std::shared_ptr<USceneComponent> GetAttachParent() const;
186
195 virtual FTransform GetSocketTransform(const std::string& InSocketName, ERelativeTransformSpace TransformSpace = RTS_World) const;
196
202 inline const FTransform& GetComponentTransform() const
203 {
204 return m_ComponentToWorld;
205 }
206
212 virtual void BeginDestroy() override;
213
223 {
224 return m_bAbsoluteLocation;
225 }
226
236 {
237 return m_bAbsoluteRotation;
238 }
239
249 {
250 return m_bAbsoluteScale;
251 }
252
267 void SetRelativeTransform(const FTransform& NewTransform/*, bool bSweep = false, FHitResult* OutSweepHitResult = nullptr, ETeleportType Teleport = ETeleportType::None*/);
268
275 {
276 //UpdateComponentToWorldWithParent(GetAttachParent(), GetAttachSocketName(), UpdateTransformFlags, RelativeRotationCache.RotatorToQuat(GetRelativeRotation()), Teleport);
277
278 }
279
285 FORCEINLINE const std::string& GetAttachSocketName() const
286 {
287 return m_AttachSocketName;
288 }
289 };
290}
This file contains the class UActorComponent.
EUpdateTransformFlags
Information about how to update transform when something is moved.
Definition ActorComponent.h:38
@ None
Definition ActorComponent.h:40
#define KARMA_API
Defining Karma's API macro for storage class information.
Definition Core.h:41
#define FORCEINLINE
Typical inlining macro for clarity.
Definition Core.h:170
#define DECLARE_KARMA_CLASS(TClass, TSuperClass)
Karma's gamecode object class declaration.
Definition GFrameworkMacros.h:45
ETeleportType
Definition KarmaTypes.h:682
@ None
Definition KarmaTypes.h:684
ERelativeTransformSpace
The space for the transform.
Definition SceneComponent.h:24
@ RTS_World
Definition SceneComponent.h:26
@ RTS_Component
Definition SceneComponent.h:30
@ RTS_Actor
Definition SceneComponent.h:28
@ RTS_ParentBoneSpace
Definition SceneComponent.h:32
This file contains the math specific for transforms.
Transform composed of Scale, Rotation (as a quaternion), and Translation.
Definition Transform.h:125
UActorComponent()
A constructor.
Definition ActorComponent.cpp:8
A SceneComponent has a transform and supports attachment, but has no rendering or collision capabilit...
Definition SceneComponent.h:42
bool IsUsingAbsoluteScale() const
Gets the literal value of bAbsoluteScale.
Definition SceneComponent.h:248
bool IsUsingAbsoluteLocation() const
Gets the literal value of bAbsoluteLocation.
Definition SceneComponent.h:222
const glm::vec3 & GetRelativeRotation() const
Gets the literal value of RelativeRotation.
Definition SceneComponent.h:111
glm::vec3 m_ComponentVelocity
Definition SceneComponent.h:89
const glm::vec3 & GetRelativeLocation() const
Gets the literal value of RelativeLocation.
Definition SceneComponent.h:126
FORCEINLINE const std::string & GetAttachSocketName() const
Getter for the m_AttachSocektName.
Definition SceneComponent.h:285
const glm::vec3 & GetRelativeScale3D() const
Gets the literal value of RelativeScale3D.
Definition SceneComponent.h:141
virtual void UpdateComponentToWorld(EUpdateTransformFlags UpdateTransformFlags=EUpdateTransformFlags::None, ETeleportType Teleport=ETeleportType::None) override final
Recalculate the value of our component to world transform.
Definition SceneComponent.h:274
bool IsUsingAbsoluteRotation() const
Gets the literal value of bAbsoluteRotation.
Definition SceneComponent.h:235
const FTransform & GetComponentTransform() const
Get the current component-to-world transform for this component.
Definition SceneComponent.h:202
USceneComponent()
A constructor.
Definition SceneComponent.cpp:8
std::vector< std::shared_ptr< USceneComponent > > m_AttachChildren
Definition SceneComponent.h:99
std::string m_AttachSocketName
Definition SceneComponent.h:96