From a74ae213158c2458e13a195c4a4c8d0d01d6330e Mon Sep 17 00:00:00 2001 From: sanine Date: Wed, 22 Mar 2023 18:01:54 -0500 Subject: add ground plane --- main.lua | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'main.lua') 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) -- cgit v1.2.1