37 m_localMatrix{ComposeMatrix(scale, rot, pos)},
38 m_worldMatrix{m_localMatrix}
40 NC_ASSERT(!HasAnyZeroElement(scale),
"Invalid scale(elements cannot be 0)");
47 DirectX::FXMMATRIX parentTransform)
49 m_localMatrix{ComposeMatrix(scale, rot, pos)},
50 m_worldMatrix{m_localMatrix * parentTransform}
52 NC_ASSERT(!HasAnyZeroElement(scale),
"Invalid scale(elements cannot be 0)");
65 auto PositionXM() const noexcept -> DirectX::FXMVECTOR {
return m_worldMatrix.r[3]; }
71 auto LocalPositionXM() const noexcept -> DirectX::FXMVECTOR {
return m_localMatrix.r[3]; }
77 auto RotationXM() const noexcept -> DirectX::XMVECTOR {
return DecomposeRotation(m_worldMatrix); }
83 auto LocalRotationXM() const noexcept -> DirectX::XMVECTOR {
return DecomposeRotation(m_localMatrix); }
89 auto ScaleXM() const noexcept -> DirectX::XMVECTOR {
return DecomposeScale(m_worldMatrix); }
95 auto LocalScaleXM() const noexcept -> DirectX::XMVECTOR {
return DecomposeScale(m_localMatrix); }
110 auto UpXM() const noexcept -> DirectX::XMVECTOR;
122 auto RightXM() const noexcept -> DirectX::XMVECTOR;
145 const auto scale = DecomposeScale(m_localMatrix);
146 m_localMatrix = DirectX::XMMatrixScalingFromVector(scale) *
147 DirectX::XMMatrixRotationQuaternion(orientation);
148 m_localMatrix.r[3] = DirectX::XMVectorSetW(position, 1.0f);
152 void SetTransformationMatrix(DirectX::FXMMATRIX matrix)
154 m_localMatrix = matrix;
171 void Rotate(DirectX::FXMVECTOR quaternion);
183 friend class ecs::EcsModule;
184 bool m_dirty =
false;
185 DirectX::XMMATRIX m_localMatrix;
186 DirectX::XMMATRIX m_worldMatrix;
188 auto IsDirty() const noexcept
193 void UpdateWorldMatrix()
196 m_worldMatrix = m_localMatrix;
199 void UpdateWorldMatrix(DirectX::FXMMATRIX parentMatrix)
202 m_worldMatrix = m_localMatrix * parentMatrix;
Optional base class for components.
Definition: Component.h:27
Identifies an object in the registry.
Definition: Entity.h:18
Quaternion type for representing 3D rotations.
Definition: Quaternion.h:13
A three component vector.
Definition: Vector.h:29