-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.lua
More file actions
136 lines (101 loc) · 3.42 KB
/
Copy pathmain.lua
File metadata and controls
136 lines (101 loc) · 3.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
local Transform = require("transform")
local Platform = require("platform")
local Block = require("block")
local Expression_Block = require("lua.expression_block")
local String_Block = require("lua.string_block")
local Number_Block = require("lua.number_block")
local Workspace = require("workspace")
local Slot = require("slot")
local HBlock = require("blocks/horizontal_block")
local VBlock = require("blocks/vertical_block")
local Parser = require("lua.blockie_parser")
local w = Workspace:new()
local c = w:get_cursor()
local b = {}
local test_src = [[local x, y, z = 'hello', 'lovr', 'people!'
x = (y .. 'test')
z = 10 * 15^2
return z, y, x ]]
local src = Parser:parse(test_src)
if lovr then
local m4 = lovr.math.mat4(lovr.math.vec3(-0.4, 1.5, -1.2))
for i, v in ipairs(src) do
v:move(m4)
w:add_block(v)
m4:translate(0.2,-0.2,0)
end
local x, y, z = 0, 0, 0
local was_pressed = false
local t = Transform:new(lovr.math.newMat4())
-- local b = String_Block:new("Test")
-- b:measure()
-- w:add_block(b)
-- b = 10 c,d = 12, 13 local e = 14, 26]]
function lovr.load()
models = {
left = lovr.headset.newModel('hand/left', { animated = true }),
right = lovr.headset.newModel('hand/right', { animated = true })
}
-- w:add_block(b)
-- wc, hc = c.collider:get_size()
-- wb, hb = b:get_size()
end
function lovr.update()
local hands = lovr.headset.getHands()
if lovr.headset.isDown(hands[1], 'trigger') then
local m4 = mat4(lovr.headset.getPose(hands[1])):translate(0,0,-0.2)
-- b:move(m4)
end
-- if lovr.headset.isDown(hands[2], 'trigger') then
local m4 = mat4(lovr.headset.getPose(hands[2])):translate(0,0,-0.2)
c:move(m4)
if lovr.headset.isDown(hands[2], 'trigger') and not was_pressed then
was_pressed = true
c:pick()
elseif not lovr.headset.isDown(hands[2], 'trigger') and was_pressed then
was_pressed = false
c:drop()
end
end
function lovr.draw()
lovr.graphics.setColor(1,1,1)
for hand, model in pairs(models) do
if lovr.headset.isTracked(hand) then
local handPose = mat4(lovr.headset.getPose(hand))
local success = lovr.headset.animate(hand, model)
model:draw(handPose)
end
end
w:draw()
if false then
local text = "This is a test ->\n->\n->"
local w, h = Platform:get_text_size( text )
Platform.draw_box( t, w, h, 0.3, 0.3, 0.3)
local t_right = t:offset(w,0)
Platform.draw_box( t_right, w, h, 1,0.3,0.3)
local t_down = t:offset(0,h)
Platform.draw_box( t_down, w, h, 0.3,0.1,0.3)
local tt = Transform:new(lovr.math.mat4(t:unpack()):translate(0,0,0.03))
Platform.draw_text(tt, text , 0.6,0.6,0)
end
local xx, yy, zz = t:unpack():unpack(false)
-- lovr.graphics.sphere(xx, yy, zz, .01 )
-- lovr.graphics.print('X: ' .. x .. '\nY: ' .. y .. '\nZ: ' .. z , 0, 1.7, -3, .5)
end
else
for i, v in ipairs(src) do
w:add_block(v)
end
function love.draw()
w:draw()
end
function love.mousemoved( x, y, dx, dy, istouch )
c:move(x - 8, y - 8)
end
function love.mousepressed()
c:pick()
end
function love.mousereleased()
c:drop()
end
end