summaryrefslogtreecommitdiff
path: root/main.lua
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2023-03-22 18:01:54 -0500
committersanine <sanine.not@pm.me>2023-03-22 18:01:54 -0500
commita74ae213158c2458e13a195c4a4c8d0d01d6330e (patch)
tree0e62d7819d094d38eac1fa1ce5729f3e08a8ccd6 /main.lua
parent92803015adf19848c3f3a30caea889006ad05999 (diff)
add ground plane
Diffstat (limited to 'main.lua')
-rw-r--r--main.lua18
1 files changed, 18 insertions, 0 deletions
diff --git a/main.lua b/main.lua
index 0019711..d6971b7 100644
--- a/main.lua
+++ b/main.lua
@@ -30,6 +30,7 @@ local shader = honey.Shader{
}
-- load models
+local plane = honey.mesh.loadFile("assets/plane.obj")[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]
@@ -65,8 +66,19 @@ local leaf = {
shader=shader,
}
local root = growLine(leaf, 24)
+root.update = function(self, dt)
+ self.transform:rotateY(0.2 * math.pi * dt)
+end
level:addEntity(root)
+local groundPlane = {
+ transform=Mat4():identity():translate(Vec3{0, -2, 0}):scale(Vec3{10, 10, 10}),
+ parent=false,
+ mesh=plane,
+ shader=shader,
+}
+level:addEntity(groundPlane)
+
-- close window on ESCAPE key
window:setKeyCallback(function(_, key)
if key == glfw.KEY_ESCAPE then
@@ -74,6 +86,12 @@ window:setKeyCallback(function(_, key)
end
end)
+-- resize window correctly
+window:setFramebufferSizeCallback(function(_, width, height)
+ gl.Viewport(0, 0, width, height)
+ camera.projection:perspectiveResize(width/height)
+end)
+
-- main loop
honey.loop(window, function(dt)
gl.ClearColor(0.2, 0.4, 1.0, 1.0)