Somewhat improved wrapping
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user