add 'color' VCA directive

This commit is contained in:
MihailRis 2026-10-09 00:14:59 +03:00
parent 371b8baed1
commit 51c8d78b88
3 changed files with 14 additions and 1 deletions

View file

@ -47,6 +47,7 @@ local M = {
CH_TEXTURE = 5,
CH_SHOW = 6,
CH_MODEL = 7,
CH_COLOR = 8,
INT_CONST = 1,
INT_LINEAR = 2,

View file

@ -173,6 +173,7 @@ local function codegen_track(raw_track, lineset, keysets, use_tsf, target_type)
local translation = {false, false, false}
local rotation = {false, false, false}
local scale = {false, false, false}
local color = {false, false, false, false}
for i, line in ipairs(lines) do
code = code .. string.format("\n local l%d = ", i)
@ -200,9 +201,19 @@ local function codegen_track(raw_track, lineset, keysets, use_tsf, target_type)
else
code = code .. string.format("\n target:set_visible(l%d)", i)
end
elseif line.channel == animation.CH_COLOR then
color[line.axis] = i
end
end
if color[1] or color[2] or color[3] or color[4] then
code = code .. "\n target:set_color({" ..
(color[1] and ("l" .. color[1]) or '1').. ", " ..
(color[2] and ("l" .. color[2]) or '1').. ", " ..
(color[3] and ("l" .. color[3]) or '1').. ", " ..
(color[4] and ("l" .. color[4]) or '1').. "})"
end
if not has_tsf or not use_tsf then
return code
end

View file

@ -10,6 +10,7 @@ local action_to_channel = {
texture = animation.CH_TEXTURE,
show = animation.CH_SHOW,
model = animation.CH_MODEL,
color = animation.CH_COLOR,
}
local curve_to_interp = {
@ -115,7 +116,7 @@ local function parse_directive(node, raw_track)
error("unknown directive " .. tag:escape())
end
local line = {
axis = node.by and ("xyz"):find(node.by) or "",
axis = node.by and (("xyz"):find(node.by) or ("rgba"):find(node.by)) or "",
channel = channel,
period = node.period or animation.MAX_FRAMES
}