diff options
author | sanine-a <sanine.not@pm.me> | 2020-11-29 22:38:45 -0600 |
---|---|---|
committer | sanine-a <sanine.not@pm.me> | 2020-11-29 22:38:45 -0600 |
commit | 306e6cca8e49638779b111d66852877416971a59 (patch) | |
tree | 0faaf9087b9acaa8a74ff2716ad2b406e4dfc526 /demo | |
parent | 8a75194c51a189f9c8f72d9821beb00b7f75d06d (diff) |
add camera functions and fix bug in argument parsing
Diffstat (limited to 'demo')
-rw-r--r-- | demo/main.lua | 96 |
1 files changed, 2 insertions, 94 deletions
diff --git a/demo/main.lua b/demo/main.lua index 660614d..ec5746a 100644 --- a/demo/main.lua +++ b/demo/main.lua @@ -1,95 +1,3 @@ -local Vector = require('Vector') -local Matrix = require('Matrix') -local FPSCamera = require('FPSCamera') -local Node = require('Node') -local SpatialShader = require('SpatialShader') -local ScreenQuad = require('ScreenQuad') -local MeshInstance = require('MeshInstance') -FPSCamera.movement_speed = 5 +local v = honey.glm.vec3() -honey.input.key.bind(honey.input.key.escape, honey.exit) - -local buffer = false -honey.input.key.bind(honey.input.key.f, function(action) if action == 1 then buffer = not buffer end end) - -local tex = honey.texture.new() -honey.texture.load(tex, 'checkerboard.png', false) - -local sceneRoot = Node.new(nil, - Vector.Vec3.new(), - Vector.Vec3.new(), - Vector.Vec3.new{1,1,1}) - -local shader = SpatialShader.new(tex) -local lightDirection = Vector.Vec3.new{1,1,1} -lightDirection:normalize() -shader:setVec3('directional_lights[0].direction', lightDirection) -shader:setVec3('directional_lights[0].color', Vector.Vec3.new{0,1,0}) -local meshes = honey.mesh.load('Suzanne.obj') -print(#meshes) -local suzanne = MeshInstance.new(sceneRoot, - Vector.Vec3.new{0,0,-3}, - Vector.Vec3.new{0,math.pi,0}, - Vector.Vec3.new{0.5,1,0.5}, - meshes[1], - shader) -local plane = MeshInstance.new(suzanne, - Vector.Vec3.new{1,0,0}, - Vector.Vec3.new{0,0,0}, - Vector.Vec3.new{1,1,1}, - honey.primitives.plane(4,4), - shader) -local plane2 = MeshInstance.new(suzanne, - Vector.Vec3.new{5,0,0}, - Vector.Vec3.new{0,math.pi,0}, - Vector.Vec3.new{1,1,1}, - honey.primitives.plane(4,4), - shader) - -suzanne.update = function(self, dt) - --local angle = dt * math.pi - --self:yaw(angle) -end - -local total_frames = 0 -local total_time = 0 - -honey.window.set_size(640, 480) - -function honey.update(dt) - total_time = total_time + dt - FPSCamera:update(dt) - sceneRoot:updateCascade(dt) - if total_time > 1 then - print('FPS: '..tostring(total_frames/total_time)) - total_time = 0 - total_frames = 0 - end -end - -function draw_suzanne() - sceneRoot:drawCascade(FPSCamera) -end - -function honey.draw() - total_frames = total_frames + 1 - - if buffer then - honey.set_framebuffer(ScreenQuad.fb) - honey.set_viewport_size(480,640) - honey.clear_color(Vector.Vec4.new().array, true, true, false) - honey.enable_depth_test(true) - draw_suzanne() - - honey.set_framebuffer(0) - honey.set_viewport_size(640, 480) - honey.enable_depth_test(false) - honey.clear_color(Vector.Vec4.new{0,0,1,1}.array, true, false, false) - ScreenQuad:draw() - else - honey.clear_color(Vector.Vec4.new{1,1,0,1}.array, true, true, false) - honey.set_viewport_size(640, 480) - honey.enable_depth_test(true) - draw_suzanne() - end -end +v.dot(v, v) |