wren
Vulkan-based game engine
Toggle main menu visibility
Loading...
Searching...
No Matches
transform.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include <
wren/math/geometry.hpp
>
4
#include <
wren/math/matrix.hpp
>
5
#include <
wren/math/quaternion.hpp
>
6
#include <
wren/math/vector.hpp
>
7
8
namespace
wren::scene::components
{
9
10
struct
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 =
17
math::translate
(
math::Mat4f::identity
(),
position
);
18
const
math::Mat4f
rotate =
math::Quaternionf
(
rotation
).
to_mat
();
19
const
math::Mat4f
scaled =
math::scale
(
math::Mat4f::identity
(),
scale
);
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
wren::math::Mat< float, 4, 4 >::identity
static constexpr auto identity()
Definition
matrix.hpp:18
geometry.hpp
matrix.hpp
wren::math::scale
auto scale(const Mat4f &matrix, const Vec3f &scale) -> Mat4f
Definition
geometry.cpp:49
wren::math::Quaternionf
Quaternion< float > Quaternionf
Definition
quaternion.hpp:80
wren::math::translate
auto translate(Mat4f mat, Vec4f offset) -> Mat4f
Definition
geometry.cpp:34
wren::scene::components
Definition
collider.cpp:3
quaternion.hpp
wren::math::Mat4f
Definition
matrix.hpp:86
wren::math::Quaternion::to_mat
auto to_mat()
Definition
quaternion.hpp:44
wren::math::Vec3f
Definition
vector.hpp:174
wren::scene::components::Transform
Definition
transform.hpp:10
wren::scene::components::Transform::right
auto right() const
Definition
transform.hpp:24
wren::scene::components::Transform::matrix
auto matrix() const
Definition
transform.hpp:15
wren::scene::components::Transform::up
auto up() const
Definition
transform.hpp:29
wren::scene::components::Transform::scale
math::Vec3f scale
Definition
transform.hpp:13
wren::scene::components::Transform::forward
auto forward() const
Definition
transform.hpp:34
wren::scene::components::Transform::position
math::Vec3f position
Definition
transform.hpp:11
wren::scene::components::Transform::rotation
math::Vec3f rotation
Definition
transform.hpp:12
vector.hpp
wren
include
wren
scene
components
transform.hpp
Generated by
1.17.0