add time over users head

This commit is contained in:
uvos 2025-05-25 20:54:40 +02:00
parent 012271df51
commit 7b78e0e0ef

View file

@ -1,6 +1,13 @@
-- Bootstrap -- Bootstrap
appName = "lovr-playspace" appName = "lovr-playspace"
-- Function to get the current time
function getCurrentTime()
local time = os.time()
local date = os.date("*t", time)
return string.format("%02d:%02d", date.hour, date.min)
end
-- App -- App
hands = {"hand/right","hand/left"} hands = {"hand/right","hand/left"}
limbs = { limbs = {
@ -37,6 +44,11 @@ function getFloorMatrix()
return lovr.math.newMat4(lovr.math.vec3(fx, fy, fz), lovr.math.vec3(1, 1, 1), lovr.math.quat(fangle, fax, fay, faz)) return lovr.math.newMat4(lovr.math.vec3(fx, fy, fz), lovr.math.vec3(1, 1, 1), lovr.math.quat(fangle, fax, fay, faz))
end end
function getHeadMatrix()
local fx, fy, fz, fangle, fax, fay, faz = lovr.headset.getPose("head")
return lovr.math.newMat4(lovr.math.vec3(fx, fy, fz), lovr.math.vec3(1, 1, 1), lovr.math.quat(fangle, fax, fay, faz))
end
function getLineDistance(x, _, z, point1, point2) -- Notice the underscore for y function getLineDistance(x, _, z, point1, point2) -- Notice the underscore for y
-- Vector from point1 to point2 -- Vector from point1 to point2
local dx = point2[1] - point1[1] local dx = point2[1] - point1[1]
@ -378,5 +390,17 @@ function modeDraw(pass)
end end
function lovr.draw(pass) function lovr.draw(pass)
mode(pass) mode(pass)
local hx, hy, hz = lovr.headset.getPosition("head")
local hangle, hax, hay, haz = lovr.headset.getOrientation("head")
local currentTime = getCurrentTime()
pass:setColor(1, 1, 1, 0.25)
local transform = lovr.math.newMat4()
transform:translate(hx, hy + 1.5, hz)
transform:rotate(math.pi / 2, 1, 0, 0)
transform:rotate(math.pi - math.atan2(hax, haz)*2, 0, 0, 1)
transform:translate(0, -0.1, 0)
transform:scale(0.1, 0.1, 0.1)
pass:text(currentTime, transform)
end end