Face the text toward the user's head
This commit is contained in:
parent
a4378d7d94
commit
af7d9a9e19
32
main.lua
32
main.lua
|
@ -252,19 +252,31 @@ 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
|
||||||
|
local dirY = hy - cy
|
||||||
|
local dirZ = hz - cz
|
||||||
|
|
||||||
|
-- Compute the rotation angle to make the text face the headset
|
||||||
|
local angle = math.atan2(dirX, dirZ)
|
||||||
|
|
||||||
|
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(
|
pass:text(
|
||||||
"- Press '" ..settings.action_button.. "' to add a point -\n" ..
|
"- Press '" .. settings.action_button .. "' to add a point -\n" ..
|
||||||
"- Hold '" ..settings.action_button.. "' to save -\n\n" ..
|
"- Hold '" .. settings.action_button .. "' to save -\n\n" ..
|
||||||
string.format("%.2f",x) .. "," .. string.format("%.2f",y) .. "," .. string.format("%.2f",z)
|
string.format("%.2f", cx) .. "," .. string.format("%.2f", cy) .. "," .. string.format("%.2f", cz),
|
||||||
,x,y - 0.3,z,0.066)
|
cx, cy - 0.3, cz, 0.066, angle, 0, 1, 0
|
||||||
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue