wren
Vulkan-based game engine
Loading...
Searching...
No Matches
transform.hpp
Go to the documentation of this file.
1#pragma once
2
7
9
10struct Transform {
11 math::Vec3f position = {0, 0, 0};
12 math::Vec3f rotation = {0, 0, 0};
13 math::Vec3f scale = {1, 1, 1};
14
15 [[nodiscard]] auto matrix() const {
16 const math::Mat4f translate =
20
21 return translate * rotate * scaled;
22 }
23
24 [[nodiscard]] auto right() const {
25 return (math::Quaternionf{rotation}.to_mat() * math::Vec3f{1, 0, 0})
26 .normalized();
27 }
28
29 [[nodiscard]] auto up() const {
30 return (math::Quaternionf{rotation}.to_mat() * math::Vec3f{0, 1, 0})
31 .normalized();
32 }
33
34 [[nodiscard]] auto forward() const {
35 return (math::Quaternionf{rotation}.to_mat() * math::Vec3f{0, 0, 1})
36 .normalized();
37 }
38};
39
40} // namespace wren::scene::components
static constexpr auto identity()
Definition matrix.hpp:18
auto scale(const Mat4f &matrix, const Vec3f &scale) -> Mat4f
Definition geometry.cpp:49
Quaternion< float > Quaternionf
Definition quaternion.hpp:80
auto translate(Mat4f mat, Vec4f offset) -> Mat4f
Definition geometry.cpp:34
Definition collider.cpp:3
Definition matrix.hpp:86
auto to_mat()
Definition quaternion.hpp:44
Definition vector.hpp:174
Definition transform.hpp:10
auto right() const
Definition transform.hpp:24
auto matrix() const
Definition transform.hpp:15
auto up() const
Definition transform.hpp:29
math::Vec3f scale
Definition transform.hpp:13
auto forward() const
Definition transform.hpp:34
math::Vec3f position
Definition transform.hpp:11
math::Vec3f rotation
Definition transform.hpp:12