71 glm::vec3 Translation = { 0.0f, 0.0f, 0.0f };
72 glm::vec3 Scale = { 1.0f, 1.0f, 1.0f };
75 glm::vec3 RotationEuler = { 0.0f, 0.0f, 0.0f };
76 glm::quat Rotation = { 1.0f, 0.0f, 0.0f, 0.0f };
79 float Rotation2D = 0.0f;
80 bool bIsStatic =
false;
85 : Translation(Translation)
89 FORCEINLINE glm::vec3 GetTranslation()
const {
return Translation; }
90 FORCEINLINE glm::vec3 GetScale()
const {
return Scale; }
92 FORCEINLINE
float GetRotation2D()
const {
return Rotation2D; }
94 FORCEINLINE glm::mat4 GetTransform()
const
96 return glm::translate(glm::mat4(1.0f), Translation)
97 * glm::toMat4(Rotation)
98 * glm::scale(glm::mat4(1.0f), Scale);
101 FORCEINLINE glm::mat4 GetInvTransform()
const
103 glm::mat4 inv_translation = glm::translate(glm::mat4(1.0f), -Translation);
104 glm::quat inv_rotation = glm::conjugate(Rotation);
105 glm::mat4 inv_scale = glm::scale(glm::mat4(1.0f), glm::vec3(1.0f / Scale.x, 1.0f / Scale.y, 1.0f / Scale.z));
106 return inv_scale * glm::toMat4(inv_rotation) * inv_translation;
109 FORCEINLINE glm::quat GetRotation()
const {
return Rotation; }
110 FORCEINLINE glm::vec3 GetRotationEuler()
const {
return RotationEuler; }
112 FORCEINLINE
void SetRotationEuler(
const glm::vec3& euler)
114 RotationEuler = euler;
115 Rotation = glm::quat(RotationEuler);
118 FORCEINLINE
void SetRotation(
const glm::quat& InQuat)
122 const glm::vec3 OriginalEulerer = RotationEuler;
123 RotationEuler = glm::eulerAngles(Rotation);
126 if ((fabs(RotationEuler.x - OriginalEulerer.x) == glm::pi<float>())
127 && (fabs(RotationEuler.z - OriginalEulerer.z) == glm::pi<float>()))
129 RotationEuler.x = OriginalEulerer.x;
130 RotationEuler.y = glm::pi<float>() - RotationEuler.y;
131 RotationEuler.z = OriginalEulerer.z;
135 FORCEINLINE
bool IsStatic()
const {
return bIsStatic; }
137 virtual std::string ToString()
const override
139 return LK_FMT_LIB::format(
"[TransformComponent] Translation={} Scale={} RotEuler={}", Translation, Scale, RotationEuler);
145 std::string FilePath;
148 bool Passthrough =
false;
151 const glm::vec2& size = { 100.0f, 100.0f },
152 const glm::vec4& color = { 1.0f, 1.0f, 1.0f, 1.0f })
160 const glm::vec4& color = { 1.0f, 1.0f, 1.0f, 1.0f })
167 const glm::vec2& GetSize()
const {
return Size; }
168 const glm::vec4& GetColor()
const {
return Color; }
169 float GetWidth()
const {
return Size.x; }
170 float GetHeight()
const {
return Size.y; }
172 void SetSize(
const glm::vec2& size)
177 void SetSize(
float x,
float y) { Size = { x, y }; }
178 void SetPassthrough(
bool passthrough) { Passthrough = passthrough; }
179 bool IsPassthrough()
const {
return Passthrough; }
185 ECameraProjection ProjectionType = ECameraProjection::Perspective;
186 bool bPrimary =
true;
190 : Camera(Other.Camera)
191 , ProjectionType(Other.ProjectionType)
198 std::string ToString()
const
200 return LK_FMT_LIB::format(
"[CameraComponent] Primary={} "
201 "CameraType={} ProjectionType={} Pitch={:.2f} Yaw={:.2f}",
202 (bPrimary ?
"True" :
"False"),
203 Enum::ToString(Camera.GetType()), Enum::ToString(ProjectionType),
204 Camera.GetPitch(), Camera.GetYaw()
Definition Components.h:220