MXVK Vulkan Framework 0.24.0
C++20 Vulkan rendering framework for practical 2D and 3D application development with SDL3.
Loading...
Searching...
No Matches
ship.cpp
Go to the documentation of this file.
1#include "ship.hpp"
2
3namespace space {
4
5 glm::vec3 Ship::forward() const {
6 glm::mat4 rot(1.0f);
7 rot = glm::rotate(rot, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
8 rot = glm::rotate(rot, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
9 return normalize_or_zero(glm::vec3(rot * glm::vec4(0.0f, 0.0f, -1.0f, 0.0f)));
10 }
11
12} // namespace space
Player ship state for the Asteroids simulation.
glm::vec3 rotation
Euler rotation in degrees.
Definition ship.hpp:26
glm::vec3 forward() const
Returns the normalized world-space direction in which the ship points.
Definition ship.cpp:5
glm::vec3 normalize_or_zero(const glm::vec3 &value)
Normalizes a direction with a stable fallback.