summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsanine-a <sanine.not@pm.me>2020-10-28 22:29:38 -0500
committersanine-a <sanine.not@pm.me>2020-10-28 22:29:38 -0500
commita9f0521984f43f3048d3e0fec15082916e7f8331 (patch)
tree298921a1bb16dca39664f460c60cb78b368b64c8
parentc6790ae7b77e32af33ab290ff6b645536b69210e (diff)
fix bug in model loading
-rw-r--r--demo/FPSCamera.lua4
-rw-r--r--demo/Matrix.lua4
-rw-r--r--demo/main.lua19
-rw-r--r--src/mesh/mesh.c2
4 files changed, 15 insertions, 14 deletions
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
diff --git a/src/mesh/mesh.c b/src/mesh/mesh.c
index ab3e92c..2f3b330 100644
--- a/src/mesh/mesh.c
+++ b/src/mesh/mesh.c
@@ -150,7 +150,7 @@ int honey_mesh_load(lua_State* L)
lua_createtable(L, 0, 0);
- process_nodes_recursively(L, scene, scene->mRootNode, n_meshes);
+ process_nodes_recursively(L, scene, scene->mRootNode, &n_meshes);
return 1;
}