From a1d223ed29ce49ce11f82f754b5cecd4cd8e3080 Mon Sep 17 00:00:00 2001 From: uvos Date: Fri, 18 Apr 2025 21:42:38 +0200 Subject: [PATCH] Inital commit --- inwardlines/main.lua | 28 ++++++++++++++++++++++++++++ static/main.lua | 33 +++++++++++++++++++++++++++++++++ tracking/main.lua | 22 ++++++++++++++++++++++ 3 files changed, 83 insertions(+) create mode 100644 inwardlines/main.lua create mode 100644 static/main.lua create mode 100644 tracking/main.lua diff --git a/inwardlines/main.lua b/inwardlines/main.lua new file mode 100644 index 0000000..d7a960d --- /dev/null +++ b/inwardlines/main.lua @@ -0,0 +1,28 @@ +local width = 1 +local distance = 10 + +local init = false +local x = 0 +local y = 0 +local z = 0 + +function drawGrid(pass, y) + pass:setColor(0, 1, 0) + + for i=-0.5,0.5,0.05 do + pass:line(x+width*i, y-0.1, z, x, y-0.1, z-distance) + end +end + +function lovr.draw(pass) + + if not init and lovr.headset.isTracked('head') then + x, y, z = lovr.headset.getPosition('head') + init = true + end + + drawGrid(pass, y) + pass:circle(x, y-0.1, z-distance, 0.05, 0, 0, 0, 1, 'fill') + +end + diff --git a/static/main.lua b/static/main.lua new file mode 100644 index 0000000..5252198 --- /dev/null +++ b/static/main.lua @@ -0,0 +1,33 @@ +-- Set the units of the default font to pixels instead of meters +local font = lovr.graphics.getDefaultFont() +font:setPixelDensity(1) + +-- Set up a 2D orthographic projection, where (0, 0) is the upper +-- left of the window and the units are in pixels +local width, height = lovr.system.getWindowDimensions() +local projection = Mat4():orthographic(0, width, 0, height, -10, 10) + +function drawGrid(pass) + pass:setColor(0, 1, 0) + for i=0,1,0.025 do + pass:line(0, height*i, 0, width, height*i, 0) + end + + for i=0,1,0.025 do + pass:line(width*i, 0, 0, width*i, height, 0) + end +end + +function lovr.draw(pass) + pass:setViewPose(1, mat4():identity()) + pass:setProjection(1, projection) + pass:setDepthTest() + + drawGrid(pass) + pass:circle(width/2, height/2, 0, 2, 0, 0, 0, 1, 'fill') + + pass:setViewPose(2, mat4():identity()) + pass:setProjection(2, projection) + drawGrid(pass) + pass:circle(width/2, height/2, 0, 2, 0, 0, 0, 1, 'fill') +end diff --git a/tracking/main.lua b/tracking/main.lua new file mode 100644 index 0000000..1a6a37f --- /dev/null +++ b/tracking/main.lua @@ -0,0 +1,22 @@ +local width = 20 +local height = 20 +local distance = 10 + +function drawGrid(pass) + pass:setColor(0, 1, 0) + for i=-0.5,0.5,0.05 do + pass:line(width*-0.5, height*i, -distance, width*0.5, height*i, -distance) + end + + for i=-0.5,0.5,0.05 do + pass:line(width*i, height*-0.5, -distance, width*i, height*0.5, -distance) + end +end + +function lovr.draw(pass) + + drawGrid(pass) + pass:circle(0, 0, -distance, 0.05, 0, 0, 0, 1, 'fill') + +end +