Face the text toward the user's head

This commit is contained in:
BabbleBones 2023-09-26 19:32:34 -04:00
parent a4378d7d94
commit af7d9a9e19

View file

@ -252,21 +252,33 @@ function deinitConfigure()
end end
function modeConfigure(pass) function modeConfigure(pass)
local _,hy,_ = lovr.headset.getPosition("head") local hx, hy, hz = lovr.headset.getPosition("head")
for _,hand in ipairs(hands) do for _, hand in ipairs(hands) do
if isTracked(hand .. "/point") then if isTracked(hand .. "/point") then
local x,y,z = lovr.headset.getPosition(hand .. "/point") local cx, cy, cz = lovr.headset.getPosition(hand .. "/point")
pass:setColor(1,0,0,0.5 * saveProg)
pass:sphere(x,y,z,0.1) -- Compute the direction from the controller to the headset
pass:setColor(1,1,1,saveProg) local dirX = hx - cx
pass:text( local dirY = hy - cy
"- Press '" ..settings.action_button.. "' to add a point -\n" .. local dirZ = hz - cz
"- Hold '" ..settings.action_button.. "' to save -\n\n" ..
string.format("%.2f",x) .. "," .. string.format("%.2f",y) .. "," .. string.format("%.2f",z) -- Compute the rotation angle to make the text face the headset
,x,y - 0.3,z,0.066) local angle = math.atan2(dirX, dirZ)
end
end pass:setColor(1, 0, 0, 0.5 * saveProg)
pass:sphere(cx, cy, cz, 0.1)
pass:setColor(1, 1, 1, saveProg)
-- Draw the text with the computed rotation
pass:text(
"- Press '" .. settings.action_button .. "' to add a point -\n" ..
"- Hold '" .. settings.action_button .. "' to save -\n\n" ..
string.format("%.2f", cx) .. "," .. string.format("%.2f", cy) .. "," .. string.format("%.2f", cz),
cx, cy - 0.3, cz, 0.066, angle, 0, 1, 0
)
end
end
local inputDev = getButton(lovr.headset.wasReleased,settings.action_button,hands) local inputDev = getButton(lovr.headset.wasReleased,settings.action_button,hands)
if inputDev ~= nil and isTracked(inputDev) then if inputDev ~= nil and isTracked(inputDev) then