Somewhat improved wrapping

This commit is contained in:
Dane Johnson
2021-01-15 17:51:19 -06:00
parent 2a12a1f119
commit 7651923ee8
5 changed files with 34 additions and 6 deletions

View File

@@ -13,3 +13,13 @@ Transform::Transform(Vector3 position, Vector3 rotation) {
void Transform::Translate(cfloat x, cfloat y, cfloat z) {
position = position + Vector3(x, y, z);
}
Vector3 Transform::Forward() {
Vector3 forward(0.0f, 0.0f, -1.0f);
Matrix mat(1.0f);
mat = glm::rotate(mat, this->rotation.x, Vector3(1.0f, 0.0f, 0.0f));
mat = glm::rotate(mat, this->rotation.y, Vector3(0.0f, 1.0f, 0.0f));
mat = glm::rotate(mat, this->rotation.z, Vector3(0.0f, 0.0f, 1.0f));
return mat * glm::vec4(forward, 1.0f);
}

View File

@@ -1,6 +1,8 @@
#ifndef TRANSFORM_H
#define TRANSFORM_H
#include <glm/gtc/matrix_transform.hpp>
#include "types.h"
struct Transform {
@@ -9,6 +11,7 @@ struct Transform {
Vector3 position;
Vector3 rotation;
void Translate(cfloat x, cfloat y, cfloat z);
Vector3 Forward();
};
#endif /* TRANSFORM_H */