From a9f0521984f43f3048d3e0fec15082916e7f8331 Mon Sep 17 00:00:00 2001 From: sanine-a Date: Wed, 28 Oct 2020 22:29:38 -0500 Subject: fix bug in model loading --- demo/FPSCamera.lua | 4 ++-- demo/Matrix.lua | 4 ++-- demo/main.lua | 19 ++++++++++--------- 3 files changed, 14 insertions(+), 13 deletions(-) (limited to 'demo') diff --git a/demo/FPSCamera.lua b/demo/FPSCamera.lua index 1ec5097..7182638 100644 --- a/demo/FPSCamera.lua +++ b/demo/FPSCamera.lua @@ -20,7 +20,7 @@ camera.projection = Matrix.Mat4.perspective(math.rad(90), 0.1, 8192) -function camera:update() +function camera:update(dt) local M = Matrix.Mat4.eye() M:rotate(Vector.Vec3.ZERO, self.basis.x, math.rad(self.pitch)) M:rotate(Vector.Vec3.ZERO, Vector.Vec3.Y_UNIT, math.rad(self.yaw)) @@ -42,7 +42,7 @@ function camera:update() movement:setAt(1, 0) movement:normalize() - movement:muls(self.movement_speed, movement) + movement:muls(self.movement_speed*dt, movement) self.position:add(movement, self.position) Matrix.Mat4.look(self.position, self.basis.z, Vector.Vec3.Y_UNIT, self.view) diff --git a/demo/Matrix.lua b/demo/Matrix.lua index eae210f..d38b20b 100644 --- a/demo/Matrix.lua +++ b/demo/Matrix.lua @@ -47,7 +47,7 @@ end Matrix.Mat3.prototype.mulv = function(self, v, dest) local result if dest == nil then - result = Matrix.Mat3.new() + result = Matrix.Vec3.new() else result = dest end @@ -218,7 +218,7 @@ end Matrix.Mat4.prototype.mulv = function(self, v, dest) local result if dest == nil then - result = Matrix.Mat4.new() + result = Matrix.Vec4.new() else result = dest end diff --git a/demo/main.lua b/demo/main.lua index f534952..81f7354 100644 --- a/demo/main.lua +++ b/demo/main.lua @@ -27,7 +27,7 @@ out vec4 color; void main() { color = base_color; } ]] local shader = honey.shader.new(vertex_shader, fragment_shader) -local plane = honey.primitives.cube(10,10,10) +local plane = honey.mesh.load('Suzanne.obj')[1] local color1 = Vector.Vec4.new{1,0,0,1} local color2 = Vector.Vec4.new{0,0,1,1} @@ -36,15 +36,16 @@ local color = Vector.Vec4.new() local total_time = 0 function honey.update(dt) - total_time = total_time + dt - color1:lerp(color2, 0.5*(math.sin(math.pi*total_time)+1), color) + total_time = total_time + dt + color1:lerp(color2, 0.5*(math.sin(math.pi*total_time)+1), color) + FPSCamera:update(dt) end function honey.draw() - FPSCamera:update() - honey.shader.set_mat4(shader, 'model', model.array) - honey.shader.set_mat4(shader, 'view', FPSCamera.view.array) - honey.shader.set_mat4(shader, 'projection', FPSCamera.projection.array) - honey.shader.set_vec4(shader, "base_color", color.array) - honey.mesh.draw(plane, shader) + + honey.shader.set_mat4(shader, 'model', model.array) + honey.shader.set_mat4(shader, 'view', FPSCamera.view.array) + honey.shader.set_mat4(shader, 'projection', FPSCamera.projection.array) + honey.shader.set_vec4(shader, "base_color", color.array) + honey.mesh.draw(plane, shader) end -- cgit v1.2.1