summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--assets/plane.mtl10
-rw-r--r--assets/plane.obj17
-rw-r--r--main.lua18
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
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)