diff options
| author | vimene <vincent.menegaux@gmail.com> | 2026-01-13 02:04:52 +0100 |
|---|---|---|
| committer | vimene <vincent.menegaux@gmail.com> | 2026-01-13 02:04:52 +0100 |
| commit | db41d43345ea73cf7c1bbb29448e52ffb822e3e0 (patch) | |
| tree | 4635d654e301b3f31f8d2626f3bc2c6f2a6e50a8 /src/math/utils.hpp | |
| parent | 7f08187a46e30925e4563585fab2c6f92400330a (diff) | |
| download | engine-db41d43345ea73cf7c1bbb29448e52ffb822e3e0.tar.gz | |
added textures for the hardware renderer
- removed "using" directive in .hpp
- reverse order of arguments for quaternion rotation, i.e. q.rot(v)
instead of v.rot(q), where q is a quaterinon and v a vector
- pass the inverse of the view matrix to render_and_present_frame, to
allow light calculation in shaders (we used to just pass the matrix of
the quaternion of the transformation, i.e. discard scaling and
translations)
- added another mesh and texture (viking_room) for testing purposes
- added transparent background option
- added Quaternion::look_towards(), which is the equivalent of
Matrix4::look_at() but only for rotations
- various improvement to .obj parsing
- load texture coordinates from .obj file
- merged duplicate vertices in Mesh::linearize_indices()
Diffstat (limited to 'src/math/utils.hpp')
| -rw-r--r-- | src/math/utils.hpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/math/utils.hpp b/src/math/utils.hpp new file mode 100644 index 0000000..5ec5959 --- /dev/null +++ b/src/math/utils.hpp @@ -0,0 +1,24 @@ +#ifndef MATH_UTILS_HPP +#define MATH_UTILS_HPP + +#include <array> +#include <utility> +#include "math/vector.hpp" + +namespace engine::math::utils { + +template<size_t size> struct Vector; +template<> struct Vector<2> { using type = engine::math::Vector2; }; +template<> struct Vector<3> { using type = engine::math::Vector3; }; +template<> struct Vector<4> { using type = engine::math::Vector4; }; + +template<size_t vector_size> +constexpr Vector<vector_size>::type array_to_vec(const std::array<float, vector_size>& coords) { + return [&]<size_t... i>(std::index_sequence<i...>) constexpr -> Vector<vector_size>::type { + return { coords[i] ... }; + }(std::make_index_sequence<vector_size>()); +} + +} + +#endif // MATH_UTILS_HPP |
