mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-11-22 10:29:47 +00:00
add 'control' VCA directive and 'visible' flag
This commit is contained in:
parent
b21f4d4439
commit
fed89b64c7
3 changed files with 38 additions and 18 deletions
|
|
@ -39,12 +39,13 @@ local function bezier_interpolation(k0, k1, t)
|
||||||
return bezier(k0.value, k0.ry + k0.value, k1.ly + k1.value, k1.value, u)
|
return bezier(k0.value, k0.ry + k0.value, k1.ly + k1.value, k1.value, u)
|
||||||
end
|
end
|
||||||
|
|
||||||
local this = {
|
local M = {
|
||||||
CH_TRANSLATE = 1,
|
CH_TRANSLATE = 1,
|
||||||
CH_ROTATE = 2,
|
CH_ROTATE = 2,
|
||||||
CH_SCALE = 3,
|
CH_SCALE = 3,
|
||||||
CH_ZOOM = 4,
|
CH_ZOOM = 4,
|
||||||
CH_TEXTURE = 5,
|
CH_TEXTURE = 5,
|
||||||
|
CH_CONTROL = 6,
|
||||||
|
|
||||||
INT_CONST = 1,
|
INT_CONST = 1,
|
||||||
INT_LINEAR = 2,
|
INT_LINEAR = 2,
|
||||||
|
|
@ -53,7 +54,7 @@ local this = {
|
||||||
MAX_DURATION = 1e9,
|
MAX_DURATION = 1e9,
|
||||||
MAX_FRAMES = 1e9,
|
MAX_FRAMES = 1e9,
|
||||||
|
|
||||||
TRACE_CODEGEN = false,
|
TRACE_CODEGEN = true,
|
||||||
|
|
||||||
maths = {
|
maths = {
|
||||||
bezier_interpolation = bezier_interpolation
|
bezier_interpolation = bezier_interpolation
|
||||||
|
|
@ -67,14 +68,14 @@ function internals.store_animation(name, track)
|
||||||
loaded_tracks[name] = track
|
loaded_tracks[name] = track
|
||||||
end
|
end
|
||||||
|
|
||||||
function this.get_track(identifier)
|
function M.get_track(identifier)
|
||||||
return loaded_tracks[identifier]
|
return loaded_tracks[identifier]
|
||||||
end
|
end
|
||||||
|
|
||||||
local running_actions = {}
|
local running_actions = {}
|
||||||
local playing_tracks = {}
|
local playing_tracks = {}
|
||||||
|
|
||||||
function this.action(func)
|
function M.action(func)
|
||||||
table.insert(running_actions, coroutine.create(func))
|
table.insert(running_actions, coroutine.create(func))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -98,7 +99,7 @@ local PlayingTrack = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function this.play(name, target)
|
function M.play(name, target)
|
||||||
if target and target.reset_pose then
|
if target and target.reset_pose then
|
||||||
target:reset_pose()
|
target:reset_pose()
|
||||||
end
|
end
|
||||||
|
|
@ -156,4 +157,4 @@ function internals.restore_animation_backup()
|
||||||
loaded_tracks, backup_tracks = backup_tracks, {}
|
loaded_tracks, backup_tracks = backup_tracks, {}
|
||||||
end
|
end
|
||||||
|
|
||||||
return this
|
return M
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ local env = {
|
||||||
return keys[left].value
|
return keys[left].value
|
||||||
end
|
end
|
||||||
left = keys[left]
|
left = keys[left]
|
||||||
if interp == INT_CONST then
|
if not interp or interp == INT_CONST then
|
||||||
return left.value
|
return left.value
|
||||||
end
|
end
|
||||||
right = keys[right]
|
right = keys[right]
|
||||||
|
|
@ -170,7 +170,7 @@ local function codegen_track(raw_track, lineset, keysets, use_tsf)
|
||||||
local rotation = {false, false, false}
|
local rotation = {false, false, false}
|
||||||
local scale = {false, false, false}
|
local scale = {false, false, false}
|
||||||
for i, line in ipairs(lines) do
|
for i, line in ipairs(lines) do
|
||||||
code = code .. string.format("\n local l%d = ", i)
|
code = code .. string.format("\n local l%d = ", i)
|
||||||
.. codegen_line(raw_track, lineset, line, i, keysets)
|
.. codegen_line(raw_track, lineset, line, i, keysets)
|
||||||
|
|
||||||
if line.channel == animation.CH_TRANSLATE then
|
if line.channel == animation.CH_TRANSLATE then
|
||||||
|
|
@ -185,8 +185,12 @@ local function codegen_track(raw_track, lineset, keysets, use_tsf)
|
||||||
elseif line.channel == animation.CH_ZOOM then
|
elseif line.channel == animation.CH_ZOOM then
|
||||||
code = code .. "\n zoom = l" .. i
|
code = code .. "\n zoom = l" .. i
|
||||||
elseif line.channel == animation.CH_TEXTURE then
|
elseif line.channel == animation.CH_TEXTURE then
|
||||||
code = code .. string.format("\n target:set_texture(%s, %s)",
|
code = code .. string.format("\n target:set_texture(%s, l%d)",
|
||||||
lineset.target_name:escape(), "l"..i)
|
lineset.target_name:escape(), i)
|
||||||
|
elseif line.channel == animation.CH_CONTROL then
|
||||||
|
if lineset.flag == "visible" then
|
||||||
|
code = code .. string.format("\n target:set_visible(bone_index, l%d)", i)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -231,11 +235,13 @@ local function codegen_rig_target(raw_track, context)
|
||||||
end
|
end
|
||||||
local lineset_code = codegen_track(raw_track, lineset, context.keysets, true)
|
local lineset_code = codegen_track(raw_track, lineset, context.keysets, true)
|
||||||
|
|
||||||
|
code = code .. string.format("\n local bone_index = target:index(%s)", string.escape(bone))
|
||||||
|
if context.has_tsf then
|
||||||
|
code = code .. "\n local dst = target:get_matrix(bone_index)"
|
||||||
|
end
|
||||||
code = code
|
code = code
|
||||||
.. string.format("\n local bone_index = target:index(%s)"
|
|
||||||
.. "\n local dst = target:get_matrix(bone_index)", string.escape(bone))
|
|
||||||
.. "\n do" .. lineset_code .. "\n end\n"
|
.. "\n do" .. lineset_code .. "\n end\n"
|
||||||
if lineset.target_type == "bone" then
|
if lineset.target_type == "bone" and context.has_tsf then
|
||||||
code = code ..
|
code = code ..
|
||||||
" target:set_matrix(bone_index, dst)\n"
|
" target:set_matrix(bone_index, dst)\n"
|
||||||
end
|
end
|
||||||
|
|
@ -298,10 +304,8 @@ function internals.compile_animation_track(raw_track, track_name)
|
||||||
), "<curve>", "t", env)()
|
), "<curve>", "t", env)()
|
||||||
end
|
end
|
||||||
|
|
||||||
if context.has_tsf then
|
code = code .. codegen_rig_target(raw_track, context)
|
||||||
code = code .. codegen_rig_target(raw_track, context)
|
code = code .. codegen_object_target(raw_track, context)
|
||||||
code = code .. codegen_object_target(raw_track, context)
|
|
||||||
end
|
|
||||||
code = code .. codegen_camera_target(raw_track, context)
|
code = code .. codegen_camera_target(raw_track, context)
|
||||||
|
|
||||||
local src = "return function(target, t, intensity, m)\n"
|
local src = "return function(target, t, intensity, m)\n"
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ local action_to_channel = {
|
||||||
scale = animation.CH_SCALE,
|
scale = animation.CH_SCALE,
|
||||||
zoom = animation.CH_ZOOM,
|
zoom = animation.CH_ZOOM,
|
||||||
texture = animation.CH_TEXTURE,
|
texture = animation.CH_TEXTURE,
|
||||||
|
control = animation.CH_CONTROL,
|
||||||
}
|
}
|
||||||
|
|
||||||
local curve_to_interp = {
|
local curve_to_interp = {
|
||||||
|
|
@ -62,6 +63,17 @@ local function parse_simple_frames(line, node)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function parse_boolean_frames(line, node)
|
||||||
|
line.keys = {}
|
||||||
|
for j, key_node in ipairs(node) do
|
||||||
|
local keyframe = {
|
||||||
|
frame = tonumber(key_node.frame),
|
||||||
|
value = key_node.value == "on",
|
||||||
|
}
|
||||||
|
table.insert(line.keys, keyframe)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local function parse_directive(node, raw_track)
|
local function parse_directive(node, raw_track)
|
||||||
local linesets = raw_track.linesets
|
local linesets = raw_track.linesets
|
||||||
local tag = node['#']
|
local tag = node['#']
|
||||||
|
|
@ -85,7 +97,8 @@ local function parse_directive(node, raw_track)
|
||||||
lineset = {
|
lineset = {
|
||||||
lines = {},
|
lines = {},
|
||||||
target_type = target_type,
|
target_type = target_type,
|
||||||
target_name = target_name
|
target_name = target_name,
|
||||||
|
flag = node.flag,
|
||||||
}
|
}
|
||||||
linesets[target_name] = lineset
|
linesets[target_name] = lineset
|
||||||
end
|
end
|
||||||
|
|
@ -103,6 +116,8 @@ local function parse_directive(node, raw_track)
|
||||||
line.expression = node.func
|
line.expression = node.func
|
||||||
elseif node.curve then
|
elseif node.curve then
|
||||||
parse_curve(line, node)
|
parse_curve(line, node)
|
||||||
|
elseif node.flag then
|
||||||
|
parse_boolean_frames(line, node)
|
||||||
else
|
else
|
||||||
parse_simple_frames(line, node)
|
parse_simple_frames(line, node)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue