diff --git a/core/couch.cpp b/core/couch.cpp index ebf5bf4..46ebec0 100644 --- a/core/couch.cpp +++ b/core/couch.cpp @@ -100,6 +100,9 @@ int main() { Matrix view(1.0f); Camera *camera = Camera::GetCurrentCamera(); + view = glm::rotate(view, -camera->transform.rotation.x, Vector3(1.0f, 0.0f, 0.0f)); + view = glm::rotate(view, -camera->transform.rotation.y, Vector3(0.0f, 1.0f, 0.0f)); + view = glm::rotate(view, -camera->transform.rotation.z, Vector3(0.0f, 0.0f, 1.0f)); view = glm::translate(view, -camera->transform.position); shader.UpdateView(view); @@ -112,10 +115,10 @@ 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)); + model = glm::translate(model, mesh->transform.position); shader.UpdateModel(model); mesh->Draw(); } diff --git a/main.lua b/main.lua index cac7cbc..63eb715 100644 --- a/main.lua +++ b/main.lua @@ -5,12 +5,15 @@ local LEFT = 263 local RIGHT = 262 local UP = 265 local DOWN = 264 +local Q = 81 local vx = 0.0 local vz = 0.0 local ballvy = -1.0 +local cam_rot_x = 0.0 + function init() camera = couch.Camera() camera:MakeCurrent() @@ -27,6 +30,7 @@ end function update(delta) camera.transform:Translate(vx * delta, 0.0, vz * delta) + camera.transform.rotation.y = camera.transform.rotation.y + cam_rot_x * delta local loc = ball1.transform.position if loc.y > 4.0 then @@ -37,6 +41,7 @@ function update(delta) ball1.transform.position.y = ball1.transform.position.y + ballvy * delta ball.transform.rotation.z = ball.transform.rotation.z + 1.0 * delta; + ball.transform.rotation.y = ball.transform.rotation.y + 1.0 * delta; ball.transform.rotation.x = ball.transform.rotation.x + 1.0 * delta; end @@ -56,4 +61,12 @@ function onkey(key, code, action, mod) elseif (key == DOWN or key == UP) and action == 0 then vz = 0.0 end + + if key == Q then + if action == 1 then + cam_rot_x = 1.0 + else + cam_rot_x = 0.0 + end + end end