Rotation
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user