mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-11 14:01:49 +00:00
add animation.parse_track
This commit is contained in:
parent
68a5a0bd7a
commit
57c9da2eb1
1 changed files with 38 additions and 0 deletions
|
|
@ -162,6 +162,44 @@ local function codegen_track(lines, memoised, keysets)
|
||||||
return code
|
return code
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local action_to_channel = {
|
||||||
|
move = CH_TRANSLATE,
|
||||||
|
rotate = CH_ROTATE
|
||||||
|
}
|
||||||
|
|
||||||
|
function this.parse_track(root)
|
||||||
|
local linesets = {}
|
||||||
|
for i, node in ipairs(root) do
|
||||||
|
if type(node) == "string" then
|
||||||
|
goto continue
|
||||||
|
end
|
||||||
|
local tag = node['#']
|
||||||
|
local bone = node.bone
|
||||||
|
|
||||||
|
local lineset = linesets[bone]
|
||||||
|
if not lineset then
|
||||||
|
lineset = {lines = {}}
|
||||||
|
linesets[bone] = lineset
|
||||||
|
end
|
||||||
|
|
||||||
|
local line
|
||||||
|
if node.func then
|
||||||
|
line = {
|
||||||
|
axis = ("xyz"):find(node.by),
|
||||||
|
channel = action_to_channel[tag],
|
||||||
|
expression = node.func,
|
||||||
|
}
|
||||||
|
elseif #node > 0 then
|
||||||
|
error("not implemented")
|
||||||
|
end
|
||||||
|
|
||||||
|
table.insert(lineset.lines, line)
|
||||||
|
::continue::
|
||||||
|
end
|
||||||
|
return linesets
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
function this.compile_track(linesets)
|
function this.compile_track(linesets)
|
||||||
local code = ""
|
local code = ""
|
||||||
local memoised = {}
|
local memoised = {}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue