From 51c8d78b88fdcc241abfd9cc0b16feb6f84c416b Mon Sep 17 00:00:00 2001 From: MihailRis Date: Fri, 9 Oct 2026 00:14:59 +0300 Subject: [PATCH] add 'color' VCA directive --- res/modules/animation.lua | 1 + res/modules/internal/animation_codegen.lua | 11 +++++++++++ res/modules/internal/formats/vca.lua | 3 ++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/res/modules/animation.lua b/res/modules/animation.lua index 89a1ae6e2..a4e1f73d9 100644 --- a/res/modules/animation.lua +++ b/res/modules/animation.lua @@ -47,6 +47,7 @@ local M = { CH_TEXTURE = 5, CH_SHOW = 6, CH_MODEL = 7, + CH_COLOR = 8, INT_CONST = 1, INT_LINEAR = 2, diff --git a/res/modules/internal/animation_codegen.lua b/res/modules/internal/animation_codegen.lua index 8230c28dd..5a7c5d8e0 100644 --- a/res/modules/internal/animation_codegen.lua +++ b/res/modules/internal/animation_codegen.lua @@ -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 diff --git a/res/modules/internal/formats/vca.lua b/res/modules/internal/formats/vca.lua index 0c72203c7..1ebac16f8 100644 --- a/res/modules/internal/formats/vca.lua +++ b/res/modules/internal/formats/vca.lua @@ -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 }