add modeltree:get_matrix, :set_matrix
This commit is contained in:
@@ -5,8 +5,14 @@ local rig = entity.modeltree
|
||||
inair = true
|
||||
ready = false
|
||||
|
||||
|
||||
local rotation = mat4.rotate({0, 1, 0}, math.random() * 360)
|
||||
mat4.rotate(rotation, {1, 0, 0}, math.random() * 360, rotation)
|
||||
mat4.rotate(rotation, {0, 0, 1}, math.random() * 360, rotation)
|
||||
rig:set_matrix(0, rotation)
|
||||
|
||||
function on_grounded(force)
|
||||
tsf:set_rot(mat4.rotate({0, 1, 0}, math.random()*360))
|
||||
rig:set_matrix(0, mat4.rotate({0, 1, 0}, math.random()*360))
|
||||
inair = false
|
||||
ready = true
|
||||
end
|
||||
@@ -25,7 +31,9 @@ end
|
||||
function on_update()
|
||||
if inair then
|
||||
local dt = time.delta();
|
||||
tsf:set_rot(mat4.rotate(tsf:get_rot(), {0, 1, 0}, 240*dt))
|
||||
tsf:set_rot(mat4.rotate(tsf:get_rot(), {0, 0, 1}, 240*dt))
|
||||
local matrix = rig:get_matrix(0)
|
||||
mat4.rotate(matrix, {0, 1, 0}, 240*dt, matrix)
|
||||
mat4.rotate(matrix, {0, 0, 1}, 240*dt, matrix)
|
||||
rig:set_matrix(0, matrix)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -16,8 +16,6 @@ function on_hud_open()
|
||||
|
||||
local drop = entities.spawn("base:drop", ppos)
|
||||
drop.rigidbody:set_vel(vec3.add(throw_force, vec3.add(pvel, DROP_INIT_VEL)))
|
||||
drop.transform:set_rot(mat4.rotate(mat4.rotate(mat4.rotate({0, 1, 0}, math.random() * 360),
|
||||
{1, 0, 0}, math.random() * 360), {0, 0, 1}, math.random() * 360))
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user