adding transformations

This commit is contained in:
Kbz-8
2024-11-13 12:17:59 +01:00
parent 71d1c20a27
commit 35b7408eab
18 changed files with 141 additions and 130 deletions

View File

@@ -2,6 +2,8 @@
#define __MLX_DRAWABLE__
#include <Graphics/Enums.h>
#include <Maths/Quaternions.h>
#include <Maths/EulerAngles.h>
namespace mlx
{
@@ -12,13 +14,19 @@ namespace mlx
public:
inline Drawable(DrawableType type) : m_type(type) {}
inline void SetColor(Vec4f color) noexcept { m_color = color; }
inline void SetPosition(Vec2f position) noexcept { m_position = position; }
inline void SetColor(Vec4f color) noexcept { m_color = std::move(color); }
inline void SetPosition(Vec2f position) noexcept { m_position = std::move(position); }
inline void SetScale(Vec2f scale) noexcept { m_scale = std::move(scale); }
inline void SetRotation(float rotation) noexcept { m_rotation = EulerAnglesf{ 0.0f, 0.0f, rotation }; }
inline void SetCenter(Vec2f center) noexcept { m_center = std::move(center); }
inline virtual void Update([[maybe_unused]] VkCommandBuffer cmd) {}
[[nodiscard]] MLX_FORCEINLINE const Vec4f& GetColor() const noexcept { return m_color; }
[[nodiscard]] MLX_FORCEINLINE const Vec2f& GetPosition() const noexcept { return m_position; }
[[nodiscard]] MLX_FORCEINLINE const Vec2f& GetScale() const noexcept { return m_scale; }
[[nodiscard]] MLX_FORCEINLINE const Quatf& GetRotation() const noexcept { return m_rotation; }
[[nodiscard]] MLX_FORCEINLINE const Vec2f& GetCenter() const noexcept { return m_center; }
[[nodiscard]] MLX_FORCEINLINE std::shared_ptr<Mesh> GetMesh() const { return p_mesh; }
[[nodiscard]] MLX_FORCEINLINE DrawableType GetType() const noexcept { return m_type; }
@@ -38,8 +46,11 @@ namespace mlx
protected:
std::shared_ptr<DescriptorSet> p_set;
std::shared_ptr<Mesh> p_mesh;
Quatf m_rotation = Quatf::Identity();
Vec4f m_color = Vec4f{ 1.0f, 1.0f, 1.0f, 1.0f };
Vec2f m_position = Vec2f{ 0.0f, 0.0f };
Vec2f m_scale = Vec2f{ 1.0f, 1.0f };
Vec2f m_center;
DrawableType m_type;
};
}

View File

@@ -17,7 +17,7 @@ namespace mlx
Scene() = default;
Sprite& CreateSprite(NonOwningPtr<class Texture> texture) noexcept;
NonOwningPtr<Sprite> GetSpriteFromTextureAndPosition(NonOwningPtr<Texture> texture, const Vec2f& position) const;
NonOwningPtr<Sprite> GetSpriteFromTexturePositionScaleRotation(NonOwningPtr<Texture> texture, const Vec2f& position, float scale, float rotation) const;
void TryEraseSpriteFromTexture(NonOwningPtr<Texture> texture);
bool IsTextureAtGivenDrawLayer(NonOwningPtr<Texture> texture, std::uint64_t draw_layer) const;