From 53b151b3fd6d4c2b953d8ed93261125577f1c123 Mon Sep 17 00:00:00 2001 From: sanine Date: Mon, 13 Mar 2023 12:29:35 -0500 Subject: cycle through all meshes --- main.lua | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) (limited to 'main.lua') diff --git a/main.lua b/main.lua index 95068eb..0ff081c 100644 --- a/main.lua +++ b/main.lua @@ -84,16 +84,27 @@ gl.DeleteShader(vertexShader) gl.DeleteShader(fragmentShader) -local mesh = honey.mesh.loadFile("assets/tetrahedron.obj")[1] ---local mesh = honey.mesh.Mesh( --- { --- 0, 0, 0, 0, 0, 1, 0, 0, --- 1, 0, 0, 0, 0, 1, 1, 0, --- 0, 1, 0, 0, 0, 1, 0, 1, --- }, --- { 0, 2, 1 } ---) - +local tetra = honey.mesh.loadFile("assets/tetrahedron.obj")[1] +local cube = honey.mesh.loadFile("assets/cube.obj")[1] +local octa = honey.mesh.loadFile("assets/octahedron.obj")[1] +local dodeca = honey.mesh.loadFile("assets/dodecahedron.obj")[1] +local icosa = honey.mesh.loadFile("assets/icosahedron.obj")[1] + +local meshes = { tetra, cube, octa, dodeca, icosa } +local meshIndex = 1 +local mesh = meshes[1] + +window:setKeyCallback(function(_, key, scancode, action, mods) + if action ~= glfw.PRESS then return end + + if key == glfw.KEY_SPACE then + meshIndex = meshIndex + 1 + if meshIndex > #meshes then meshIndex = 1 end + mesh = meshes[meshIndex] + elseif key == glfw.KEY_ESCAPE then + window:setShouldClose(true) + end +end) while not window:shouldClose() do -- cgit v1.2.1