This commit is contained in:
Dane Johnson
2021-01-13 20:08:39 -06:00
parent 3c652884c2
commit e9a669eebe
4 changed files with 12 additions and 3 deletions

View File

@@ -4,8 +4,9 @@ Transform::Transform() {
position = Vector3(0.0f);
}
Transform::Transform(Vector3 position) {
Transform::Transform(Vector3 position, Vector3 rotation) {
this->position = position;
this->rotation = rotation;
}
void Transform::Translate(cfloat x, cfloat y, cfloat z) {

View File

@@ -5,8 +5,9 @@
struct Transform {
Transform();
Transform(Vector3 position);
Transform(Vector3 position, Vector3 rotation);
Vector3 position;
Vector3 rotation;
void Translate(cfloat x, cfloat y, cfloat z);
};

View File

@@ -113,6 +113,9 @@ int main() {
for (Mesh *mesh : meshes) {
Matrix model(1.0f);
model = glm::translate(model, mesh->transform.position);
model = glm::rotate(model, mesh->transform.rotation.x, Vector3(1.0f, 0.0f, 0.0f));
model = glm::rotate(model, mesh->transform.rotation.y, Vector3(0.0f, 1.0f, 0.0f));
model = glm::rotate(model, mesh->transform.rotation.z, Vector3(0.0f, 0.0f, 1.0f));
shader.UpdateModel(model);
mesh->Draw();
}