diff options
author | sanine <sanine.not@pm.me> | 2023-03-22 18:01:54 -0500 |
---|---|---|
committer | sanine <sanine.not@pm.me> | 2023-03-22 18:01:54 -0500 |
commit | a74ae213158c2458e13a195c4a4c8d0d01d6330e (patch) | |
tree | 0e62d7819d094d38eac1fa1ce5729f3e08a8ccd6 | |
parent | 92803015adf19848c3f3a30caea889006ad05999 (diff) |
add ground plane
-rw-r--r-- | assets/plane.mtl | 10 | ||||
-rw-r--r-- | assets/plane.obj | 17 | ||||
-rw-r--r-- | main.lua | 18 |
3 files changed, 45 insertions, 0 deletions
diff --git a/assets/plane.mtl b/assets/plane.mtl new file mode 100644 index 0000000..f231bdf --- /dev/null +++ b/assets/plane.mtl @@ -0,0 +1,10 @@ +# Blender MTL File: 'None' +# Material Count: 1 + +newmtl None +Ns 500 +Ka 0.8 0.8 0.8 +Kd 0.8 0.8 0.8 +Ks 0.8 0.8 0.8 +d 1 +illum 2 diff --git a/assets/plane.obj b/assets/plane.obj new file mode 100644 index 0000000..adae864 --- /dev/null +++ b/assets/plane.obj @@ -0,0 +1,17 @@ +# Blender v3.4.1 OBJ File: '' +# www.blender.org +mtllib plane.mtl +o Plane +v -1.000000 0.000000 1.000000 +v 1.000000 0.000000 1.000000 +v -1.000000 0.000000 -1.000000 +v 1.000000 0.000000 -1.000000 +vt 1.000000 0.000000 +vt 0.000000 1.000000 +vt 0.000000 0.000000 +vt 1.000000 1.000000 +vn 0.0000 1.0000 0.0000 +usemtl None +s off +f 2/1/1 3/2/1 1/3/1 +f 2/1/1 4/4/1 3/2/1 @@ -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) |