mirror of
https://github.com/CapsAdmin/pac3.git
synced 2025-03-04 03:03:01 -05:00
wip faceposer presets
This commit is contained in:
parent
4b440180fb
commit
3695692080
@ -6,11 +6,58 @@ PART.FriendlyName = "face poser"
|
||||
PART.Icon = 'icon16/monkey.png'
|
||||
PART.Group = 'entity'
|
||||
|
||||
|
||||
BUILDER:StartStorableVars()
|
||||
:GetSet("Preset", "", {enums = function(part)
|
||||
local ent = part:GetOwner()
|
||||
if not ent:IsValid() then return end
|
||||
|
||||
local maps = {}
|
||||
|
||||
local toolgun = {}
|
||||
for i = 0, 255 do
|
||||
local name = ent:GetFlexName(i)
|
||||
if name then
|
||||
toolgun[name] = GetConVar("faceposer_flex" .. i):GetFloat()
|
||||
end
|
||||
end
|
||||
|
||||
maps.toolgun = util.TableToJSON({
|
||||
scale = GetConVar("faceposer_scale"):GetFloat(),
|
||||
weight_map = util.TableToJSON(toolgun),
|
||||
})
|
||||
|
||||
for preset_name, map in pairs(presets.GetTable( "face" )) do
|
||||
local preset = {}
|
||||
for key, weight in pairs(map) do
|
||||
local i = tonumber(key:match("faceposer_flex(%d+)"))
|
||||
if i then
|
||||
local name = ent:GetFlexName(i)
|
||||
if name then
|
||||
preset[name] = tonumber(weight)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
maps[preset_name] = util.TableToJSON({
|
||||
scale = tonumber(map.faceposer_scale),
|
||||
weight_map = util.TableToJSON(preset),
|
||||
})
|
||||
end
|
||||
|
||||
return maps
|
||||
end})
|
||||
:GetSet("FlexWeights", "", {editor_panel = "flex_weights"})
|
||||
:GetSet("Scale", 1)
|
||||
:EndStorableVars()
|
||||
|
||||
function PART:SetPreset(json)
|
||||
local preset = util.JSONToTable(json)
|
||||
self:SetFlexWeights(preset.weight_map)
|
||||
self:SetScale(preset.scale)
|
||||
self.Preset = ""
|
||||
end
|
||||
|
||||
function PART:GetNiceName()
|
||||
return "face pose"
|
||||
end
|
||||
@ -34,9 +81,11 @@ function PART:UpdateFlex()
|
||||
|
||||
for name, weight in pairs(self:GetWeightMap()) do
|
||||
local id = ent:GetFlexIDByName(name)
|
||||
if id then
|
||||
ent:SetFlexWeight(id, ent:GetFlexWeight(id) + weight)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function PART:BuildBonePositions()
|
||||
self:UpdateFlex()
|
||||
|
@ -589,7 +589,7 @@ do -- flex 2
|
||||
|
||||
tbl[name] = {
|
||||
sort_key = -i,
|
||||
val = weight_map[name],
|
||||
val = tonumber(weight_map[name]),
|
||||
callback = function(val)
|
||||
if ent:IsValid() and ent.GetFlexNum and ent:GetFlexNum() == 0 then return end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user