That's..... not right. Lemme fix that

This commit is contained in:
maelstrom 2024-09-29 19:30:52 +02:00
parent 103bff0e50
commit 49672a793e
2 changed files with 10 additions and 1 deletions

View file

@ -108,12 +108,15 @@ void processInput(GLFWwindow* window) {
shiftFactor *= deltaTime;
if (glfwGetKey(window, GLFW_KEY_X) == GLFW_PRESS) {
parts.back().rotation.x += shiftFactor;
syncPartPhysics(parts.back());
}
if (glfwGetKey(window, GLFW_KEY_Y) == GLFW_PRESS) {
parts.back().rotation.y += shiftFactor;
syncPartPhysics(parts.back());
}
if (glfwGetKey(window, GLFW_KEY_Z) == GLFW_PRESS) {
parts.back().rotation.z += shiftFactor;
syncPartPhysics(parts.back());
}
}
}
@ -165,22 +168,28 @@ void keyCallback(GLFWwindow* window, int key, int scancode, int action, int mods
if (mode == 0) {
if (key == GLFW_KEY_X && action == GLFW_PRESS) {
parts.back().position.x += shiftFactor;
syncPartPhysics(parts.back());
}
if (key == GLFW_KEY_Y && action == GLFW_PRESS) {
parts.back().position.y += shiftFactor;
syncPartPhysics(parts.back());
}
if (key == GLFW_KEY_Z && action == GLFW_PRESS) {
parts.back().position.z += shiftFactor;
syncPartPhysics(parts.back());
}
} else if (mode == 1) {
if (key == GLFW_KEY_X && action == GLFW_PRESS) {
parts.back().scale.x += shiftFactor;
syncPartPhysics(parts.back());
}
if (key == GLFW_KEY_Y && action == GLFW_PRESS) {
parts.back().scale.y += shiftFactor;
syncPartPhysics(parts.back());
}
if (key == GLFW_KEY_Z && action == GLFW_PRESS) {
parts.back().scale.z += shiftFactor;
syncPartPhysics(parts.back());
}
}

View file

@ -75,10 +75,10 @@ void render(GLFWwindow* window) {
for (Part part : parts) {
glm::mat4 model = glm::mat4(1.0f);
model = glm::translate(model, part.position);
model = glm::scale(model, part.scale);
model = glm::rotate(model, part.rotation.x, glm::vec3(1., 0., 0.));
model = glm::rotate(model, part.rotation.y, glm::vec3(0., 1., 0.));
model = glm::rotate(model, part.rotation.z, glm::vec3(0., 0., 1.));
model = glm::scale(model, part.scale);
shader->set("model", model);
glm::mat3 normalMatrix = glm::mat3(glm::transpose(glm::inverse(model)));
shader->set("normalMatrix", normalMatrix);