diff --git a/build/Rosetta.luau b/build/Rosetta.luau index c6803e1..b6e427f 100644 --- a/build/Rosetta.luau +++ b/build/Rosetta.luau @@ -162673,7 +162673,8 @@ __FILES["model/blend"] = function() -- meshes of every storage generation (MFace, MPoly / MLoop, attribute layers, AttributeStorage) with UV maps, colour -- attributes, custom normals, material slots; Principled BSDF materials; packed and external images; cameras; lights; -- armatures, skins (vertex groups, top 4 weights), shape keys (relative keys, vertex groups); actions sampled into --- channels; rig data (bone collections / layers, colours, custom shapes, pose settings, constraint stacks) as extras. +-- channels, and every action's raw f-curves in meta.blend.actions; rig data (bone collections / layers, colours, +-- custom shapes, pose settings, constraint stacks) as extras. -- Not supported: modifiers (listed in meta.source.modifiers), curves / text / metaballs / grease pencil / volumes, -- NLA strips, drivers, constraint evaluation, f-curve modifiers, linked libraries, collection instances. @@ -162706,6 +162707,7 @@ type DecodeOptions = { scene: string?, -- a scene by name (default: the file's current scene) sampleStep: number?, -- frames between animation samples (default 1) animations: boolean?, -- default true + rawActions: boolean?, -- every action's f-curves and keys in meta.blend.actions (default true) resolve: ((uri: string) -> any)?, -- external images files: { [string]: any }?, maxBytes: number?, -- decompressed size limit (default 2^31) @@ -162827,6 +162829,54 @@ local function curve(f: Blend.File, fc: Blend.View): Curve? return { path = path, index = fc:num("array_index") or 0, keys = keys, extend = fc:num("extend") or 0, modifiers = #mods } end +-- an action's f-curves: the legacy list, or (4.4+ layered actions) the channel bags of the strips of every layer whose +-- slot handle matches (handle nil: the first layer's first strip's first channel bag) +local function fcurves(f: Blend.File, act: Blend.View, handle: number?): { Blend.View } + local list: { Blend.View } = act:list("curves", "FCurve") + if #list > 0 or not act:has("layer_array") then + return list + end + local datas = act:pointers("strip_keyframe_data_array", act:num("strip_keyframe_data_array_num")) + for _, la in act:pointers("layer_array", act:num("layer_array_num")) do + local lblk = la and Blend.resolve(f, la, act.block) + local layer = lblk and Blend.struct(f, lblk, 0, "ActionLayer") + if layer then + for _, sa in layer:pointers("strip_array", layer:num("strip_array_num")) do + local sblk = sa and Blend.resolve(f, sa, act.block) + local strip = sblk and Blend.struct(f, sblk, 0, "ActionStrip") + local di = strip and strip:num("data_index") + local dblk = di and datas[di + 1] and Blend.resolve(f, datas[di + 1], act.block) + local kd = dblk and Blend.struct(f, dblk, 0, "ActionStripKeyframeData") + if kd then + for _, ba in kd:pointers("channelbag_array", kd:num("channelbag_array_num")) do + local bblk = ba and Blend.resolve(f, ba, act.block) + local bag = bblk and (Blend.struct(f, bblk, 0, "ActionChannelBag") or Blend.struct(f, bblk, 0, "ActionChannelbag")) + if bag and (handle == nil or (bag:num("slot_handle") or 0) == handle) then + for _, ca in bag:pointers("fcurve_array", bag:num("fcurve_array_num")) do + local cblk = ca and Blend.resolve(f, ca, act.block) + local fc = cblk and Blend.struct(f, cblk, 0, "FCurve") + if fc then + table.insert(list, fc) + end + end + if handle == nil then + return list + end + end + end + end + if handle == nil then + return list + end + end + end + if handle == nil then + return list + end + end + return list +end + function Anim.curves(f: Blend.File, adt: Blend.View?): ({ Curve }?, string?) if not adt then return nil, nil @@ -162835,41 +162885,8 @@ function Anim.curves(f: Blend.File, adt: Blend.View?): ({ Curve }?, string?) if not act then return nil, nil end - local list: { Blend.View } = act:list("curves", "FCurve") - if #list == 0 and act:has("layer_array") then - local handle = adt:num("slot_handle") or 0 - local datas = act:pointers("strip_keyframe_data_array", act:num("strip_keyframe_data_array_num")) - for _, la in act:pointers("layer_array", act:num("layer_array_num")) do - local lblk = la and Blend.resolve(f, la, act.block) - local layer = lblk and Blend.struct(f, lblk, 0, "ActionLayer") - if layer then - for _, sa in layer:pointers("strip_array", layer:num("strip_array_num")) do - local sblk = sa and Blend.resolve(f, sa, act.block) - local strip = sblk and Blend.struct(f, sblk, 0, "ActionStrip") - local di = strip and strip:num("data_index") - local dblk = di and datas[di + 1] and Blend.resolve(f, datas[di + 1], act.block) - local kd = dblk and Blend.struct(f, dblk, 0, "ActionStripKeyframeData") - if kd then - for _, ba in kd:pointers("channelbag_array", kd:num("channelbag_array_num")) do - local bblk = ba and Blend.resolve(f, ba, act.block) - local bag = bblk and (Blend.struct(f, bblk, 0, "ActionChannelBag") or Blend.struct(f, bblk, 0, "ActionChannelbag")) - if bag and (bag:num("slot_handle") or 0) == handle then - for _, ca in bag:pointers("fcurve_array", bag:num("fcurve_array_num")) do - local cblk = ca and Blend.resolve(f, ca, act.block) - local fc = cblk and Blend.struct(f, cblk, 0, "FCurve") - if fc then - table.insert(list, fc) - end - end - end - end - end - end - end - end - end local out: { Curve } = {} - for _, fc in list do + for _, fc in fcurves(f, act, adt:num("slot_handle") or 0) do local c = curve(f, fc) if c then table.insert(out, c) @@ -162878,6 +162895,67 @@ function Anim.curves(f: Blend.File, adt: Blend.View?): ({ Curve }?, string?) return out, act:idName() end +-- ------------------------------------------------------------------------------------------------ raw actions +local INTERPOLATION: { [number]: string } = { + [0] = "CONSTANT", [1] = "LINEAR", [2] = "BEZIER", [3] = "BACK", [4] = "BOUNCE", [5] = "CIRC", [6] = "CUBIC", + [7] = "ELASTIC", [8] = "EXPO", [9] = "QUAD", [10] = "QUART", [11] = "QUINT", [12] = "SINE", +} +local EASING: { [number]: string } = { [0] = "AUTO", [1] = "EASE_IN", [2] = "EASE_OUT", [3] = "EASE_IN_OUT" } +local HANDLE: { [number]: string } = { [0] = "FREE", [1] = "AUTO", [2] = "VECTOR", [3] = "ALIGNED", [4] = "AUTO_CLAMPED" } +local ACT_FRAME_RANGE = 0x1000 + +-- an action as Blender's API shows it: frame_range (the manual range, else the keys' span, at least one frame) and +-- every f-curve with its keyframe points +function Anim.raw(f: Blend.File, act: Blend.View): { [string]: any } + local curves: { { [string]: any } } = {} + local lo: number, hi: number = math.huge, -math.huge + for _, fc in fcurves(f, act, nil) do + local path = fc:cstring("rna_path") or "" + local kind, who, rest = Anim.split(path) + local keys: { { [string]: any } } = {} + for _, b in fc:array("bezt", "BezTriple") do + local v = b:vec("vec") + if v and #v >= 9 then + local x: number = v[4] + local k: { [string]: any } = { co = { x, v[5] }, handle_left = { v[1], v[2] }, handle_right = { v[7], v[8] } } + k.interpolation = INTERPOLATION[b:num("ipo") or 2] or "BEZIER" + k.easing = EASING[b:num("easing") or 0] or "AUTO" + k.handle_left_type, k.handle_right_type = HANDLE[b:num("h1") or 0], HANDLE[b:num("h2") or 0] + k.back, k.amplitude, k.period = b:num("back") or 1.70158, b:num("amplitude") or 0.8, b:num("period") or 4.1 + table.insert(keys, k) + lo, hi = math.min(lo, x), math.max(hi, x) + end + end + if #keys == 0 then + for _, p in fc:array("fpt", "FPoint") do + local v = p:vec("vec") + if v and #v >= 2 then + local x: number = v[1] + local k: { [string]: any } = { co = { x, v[2] } } + k.interpolation = "LINEAR" + table.insert(keys, k) + lo, hi = math.min(lo, x), math.max(hi, x) + end + end + end + local entry: { [string]: any } = { data_path = path, path = if kind == "pose.bones" then rest else path, keys = keys } + entry.bone = if kind == "pose.bones" then who else nil + entry.array_index = fc:num("array_index") or 0 + entry.extrapolation = if (fc:num("extend") or 0) == 1 then "LINEAR" else "CONSTANT" + table.insert(curves, entry) + end + if bit32.band(act:num("flag") or 0, ACT_FRAME_RANGE) ~= 0 and act:has("frame_start") then + lo = act:num("frame_start") or 0 + hi = act:num("frame_end") or 0 + elseif lo > hi then + lo, hi = 0, 0 + end + if hi <= lo then + hi = lo + 1 + end + return { frame_range = { lo, hi }, curves = curves } +end + -- pre-2.5 IPO curves (Object.ipo / Key.ipo): the curve's adrcode picks the channel; object rotations are in units of -- 10 degrees; the interpolation and extrapolation (0 constant, 1 linear; cyclic ones as constant) are per curve local OB_ADR: { [number]: { any } } = { @@ -163115,8 +163193,10 @@ __FILES["model/blend/Armature"] = function() -- armature space, deform, connect, wire), bone collections (4.x BoneCollection arrays and lists; before 4.0 the layers -- and bone groups converted as Blender 4.0's versioning does), bone colours (BoneColor; bone group colours before 4.0), -- pose bones (custom shapes, locks, rotation mode, IK settings) and constraint stacks (bConstraint and the data structs --- of IK, copy rotation / location / scale / transforms, damped track, limit rotation / location / scale, child of; the --- common fields for the rest). Flags from DNA_armature_types.h, DNA_action_types.h, DNA_constraint_types.h. +-- of IK, copy rotation / location / scale / transforms, damped track, limit rotation / location / scale, child of, +-- action, transform, stretch to, armature, floor, limit distance, track to, locked track; the common fields for the +-- rest), bone inheritance and b-bone settings, the stored pose basis. Flags from DNA_armature_types.h, +-- DNA_action_types.h, DNA_constraint_types.h. local Blend = __include("containers/Blend") local Armature = {} @@ -163174,6 +163254,33 @@ local PCHAN_DRAW_NO_CUSTOM_BONE_SIZE = 1 local LOCK_LOC, LOCK_ROT, LOCK_SCALE, LOCK_ROTW, LOCK_ROT4D = { 1, 2, 4 }, { 8, 16, 32 }, { 64, 128, 256 }, 512, 1024 local IK_NO_DOF, IK_LIMIT = { 1, 2, 4 }, { 8, 16, 32 } local AXES = { "x", "y", "z" } +local XYZ: { [number]: string } = { [0] = "X", [1] = "Y", [2] = "Z" } +-- bActionConstraint.type, .mix_mode +local ACTION_CHANNEL: { [number]: string } = { + [0] = "ROTATION_X", [1] = "ROTATION_Y", [2] = "ROTATION_Z", [10] = "SCALE_X", [11] = "SCALE_Y", [12] = "SCALE_Z", + [20] = "LOCATION_X", [21] = "LOCATION_Y", [22] = "LOCATION_Z", +} +local ACTION_MIX: { [number]: string } = { [0] = "AFTER_FULL", [1] = "AFTER", [2] = "BEFORE", [3] = "BEFORE_FULL", [4] = "BEFORE_SPLIT", [5] = "AFTER_SPLIT" } +local MAP: { [number]: string } = { [0] = "LOCATION", [1] = "ROTATION", [2] = "SCALE" } +-- the driver target rotation modes (DTAR_ROTMODE_*) +local FROM_ROT: { [number]: string } = { + [0] = "AUTO", [1] = "XYZ", [2] = "XZY", [3] = "YXZ", [4] = "YZX", [5] = "ZXY", [6] = "ZYX", [7] = "QUATERNION", + [8] = "SWING_TWIST_X", [9] = "SWING_TWIST_Y", [10] = "SWING_TWIST_Z", +} +local MIX_LOC: { [number]: string } = { [0] = "ADD", [1] = "REPLACE" } +local MIX_ROT: { [number]: string } = { [0] = "ADD", [1] = "REPLACE", [2] = "BEFORE", [3] = "AFTER" } +local MIX_SCALE: { [number]: string } = { [0] = "REPLACE", [1] = "MULTIPLY" } +local VOLUME: { [number]: string } = { [0] = "VOLUME_XZX", [1] = "VOLUME_X", [2] = "VOLUME_Z", [3] = "NO_VOLUME" } +local KEEP_AXIS: { [number]: string } = { [0] = "PLANE_X", [1] = "SWING_Y", [2] = "PLANE_Z" } +local FLOOR: { [number]: string } = { [0] = "FLOOR_X", [1] = "FLOOR_Y", [2] = "FLOOR_Z", [3] = "FLOOR_NEGATIVE_X", [4] = "FLOOR_NEGATIVE_Y", [5] = "FLOOR_NEGATIVE_Z" } +local DIST_MODE: { [number]: string } = { [0] = "LIMITDIST_INSIDE", [1] = "LIMITDIST_OUTSIDE", [2] = "LIMITDIST_ONSURFACE" } +local UP: { [number]: string } = { [0] = "UP_X", [1] = "UP_Y", [2] = "UP_Z" } +local LOCK: { [number]: string } = { [0] = "LOCK_X", [1] = "LOCK_Y", [2] = "LOCK_Z" } +-- Bone.inherit_scale_mode, bbone_prev_type / bbone_next_type, bbone_mapping_mode +local INHERIT_SCALE: { [number]: string } = { [0] = "FULL", [1] = "FIX_SHEAR", [2] = "AVERAGE", [3] = "NONE", [4] = "NONE_LEGACY", [5] = "ALIGNED" } +local HANDLE_TYPE: { [number]: string } = { [0] = "AUTO", [1] = "ABSOLUTE", [2] = "RELATIVE", [3] = "TANGENT" } +local MAPPING: { [number]: string } = { [0] = "STRAIGHT", [1] = "CURVED" } +local BONE_HINGE, BONE_NO_SCALE, BONE_NO_LOCAL_LOCATION, BONE_RELATIVE_PARENTING, BONE_ADD_PARENT_END_ROLL = 0x200, 0x8000, 0x400000, 0x800000, 0x1000000 local function bit(v: number?, mask: number): boolean return bit32.band(v or 0, mask) ~= 0 @@ -163348,7 +163455,35 @@ function Armature.bone(bone: Blend.View, pc: Blend.View?, pose: Blend.View?): { head_local = vec3(bone, "arm_head"), tail_local = vec3(bone, "arm_tail"), roll = bone:num("arm_roll"), + use_inherit_rotation = not bit(flag, BONE_HINGE), + use_local_location = not bit(flag, BONE_NO_LOCAL_LOCATION), + use_relative_parent = bit(flag, BONE_RELATIVE_PARENTING), } + local ism = bone:num("inherit_scale_mode") + e.inherit_scale = if ism then INHERIT_SCALE[ism] else (if bit(flag, BONE_NO_SCALE) then "NONE_LEGACY" else "FULL") -- BONE_NO_SCALE before 2.81 + e.bbone_segments = bone:num("segments") or 1 + e.bbone_x, e.bbone_z = bone:num("xwidth"), bone:num("zwidth") + e.bbone_easein, e.bbone_easeout = bone:num("ease1") or 1, bone:num("ease2") or 1 + e.bbone_rollin, e.bbone_rollout = bone:num("roll1") or 0, bone:num("roll2") or 0 + e.bbone_curveinx, e.bbone_curveinz = bone:num("curveInX") or 0, bone:num("curveInY") or 0 -- curveInY is the API's z + e.bbone_curveoutx, e.bbone_curveoutz = bone:num("curveOutX") or 0, bone:num("curveOutY") or 0 + for _, side in { "in", "out" } do + local cap = if side == "in" then "In" else "Out" + local v = vec3(bone, "scale_" .. side) + if not v then + -- before 3.0: scaleIn (x) and scale_in_y (z); before 2.8 one value for both + local x = bone:num("scale" .. cap) or 1 + v = { x, 1, bone:num("scale_" .. side .. "_y") or x } + end + e["bbone_scale" .. side] = v + end + e.bbone_handle_type_start = HANDLE_TYPE[bone:num("bbone_prev_type") or 0] + e.bbone_handle_type_end = HANDLE_TYPE[bone:num("bbone_next_type") or 0] + local prev, nxt = bone:deref("bbone_prev", 0, "Bone"), bone:deref("bbone_next", 0, "Bone") + e.bbone_custom_handle_start = if prev then prev:str("name") else nil + e.bbone_custom_handle_end = if nxt then nxt:str("name") else nil + e.use_endroll_as_inroll = if bone:has("bbone_flag") then bit(bone:num("bbone_flag"), 1) else bit(flag, BONE_ADD_PARENT_END_ROLL) + e.bbone_mapping_mode = MAPPING[bone:num("bbone_mapping_mode") or 0] if bone:has("color") then e.color = boneColor(bone) elseif pc and pose then @@ -163395,10 +163530,72 @@ local function constraintData(e: { [string]: any }, kind: string, d: Blend.View, e.invert_x, e.invert_y, e.invert_z = bit(flag, 16), bit(flag, 32), bit(flag, 64) e.use_offset = bit(flag, 128) elseif kind == "COPY_SCALE" then - -- SIZELIKE_X 1, Y 2, Z 4, OFFSET 8 + -- SIZELIKE_X 1, Y 2, Z 4, OFFSET 8, MULTIPLY 16 (use_add is its inverse), UNIFORM 32 e.use_x, e.use_y, e.use_z = bit(flag, 1), bit(flag, 2), bit(flag, 4) e.use_offset = bit(flag, 8) + e.use_add = not bit(flag, 16) + e.use_make_uniform = bit(flag, 32) e.power = d:num("power") or 1 + elseif kind == "ACTION" then + -- flag: ACTCON_BONE_USE_OBJECT_ACTION 1, ACTCON_USE_EVAL_TIME 2 + local act = d:deref("act", 0, "bAction") + e.action = if act then act:idName() else nil + e.transform_channel = ACTION_CHANNEL[d:num("type") or 20] + e.frame_start, e.frame_end = d:num("start") or 1, d:num("end") or 1 + e.min, e.max = d:num("min") or 0, d:num("max") or 0 + e.mix_mode = ACTION_MIX[d:num("mix_mode") or 0] + e.use_bone_object_action = bit(flag, 1) + e.use_eval_time = bit(flag, 2) + e.eval_time = d:num("eval_time") or 0 + elseif kind == "TRANSFORM" then + e.map_from, e.map_to = MAP[d:num("from") or 0], MAP[d:num("to") or 0] + local map = d.struct.byName.map + for i, a in AXES do + local o = map and d.offset + map.offset + i - 1 + e["map_to_" .. a .. "_from"] = XYZ[if o and o < buffer.len(d.file.buf) then buffer.readu8(d.file.buf, o) else i - 1] + end + e.use_motion_extrapolate = (d:num("expo") or 0) ~= 0 + e.from_rotation_mode = FROM_ROT[d:num("from_rotation_mode") or 0] + e.to_euler_order = EULER_ORDER[d:num("to_euler_order") or 0] + e.mix_mode = MIX_LOC[d:num("mix_mode_loc") or 0] + e.mix_mode_rot = MIX_ROT[d:num("mix_mode_rot") or 0] + e.mix_mode_scale = MIX_SCALE[d:num("mix_mode_scale") or 0] + for _, side in { "from", "to" } do + for _, suffix in { "", "_rot", "_scale" } do + local lo, hi = d:vec(side .. "_min" .. suffix), d:vec(side .. "_max" .. suffix) + for i, a in AXES do + e[side .. "_min_" .. a .. suffix] = lo and lo[i] or 0 + e[side .. "_max_" .. a .. suffix] = hi and hi[i] or 0 + end + end + end + elseif kind == "STRETCH_TO" then + -- STRETCHTOCON_USE_BULGE_MIN 1, MAX 2 + e.rest_length = d:num("orglength") + e.bulge = d:num("bulge") + e.volume = VOLUME[d:num("volmode") or 0] + e.keep_axis = KEEP_AXIS[d:num("plane") or 0] + e.use_bulge_min, e.use_bulge_max = bit(flag, 1), bit(flag, 2) + e.bulge_min, e.bulge_max, e.bulge_smooth = d:num("bulge_min"), d:num("bulge_max"), d:num("bulge_smooth") + elseif kind == "ARMATURE" then + -- CONSTRAINT_ARMATURE_QUATERNION 1, ENVELOPE 2, CUR_LOCATION 4 + e.use_deform_preserve_volume, e.use_bone_envelopes, e.use_current_location = bit(flag, 1), bit(flag, 2), bit(flag, 4) + elseif kind == "FLOOR" then + -- flag: MINMAX_USEROT 4 + e.floor_location = FLOOR[d:num("minmaxflag") or 2] + e.offset = d:num("offset") or 0 + e.use_rotation = bit(flag, 4) + elseif kind == "LIMIT_DISTANCE" then + e.distance = d:num("dist") + e.limit_mode = DIST_MODE[d:num("mode") or 0] + elseif kind == "TRACK_TO" then + -- reserved1 the track axis, reserved2 the up axis; flags TARGET_Z_UP 1 + e.track_axis = TRACK[d:num("reserved1") or 1] + e.up_axis = UP[d:num("reserved2") or 2] + e.use_target_z = bit(d:num("flags"), 1) + elseif kind == "LOCKED_TRACK" then + e.track_axis = TRACK[d:num("trackflag") or 1] + e.lock_axis = LOCK[d:num("lockflag") or 2] elseif kind == "COPY_TRANSFORMS" then e.mix_mode = TRANS_MIX[d:num("mix_mode") or 0] e.remove_target_shear = bit(flag, 1) @@ -163511,6 +163708,14 @@ function Armature.pose(e: { [string]: any }, pc: Blend.View, resolve: Resolve, s e["ik_stiffness_" .. a] = stiff and stiff[i] or 0 end e.pose_color = if pc:has("color") then boneColor(pc) else nil + -- the stored basis (rotation_quaternion w, x, y, z; rotation_axis_angle angle, x, y, z) + e.location = vec3(pc, "loc", { 0, 0, 0 }) + local q = pc:vec("quat") + e.rotation_quaternion = if q and #q >= 4 then { q[1], q[2], q[3], q[4] } else { 1, 0, 0, 0 } + e.rotation_euler = vec3(pc, "eul", { 0, 0, 0 }) + local axis = vec3(pc, "rotAxis", { 0, 1, 0 }) :: { number } + e.rotation_axis_angle = { pc:num("rotAngle") or 0, axis[1], axis[2], axis[3] } + e.scale = vec3(pc, "size", nil) or vec3(pc, "scale", { 1, 1, 1 }) e.constraints = Armature.constraints(pc, resolve) end @@ -165255,6 +165460,7 @@ type Options = { scene: string?, -- the scene to read (default: the file's current scene) sampleStep: number?, -- frames between animation samples (default 1) animations: boolean?, -- default true + rawActions: boolean?, -- every action's f-curves in meta.blend.actions (default true) resolve: ((uri: string) -> any)?, files: { [string]: any }?, maxVertices: number?, @@ -166240,8 +166446,27 @@ function Read.scene(f: Blend.File, opts: Options?): (Types.Scene?, string?) end end skins(ctx) + local mb: { [string]: any } = {} if next(ctx.armatures) ~= nil then - scene.meta.blend = { widgets = widgetList(ctx), bone_color_sets = Armature.colorSets() } + mb.widgets = widgetList(ctx) + mb.bone_color_sets = Armature.colorSets() + end + -- every action in the file by name (assigned or not: action constraints and the NLA refer to them) + if o.rawActions ~= false then + local acts: { [string]: any } = {} + for _, b in Blend.blocks(f, "AC") do + local act = Blend.struct(f, b, 0, "bAction") + local name = act and act:idName() + if act and name and not acts[name] then + acts[name] = Anim.raw(f, act) + end + end + if next(acts) ~= nil then + mb.actions = acts + end + end + if next(mb) ~= nil then + scene.meta.blend = mb end if o.animations ~= false then animations(ctx) diff --git a/build/Rosetta.luau.linemap.json b/build/Rosetta.luau.linemap.json index a0ea9ee..af57614 100644 --- a/build/Rosetta.luau.linemap.json +++ b/build/Rosetta.luau.linemap.json @@ -436,187 +436,187 @@ [162043, "src/Rosetta/model/b3d/init.luau"], [162098, "src/Rosetta/model/b3d/Read.luau"], [162669, "src/Rosetta/model/blend/init.luau"], -[162767, "src/Rosetta/model/blend/Anim.luau"], -[163113, "src/Rosetta/model/blend/Armature.luau"], -[163520, "src/Rosetta/model/blend/Material.luau"], -[163872, "src/Rosetta/model/blend/Mesh.luau"], -[164560, "src/Rosetta/model/blend/Normals.luau"], -[164721, "src/Rosetta/model/blend/Prim.luau"], -[165228, "src/Rosetta/model/blend/Read.luau"], -[166267, "src/Rosetta/model/bsp/init.luau"], -[166458, "src/Rosetta/model/bsp/Lightmap.luau"], -[166524, "src/Rosetta/model/bsp/Quake.luau"], -[166913, "src/Rosetta/model/bsp/Quake3.luau"], -[167142, "src/Rosetta/model/bsp/Tree.luau"], -[167530, "src/Rosetta/model/buildmap/init.luau"], -[167802, "src/Rosetta/model/buildmap/Geometry.luau"], -[168205, "src/Rosetta/model/d3map/init.luau"], -[168487, "src/Rosetta/model/d3map/Parse.luau"], -[168685, "src/Rosetta/model/dae/init.luau"], -[168874, "src/Rosetta/model/dae/Math.luau"], -[168921, "src/Rosetta/model/dae/Read.luau"], -[170771, "src/Rosetta/model/dae/Write.luau"], -[171140, "src/Rosetta/model/fbx/init.luau"], -[171288, "src/Rosetta/model/fbx/Ascii.luau"], -[171558, "src/Rosetta/model/fbx/Binary.luau"], -[172013, "src/Rosetta/model/fbx/Read.luau"], -[173375, "src/Rosetta/model/fbx/Write.luau"], -[174360, "src/Rosetta/model/fbx/Xform.luau"], -[174401, "src/Rosetta/model/gltf/init.luau"], -[174638, "src/Rosetta/model/gltf/Pack.luau"], -[174707, "src/Rosetta/model/gltf/Read.luau"], -[175448, "src/Rosetta/model/gltf/Write.luau"], -[176134, "src/Rosetta/model/godot/init.luau"], -[176225, "src/Rosetta/model/godot/Build.luau"], -[176767, "src/Rosetta/model/godot/Primitives.luau"], -[177042, "src/Rosetta/model/godot/Surface.luau"], -[177527, "src/Rosetta/model/godot/Write.luau"], -[177856, "src/Rosetta/model/iqm/init.luau"], -[177932, "src/Rosetta/model/iqm/Read.luau"], -[178287, "src/Rosetta/model/iqm/Write.luau"], -[178974, "src/Rosetta/model/ldraw/init.luau"], -[179052, "src/Rosetta/model/ldraw/Colors.luau"], -[179370, "src/Rosetta/model/ldraw/Read.luau"], -[179947, "src/Rosetta/model/lwo/init.luau"], -[180023, "src/Rosetta/model/lwo/Build.luau"], -[180485, "src/Rosetta/model/lwo/Parse.luau"], -[181028, "src/Rosetta/model/map/init.luau"], -[181345, "src/Rosetta/model/map/Build.luau"], -[181589, "src/Rosetta/model/map/Parse.luau"], -[181974, "src/Rosetta/model/map/Write.luau"], -[182120, "src/Rosetta/model/mca/init.luau"], -[182462, "src/Rosetta/model/mca/Chunk.luau"], -[182595, "src/Rosetta/model/mca/Lz4Block.luau"], -[182665, "src/Rosetta/model/md2/init.luau"], -[182864, "src/Rosetta/model/md3/init.luau"], -[183092, "src/Rosetta/model/md5/init.luau"], -[183173, "src/Rosetta/model/md5/Read.luau"], -[183606, "src/Rosetta/model/mdl/init.luau"], -[183688, "src/Rosetta/model/mdl/HalfLife.luau"], -[183992, "src/Rosetta/model/mdl/Quake.luau"], -[184210, "src/Rosetta/model/ms3d/init.luau"], -[184282, "src/Rosetta/model/ms3d/Read.luau"], -[184728, "src/Rosetta/model/ms3d/Write.luau"], -[185197, "src/Rosetta/model/obj/init.luau"], -[186015, "src/Rosetta/model/obj/Mtl.luau"], -[186303, "src/Rosetta/model/off/init.luau"], -[186765, "src/Rosetta/model/ply/init.luau"], -[187870, "src/Rosetta/model/ply/Binary.luau"], -[188071, "src/Rosetta/model/pmx/init.luau"], -[188140, "src/Rosetta/model/pmx/Build.luau"], -[188436, "src/Rosetta/model/pmx/Pmd.luau"], -[188771, "src/Rosetta/model/pmx/Read.luau"], -[189175, "src/Rosetta/model/proc/init.luau"], -[189557, "src/Rosetta/model/qb/init.luau"], -[189950, "src/Rosetta/model/rbxm/init.luau"], -[190543, "src/Rosetta/model/rbxmx/init.luau"], -[191219, "src/Rosetta/model/robloxmesh/init.luau"], -[191878, "src/Rosetta/model/robloxmesh/Parse.luau"], -[192335, "src/Rosetta/model/robloxmesh/Write.luau"], -[192444, "src/Rosetta/model/schematic/init.luau"], -[192765, "src/Rosetta/model/schematic/Common.luau"], -[192885, "src/Rosetta/model/schematic/Litematic.luau"], -[193096, "src/Rosetta/model/schematic/Mcedit.luau"], -[193340, "src/Rosetta/model/schematic/Sponge.luau"], -[193469, "src/Rosetta/model/smd/init.luau"], -[193536, "src/Rosetta/model/smd/Read.luau"], -[193805, "src/Rosetta/model/smd/Write.luau"], -[194048, "src/Rosetta/model/sourcemdl/init.luau"], -[194219, "src/Rosetta/model/sourcemdl/Build.luau"], -[194649, "src/Rosetta/model/sourcemdl/Material.luau"], -[194810, "src/Rosetta/model/sourcemdl/Mdl.luau"], -[195337, "src/Rosetta/model/sourcemdl/Phy.luau"], -[195460, "src/Rosetta/model/sourcemdl/Vtx.luau"], -[195642, "src/Rosetta/model/sourcemdl/Vvd.luau"], -[195736, "src/Rosetta/model/stl/init.luau"], -[196186, "src/Rosetta/model/stl/Decode.luau"], -[196260, "src/Rosetta/model/t3d/init.luau"], -[196354, "src/Rosetta/model/t3d/Build.luau"], -[196759, "src/Rosetta/model/t3d/Parse.luau"], -[196927, "src/Rosetta/model/udmf/init.luau"], -[197010, "src/Rosetta/model/usda/init.luau"], -[197219, "src/Rosetta/model/usda/Build.luau"], -[198497, "src/Rosetta/model/usda/Parse.luau"], -[199295, "src/Rosetta/model/usda/Write.luau"], -[200112, "src/Rosetta/model/vbsp/init.luau"], -[200558, "src/Rosetta/model/vbsp/Faces.luau"], -[200782, "src/Rosetta/model/vbsp/Props.luau"], -[200874, "src/Rosetta/model/vmf/init.luau"], -[201199, "src/Rosetta/model/vmf/Build.luau"], -[201623, "src/Rosetta/model/vox/init.luau"], -[202509, "src/Rosetta/model/vox/Grid.luau"], -[202566, "src/Rosetta/model/vrml/init.luau"], -[202632, "src/Rosetta/model/x/init.luau"], -[202762, "src/Rosetta/model/x/Build.luau"], -[203325, "src/Rosetta/model/x/Parse.luau"], -[203622, "src/Rosetta/model/x3d/init.luau"], -[203700, "src/Rosetta/music/669/init.luau"], -[203907, "src/Rosetta/music/ahx/init.luau"], -[203959, "src/Rosetta/music/far/init.luau"], -[204189, "src/Rosetta/music/hmp/init.luau"], -[204454, "src/Rosetta/music/hvl/init.luau"], -[204506, "src/Rosetta/music/it/init.luau"], -[204925, "src/Rosetta/music/it/Itsex.luau"], -[205042, "src/Rosetta/music/med/init.luau"], -[205690, "src/Rosetta/music/midi/init.luau"], -[205834, "src/Rosetta/music/midi/Smf.luau"], -[206246, "src/Rosetta/music/mod/init.luau"], -[206600, "src/Rosetta/music/mtm/init.luau"], -[206823, "src/Rosetta/music/mus/init.luau"], -[206981, "src/Rosetta/music/okt/init.luau"], -[207263, "src/Rosetta/music/ptm/init.luau"], -[207486, "src/Rosetta/music/s3m/init.luau"], -[207723, "src/Rosetta/music/sf2/init.luau"], -[207767, "src/Rosetta/music/stm/init.luau"], -[207999, "src/Rosetta/music/ult/init.luau"], -[208304, "src/Rosetta/music/umx/init.luau"], -[208521, "src/Rosetta/music/xm/init.luau"], -[209083, "src/Rosetta/music/xmi/init.luau"], -[209292, "src/Rosetta/ops/AudioOps.luau"], -[209771, "src/Rosetta/ops/ImageOps/init.luau"], -[210419, "src/Rosetta/ops/ImageOps/Kernels.luau"], -[211059, "src/Rosetta/ops/LayerOps.luau"], -[211152, "src/Rosetta/ops/MeshOps/init.luau"], -[212292, "src/Rosetta/ops/MeshOps/Greedy.luau"], -[212459, "src/Rosetta/ops/MusicOps.luau"], -[212808, "src/Rosetta/playlist/m3u/init.luau"], -[213161, "src/Rosetta/playlist/pls/init.luau"], -[213339, "src/Rosetta/playlist/xspf/init.luau"], -[213542, "src/Rosetta/subtitle/ass/init.luau"], -[213986, "src/Rosetta/subtitle/srt/init.luau"], -[214159, "src/Rosetta/subtitle/vtt/init.luau"], -[214362, "src/Rosetta/vector/gamemaps/init.luau"], -[214549, "src/Rosetta/vector/gamemaps/Expand.luau"], -[214646, "src/Rosetta/vector/ldtk/init.luau"], -[214738, "src/Rosetta/vector/ldtk/Read.luau"], -[215074, "src/Rosetta/vector/ldtk/Write.luau"], -[215722, "src/Rosetta/vector/ogmo/init.luau"], -[215841, "src/Rosetta/vector/ogmo/Read.luau"], -[216246, "src/Rosetta/vector/ogmo/Write.luau"], -[216600, "src/Rosetta/vector/svg/init.luau"], -[216686, "src/Rosetta/vector/svg/Parse.luau"], -[217432, "src/Rosetta/vector/svg/PathData.luau"], -[217800, "src/Rosetta/vector/svg/Render.luau"], -[218217, "src/Rosetta/vector/svg/Style.luau"], -[218589, "src/Rosetta/vector/svg/Write.luau"], -[218789, "src/Rosetta/vector/tiled/init.luau"], -[218969, "src/Rosetta/vector/tiled/Data.luau"], -[219120, "src/Rosetta/vector/tiled/Tmj.luau"], -[219751, "src/Rosetta/vector/tiled/Tmx.luau"], -[220363, "src/Rosetta/video/avi/init.luau"], -[220657, "src/Rosetta/video/fli/init.luau"], -[220808, "src/Rosetta/video/flv/init.luau"], -[221192, "src/Rosetta/video/flv/Amf.luau"], -[221350, "src/Rosetta/video/flv/Mux.luau"], -[221631, "src/Rosetta/video/h264/init.luau"], -[221770, "src/Rosetta/video/mkv/init.luau"], -[221926, "src/Rosetta/video/mkv/Mux.luau"], -[222205, "src/Rosetta/video/mkv/Parse.luau"], -[222926, "src/Rosetta/video/mp4/init.luau"], -[223254, "src/Rosetta/video/mpegps/init.luau"], -[223441, "src/Rosetta/video/mpegts/init.luau"], -[223687, "src/Rosetta/video/ogv/init.luau"], -[224082, "src/Rosetta/video/smk/init.luau"], -[224391, "src/Rosetta/video/smk/Audio.luau"], -[224511, "src/Rosetta/video/y4m/init.luau"] +[162769, "src/Rosetta/model/blend/Anim.luau"], +[163191, "src/Rosetta/model/blend/Armature.luau"], +[163725, "src/Rosetta/model/blend/Material.luau"], +[164077, "src/Rosetta/model/blend/Mesh.luau"], +[164765, "src/Rosetta/model/blend/Normals.luau"], +[164926, "src/Rosetta/model/blend/Prim.luau"], +[165433, "src/Rosetta/model/blend/Read.luau"], +[166492, "src/Rosetta/model/bsp/init.luau"], +[166683, "src/Rosetta/model/bsp/Lightmap.luau"], +[166749, "src/Rosetta/model/bsp/Quake.luau"], +[167138, "src/Rosetta/model/bsp/Quake3.luau"], +[167367, "src/Rosetta/model/bsp/Tree.luau"], +[167755, "src/Rosetta/model/buildmap/init.luau"], +[168027, "src/Rosetta/model/buildmap/Geometry.luau"], +[168430, "src/Rosetta/model/d3map/init.luau"], +[168712, "src/Rosetta/model/d3map/Parse.luau"], +[168910, "src/Rosetta/model/dae/init.luau"], +[169099, "src/Rosetta/model/dae/Math.luau"], +[169146, "src/Rosetta/model/dae/Read.luau"], +[170996, "src/Rosetta/model/dae/Write.luau"], +[171365, "src/Rosetta/model/fbx/init.luau"], +[171513, "src/Rosetta/model/fbx/Ascii.luau"], +[171783, "src/Rosetta/model/fbx/Binary.luau"], +[172238, "src/Rosetta/model/fbx/Read.luau"], +[173600, "src/Rosetta/model/fbx/Write.luau"], +[174585, "src/Rosetta/model/fbx/Xform.luau"], +[174626, "src/Rosetta/model/gltf/init.luau"], +[174863, "src/Rosetta/model/gltf/Pack.luau"], +[174932, "src/Rosetta/model/gltf/Read.luau"], +[175673, "src/Rosetta/model/gltf/Write.luau"], +[176359, "src/Rosetta/model/godot/init.luau"], +[176450, "src/Rosetta/model/godot/Build.luau"], +[176992, "src/Rosetta/model/godot/Primitives.luau"], +[177267, "src/Rosetta/model/godot/Surface.luau"], +[177752, "src/Rosetta/model/godot/Write.luau"], +[178081, "src/Rosetta/model/iqm/init.luau"], +[178157, "src/Rosetta/model/iqm/Read.luau"], +[178512, "src/Rosetta/model/iqm/Write.luau"], +[179199, "src/Rosetta/model/ldraw/init.luau"], +[179277, "src/Rosetta/model/ldraw/Colors.luau"], +[179595, "src/Rosetta/model/ldraw/Read.luau"], +[180172, "src/Rosetta/model/lwo/init.luau"], +[180248, "src/Rosetta/model/lwo/Build.luau"], +[180710, "src/Rosetta/model/lwo/Parse.luau"], +[181253, "src/Rosetta/model/map/init.luau"], +[181570, "src/Rosetta/model/map/Build.luau"], +[181814, "src/Rosetta/model/map/Parse.luau"], +[182199, "src/Rosetta/model/map/Write.luau"], +[182345, "src/Rosetta/model/mca/init.luau"], +[182687, "src/Rosetta/model/mca/Chunk.luau"], +[182820, "src/Rosetta/model/mca/Lz4Block.luau"], +[182890, "src/Rosetta/model/md2/init.luau"], +[183089, "src/Rosetta/model/md3/init.luau"], +[183317, "src/Rosetta/model/md5/init.luau"], +[183398, "src/Rosetta/model/md5/Read.luau"], +[183831, "src/Rosetta/model/mdl/init.luau"], +[183913, "src/Rosetta/model/mdl/HalfLife.luau"], +[184217, "src/Rosetta/model/mdl/Quake.luau"], +[184435, "src/Rosetta/model/ms3d/init.luau"], +[184507, "src/Rosetta/model/ms3d/Read.luau"], +[184953, "src/Rosetta/model/ms3d/Write.luau"], +[185422, "src/Rosetta/model/obj/init.luau"], +[186240, "src/Rosetta/model/obj/Mtl.luau"], +[186528, "src/Rosetta/model/off/init.luau"], +[186990, "src/Rosetta/model/ply/init.luau"], +[188095, "src/Rosetta/model/ply/Binary.luau"], +[188296, "src/Rosetta/model/pmx/init.luau"], +[188365, "src/Rosetta/model/pmx/Build.luau"], +[188661, "src/Rosetta/model/pmx/Pmd.luau"], +[188996, "src/Rosetta/model/pmx/Read.luau"], +[189400, "src/Rosetta/model/proc/init.luau"], +[189782, "src/Rosetta/model/qb/init.luau"], +[190175, "src/Rosetta/model/rbxm/init.luau"], +[190768, "src/Rosetta/model/rbxmx/init.luau"], +[191444, "src/Rosetta/model/robloxmesh/init.luau"], +[192103, "src/Rosetta/model/robloxmesh/Parse.luau"], +[192560, "src/Rosetta/model/robloxmesh/Write.luau"], +[192669, "src/Rosetta/model/schematic/init.luau"], +[192990, "src/Rosetta/model/schematic/Common.luau"], +[193110, "src/Rosetta/model/schematic/Litematic.luau"], +[193321, "src/Rosetta/model/schematic/Mcedit.luau"], +[193565, "src/Rosetta/model/schematic/Sponge.luau"], +[193694, "src/Rosetta/model/smd/init.luau"], +[193761, "src/Rosetta/model/smd/Read.luau"], +[194030, "src/Rosetta/model/smd/Write.luau"], +[194273, "src/Rosetta/model/sourcemdl/init.luau"], +[194444, "src/Rosetta/model/sourcemdl/Build.luau"], +[194874, "src/Rosetta/model/sourcemdl/Material.luau"], +[195035, "src/Rosetta/model/sourcemdl/Mdl.luau"], +[195562, "src/Rosetta/model/sourcemdl/Phy.luau"], +[195685, "src/Rosetta/model/sourcemdl/Vtx.luau"], +[195867, "src/Rosetta/model/sourcemdl/Vvd.luau"], +[195961, "src/Rosetta/model/stl/init.luau"], +[196411, "src/Rosetta/model/stl/Decode.luau"], +[196485, "src/Rosetta/model/t3d/init.luau"], +[196579, "src/Rosetta/model/t3d/Build.luau"], +[196984, "src/Rosetta/model/t3d/Parse.luau"], +[197152, "src/Rosetta/model/udmf/init.luau"], +[197235, "src/Rosetta/model/usda/init.luau"], +[197444, "src/Rosetta/model/usda/Build.luau"], +[198722, "src/Rosetta/model/usda/Parse.luau"], +[199520, "src/Rosetta/model/usda/Write.luau"], +[200337, "src/Rosetta/model/vbsp/init.luau"], +[200783, "src/Rosetta/model/vbsp/Faces.luau"], +[201007, "src/Rosetta/model/vbsp/Props.luau"], +[201099, "src/Rosetta/model/vmf/init.luau"], +[201424, "src/Rosetta/model/vmf/Build.luau"], +[201848, "src/Rosetta/model/vox/init.luau"], +[202734, "src/Rosetta/model/vox/Grid.luau"], +[202791, "src/Rosetta/model/vrml/init.luau"], +[202857, "src/Rosetta/model/x/init.luau"], +[202987, "src/Rosetta/model/x/Build.luau"], +[203550, "src/Rosetta/model/x/Parse.luau"], +[203847, "src/Rosetta/model/x3d/init.luau"], +[203925, "src/Rosetta/music/669/init.luau"], +[204132, "src/Rosetta/music/ahx/init.luau"], +[204184, "src/Rosetta/music/far/init.luau"], +[204414, "src/Rosetta/music/hmp/init.luau"], +[204679, "src/Rosetta/music/hvl/init.luau"], +[204731, "src/Rosetta/music/it/init.luau"], +[205150, "src/Rosetta/music/it/Itsex.luau"], +[205267, "src/Rosetta/music/med/init.luau"], +[205915, "src/Rosetta/music/midi/init.luau"], +[206059, "src/Rosetta/music/midi/Smf.luau"], +[206471, "src/Rosetta/music/mod/init.luau"], +[206825, "src/Rosetta/music/mtm/init.luau"], +[207048, "src/Rosetta/music/mus/init.luau"], +[207206, "src/Rosetta/music/okt/init.luau"], +[207488, "src/Rosetta/music/ptm/init.luau"], +[207711, "src/Rosetta/music/s3m/init.luau"], +[207948, "src/Rosetta/music/sf2/init.luau"], +[207992, "src/Rosetta/music/stm/init.luau"], +[208224, "src/Rosetta/music/ult/init.luau"], +[208529, "src/Rosetta/music/umx/init.luau"], +[208746, "src/Rosetta/music/xm/init.luau"], +[209308, "src/Rosetta/music/xmi/init.luau"], +[209517, "src/Rosetta/ops/AudioOps.luau"], +[209996, "src/Rosetta/ops/ImageOps/init.luau"], +[210644, "src/Rosetta/ops/ImageOps/Kernels.luau"], +[211284, "src/Rosetta/ops/LayerOps.luau"], +[211377, "src/Rosetta/ops/MeshOps/init.luau"], +[212517, "src/Rosetta/ops/MeshOps/Greedy.luau"], +[212684, "src/Rosetta/ops/MusicOps.luau"], +[213033, "src/Rosetta/playlist/m3u/init.luau"], +[213386, "src/Rosetta/playlist/pls/init.luau"], +[213564, "src/Rosetta/playlist/xspf/init.luau"], +[213767, "src/Rosetta/subtitle/ass/init.luau"], +[214211, "src/Rosetta/subtitle/srt/init.luau"], +[214384, "src/Rosetta/subtitle/vtt/init.luau"], +[214587, "src/Rosetta/vector/gamemaps/init.luau"], +[214774, "src/Rosetta/vector/gamemaps/Expand.luau"], +[214871, "src/Rosetta/vector/ldtk/init.luau"], +[214963, "src/Rosetta/vector/ldtk/Read.luau"], +[215299, "src/Rosetta/vector/ldtk/Write.luau"], +[215947, "src/Rosetta/vector/ogmo/init.luau"], +[216066, "src/Rosetta/vector/ogmo/Read.luau"], +[216471, "src/Rosetta/vector/ogmo/Write.luau"], +[216825, "src/Rosetta/vector/svg/init.luau"], +[216911, "src/Rosetta/vector/svg/Parse.luau"], +[217657, "src/Rosetta/vector/svg/PathData.luau"], +[218025, "src/Rosetta/vector/svg/Render.luau"], +[218442, "src/Rosetta/vector/svg/Style.luau"], +[218814, "src/Rosetta/vector/svg/Write.luau"], +[219014, "src/Rosetta/vector/tiled/init.luau"], +[219194, "src/Rosetta/vector/tiled/Data.luau"], +[219345, "src/Rosetta/vector/tiled/Tmj.luau"], +[219976, "src/Rosetta/vector/tiled/Tmx.luau"], +[220588, "src/Rosetta/video/avi/init.luau"], +[220882, "src/Rosetta/video/fli/init.luau"], +[221033, "src/Rosetta/video/flv/init.luau"], +[221417, "src/Rosetta/video/flv/Amf.luau"], +[221575, "src/Rosetta/video/flv/Mux.luau"], +[221856, "src/Rosetta/video/h264/init.luau"], +[221995, "src/Rosetta/video/mkv/init.luau"], +[222151, "src/Rosetta/video/mkv/Mux.luau"], +[222430, "src/Rosetta/video/mkv/Parse.luau"], +[223151, "src/Rosetta/video/mp4/init.luau"], +[223479, "src/Rosetta/video/mpegps/init.luau"], +[223666, "src/Rosetta/video/mpegts/init.luau"], +[223912, "src/Rosetta/video/ogv/init.luau"], +[224307, "src/Rosetta/video/smk/init.luau"], +[224616, "src/Rosetta/video/smk/Audio.luau"], +[224736, "src/Rosetta/video/y4m/init.luau"] ] diff --git a/build/Rosetta.rbxm b/build/Rosetta.rbxm index 7552f63..5df75c4 100644 Binary files a/build/Rosetta.rbxm and b/build/Rosetta.rbxm differ diff --git a/build/Rosetta.rbxm.linemap.json b/build/Rosetta.rbxm.linemap.json index bd03d67..51c8097 100644 --- a/build/Rosetta.rbxm.linemap.json +++ b/build/Rosetta.rbxm.linemap.json @@ -48,8 +48,8 @@ "image_1": [[8, "src/Rosetta/image/ani/init.luau"], [188, "src/Rosetta/image/art/init.luau"], [676, "src/Rosetta/image/blp/init.luau"], [934, "src/Rosetta/image/bmp/init.luau"], [1349, "src/Rosetta/image/dds/init.luau"], [1832, "src/Rosetta/image/exr/init.luau"], [2592, "src/Rosetta/image/exr/Codec.luau"], [2703, "src/Rosetta/image/exr/Piz.luau"], [3060, "src/Rosetta/image/gif/init.luau"], [3576, "src/Rosetta/image/gif/Decode.luau"], [3652, "src/Rosetta/image/hdr/init.luau"], [3881, "src/Rosetta/image/hdr/Codec.luau"], [4092, "src/Rosetta/image/icns/init.luau"], [4423, "src/Rosetta/image/ico/init.luau"], [4700, "src/Rosetta/image/ico/Dib.luau"], [4795, "src/Rosetta/image/ilbm/init.luau"], [5114, "src/Rosetta/image/jpeg/init.luau"], [5250, "src/Rosetta/image/ktx/init.luau"], [5910, "src/Rosetta/image/lmp/init.luau"], [6043, "src/Rosetta/image/pcx/init.luau"], [6307, "src/Rosetta/image/pnm/init.luau"], [6685, "src/Rosetta/image/pnm/Codec.luau"], [6962, "src/Rosetta/image/qoi/init.luau"], [7084, "src/Rosetta/image/qoi/Codec.luau"], [7241, "src/Rosetta/image/sgi/init.luau"], [7526, "src/Rosetta/image/spr/init.luau"]], "image_2": [[8, "src/Rosetta/image/sunras/init.luau"], [254, "src/Rosetta/image/tga/init.luau"], [524, "src/Rosetta/image/tga/Codec.luau"], [724, "src/Rosetta/image/tiff/init.luau"], [1551, "src/Rosetta/image/tiff/Pixels.luau"], [1941, "src/Rosetta/image/tim/init.luau"], [2183, "src/Rosetta/image/vtf/init.luau"], [2418, "src/Rosetta/image/webp/init.luau"], [3028, "src/Rosetta/image/webp/Alpha.luau"], [3104, "src/Rosetta/image/webp/Anim.luau"], [3259, "src/Rosetta/image/xbm/init.luau"], [3420, "src/Rosetta/image/xpm/init.luau"], [3688, "src/Rosetta/image/xpm/Names.luau"]], "layered": [[8, "src/Rosetta/layered/aseprite/init.luau"], [746, "src/Rosetta/layered/ora/init.luau"], [1033, "src/Rosetta/layered/psd/init.luau"], [1768, "src/Rosetta/layered/psd/Channels.luau"]], -"model_1": [[8, "src/Rosetta/model/3ds/init.luau"], [91, "src/Rosetta/model/3ds/Build.luau"], [738, "src/Rosetta/model/3ds/Read.luau"], [1234, "src/Rosetta/model/3ds/Write.luau"], [2039, "src/Rosetta/model/3mf/init.luau"], [2121, "src/Rosetta/model/3mf/Read.luau"], [2709, "src/Rosetta/model/3mf/Write.luau"], [3114, "src/Rosetta/model/ase/init.luau"], [3237, "src/Rosetta/model/ase/Build.luau"], [3811, "src/Rosetta/model/ase/Parse.luau"], [3880, "src/Rosetta/model/ase/Write.luau"], [4343, "src/Rosetta/model/b3d/init.luau"], [4398, "src/Rosetta/model/b3d/Read.luau"], [4969, "src/Rosetta/model/blend/init.luau"], [5067, "src/Rosetta/model/blend/Anim.luau"], [5413, "src/Rosetta/model/blend/Armature.luau"], [5820, "src/Rosetta/model/blend/Material.luau"], [6172, "src/Rosetta/model/blend/Mesh.luau"], [6860, "src/Rosetta/model/blend/Normals.luau"], [7021, "src/Rosetta/model/blend/Prim.luau"]], -"model_2": [[8, "src/Rosetta/model/blend/Read.luau"], [1047, "src/Rosetta/model/bsp/init.luau"], [1238, "src/Rosetta/model/bsp/Lightmap.luau"], [1304, "src/Rosetta/model/bsp/Quake.luau"], [1693, "src/Rosetta/model/bsp/Quake3.luau"], [1922, "src/Rosetta/model/bsp/Tree.luau"], [2310, "src/Rosetta/model/buildmap/init.luau"], [2582, "src/Rosetta/model/buildmap/Geometry.luau"], [2985, "src/Rosetta/model/d3map/init.luau"], [3267, "src/Rosetta/model/d3map/Parse.luau"], [3465, "src/Rosetta/model/dae/init.luau"], [3654, "src/Rosetta/model/dae/Math.luau"], [3701, "src/Rosetta/model/dae/Read.luau"], [5551, "src/Rosetta/model/dae/Write.luau"], [5920, "src/Rosetta/model/fbx/init.luau"], [6068, "src/Rosetta/model/fbx/Ascii.luau"], [6338, "src/Rosetta/model/fbx/Binary.luau"]], +"model_1": [[8, "src/Rosetta/model/3ds/init.luau"], [91, "src/Rosetta/model/3ds/Build.luau"], [738, "src/Rosetta/model/3ds/Read.luau"], [1234, "src/Rosetta/model/3ds/Write.luau"], [2039, "src/Rosetta/model/3mf/init.luau"], [2121, "src/Rosetta/model/3mf/Read.luau"], [2709, "src/Rosetta/model/3mf/Write.luau"], [3114, "src/Rosetta/model/ase/init.luau"], [3237, "src/Rosetta/model/ase/Build.luau"], [3811, "src/Rosetta/model/ase/Parse.luau"], [3880, "src/Rosetta/model/ase/Write.luau"], [4343, "src/Rosetta/model/b3d/init.luau"], [4398, "src/Rosetta/model/b3d/Read.luau"], [4969, "src/Rosetta/model/blend/init.luau"], [5069, "src/Rosetta/model/blend/Anim.luau"], [5491, "src/Rosetta/model/blend/Armature.luau"], [6025, "src/Rosetta/model/blend/Material.luau"], [6377, "src/Rosetta/model/blend/Mesh.luau"], [7065, "src/Rosetta/model/blend/Normals.luau"]], +"model_2": [[8, "src/Rosetta/model/blend/Prim.luau"], [515, "src/Rosetta/model/blend/Read.luau"], [1574, "src/Rosetta/model/bsp/init.luau"], [1765, "src/Rosetta/model/bsp/Lightmap.luau"], [1831, "src/Rosetta/model/bsp/Quake.luau"], [2220, "src/Rosetta/model/bsp/Quake3.luau"], [2449, "src/Rosetta/model/bsp/Tree.luau"], [2837, "src/Rosetta/model/buildmap/init.luau"], [3109, "src/Rosetta/model/buildmap/Geometry.luau"], [3512, "src/Rosetta/model/d3map/init.luau"], [3794, "src/Rosetta/model/d3map/Parse.luau"], [3992, "src/Rosetta/model/dae/init.luau"], [4181, "src/Rosetta/model/dae/Math.luau"], [4228, "src/Rosetta/model/dae/Read.luau"], [6078, "src/Rosetta/model/dae/Write.luau"], [6447, "src/Rosetta/model/fbx/init.luau"], [6595, "src/Rosetta/model/fbx/Ascii.luau"], [6865, "src/Rosetta/model/fbx/Binary.luau"]], "model_3": [[8, "src/Rosetta/model/fbx/Read.luau"], [1370, "src/Rosetta/model/fbx/Write.luau"], [2355, "src/Rosetta/model/fbx/Xform.luau"], [2396, "src/Rosetta/model/gltf/init.luau"], [2633, "src/Rosetta/model/gltf/Pack.luau"], [2702, "src/Rosetta/model/gltf/Read.luau"], [3443, "src/Rosetta/model/gltf/Write.luau"], [4129, "src/Rosetta/model/godot/init.luau"], [4220, "src/Rosetta/model/godot/Build.luau"], [4762, "src/Rosetta/model/godot/Primitives.luau"], [5037, "src/Rosetta/model/godot/Surface.luau"], [5522, "src/Rosetta/model/godot/Write.luau"], [5851, "src/Rosetta/model/iqm/init.luau"], [5927, "src/Rosetta/model/iqm/Read.luau"], [6282, "src/Rosetta/model/iqm/Write.luau"], [6969, "src/Rosetta/model/ldraw/init.luau"], [7047, "src/Rosetta/model/ldraw/Colors.luau"]], "model_4": [[8, "src/Rosetta/model/ldraw/Read.luau"], [585, "src/Rosetta/model/lwo/init.luau"], [661, "src/Rosetta/model/lwo/Build.luau"], [1123, "src/Rosetta/model/lwo/Parse.luau"], [1666, "src/Rosetta/model/map/init.luau"], [1983, "src/Rosetta/model/map/Build.luau"], [2227, "src/Rosetta/model/map/Parse.luau"], [2612, "src/Rosetta/model/map/Write.luau"], [2758, "src/Rosetta/model/mca/init.luau"], [3100, "src/Rosetta/model/mca/Chunk.luau"], [3233, "src/Rosetta/model/mca/Lz4Block.luau"], [3303, "src/Rosetta/model/md2/init.luau"], [3502, "src/Rosetta/model/md3/init.luau"], [3730, "src/Rosetta/model/md5/init.luau"], [3811, "src/Rosetta/model/md5/Read.luau"], [4244, "src/Rosetta/model/mdl/init.luau"], [4326, "src/Rosetta/model/mdl/HalfLife.luau"], [4630, "src/Rosetta/model/mdl/Quake.luau"], [4848, "src/Rosetta/model/ms3d/init.luau"], [4920, "src/Rosetta/model/ms3d/Read.luau"], [5366, "src/Rosetta/model/ms3d/Write.luau"], [5835, "src/Rosetta/model/obj/init.luau"], [6653, "src/Rosetta/model/obj/Mtl.luau"], [6941, "src/Rosetta/model/off/init.luau"]], "model_5": [[8, "src/Rosetta/model/ply/init.luau"], [1113, "src/Rosetta/model/ply/Binary.luau"], [1314, "src/Rosetta/model/pmx/init.luau"], [1383, "src/Rosetta/model/pmx/Build.luau"], [1679, "src/Rosetta/model/pmx/Pmd.luau"], [2014, "src/Rosetta/model/pmx/Read.luau"], [2418, "src/Rosetta/model/proc/init.luau"], [2800, "src/Rosetta/model/qb/init.luau"], [3193, "src/Rosetta/model/rbxm/init.luau"], [3786, "src/Rosetta/model/rbxmx/init.luau"], [4462, "src/Rosetta/model/robloxmesh/init.luau"], [5121, "src/Rosetta/model/robloxmesh/Parse.luau"], [5578, "src/Rosetta/model/robloxmesh/Write.luau"], [5687, "src/Rosetta/model/schematic/init.luau"], [6008, "src/Rosetta/model/schematic/Common.luau"], [6128, "src/Rosetta/model/schematic/Litematic.luau"], [6339, "src/Rosetta/model/schematic/Mcedit.luau"], [6583, "src/Rosetta/model/schematic/Sponge.luau"], [6712, "src/Rosetta/model/smd/init.luau"], [6779, "src/Rosetta/model/smd/Read.luau"], [7048, "src/Rosetta/model/smd/Write.luau"], [7291, "src/Rosetta/model/sourcemdl/init.luau"], [7462, "src/Rosetta/model/sourcemdl/Build.luau"], [7892, "src/Rosetta/model/sourcemdl/Material.luau"]], diff --git a/build/Rosetta.rbxmx b/build/Rosetta.rbxmx index 702ce28..ab2ca64 100644 --- a/build/Rosetta.rbxmx +++ b/build/Rosetta.rbxmx @@ -453,7 +453,7 @@ local __CHUNK = { ["model/blend/Material"] = "model_1", ["model/blend/Mesh"] = "model_1", ["model/blend/Normals"] = "model_1", - ["model/blend/Prim"] = "model_1", + ["model/blend/Prim"] = "model_2", ["model/blend/Read"] = "model_2", ["model/bsp"] = "model_2", ["model/bsp/Lightmap"] = "model_2", @@ -160288,7 +160288,7 @@ end --!optimize 2 --!nocheck -- rosetta chunk model_1 (build/Rosetta.rbxm): GENERATED by tools/bundle.py from src/Rosetta - do not edit. --- 20 modules (0 native: @native); the Rosetta root requires it when one of them is first included. +-- 19 modules (0 native: @native); the Rosetta root requires it when one of them is first included. -- Error lines map back to the sources through Rosetta.rbxm.linemap.json (tools/bundle.py --where). return function(__FILES, __include) __FILES["model/3ds"] = function() @@ -165260,7 +165260,8 @@ __FILES["model/blend"] = function() -- meshes of every storage generation (MFace, MPoly / MLoop, attribute layers, AttributeStorage) with UV maps, colour -- attributes, custom normals, material slots; Principled BSDF materials; packed and external images; cameras; lights; -- armatures, skins (vertex groups, top 4 weights), shape keys (relative keys, vertex groups); actions sampled into --- channels; rig data (bone collections / layers, colours, custom shapes, pose settings, constraint stacks) as extras. +-- channels, and every action's raw f-curves in meta.blend.actions; rig data (bone collections / layers, colours, +-- custom shapes, pose settings, constraint stacks) as extras. -- Not supported: modifiers (listed in meta.source.modifiers), curves / text / metaballs / grease pencil / volumes, -- NLA strips, drivers, constraint evaluation, f-curve modifiers, linked libraries, collection instances. @@ -165293,6 +165294,7 @@ type DecodeOptions = { scene: string?, -- a scene by name (default: the file's current scene) sampleStep: number?, -- frames between animation samples (default 1) animations: boolean?, -- default true + rawActions: boolean?, -- every action's f-curves and keys in meta.blend.actions (default true) resolve: ((uri: string) -> any)?, -- external images files: { [string]: any }?, maxBytes: number?, -- decompressed size limit (default 2^31) @@ -165414,6 +165416,54 @@ local function curve(f: Blend.File, fc: Blend.View): Curve? return { path = path, index = fc:num("array_index") or 0, keys = keys, extend = fc:num("extend") or 0, modifiers = #mods } end +-- an action's f-curves: the legacy list, or (4.4+ layered actions) the channel bags of the strips of every layer whose +-- slot handle matches (handle nil: the first layer's first strip's first channel bag) +local function fcurves(f: Blend.File, act: Blend.View, handle: number?): { Blend.View } + local list: { Blend.View } = act:list("curves", "FCurve") + if #list > 0 or not act:has("layer_array") then + return list + end + local datas = act:pointers("strip_keyframe_data_array", act:num("strip_keyframe_data_array_num")) + for _, la in act:pointers("layer_array", act:num("layer_array_num")) do + local lblk = la and Blend.resolve(f, la, act.block) + local layer = lblk and Blend.struct(f, lblk, 0, "ActionLayer") + if layer then + for _, sa in layer:pointers("strip_array", layer:num("strip_array_num")) do + local sblk = sa and Blend.resolve(f, sa, act.block) + local strip = sblk and Blend.struct(f, sblk, 0, "ActionStrip") + local di = strip and strip:num("data_index") + local dblk = di and datas[di + 1] and Blend.resolve(f, datas[di + 1], act.block) + local kd = dblk and Blend.struct(f, dblk, 0, "ActionStripKeyframeData") + if kd then + for _, ba in kd:pointers("channelbag_array", kd:num("channelbag_array_num")) do + local bblk = ba and Blend.resolve(f, ba, act.block) + local bag = bblk and (Blend.struct(f, bblk, 0, "ActionChannelBag") or Blend.struct(f, bblk, 0, "ActionChannelbag")) + if bag and (handle == nil or (bag:num("slot_handle") or 0) == handle) then + for _, ca in bag:pointers("fcurve_array", bag:num("fcurve_array_num")) do + local cblk = ca and Blend.resolve(f, ca, act.block) + local fc = cblk and Blend.struct(f, cblk, 0, "FCurve") + if fc then + table.insert(list, fc) + end + end + if handle == nil then + return list + end + end + end + end + if handle == nil then + return list + end + end + end + if handle == nil then + return list + end + end + return list +end + function Anim.curves(f: Blend.File, adt: Blend.View?): ({ Curve }?, string?) if not adt then return nil, nil @@ -165422,41 +165472,8 @@ function Anim.curves(f: Blend.File, adt: Blend.View?): ({ Curve }?, string?) if not act then return nil, nil end - local list: { Blend.View } = act:list("curves", "FCurve") - if #list == 0 and act:has("layer_array") then - local handle = adt:num("slot_handle") or 0 - local datas = act:pointers("strip_keyframe_data_array", act:num("strip_keyframe_data_array_num")) - for _, la in act:pointers("layer_array", act:num("layer_array_num")) do - local lblk = la and Blend.resolve(f, la, act.block) - local layer = lblk and Blend.struct(f, lblk, 0, "ActionLayer") - if layer then - for _, sa in layer:pointers("strip_array", layer:num("strip_array_num")) do - local sblk = sa and Blend.resolve(f, sa, act.block) - local strip = sblk and Blend.struct(f, sblk, 0, "ActionStrip") - local di = strip and strip:num("data_index") - local dblk = di and datas[di + 1] and Blend.resolve(f, datas[di + 1], act.block) - local kd = dblk and Blend.struct(f, dblk, 0, "ActionStripKeyframeData") - if kd then - for _, ba in kd:pointers("channelbag_array", kd:num("channelbag_array_num")) do - local bblk = ba and Blend.resolve(f, ba, act.block) - local bag = bblk and (Blend.struct(f, bblk, 0, "ActionChannelBag") or Blend.struct(f, bblk, 0, "ActionChannelbag")) - if bag and (bag:num("slot_handle") or 0) == handle then - for _, ca in bag:pointers("fcurve_array", bag:num("fcurve_array_num")) do - local cblk = ca and Blend.resolve(f, ca, act.block) - local fc = cblk and Blend.struct(f, cblk, 0, "FCurve") - if fc then - table.insert(list, fc) - end - end - end - end - end - end - end - end - end local out: { Curve } = {} - for _, fc in list do + for _, fc in fcurves(f, act, adt:num("slot_handle") or 0) do local c = curve(f, fc) if c then table.insert(out, c) @@ -165465,6 +165482,67 @@ function Anim.curves(f: Blend.File, adt: Blend.View?): ({ Curve }?, string?) return out, act:idName() end +-- ------------------------------------------------------------------------------------------------ raw actions +local INTERPOLATION: { [number]: string } = { + [0] = "CONSTANT", [1] = "LINEAR", [2] = "BEZIER", [3] = "BACK", [4] = "BOUNCE", [5] = "CIRC", [6] = "CUBIC", + [7] = "ELASTIC", [8] = "EXPO", [9] = "QUAD", [10] = "QUART", [11] = "QUINT", [12] = "SINE", +} +local EASING: { [number]: string } = { [0] = "AUTO", [1] = "EASE_IN", [2] = "EASE_OUT", [3] = "EASE_IN_OUT" } +local HANDLE: { [number]: string } = { [0] = "FREE", [1] = "AUTO", [2] = "VECTOR", [3] = "ALIGNED", [4] = "AUTO_CLAMPED" } +local ACT_FRAME_RANGE = 0x1000 + +-- an action as Blender's API shows it: frame_range (the manual range, else the keys' span, at least one frame) and +-- every f-curve with its keyframe points +function Anim.raw(f: Blend.File, act: Blend.View): { [string]: any } + local curves: { { [string]: any } } = {} + local lo: number, hi: number = math.huge, -math.huge + for _, fc in fcurves(f, act, nil) do + local path = fc:cstring("rna_path") or "" + local kind, who, rest = Anim.split(path) + local keys: { { [string]: any } } = {} + for _, b in fc:array("bezt", "BezTriple") do + local v = b:vec("vec") + if v and #v >= 9 then + local x: number = v[4] + local k: { [string]: any } = { co = { x, v[5] }, handle_left = { v[1], v[2] }, handle_right = { v[7], v[8] } } + k.interpolation = INTERPOLATION[b:num("ipo") or 2] or "BEZIER" + k.easing = EASING[b:num("easing") or 0] or "AUTO" + k.handle_left_type, k.handle_right_type = HANDLE[b:num("h1") or 0], HANDLE[b:num("h2") or 0] + k.back, k.amplitude, k.period = b:num("back") or 1.70158, b:num("amplitude") or 0.8, b:num("period") or 4.1 + table.insert(keys, k) + lo, hi = math.min(lo, x), math.max(hi, x) + end + end + if #keys == 0 then + for _, p in fc:array("fpt", "FPoint") do + local v = p:vec("vec") + if v and #v >= 2 then + local x: number = v[1] + local k: { [string]: any } = { co = { x, v[2] } } + k.interpolation = "LINEAR" + table.insert(keys, k) + lo, hi = math.min(lo, x), math.max(hi, x) + end + end + end + local entry: { [string]: any } = { data_path = path, path = if kind == "pose.bones" then rest else path, keys = keys } + entry.bone = if kind == "pose.bones" then who else nil + entry.array_index = fc:num("array_index") or 0 + entry.extrapolation = if (fc:num("extend") or 0) == 1 then "LINEAR" else "CONSTANT" + table.insert(curves, entry) + end + if bit32.band(act:num("flag") or 0, ACT_FRAME_RANGE) ~= 0 and act:has("frame_start") then + lo = act:num("frame_start") or 0 + hi = act:num("frame_end") or 0 + elseif lo > hi then + lo, hi = 0, 0 + end + if hi <= lo then + hi = lo + 1 + end + return { frame_range = { lo, hi }, curves = curves } +end + -- pre-2.5 IPO curves (Object.ipo / Key.ipo): the curve's adrcode picks the channel; object rotations are in units of -- 10 degrees; the interpolation and extrapolation (0 constant, 1 linear; cyclic ones as constant) are per curve local OB_ADR: { [number]: { any } } = { @@ -165702,8 +165780,10 @@ __FILES["model/blend/Armature"] = function() -- armature space, deform, connect, wire), bone collections (4.x BoneCollection arrays and lists; before 4.0 the layers -- and bone groups converted as Blender 4.0's versioning does), bone colours (BoneColor; bone group colours before 4.0), -- pose bones (custom shapes, locks, rotation mode, IK settings) and constraint stacks (bConstraint and the data structs --- of IK, copy rotation / location / scale / transforms, damped track, limit rotation / location / scale, child of; the --- common fields for the rest). Flags from DNA_armature_types.h, DNA_action_types.h, DNA_constraint_types.h. +-- of IK, copy rotation / location / scale / transforms, damped track, limit rotation / location / scale, child of, +-- action, transform, stretch to, armature, floor, limit distance, track to, locked track; the common fields for the +-- rest), bone inheritance and b-bone settings, the stored pose basis. Flags from DNA_armature_types.h, +-- DNA_action_types.h, DNA_constraint_types.h. local Blend = __include("containers/Blend") local Armature = {} @@ -165761,6 +165841,33 @@ local PCHAN_DRAW_NO_CUSTOM_BONE_SIZE = 1 local LOCK_LOC, LOCK_ROT, LOCK_SCALE, LOCK_ROTW, LOCK_ROT4D = { 1, 2, 4 }, { 8, 16, 32 }, { 64, 128, 256 }, 512, 1024 local IK_NO_DOF, IK_LIMIT = { 1, 2, 4 }, { 8, 16, 32 } local AXES = { "x", "y", "z" } +local XYZ: { [number]: string } = { [0] = "X", [1] = "Y", [2] = "Z" } +-- bActionConstraint.type, .mix_mode +local ACTION_CHANNEL: { [number]: string } = { + [0] = "ROTATION_X", [1] = "ROTATION_Y", [2] = "ROTATION_Z", [10] = "SCALE_X", [11] = "SCALE_Y", [12] = "SCALE_Z", + [20] = "LOCATION_X", [21] = "LOCATION_Y", [22] = "LOCATION_Z", +} +local ACTION_MIX: { [number]: string } = { [0] = "AFTER_FULL", [1] = "AFTER", [2] = "BEFORE", [3] = "BEFORE_FULL", [4] = "BEFORE_SPLIT", [5] = "AFTER_SPLIT" } +local MAP: { [number]: string } = { [0] = "LOCATION", [1] = "ROTATION", [2] = "SCALE" } +-- the driver target rotation modes (DTAR_ROTMODE_*) +local FROM_ROT: { [number]: string } = { + [0] = "AUTO", [1] = "XYZ", [2] = "XZY", [3] = "YXZ", [4] = "YZX", [5] = "ZXY", [6] = "ZYX", [7] = "QUATERNION", + [8] = "SWING_TWIST_X", [9] = "SWING_TWIST_Y", [10] = "SWING_TWIST_Z", +} +local MIX_LOC: { [number]: string } = { [0] = "ADD", [1] = "REPLACE" } +local MIX_ROT: { [number]: string } = { [0] = "ADD", [1] = "REPLACE", [2] = "BEFORE", [3] = "AFTER" } +local MIX_SCALE: { [number]: string } = { [0] = "REPLACE", [1] = "MULTIPLY" } +local VOLUME: { [number]: string } = { [0] = "VOLUME_XZX", [1] = "VOLUME_X", [2] = "VOLUME_Z", [3] = "NO_VOLUME" } +local KEEP_AXIS: { [number]: string } = { [0] = "PLANE_X", [1] = "SWING_Y", [2] = "PLANE_Z" } +local FLOOR: { [number]: string } = { [0] = "FLOOR_X", [1] = "FLOOR_Y", [2] = "FLOOR_Z", [3] = "FLOOR_NEGATIVE_X", [4] = "FLOOR_NEGATIVE_Y", [5] = "FLOOR_NEGATIVE_Z" } +local DIST_MODE: { [number]: string } = { [0] = "LIMITDIST_INSIDE", [1] = "LIMITDIST_OUTSIDE", [2] = "LIMITDIST_ONSURFACE" } +local UP: { [number]: string } = { [0] = "UP_X", [1] = "UP_Y", [2] = "UP_Z" } +local LOCK: { [number]: string } = { [0] = "LOCK_X", [1] = "LOCK_Y", [2] = "LOCK_Z" } +-- Bone.inherit_scale_mode, bbone_prev_type / bbone_next_type, bbone_mapping_mode +local INHERIT_SCALE: { [number]: string } = { [0] = "FULL", [1] = "FIX_SHEAR", [2] = "AVERAGE", [3] = "NONE", [4] = "NONE_LEGACY", [5] = "ALIGNED" } +local HANDLE_TYPE: { [number]: string } = { [0] = "AUTO", [1] = "ABSOLUTE", [2] = "RELATIVE", [3] = "TANGENT" } +local MAPPING: { [number]: string } = { [0] = "STRAIGHT", [1] = "CURVED" } +local BONE_HINGE, BONE_NO_SCALE, BONE_NO_LOCAL_LOCATION, BONE_RELATIVE_PARENTING, BONE_ADD_PARENT_END_ROLL = 0x200, 0x8000, 0x400000, 0x800000, 0x1000000 local function bit(v: number?, mask: number): boolean return bit32.band(v or 0, mask) ~= 0 @@ -165935,7 +166042,35 @@ function Armature.bone(bone: Blend.View, pc: Blend.View?, pose: Blend.View?): { head_local = vec3(bone, "arm_head"), tail_local = vec3(bone, "arm_tail"), roll = bone:num("arm_roll"), + use_inherit_rotation = not bit(flag, BONE_HINGE), + use_local_location = not bit(flag, BONE_NO_LOCAL_LOCATION), + use_relative_parent = bit(flag, BONE_RELATIVE_PARENTING), } + local ism = bone:num("inherit_scale_mode") + e.inherit_scale = if ism then INHERIT_SCALE[ism] else (if bit(flag, BONE_NO_SCALE) then "NONE_LEGACY" else "FULL") -- BONE_NO_SCALE before 2.81 + e.bbone_segments = bone:num("segments") or 1 + e.bbone_x, e.bbone_z = bone:num("xwidth"), bone:num("zwidth") + e.bbone_easein, e.bbone_easeout = bone:num("ease1") or 1, bone:num("ease2") or 1 + e.bbone_rollin, e.bbone_rollout = bone:num("roll1") or 0, bone:num("roll2") or 0 + e.bbone_curveinx, e.bbone_curveinz = bone:num("curveInX") or 0, bone:num("curveInY") or 0 -- curveInY is the API's z + e.bbone_curveoutx, e.bbone_curveoutz = bone:num("curveOutX") or 0, bone:num("curveOutY") or 0 + for _, side in { "in", "out" } do + local cap = if side == "in" then "In" else "Out" + local v = vec3(bone, "scale_" .. side) + if not v then + -- before 3.0: scaleIn (x) and scale_in_y (z); before 2.8 one value for both + local x = bone:num("scale" .. cap) or 1 + v = { x, 1, bone:num("scale_" .. side .. "_y") or x } + end + e["bbone_scale" .. side] = v + end + e.bbone_handle_type_start = HANDLE_TYPE[bone:num("bbone_prev_type") or 0] + e.bbone_handle_type_end = HANDLE_TYPE[bone:num("bbone_next_type") or 0] + local prev, nxt = bone:deref("bbone_prev", 0, "Bone"), bone:deref("bbone_next", 0, "Bone") + e.bbone_custom_handle_start = if prev then prev:str("name") else nil + e.bbone_custom_handle_end = if nxt then nxt:str("name") else nil + e.use_endroll_as_inroll = if bone:has("bbone_flag") then bit(bone:num("bbone_flag"), 1) else bit(flag, BONE_ADD_PARENT_END_ROLL) + e.bbone_mapping_mode = MAPPING[bone:num("bbone_mapping_mode") or 0] if bone:has("color") then e.color = boneColor(bone) elseif pc and pose then @@ -165982,10 +166117,72 @@ local function constraintData(e: { [string]: any }, kind: string, d: Blend.View, e.invert_x, e.invert_y, e.invert_z = bit(flag, 16), bit(flag, 32), bit(flag, 64) e.use_offset = bit(flag, 128) elseif kind == "COPY_SCALE" then - -- SIZELIKE_X 1, Y 2, Z 4, OFFSET 8 + -- SIZELIKE_X 1, Y 2, Z 4, OFFSET 8, MULTIPLY 16 (use_add is its inverse), UNIFORM 32 e.use_x, e.use_y, e.use_z = bit(flag, 1), bit(flag, 2), bit(flag, 4) e.use_offset = bit(flag, 8) + e.use_add = not bit(flag, 16) + e.use_make_uniform = bit(flag, 32) e.power = d:num("power") or 1 + elseif kind == "ACTION" then + -- flag: ACTCON_BONE_USE_OBJECT_ACTION 1, ACTCON_USE_EVAL_TIME 2 + local act = d:deref("act", 0, "bAction") + e.action = if act then act:idName() else nil + e.transform_channel = ACTION_CHANNEL[d:num("type") or 20] + e.frame_start, e.frame_end = d:num("start") or 1, d:num("end") or 1 + e.min, e.max = d:num("min") or 0, d:num("max") or 0 + e.mix_mode = ACTION_MIX[d:num("mix_mode") or 0] + e.use_bone_object_action = bit(flag, 1) + e.use_eval_time = bit(flag, 2) + e.eval_time = d:num("eval_time") or 0 + elseif kind == "TRANSFORM" then + e.map_from, e.map_to = MAP[d:num("from") or 0], MAP[d:num("to") or 0] + local map = d.struct.byName.map + for i, a in AXES do + local o = map and d.offset + map.offset + i - 1 + e["map_to_" .. a .. "_from"] = XYZ[if o and o < buffer.len(d.file.buf) then buffer.readu8(d.file.buf, o) else i - 1] + end + e.use_motion_extrapolate = (d:num("expo") or 0) ~= 0 + e.from_rotation_mode = FROM_ROT[d:num("from_rotation_mode") or 0] + e.to_euler_order = EULER_ORDER[d:num("to_euler_order") or 0] + e.mix_mode = MIX_LOC[d:num("mix_mode_loc") or 0] + e.mix_mode_rot = MIX_ROT[d:num("mix_mode_rot") or 0] + e.mix_mode_scale = MIX_SCALE[d:num("mix_mode_scale") or 0] + for _, side in { "from", "to" } do + for _, suffix in { "", "_rot", "_scale" } do + local lo, hi = d:vec(side .. "_min" .. suffix), d:vec(side .. "_max" .. suffix) + for i, a in AXES do + e[side .. "_min_" .. a .. suffix] = lo and lo[i] or 0 + e[side .. "_max_" .. a .. suffix] = hi and hi[i] or 0 + end + end + end + elseif kind == "STRETCH_TO" then + -- STRETCHTOCON_USE_BULGE_MIN 1, MAX 2 + e.rest_length = d:num("orglength") + e.bulge = d:num("bulge") + e.volume = VOLUME[d:num("volmode") or 0] + e.keep_axis = KEEP_AXIS[d:num("plane") or 0] + e.use_bulge_min, e.use_bulge_max = bit(flag, 1), bit(flag, 2) + e.bulge_min, e.bulge_max, e.bulge_smooth = d:num("bulge_min"), d:num("bulge_max"), d:num("bulge_smooth") + elseif kind == "ARMATURE" then + -- CONSTRAINT_ARMATURE_QUATERNION 1, ENVELOPE 2, CUR_LOCATION 4 + e.use_deform_preserve_volume, e.use_bone_envelopes, e.use_current_location = bit(flag, 1), bit(flag, 2), bit(flag, 4) + elseif kind == "FLOOR" then + -- flag: MINMAX_USEROT 4 + e.floor_location = FLOOR[d:num("minmaxflag") or 2] + e.offset = d:num("offset") or 0 + e.use_rotation = bit(flag, 4) + elseif kind == "LIMIT_DISTANCE" then + e.distance = d:num("dist") + e.limit_mode = DIST_MODE[d:num("mode") or 0] + elseif kind == "TRACK_TO" then + -- reserved1 the track axis, reserved2 the up axis; flags TARGET_Z_UP 1 + e.track_axis = TRACK[d:num("reserved1") or 1] + e.up_axis = UP[d:num("reserved2") or 2] + e.use_target_z = bit(d:num("flags"), 1) + elseif kind == "LOCKED_TRACK" then + e.track_axis = TRACK[d:num("trackflag") or 1] + e.lock_axis = LOCK[d:num("lockflag") or 2] elseif kind == "COPY_TRANSFORMS" then e.mix_mode = TRANS_MIX[d:num("mix_mode") or 0] e.remove_target_shear = bit(flag, 1) @@ -166098,6 +166295,14 @@ function Armature.pose(e: { [string]: any }, pc: Blend.View, resolve: Resolve, s e["ik_stiffness_" .. a] = stiff and stiff[i] or 0 end e.pose_color = if pc:has("color") then boneColor(pc) else nil + -- the stored basis (rotation_quaternion w, x, y, z; rotation_axis_angle angle, x, y, z) + e.location = vec3(pc, "loc", { 0, 0, 0 }) + local q = pc:vec("quat") + e.rotation_quaternion = if q and #q >= 4 then { q[1], q[2], q[3], q[4] } else { 1, 0, 0, 0 } + e.rotation_euler = vec3(pc, "eul", { 0, 0, 0 }) + local axis = vec3(pc, "rotAxis", { 0, 1, 0 }) :: { number } + e.rotation_axis_angle = { pc:num("rotAngle") or 0, axis[1], axis[2], axis[3] } + e.scale = vec3(pc, "size", nil) or vec3(pc, "scale", { 1, 1, 1 }) e.constraints = Armature.constraints(pc, resolve) end @@ -167304,6 +167509,19 @@ end return Normals end +end + + + + + + model_2 + --!optimize 2 +--!nocheck +-- rosetta chunk model_2 (build/Rosetta.rbxm): GENERATED by tools/bundle.py from src/Rosetta - do not edit. +-- 18 modules (1 native: @native); the Rosetta root requires it when one of them is first included. +-- Error lines map back to the sources through Rosetta.rbxm.linemap.json (tools/bundle.py --where). +return function(__FILES, __include) __FILES["model/blend/Prim"] = function() -- model/blend/Prim: model/blend/Mesh polygons to Scene primitives (one per material slot): corner normals from smooth @@ -167811,19 +168029,6 @@ end return Prim end -end - - - - - - model_2 - --!optimize 2 ---!nocheck --- rosetta chunk model_2 (build/Rosetta.rbxm): GENERATED by tools/bundle.py from src/Rosetta - do not edit. --- 17 modules (1 native: @native); the Rosetta root requires it when one of them is first included. --- Error lines map back to the sources through Rosetta.rbxm.linemap.json (tools/bundle.py --where). -return function(__FILES, __include) __FILES["model/blend/Read"] = function() -- model/blend/Read: a parsed .blend (containers/Blend) to a Scene: the current scene's objects (from its collections, @@ -167855,6 +168060,7 @@ type Options = { scene: string?, -- the scene to read (default: the file's current scene) sampleStep: number?, -- frames between animation samples (default 1) animations: boolean?, -- default true + rawActions: boolean?, -- every action's f-curves in meta.blend.actions (default true) resolve: ((uri: string) -> any)?, files: { [string]: any }?, maxVertices: number?, @@ -168840,8 +169046,27 @@ function Read.scene(f: Blend.File, opts: Options?): (Types.Scene?, string?) end end skins(ctx) + local mb: { [string]: any } = {} if next(ctx.armatures) ~= nil then - scene.meta.blend = { widgets = widgetList(ctx), bone_color_sets = Armature.colorSets() } + mb.widgets = widgetList(ctx) + mb.bone_color_sets = Armature.colorSets() + end + -- every action in the file by name (assigned or not: action constraints and the NLA refer to them) + if o.rawActions ~= false then + local acts: { [string]: any } = {} + for _, b in Blend.blocks(f, "AC") do + local act = Blend.struct(f, b, 0, "bAction") + local name = act and act:idName() + if act and name and not acts[name] then + acts[name] = Anim.raw(f, act) + end + end + if next(acts) ~= nil then + mb.actions = acts + end + end + if next(mb) ~= nil then + scene.meta.blend = mb end if o.animations ~= false then animations(ctx) diff --git a/build/rosetta.lua b/build/rosetta.lua index 435a12c..e69f363 100644 --- a/build/rosetta.lua +++ b/build/rosetta.lua @@ -163315,7 +163315,8 @@ local __compat = __compat local buffer = __compat.buffer --!strict -- meshes of every storage generation (MFace, MPoly / MLoop, attribute layers, AttributeStorage) with UV maps, colour -- attributes, custom normals, material slots; Principled BSDF materials; packed and external images; cameras; lights; -- armatures, skins (vertex groups, top 4 weights), shape keys (relative keys, vertex groups); actions sampled into --- channels; rig data (bone collections / layers, colours, custom shapes, pose settings, constraint stacks) as extras. +-- channels, and every action's raw f-curves in meta.blend.actions; rig data (bone collections / layers, colours, +-- custom shapes, pose settings, constraint stacks) as extras. -- Not supported: modifiers (listed in meta.source.modifiers), curves / text / metaballs / grease pencil / volumes, -- NLA strips, drivers, constraint evaluation, f-curve modifiers, linked libraries, collection instances. @@ -163357,6 +163358,7 @@ local BlendFormat = { + function BlendFormat.sniff(r) local head = r:peek(7) if head == "BLENDER" then @@ -163406,7 +163408,7 @@ BlendFormat.ipo = Anim.ipo return BlendFormat end __FILES["model/blend/Anim"] = function() -local __compat = __compat local __iter = __compat.__iter --!strict +local __compat = __compat local bit32, __iter = __compat.bit32, __compat.__iter --!strict -- model/blend/Anim: Blender actions (legacy bAction.curves, and the layered actions of 4.4+: layers -> strips -> -- keyframe data -> channel bags matched by the AnimData slot handle) and f-curve evaluation: constant, linear, -- bezier (handles shortened so the segment stays a function of time, as Blender does) and the Penner easing modes @@ -163469,6 +163471,54 @@ return a.x < b.x return { path = path, index = fc:num("array_index") or 0, keys = keys, extend = fc:num("extend") or 0, modifiers = #mods } end +-- an action's f-curves: the legacy list, or (4.4+ layered actions) the channel bags of the strips of every layer whose +-- slot handle matches (handle nil: the first layer's first strip's first channel bag) +local function fcurves(f, act, handle) +local list= act:list("curves", "FCurve") + if #list > 0 or not act:has("layer_array") then + return list + end + local datas = act:pointers("strip_keyframe_data_array", act:num("strip_keyframe_data_array_num")) + for _, la in __iter(act:pointers("layer_array", act:num("layer_array_num"))) do + local lblk = la and Blend.resolve(f, la, act.block) + local layer = lblk and Blend.struct(f, lblk, 0, "ActionLayer") + if layer then + for _, sa in __iter(layer:pointers("strip_array", layer:num("strip_array_num"))) do + local sblk = sa and Blend.resolve(f, sa, act.block) + local strip = sblk and Blend.struct(f, sblk, 0, "ActionStrip") + local di = strip and strip:num("data_index") + local dblk = di and datas[di + 1] and Blend.resolve(f, datas[di + 1], act.block) + local kd = dblk and Blend.struct(f, dblk, 0, "ActionStripKeyframeData") + if kd then + for _, ba in __iter(kd:pointers("channelbag_array", kd:num("channelbag_array_num"))) do + local bblk = ba and Blend.resolve(f, ba, act.block) + local bag = bblk and (Blend.struct(f, bblk, 0, "ActionChannelBag") or Blend.struct(f, bblk, 0, "ActionChannelbag")) + if bag and (handle == nil or (bag:num("slot_handle") or 0) == handle) then + for _, ca in __iter(bag:pointers("fcurve_array", bag:num("fcurve_array_num"))) do + local cblk = ca and Blend.resolve(f, ca, act.block) + local fc = cblk and Blend.struct(f, cblk, 0, "FCurve") + if fc then + table.insert(list, fc) + end + end + if handle == nil then + return list + end + end + end + end + if handle == nil then + return list + end + end + end + if handle == nil then + return list + end + end + return list +end + function Anim.curves(f, adt) if not adt then return nil, nil @@ -163477,41 +163527,8 @@ if not adt then if not act then return nil, nil end - local list= act:list("curves", "FCurve") - if #list == 0 and act:has("layer_array") then - local handle = adt:num("slot_handle") or 0 - local datas = act:pointers("strip_keyframe_data_array", act:num("strip_keyframe_data_array_num")) - for _, la in __iter(act:pointers("layer_array", act:num("layer_array_num"))) do - local lblk = la and Blend.resolve(f, la, act.block) - local layer = lblk and Blend.struct(f, lblk, 0, "ActionLayer") - if layer then - for _, sa in __iter(layer:pointers("strip_array", layer:num("strip_array_num"))) do - local sblk = sa and Blend.resolve(f, sa, act.block) - local strip = sblk and Blend.struct(f, sblk, 0, "ActionStrip") - local di = strip and strip:num("data_index") - local dblk = di and datas[di + 1] and Blend.resolve(f, datas[di + 1], act.block) - local kd = dblk and Blend.struct(f, dblk, 0, "ActionStripKeyframeData") - if kd then - for _, ba in __iter(kd:pointers("channelbag_array", kd:num("channelbag_array_num"))) do - local bblk = ba and Blend.resolve(f, ba, act.block) - local bag = bblk and (Blend.struct(f, bblk, 0, "ActionChannelBag") or Blend.struct(f, bblk, 0, "ActionChannelbag")) - if bag and (bag:num("slot_handle") or 0) == handle then - for _, ca in __iter(bag:pointers("fcurve_array", bag:num("fcurve_array_num"))) do - local cblk = ca and Blend.resolve(f, ca, act.block) - local fc = cblk and Blend.struct(f, cblk, 0, "FCurve") - if fc then - table.insert(list, fc) - end - end - end - end - end - end - end - end - end local out= {} - for _, fc in __iter(list) do + for _, fc in __iter(fcurves(f, act, adt:num("slot_handle") or 0)) do local c = curve(f, fc) if c then table.insert(out, c) @@ -163520,6 +163537,67 @@ if not adt then return out, act:idName() end +-- ------------------------------------------------------------------------------------------------ raw actions +local INTERPOLATION= { + [0] = "CONSTANT", [1] = "LINEAR", [2] = "BEZIER", [3] = "BACK", [4] = "BOUNCE", [5] = "CIRC", [6] = "CUBIC", + [7] = "ELASTIC", [8] = "EXPO", [9] = "QUAD", [10] = "QUART", [11] = "QUINT", [12] = "SINE", +} +local EASING= { [0] = "AUTO", [1] = "EASE_IN", [2] = "EASE_OUT", [3] = "EASE_IN_OUT" } +local HANDLE= { [0] = "FREE", [1] = "AUTO", [2] = "VECTOR", [3] = "ALIGNED", [4] = "AUTO_CLAMPED" } +local ACT_FRAME_RANGE = 0x1000 + +-- an action as Blender's API shows it: frame_range (the manual range, else the keys' span, at least one frame) and +-- every f-curve with its keyframe points +function Anim.raw(f, act) +local curves= {} + local lo, hi= math.huge, -math.huge + for _, fc in __iter(fcurves(f, act, nil)) do + local path = fc:cstring("rna_path") or "" + local kind, who, rest = Anim.split(path) + local keys= {} + for _, b in __iter(fc:array("bezt", "BezTriple")) do + local v = b:vec("vec") + if v and #v >= 9 then + local x= v[4] + local k= { co = { x, v[5] }, handle_left = { v[1], v[2] }, handle_right = { v[7], v[8] } } + k.interpolation = INTERPOLATION[b:num("ipo") or 2] or "BEZIER" + k.easing = EASING[b:num("easing") or 0] or "AUTO" + k.handle_left_type, k.handle_right_type = HANDLE[b:num("h1") or 0], HANDLE[b:num("h2") or 0] + k.back, k.amplitude, k.period = b:num("back") or 1.70158, b:num("amplitude") or 0.8, b:num("period") or 4.1 + table.insert(keys, k) + lo, hi = math.min(lo, x), math.max(hi, x) + end + end + if #keys == 0 then + for _, p in __iter(fc:array("fpt", "FPoint")) do + local v = p:vec("vec") + if v and #v >= 2 then + local x= v[1] + local k= { co = { x, v[2] } } + k.interpolation = "LINEAR" + table.insert(keys, k) + lo, hi = math.min(lo, x), math.max(hi, x) + end + end + end + local entry= { data_path = path, path = (kind == "pose.bones" and{rest }or{path})[1], keys = keys } + entry.bone = (kind == "pose.bones" and{who }or{nil +})[1] entry.array_index = fc:num("array_index") or 0 + entry.extrapolation = (fc:num("extend") or 0) == 1 and"LINEAR" or"CONSTANT" + table.insert(curves, entry) + end + if bit32.band(act:num("flag") or 0, ACT_FRAME_RANGE) ~= 0 and act:has("frame_start") then + lo = act:num("frame_start") or 0 + hi = act:num("frame_end") or 0 + elseif lo > hi then + lo, hi = 0, 0 + end + if hi <= lo then + hi = lo + 1 + end + return { frame_range = { lo, hi }, curves = curves } +end + -- pre-2.5 IPO curves (Object.ipo / Key.ipo): the curve's adrcode picks the channel; object rotations are in units of -- 10 degrees; the interpolation and extrapolation (0 constant, 1 linear; cyclic ones as constant) are per curve local OB_ADR= { @@ -163757,8 +163835,10 @@ local __compat = __compat local buffer, bit32, type, __iter = __compat.buffer, _ -- armature space, deform, connect, wire), bone collections (4.x BoneCollection arrays and lists; before 4.0 the layers -- and bone groups converted as Blender 4.0's versioning does), bone colours (BoneColor; bone group colours before 4.0), -- pose bones (custom shapes, locks, rotation mode, IK settings) and constraint stacks (bConstraint and the data structs --- of IK, copy rotation / location / scale / transforms, damped track, limit rotation / location / scale, child of; the --- common fields for the rest). Flags from DNA_armature_types.h, DNA_action_types.h, DNA_constraint_types.h. +-- of IK, copy rotation / location / scale / transforms, damped track, limit rotation / location / scale, child of, +-- action, transform, stretch to, armature, floor, limit distance, track to, locked track; the common fields for the +-- rest), bone inheritance and b-bone settings, the stored pose basis. Flags from DNA_armature_types.h, +-- DNA_action_types.h, DNA_constraint_types.h. local Blend = __include("containers/Blend") local Armature = {} @@ -163816,6 +163896,33 @@ local PCHAN_DRAW_NO_CUSTOM_BONE_SIZE = 1 local LOCK_LOC, LOCK_ROT, LOCK_SCALE, LOCK_ROTW, LOCK_ROT4D = { 1, 2, 4 }, { 8, 16, 32 }, { 64, 128, 256 }, 512, 1024 local IK_NO_DOF, IK_LIMIT = { 1, 2, 4 }, { 8, 16, 32 } local AXES = { "x", "y", "z" } +local XYZ= { [0] = "X", [1] = "Y", [2] = "Z" } +-- bActionConstraint.type, .mix_mode +local ACTION_CHANNEL= { + [0] = "ROTATION_X", [1] = "ROTATION_Y", [2] = "ROTATION_Z", [10] = "SCALE_X", [11] = "SCALE_Y", [12] = "SCALE_Z", + [20] = "LOCATION_X", [21] = "LOCATION_Y", [22] = "LOCATION_Z", +} +local ACTION_MIX= { [0] = "AFTER_FULL", [1] = "AFTER", [2] = "BEFORE", [3] = "BEFORE_FULL", [4] = "BEFORE_SPLIT", [5] = "AFTER_SPLIT" } +local MAP= { [0] = "LOCATION", [1] = "ROTATION", [2] = "SCALE" } +-- the driver target rotation modes (DTAR_ROTMODE_*) +local FROM_ROT= { + [0] = "AUTO", [1] = "XYZ", [2] = "XZY", [3] = "YXZ", [4] = "YZX", [5] = "ZXY", [6] = "ZYX", [7] = "QUATERNION", + [8] = "SWING_TWIST_X", [9] = "SWING_TWIST_Y", [10] = "SWING_TWIST_Z", +} +local MIX_LOC= { [0] = "ADD", [1] = "REPLACE" } +local MIX_ROT= { [0] = "ADD", [1] = "REPLACE", [2] = "BEFORE", [3] = "AFTER" } +local MIX_SCALE= { [0] = "REPLACE", [1] = "MULTIPLY" } +local VOLUME= { [0] = "VOLUME_XZX", [1] = "VOLUME_X", [2] = "VOLUME_Z", [3] = "NO_VOLUME" } +local KEEP_AXIS= { [0] = "PLANE_X", [1] = "SWING_Y", [2] = "PLANE_Z" } +local FLOOR= { [0] = "FLOOR_X", [1] = "FLOOR_Y", [2] = "FLOOR_Z", [3] = "FLOOR_NEGATIVE_X", [4] = "FLOOR_NEGATIVE_Y", [5] = "FLOOR_NEGATIVE_Z" } +local DIST_MODE= { [0] = "LIMITDIST_INSIDE", [1] = "LIMITDIST_OUTSIDE", [2] = "LIMITDIST_ONSURFACE" } +local UP= { [0] = "UP_X", [1] = "UP_Y", [2] = "UP_Z" } +local LOCK= { [0] = "LOCK_X", [1] = "LOCK_Y", [2] = "LOCK_Z" } +-- Bone.inherit_scale_mode, bbone_prev_type / bbone_next_type, bbone_mapping_mode +local INHERIT_SCALE= { [0] = "FULL", [1] = "FIX_SHEAR", [2] = "AVERAGE", [3] = "NONE", [4] = "NONE_LEGACY", [5] = "ALIGNED" } +local HANDLE_TYPE= { [0] = "AUTO", [1] = "ABSOLUTE", [2] = "RELATIVE", [3] = "TANGENT" } +local MAPPING= { [0] = "STRAIGHT", [1] = "CURVED" } +local BONE_HINGE, BONE_NO_SCALE, BONE_NO_LOCAL_LOCATION, BONE_RELATIVE_PARENTING, BONE_ADD_PARENT_END_ROLL = 0x200, 0x8000, 0x400000, 0x800000, 0x1000000 local function bit(v, mask) return bit32.band(v or 0, mask) ~= 0 @@ -163990,7 +164097,35 @@ local flag = bone:num("flag") or 0 head_local = vec3(bone, "arm_head"), tail_local = vec3(bone, "arm_tail"), roll = bone:num("arm_roll"), + use_inherit_rotation = not bit(flag, BONE_HINGE), + use_local_location = not bit(flag, BONE_NO_LOCAL_LOCATION), + use_relative_parent = bit(flag, BONE_RELATIVE_PARENTING), } + local ism = bone:num("inherit_scale_mode") + e.inherit_scale = (ism and{INHERIT_SCALE[ism] }or{(bit(flag, BONE_NO_SCALE) and"NONE_LEGACY" or"FULL") -- BONE_NO_SCALE before 2.81 +})[1] e.bbone_segments = bone:num("segments") or 1 + e.bbone_x, e.bbone_z = bone:num("xwidth"), bone:num("zwidth") + e.bbone_easein, e.bbone_easeout = bone:num("ease1") or 1, bone:num("ease2") or 1 + e.bbone_rollin, e.bbone_rollout = bone:num("roll1") or 0, bone:num("roll2") or 0 + e.bbone_curveinx, e.bbone_curveinz = bone:num("curveInX") or 0, bone:num("curveInY") or 0 -- curveInY is the API's z + e.bbone_curveoutx, e.bbone_curveoutz = bone:num("curveOutX") or 0, bone:num("curveOutY") or 0 + for _, side in __iter({ "in", "out" }) do + local cap = side == "in" and"In" or"Out" + local v = vec3(bone, "scale_" .. side) + if not v then + -- before 3.0: scaleIn (x) and scale_in_y (z); before 2.8 one value for both + local x = bone:num("scale" .. cap) or 1 + v = { x, 1, bone:num("scale_" .. side .. "_y") or x } + end + e["bbone_scale" .. side] = v + end + e.bbone_handle_type_start = HANDLE_TYPE[bone:num("bbone_prev_type") or 0] + e.bbone_handle_type_end = HANDLE_TYPE[bone:num("bbone_next_type") or 0] + local prev, nxt = bone:deref("bbone_prev", 0, "Bone"), bone:deref("bbone_next", 0, "Bone") + e.bbone_custom_handle_start = (prev and{(prev:str("name") )}or{nil +})[1] e.bbone_custom_handle_end = (nxt and{(nxt:str("name") )}or{nil +})[1] e.use_endroll_as_inroll = (bone:has("bbone_flag") and{(bit(bone:num("bbone_flag"), 1) )}or{(bit(flag, BONE_ADD_PARENT_END_ROLL) +)})[1] e.bbone_mapping_mode = MAPPING[bone:num("bbone_mapping_mode") or 0] if bone:has("color") then e.color = boneColor(bone) elseif pc and pose then @@ -164037,10 +164172,72 @@ local function constraintData(e, kind, d, resolve) e.invert_x, e.invert_y, e.invert_z = bit(flag, 16), bit(flag, 32), bit(flag, 64) e.use_offset = bit(flag, 128) elseif kind == "COPY_SCALE" then - -- SIZELIKE_X 1, Y 2, Z 4, OFFSET 8 + -- SIZELIKE_X 1, Y 2, Z 4, OFFSET 8, MULTIPLY 16 (use_add is its inverse), UNIFORM 32 e.use_x, e.use_y, e.use_z = bit(flag, 1), bit(flag, 2), bit(flag, 4) e.use_offset = bit(flag, 8) + e.use_add = not bit(flag, 16) + e.use_make_uniform = bit(flag, 32) e.power = d:num("power") or 1 + elseif kind == "ACTION" then + -- flag: ACTCON_BONE_USE_OBJECT_ACTION 1, ACTCON_USE_EVAL_TIME 2 + local act = d:deref("act", 0, "bAction") + e.action = (act and{(act:idName() )}or{nil +})[1] e.transform_channel = ACTION_CHANNEL[d:num("type") or 20] + e.frame_start, e.frame_end = d:num("start") or 1, d:num("end") or 1 + e.min, e.max = d:num("min") or 0, d:num("max") or 0 + e.mix_mode = ACTION_MIX[d:num("mix_mode") or 0] + e.use_bone_object_action = bit(flag, 1) + e.use_eval_time = bit(flag, 2) + e.eval_time = d:num("eval_time") or 0 + elseif kind == "TRANSFORM" then + e.map_from, e.map_to = MAP[d:num("from") or 0], MAP[d:num("to") or 0] + local map = d.struct.byName.map + for i, a in __iter(AXES) do + local o = map and d.offset + map.offset + i - 1 + e["map_to_" .. a .. "_from"] = XYZ[(o and o < buffer.len(d.file.buf) and{(buffer.readu8(d.file.buf, o) )}or{(i - 1)})[1] ] + end + e.use_motion_extrapolate = (d:num("expo") or 0) ~= 0 + e.from_rotation_mode = FROM_ROT[d:num("from_rotation_mode") or 0] + e.to_euler_order = EULER_ORDER[d:num("to_euler_order") or 0] + e.mix_mode = MIX_LOC[d:num("mix_mode_loc") or 0] + e.mix_mode_rot = MIX_ROT[d:num("mix_mode_rot") or 0] + e.mix_mode_scale = MIX_SCALE[d:num("mix_mode_scale") or 0] + for _, side in __iter({ "from", "to" }) do + for _, suffix in __iter({ "", "_rot", "_scale" }) do + local lo, hi = d:vec(side .. "_min" .. suffix), d:vec(side .. "_max" .. suffix) + for i, a in __iter(AXES) do + e[side .. "_min_" .. a .. suffix] = lo and lo[i] or 0 + e[side .. "_max_" .. a .. suffix] = hi and hi[i] or 0 + end + end + end + elseif kind == "STRETCH_TO" then + -- STRETCHTOCON_USE_BULGE_MIN 1, MAX 2 + e.rest_length = d:num("orglength") + e.bulge = d:num("bulge") + e.volume = VOLUME[d:num("volmode") or 0] + e.keep_axis = KEEP_AXIS[d:num("plane") or 0] + e.use_bulge_min, e.use_bulge_max = bit(flag, 1), bit(flag, 2) + e.bulge_min, e.bulge_max, e.bulge_smooth = d:num("bulge_min"), d:num("bulge_max"), d:num("bulge_smooth") + elseif kind == "ARMATURE" then + -- CONSTRAINT_ARMATURE_QUATERNION 1, ENVELOPE 2, CUR_LOCATION 4 + e.use_deform_preserve_volume, e.use_bone_envelopes, e.use_current_location = bit(flag, 1), bit(flag, 2), bit(flag, 4) + elseif kind == "FLOOR" then + -- flag: MINMAX_USEROT 4 + e.floor_location = FLOOR[d:num("minmaxflag") or 2] + e.offset = d:num("offset") or 0 + e.use_rotation = bit(flag, 4) + elseif kind == "LIMIT_DISTANCE" then + e.distance = d:num("dist") + e.limit_mode = DIST_MODE[d:num("mode") or 0] + elseif kind == "TRACK_TO" then + -- reserved1 the track axis, reserved2 the up axis; flags TARGET_Z_UP 1 + e.track_axis = TRACK[d:num("reserved1") or 1] + e.up_axis = UP[d:num("reserved2") or 2] + e.use_target_z = bit(d:num("flags"), 1) + elseif kind == "LOCKED_TRACK" then + e.track_axis = TRACK[d:num("trackflag") or 1] + e.lock_axis = LOCK[d:num("lockflag") or 2] elseif kind == "COPY_TRANSFORMS" then e.mix_mode = TRANS_MIX[d:num("mix_mode") or 0] e.remove_target_shear = bit(flag, 1) @@ -164153,7 +164350,15 @@ function Armature.pose(e, pc, resolve, shape) e["ik_stiffness_" .. a] = stiff and stiff[i] or 0 end e.pose_color = (pc:has("color") and{(boneColor(pc) )}or{nil -})[1] e.constraints = Armature.constraints(pc, resolve) +})[1] -- the stored basis (rotation_quaternion w, x, y, z; rotation_axis_angle angle, x, y, z) + e.location = vec3(pc, "loc", { 0, 0, 0 }) + local q = pc:vec("quat") + e.rotation_quaternion = q and #q >= 4 and{ q[1], q[2], q[3], q[4] } or{ 1, 0, 0, 0 } + e.rotation_euler = vec3(pc, "eul", { 0, 0, 0 }) + local axis = (vec3(pc, "rotAxis", { 0, 1, 0 }) ) +e.rotation_axis_angle = { pc:num("rotAngle") or 0, axis[1], axis[2], axis[3] } + e.scale = vec3(pc, "size", nil) or vec3(pc, "scale", { 1, 1, 1 }) + e.constraints = Armature.constraints(pc, resolve) end return Armature @@ -165902,6 +166107,7 @@ local Scene = Types.Scene + local OB_EMPTY, OB_MESH, OB_LAMP, OB_CAMERA, OB_ARMATURE = 0, 1, 10, 11, 25 local PARSKEL, PARBONE = 4, 7 local LA_LOCAL, LA_SUN, LA_SPOT, LA_HEMI, LA_AREA = 0, 1, 2, 3, 4 @@ -166882,8 +167088,27 @@ local o= opts or {} end end skins(ctx) + local mb= {} if next(ctx.armatures) ~= nil then - scene.meta.blend = { widgets = widgetList(ctx), bone_color_sets = Armature.colorSets() } + mb.widgets = widgetList(ctx) + mb.bone_color_sets = Armature.colorSets() + end + -- every action in the file by name (assigned or not: action constraints and the NLA refer to them) + if o.rawActions ~= false then + local acts= {} + for _, b in __iter(Blend.blocks(f, "AC")) do + local act = Blend.struct(f, b, 0, "bAction") + local name = act and act:idName() + if act and name and not acts[name] then + acts[name] = Anim.raw(f, act) + end + end + if next(acts) ~= nil then + mb.actions = acts + end + end + if next(mb) ~= nil then + scene.meta.blend = mb end if o.animations ~= false then animations(ctx) diff --git a/build/rosetta.lua.linemap.json b/build/rosetta.lua.linemap.json index 1eb149a..34c4ac9 100644 --- a/build/rosetta.lua.linemap.json +++ b/build/rosetta.lua.linemap.json @@ -436,187 +436,187 @@ [162685, "src/Rosetta/model/b3d/init.luau"], [162740, "src/Rosetta/model/b3d/Read.luau"], [163311, "src/Rosetta/model/blend/init.luau"], -[163409, "src/Rosetta/model/blend/Anim.luau"], -[163755, "src/Rosetta/model/blend/Armature.luau"], -[164162, "src/Rosetta/model/blend/Material.luau"], -[164514, "src/Rosetta/model/blend/Mesh.luau"], -[165202, "src/Rosetta/model/blend/Normals.luau"], -[165363, "src/Rosetta/model/blend/Prim.luau"], -[165870, "src/Rosetta/model/blend/Read.luau"], -[166909, "src/Rosetta/model/bsp/init.luau"], -[167100, "src/Rosetta/model/bsp/Lightmap.luau"], -[167166, "src/Rosetta/model/bsp/Quake.luau"], -[167555, "src/Rosetta/model/bsp/Quake3.luau"], -[167784, "src/Rosetta/model/bsp/Tree.luau"], -[168172, "src/Rosetta/model/buildmap/init.luau"], -[168444, "src/Rosetta/model/buildmap/Geometry.luau"], -[168847, "src/Rosetta/model/d3map/init.luau"], -[169129, "src/Rosetta/model/d3map/Parse.luau"], -[169327, "src/Rosetta/model/dae/init.luau"], -[169516, "src/Rosetta/model/dae/Math.luau"], -[169563, "src/Rosetta/model/dae/Read.luau"], -[171413, "src/Rosetta/model/dae/Write.luau"], -[171782, "src/Rosetta/model/fbx/init.luau"], -[171930, "src/Rosetta/model/fbx/Ascii.luau"], -[172200, "src/Rosetta/model/fbx/Binary.luau"], -[172655, "src/Rosetta/model/fbx/Read.luau"], -[174017, "src/Rosetta/model/fbx/Write.luau"], -[175002, "src/Rosetta/model/fbx/Xform.luau"], -[175043, "src/Rosetta/model/gltf/init.luau"], -[175280, "src/Rosetta/model/gltf/Pack.luau"], -[175349, "src/Rosetta/model/gltf/Read.luau"], -[176090, "src/Rosetta/model/gltf/Write.luau"], -[176776, "src/Rosetta/model/godot/init.luau"], -[176867, "src/Rosetta/model/godot/Build.luau"], -[177409, "src/Rosetta/model/godot/Primitives.luau"], -[177684, "src/Rosetta/model/godot/Surface.luau"], -[178169, "src/Rosetta/model/godot/Write.luau"], -[178498, "src/Rosetta/model/iqm/init.luau"], -[178574, "src/Rosetta/model/iqm/Read.luau"], -[178929, "src/Rosetta/model/iqm/Write.luau"], -[179616, "src/Rosetta/model/ldraw/init.luau"], -[179694, "src/Rosetta/model/ldraw/Colors.luau"], -[180012, "src/Rosetta/model/ldraw/Read.luau"], -[180589, "src/Rosetta/model/lwo/init.luau"], -[180665, "src/Rosetta/model/lwo/Build.luau"], -[181127, "src/Rosetta/model/lwo/Parse.luau"], -[181670, "src/Rosetta/model/map/init.luau"], -[181987, "src/Rosetta/model/map/Build.luau"], -[182231, "src/Rosetta/model/map/Parse.luau"], -[182616, "src/Rosetta/model/map/Write.luau"], -[182762, "src/Rosetta/model/mca/init.luau"], -[183104, "src/Rosetta/model/mca/Chunk.luau"], -[183237, "src/Rosetta/model/mca/Lz4Block.luau"], -[183307, "src/Rosetta/model/md2/init.luau"], -[183506, "src/Rosetta/model/md3/init.luau"], -[183734, "src/Rosetta/model/md5/init.luau"], -[183815, "src/Rosetta/model/md5/Read.luau"], -[184248, "src/Rosetta/model/mdl/init.luau"], -[184330, "src/Rosetta/model/mdl/HalfLife.luau"], -[184634, "src/Rosetta/model/mdl/Quake.luau"], -[184852, "src/Rosetta/model/ms3d/init.luau"], -[184924, "src/Rosetta/model/ms3d/Read.luau"], -[185370, "src/Rosetta/model/ms3d/Write.luau"], -[185839, "src/Rosetta/model/obj/init.luau"], -[186657, "src/Rosetta/model/obj/Mtl.luau"], -[186945, "src/Rosetta/model/off/init.luau"], -[187407, "src/Rosetta/model/ply/init.luau"], -[188512, "src/Rosetta/model/ply/Binary.luau"], -[188713, "src/Rosetta/model/pmx/init.luau"], -[188782, "src/Rosetta/model/pmx/Build.luau"], -[189078, "src/Rosetta/model/pmx/Pmd.luau"], -[189413, "src/Rosetta/model/pmx/Read.luau"], -[189817, "src/Rosetta/model/proc/init.luau"], -[190199, "src/Rosetta/model/qb/init.luau"], -[190592, "src/Rosetta/model/rbxm/init.luau"], -[191185, "src/Rosetta/model/rbxmx/init.luau"], -[191861, "src/Rosetta/model/robloxmesh/init.luau"], -[192520, "src/Rosetta/model/robloxmesh/Parse.luau"], -[192977, "src/Rosetta/model/robloxmesh/Write.luau"], -[193086, "src/Rosetta/model/schematic/init.luau"], -[193407, "src/Rosetta/model/schematic/Common.luau"], -[193527, "src/Rosetta/model/schematic/Litematic.luau"], -[193738, "src/Rosetta/model/schematic/Mcedit.luau"], -[193982, "src/Rosetta/model/schematic/Sponge.luau"], -[194111, "src/Rosetta/model/smd/init.luau"], -[194178, "src/Rosetta/model/smd/Read.luau"], -[194447, "src/Rosetta/model/smd/Write.luau"], -[194690, "src/Rosetta/model/sourcemdl/init.luau"], -[194861, "src/Rosetta/model/sourcemdl/Build.luau"], -[195291, "src/Rosetta/model/sourcemdl/Material.luau"], -[195452, "src/Rosetta/model/sourcemdl/Mdl.luau"], -[195979, "src/Rosetta/model/sourcemdl/Phy.luau"], -[196102, "src/Rosetta/model/sourcemdl/Vtx.luau"], -[196284, "src/Rosetta/model/sourcemdl/Vvd.luau"], -[196378, "src/Rosetta/model/stl/init.luau"], -[196828, "src/Rosetta/model/stl/Decode.luau"], -[196902, "src/Rosetta/model/t3d/init.luau"], -[196996, "src/Rosetta/model/t3d/Build.luau"], -[197401, "src/Rosetta/model/t3d/Parse.luau"], -[197569, "src/Rosetta/model/udmf/init.luau"], -[197652, "src/Rosetta/model/usda/init.luau"], -[197861, "src/Rosetta/model/usda/Build.luau"], -[199139, "src/Rosetta/model/usda/Parse.luau"], -[199937, "src/Rosetta/model/usda/Write.luau"], -[200754, "src/Rosetta/model/vbsp/init.luau"], -[201200, "src/Rosetta/model/vbsp/Faces.luau"], -[201424, "src/Rosetta/model/vbsp/Props.luau"], -[201516, "src/Rosetta/model/vmf/init.luau"], -[201841, "src/Rosetta/model/vmf/Build.luau"], -[202265, "src/Rosetta/model/vox/init.luau"], -[203151, "src/Rosetta/model/vox/Grid.luau"], -[203208, "src/Rosetta/model/vrml/init.luau"], -[203274, "src/Rosetta/model/x/init.luau"], -[203404, "src/Rosetta/model/x/Build.luau"], -[203967, "src/Rosetta/model/x/Parse.luau"], -[204264, "src/Rosetta/model/x3d/init.luau"], -[204342, "src/Rosetta/music/669/init.luau"], -[204549, "src/Rosetta/music/ahx/init.luau"], -[204601, "src/Rosetta/music/far/init.luau"], -[204831, "src/Rosetta/music/hmp/init.luau"], -[205096, "src/Rosetta/music/hvl/init.luau"], -[205148, "src/Rosetta/music/it/init.luau"], -[205567, "src/Rosetta/music/it/Itsex.luau"], -[205684, "src/Rosetta/music/med/init.luau"], -[206332, "src/Rosetta/music/midi/init.luau"], -[206476, "src/Rosetta/music/midi/Smf.luau"], -[206888, "src/Rosetta/music/mod/init.luau"], -[207242, "src/Rosetta/music/mtm/init.luau"], -[207465, "src/Rosetta/music/mus/init.luau"], -[207623, "src/Rosetta/music/okt/init.luau"], -[207905, "src/Rosetta/music/ptm/init.luau"], -[208128, "src/Rosetta/music/s3m/init.luau"], -[208365, "src/Rosetta/music/sf2/init.luau"], -[208409, "src/Rosetta/music/stm/init.luau"], -[208641, "src/Rosetta/music/ult/init.luau"], -[208946, "src/Rosetta/music/umx/init.luau"], -[209163, "src/Rosetta/music/xm/init.luau"], -[209725, "src/Rosetta/music/xmi/init.luau"], -[209934, "src/Rosetta/ops/AudioOps.luau"], -[210413, "src/Rosetta/ops/ImageOps/init.luau"], -[211061, "src/Rosetta/ops/ImageOps/Kernels.luau"], -[211701, "src/Rosetta/ops/LayerOps.luau"], -[211794, "src/Rosetta/ops/MeshOps/init.luau"], -[212934, "src/Rosetta/ops/MeshOps/Greedy.luau"], -[213101, "src/Rosetta/ops/MusicOps.luau"], -[213450, "src/Rosetta/playlist/m3u/init.luau"], -[213803, "src/Rosetta/playlist/pls/init.luau"], -[213981, "src/Rosetta/playlist/xspf/init.luau"], -[214184, "src/Rosetta/subtitle/ass/init.luau"], -[214628, "src/Rosetta/subtitle/srt/init.luau"], -[214801, "src/Rosetta/subtitle/vtt/init.luau"], -[215004, "src/Rosetta/vector/gamemaps/init.luau"], -[215191, "src/Rosetta/vector/gamemaps/Expand.luau"], -[215288, "src/Rosetta/vector/ldtk/init.luau"], -[215380, "src/Rosetta/vector/ldtk/Read.luau"], -[215716, "src/Rosetta/vector/ldtk/Write.luau"], -[216364, "src/Rosetta/vector/ogmo/init.luau"], -[216483, "src/Rosetta/vector/ogmo/Read.luau"], -[216888, "src/Rosetta/vector/ogmo/Write.luau"], -[217242, "src/Rosetta/vector/svg/init.luau"], -[217328, "src/Rosetta/vector/svg/Parse.luau"], -[218074, "src/Rosetta/vector/svg/PathData.luau"], -[218442, "src/Rosetta/vector/svg/Render.luau"], -[218859, "src/Rosetta/vector/svg/Style.luau"], -[219231, "src/Rosetta/vector/svg/Write.luau"], -[219431, "src/Rosetta/vector/tiled/init.luau"], -[219611, "src/Rosetta/vector/tiled/Data.luau"], -[219762, "src/Rosetta/vector/tiled/Tmj.luau"], -[220393, "src/Rosetta/vector/tiled/Tmx.luau"], -[221005, "src/Rosetta/video/avi/init.luau"], -[221299, "src/Rosetta/video/fli/init.luau"], -[221450, "src/Rosetta/video/flv/init.luau"], -[221834, "src/Rosetta/video/flv/Amf.luau"], -[221992, "src/Rosetta/video/flv/Mux.luau"], -[222273, "src/Rosetta/video/h264/init.luau"], -[222412, "src/Rosetta/video/mkv/init.luau"], -[222568, "src/Rosetta/video/mkv/Mux.luau"], -[222847, "src/Rosetta/video/mkv/Parse.luau"], -[223568, "src/Rosetta/video/mp4/init.luau"], -[223896, "src/Rosetta/video/mpegps/init.luau"], -[224083, "src/Rosetta/video/mpegts/init.luau"], -[224329, "src/Rosetta/video/ogv/init.luau"], -[224724, "src/Rosetta/video/smk/init.luau"], -[225033, "src/Rosetta/video/smk/Audio.luau"], -[225153, "src/Rosetta/video/y4m/init.luau"] +[163411, "src/Rosetta/model/blend/Anim.luau"], +[163833, "src/Rosetta/model/blend/Armature.luau"], +[164367, "src/Rosetta/model/blend/Material.luau"], +[164719, "src/Rosetta/model/blend/Mesh.luau"], +[165407, "src/Rosetta/model/blend/Normals.luau"], +[165568, "src/Rosetta/model/blend/Prim.luau"], +[166075, "src/Rosetta/model/blend/Read.luau"], +[167134, "src/Rosetta/model/bsp/init.luau"], +[167325, "src/Rosetta/model/bsp/Lightmap.luau"], +[167391, "src/Rosetta/model/bsp/Quake.luau"], +[167780, "src/Rosetta/model/bsp/Quake3.luau"], +[168009, "src/Rosetta/model/bsp/Tree.luau"], +[168397, "src/Rosetta/model/buildmap/init.luau"], +[168669, "src/Rosetta/model/buildmap/Geometry.luau"], +[169072, "src/Rosetta/model/d3map/init.luau"], +[169354, "src/Rosetta/model/d3map/Parse.luau"], +[169552, "src/Rosetta/model/dae/init.luau"], +[169741, "src/Rosetta/model/dae/Math.luau"], +[169788, "src/Rosetta/model/dae/Read.luau"], +[171638, "src/Rosetta/model/dae/Write.luau"], +[172007, "src/Rosetta/model/fbx/init.luau"], +[172155, "src/Rosetta/model/fbx/Ascii.luau"], +[172425, "src/Rosetta/model/fbx/Binary.luau"], +[172880, "src/Rosetta/model/fbx/Read.luau"], +[174242, "src/Rosetta/model/fbx/Write.luau"], +[175227, "src/Rosetta/model/fbx/Xform.luau"], +[175268, "src/Rosetta/model/gltf/init.luau"], +[175505, "src/Rosetta/model/gltf/Pack.luau"], +[175574, "src/Rosetta/model/gltf/Read.luau"], +[176315, "src/Rosetta/model/gltf/Write.luau"], +[177001, "src/Rosetta/model/godot/init.luau"], +[177092, "src/Rosetta/model/godot/Build.luau"], +[177634, "src/Rosetta/model/godot/Primitives.luau"], +[177909, "src/Rosetta/model/godot/Surface.luau"], +[178394, "src/Rosetta/model/godot/Write.luau"], +[178723, "src/Rosetta/model/iqm/init.luau"], +[178799, "src/Rosetta/model/iqm/Read.luau"], +[179154, "src/Rosetta/model/iqm/Write.luau"], +[179841, "src/Rosetta/model/ldraw/init.luau"], +[179919, "src/Rosetta/model/ldraw/Colors.luau"], +[180237, "src/Rosetta/model/ldraw/Read.luau"], +[180814, "src/Rosetta/model/lwo/init.luau"], +[180890, "src/Rosetta/model/lwo/Build.luau"], +[181352, "src/Rosetta/model/lwo/Parse.luau"], +[181895, "src/Rosetta/model/map/init.luau"], +[182212, "src/Rosetta/model/map/Build.luau"], +[182456, "src/Rosetta/model/map/Parse.luau"], +[182841, "src/Rosetta/model/map/Write.luau"], +[182987, "src/Rosetta/model/mca/init.luau"], +[183329, "src/Rosetta/model/mca/Chunk.luau"], +[183462, "src/Rosetta/model/mca/Lz4Block.luau"], +[183532, "src/Rosetta/model/md2/init.luau"], +[183731, "src/Rosetta/model/md3/init.luau"], +[183959, "src/Rosetta/model/md5/init.luau"], +[184040, "src/Rosetta/model/md5/Read.luau"], +[184473, "src/Rosetta/model/mdl/init.luau"], +[184555, "src/Rosetta/model/mdl/HalfLife.luau"], +[184859, "src/Rosetta/model/mdl/Quake.luau"], +[185077, "src/Rosetta/model/ms3d/init.luau"], +[185149, "src/Rosetta/model/ms3d/Read.luau"], +[185595, "src/Rosetta/model/ms3d/Write.luau"], +[186064, "src/Rosetta/model/obj/init.luau"], +[186882, "src/Rosetta/model/obj/Mtl.luau"], +[187170, "src/Rosetta/model/off/init.luau"], +[187632, "src/Rosetta/model/ply/init.luau"], +[188737, "src/Rosetta/model/ply/Binary.luau"], +[188938, "src/Rosetta/model/pmx/init.luau"], +[189007, "src/Rosetta/model/pmx/Build.luau"], +[189303, "src/Rosetta/model/pmx/Pmd.luau"], +[189638, "src/Rosetta/model/pmx/Read.luau"], +[190042, "src/Rosetta/model/proc/init.luau"], +[190424, "src/Rosetta/model/qb/init.luau"], +[190817, "src/Rosetta/model/rbxm/init.luau"], +[191410, "src/Rosetta/model/rbxmx/init.luau"], +[192086, "src/Rosetta/model/robloxmesh/init.luau"], +[192745, "src/Rosetta/model/robloxmesh/Parse.luau"], +[193202, "src/Rosetta/model/robloxmesh/Write.luau"], +[193311, "src/Rosetta/model/schematic/init.luau"], +[193632, "src/Rosetta/model/schematic/Common.luau"], +[193752, "src/Rosetta/model/schematic/Litematic.luau"], +[193963, "src/Rosetta/model/schematic/Mcedit.luau"], +[194207, "src/Rosetta/model/schematic/Sponge.luau"], +[194336, "src/Rosetta/model/smd/init.luau"], +[194403, "src/Rosetta/model/smd/Read.luau"], +[194672, "src/Rosetta/model/smd/Write.luau"], +[194915, "src/Rosetta/model/sourcemdl/init.luau"], +[195086, "src/Rosetta/model/sourcemdl/Build.luau"], +[195516, "src/Rosetta/model/sourcemdl/Material.luau"], +[195677, "src/Rosetta/model/sourcemdl/Mdl.luau"], +[196204, "src/Rosetta/model/sourcemdl/Phy.luau"], +[196327, "src/Rosetta/model/sourcemdl/Vtx.luau"], +[196509, "src/Rosetta/model/sourcemdl/Vvd.luau"], +[196603, "src/Rosetta/model/stl/init.luau"], +[197053, "src/Rosetta/model/stl/Decode.luau"], +[197127, "src/Rosetta/model/t3d/init.luau"], +[197221, "src/Rosetta/model/t3d/Build.luau"], +[197626, "src/Rosetta/model/t3d/Parse.luau"], +[197794, "src/Rosetta/model/udmf/init.luau"], +[197877, "src/Rosetta/model/usda/init.luau"], +[198086, "src/Rosetta/model/usda/Build.luau"], +[199364, "src/Rosetta/model/usda/Parse.luau"], +[200162, "src/Rosetta/model/usda/Write.luau"], +[200979, "src/Rosetta/model/vbsp/init.luau"], +[201425, "src/Rosetta/model/vbsp/Faces.luau"], +[201649, "src/Rosetta/model/vbsp/Props.luau"], +[201741, "src/Rosetta/model/vmf/init.luau"], +[202066, "src/Rosetta/model/vmf/Build.luau"], +[202490, "src/Rosetta/model/vox/init.luau"], +[203376, "src/Rosetta/model/vox/Grid.luau"], +[203433, "src/Rosetta/model/vrml/init.luau"], +[203499, "src/Rosetta/model/x/init.luau"], +[203629, "src/Rosetta/model/x/Build.luau"], +[204192, "src/Rosetta/model/x/Parse.luau"], +[204489, "src/Rosetta/model/x3d/init.luau"], +[204567, "src/Rosetta/music/669/init.luau"], +[204774, "src/Rosetta/music/ahx/init.luau"], +[204826, "src/Rosetta/music/far/init.luau"], +[205056, "src/Rosetta/music/hmp/init.luau"], +[205321, "src/Rosetta/music/hvl/init.luau"], +[205373, "src/Rosetta/music/it/init.luau"], +[205792, "src/Rosetta/music/it/Itsex.luau"], +[205909, "src/Rosetta/music/med/init.luau"], +[206557, "src/Rosetta/music/midi/init.luau"], +[206701, "src/Rosetta/music/midi/Smf.luau"], +[207113, "src/Rosetta/music/mod/init.luau"], +[207467, "src/Rosetta/music/mtm/init.luau"], +[207690, "src/Rosetta/music/mus/init.luau"], +[207848, "src/Rosetta/music/okt/init.luau"], +[208130, "src/Rosetta/music/ptm/init.luau"], +[208353, "src/Rosetta/music/s3m/init.luau"], +[208590, "src/Rosetta/music/sf2/init.luau"], +[208634, "src/Rosetta/music/stm/init.luau"], +[208866, "src/Rosetta/music/ult/init.luau"], +[209171, "src/Rosetta/music/umx/init.luau"], +[209388, "src/Rosetta/music/xm/init.luau"], +[209950, "src/Rosetta/music/xmi/init.luau"], +[210159, "src/Rosetta/ops/AudioOps.luau"], +[210638, "src/Rosetta/ops/ImageOps/init.luau"], +[211286, "src/Rosetta/ops/ImageOps/Kernels.luau"], +[211926, "src/Rosetta/ops/LayerOps.luau"], +[212019, "src/Rosetta/ops/MeshOps/init.luau"], +[213159, "src/Rosetta/ops/MeshOps/Greedy.luau"], +[213326, "src/Rosetta/ops/MusicOps.luau"], +[213675, "src/Rosetta/playlist/m3u/init.luau"], +[214028, "src/Rosetta/playlist/pls/init.luau"], +[214206, "src/Rosetta/playlist/xspf/init.luau"], +[214409, "src/Rosetta/subtitle/ass/init.luau"], +[214853, "src/Rosetta/subtitle/srt/init.luau"], +[215026, "src/Rosetta/subtitle/vtt/init.luau"], +[215229, "src/Rosetta/vector/gamemaps/init.luau"], +[215416, "src/Rosetta/vector/gamemaps/Expand.luau"], +[215513, "src/Rosetta/vector/ldtk/init.luau"], +[215605, "src/Rosetta/vector/ldtk/Read.luau"], +[215941, "src/Rosetta/vector/ldtk/Write.luau"], +[216589, "src/Rosetta/vector/ogmo/init.luau"], +[216708, "src/Rosetta/vector/ogmo/Read.luau"], +[217113, "src/Rosetta/vector/ogmo/Write.luau"], +[217467, "src/Rosetta/vector/svg/init.luau"], +[217553, "src/Rosetta/vector/svg/Parse.luau"], +[218299, "src/Rosetta/vector/svg/PathData.luau"], +[218667, "src/Rosetta/vector/svg/Render.luau"], +[219084, "src/Rosetta/vector/svg/Style.luau"], +[219456, "src/Rosetta/vector/svg/Write.luau"], +[219656, "src/Rosetta/vector/tiled/init.luau"], +[219836, "src/Rosetta/vector/tiled/Data.luau"], +[219987, "src/Rosetta/vector/tiled/Tmj.luau"], +[220618, "src/Rosetta/vector/tiled/Tmx.luau"], +[221230, "src/Rosetta/video/avi/init.luau"], +[221524, "src/Rosetta/video/fli/init.luau"], +[221675, "src/Rosetta/video/flv/init.luau"], +[222059, "src/Rosetta/video/flv/Amf.luau"], +[222217, "src/Rosetta/video/flv/Mux.luau"], +[222498, "src/Rosetta/video/h264/init.luau"], +[222637, "src/Rosetta/video/mkv/init.luau"], +[222793, "src/Rosetta/video/mkv/Mux.luau"], +[223072, "src/Rosetta/video/mkv/Parse.luau"], +[223793, "src/Rosetta/video/mp4/init.luau"], +[224121, "src/Rosetta/video/mpegps/init.luau"], +[224308, "src/Rosetta/video/mpegts/init.luau"], +[224554, "src/Rosetta/video/ogv/init.luau"], +[224949, "src/Rosetta/video/smk/init.luau"], +[225258, "src/Rosetta/video/smk/Audio.luau"], +[225378, "src/Rosetta/video/y4m/init.luau"] ] diff --git a/docs/guide/scene.md b/docs/guide/scene.md index 53c1857..2c03461 100644 --- a/docs/guide/scene.md +++ b/docs/guide/scene.md @@ -985,11 +985,11 @@ hold the saved pose. | Where | Fields | |---|---| -| joint node `extras.blend` (Bone) | `bone = true`, `length`, `deform`, `use_connect`, `show_wire`, `hide`, `head_local` / `tail_local` (armature space), `roll` (radians, armature space), `collections` (names, in collection order), `color` | -| joint node `extras.blend` (pose bone) | `rotation_mode` (`"QUATERNION"`, `"XYZ"` .. `"ZYX"`, `"AXIS_ANGLE"`), `lock_location` / `lock_rotation` / `lock_scale` (3 booleans), `lock_rotation_w`, `lock_rotations_4d`, `custom_shape` (node index, or the object's name when it is not in the scene), `custom_shape_transform` (bone name), `custom_shape_translation` / `custom_shape_rotation_euler` / `custom_shape_scale_xyz`, `use_custom_shape_bone_size`, `custom_shape_wire_width` (4.2+), `ik_stretch`, `lock_ik_x/y/z`, `use_ik_limit_x/y/z`, `ik_min_x/y/z`, `ik_max_x/y/z`, `ik_stiffness_x/y/z`, `pose_color`, `constraints` | +| joint node `extras.blend` (Bone) | `bone = true`, `length`, `deform`, `use_connect`, `show_wire`, `hide`, `head_local` / `tail_local` (armature space), `roll` (radians, armature space), `collections` (names, in collection order), `color`, `inherit_scale` (`"FULL"`, `"FIX_SHEAR"`, `"ALIGNED"`, `"AVERAGE"`, `"NONE"`, `"NONE_LEGACY"`), `use_inherit_rotation`, `use_local_location`, `use_relative_parent`; b-bones: `bbone_segments`, `bbone_x`, `bbone_z`, `bbone_easein` / `bbone_easeout`, `bbone_rollin` / `bbone_rollout`, `bbone_curveinx` / `bbone_curveinz` / `bbone_curveoutx` / `bbone_curveoutz`, `bbone_scalein` / `bbone_scaleout` (3 numbers), `bbone_handle_type_start` / `_end` (`"AUTO"`, `"ABSOLUTE"`, `"RELATIVE"`, `"TANGENT"`), `bbone_custom_handle_start` / `_end` (bone names), `use_endroll_as_inroll`, `bbone_mapping_mode` | +| joint node `extras.blend` (pose bone) | `rotation_mode` (`"QUATERNION"`, `"XYZ"` .. `"ZYX"`, `"AXIS_ANGLE"`), `lock_location` / `lock_rotation` / `lock_scale` (3 booleans), `lock_rotation_w`, `lock_rotations_4d`, `custom_shape` (node index, or the object's name when it is not in the scene), `custom_shape_transform` (bone name), `custom_shape_translation` / `custom_shape_rotation_euler` / `custom_shape_scale_xyz`, `use_custom_shape_bone_size`, `custom_shape_wire_width` (4.2+), `ik_stretch`, `lock_ik_x/y/z`, `use_ik_limit_x/y/z`, `ik_min_x/y/z`, `ik_max_x/y/z`, `ik_stiffness_x/y/z`, `pose_color`, `constraints`; the stored basis `location`, `rotation_quaternion` (w, x, y, z), `rotation_euler`, `rotation_axis_angle` (angle, x, y, z), `scale` | | armature node `extras.blend` | `bone_collections`: `{ name, visible, parent? }` (parent by name; files before 4.0 get Blender 4.0's conversion: a `Layer N` collection per used layer, then one hidden collection per bone group) | | any object node `extras.blend` | `constraints` (object constraints), `hide_viewport`, `hide_render` (when set) | -| `scene.meta.blend` | `widgets`: every custom shape object `{ name, type, node?, mesh? }` (objects outside the scene's collections get a mesh without a node; edge-only meshes as `"lines"` primitives); `bone_color_sets`: the default theme's `THEME01` .. `THEME20` | +| `scene.meta.blend` | `widgets`: every custom shape object `{ name, type, node?, mesh? }` (objects outside the scene's collections get a mesh without a node; edge-only meshes as `"lines"` primitives); `bone_color_sets`: the default theme's `THEME01` .. `THEME20`; `actions`: every action in the file (below) | A colour is `{ palette, normal, select, active }`: `palette` is `"THEME01"` .. `"THEME20"` or `"CUSTOM"` (nil: the default colour), the three colours are 0..1 sRGB (the custom colours, or the theme set's). Before 4.0 the bone group @@ -1005,17 +1005,37 @@ Type fields: | `IK` | `pole_target`, `pole_subtarget`, `pole_angle`, `chain_count`, `iterations`, `use_tail`, `use_stretch`, `use_location`, `use_rotation`, `weight`, `orient_weight`, `lock_location_x/y/z`, `lock_rotation_x/y/z`, `ik_type`, `distance` | | `COPY_ROTATION` | `use_x/y/z`, `invert_x/y/z`, `euler_order`, `mix_mode` | | `COPY_LOCATION` | `use_x/y/z`, `invert_x/y/z`, `use_offset` | -| `COPY_SCALE` | `use_x/y/z`, `use_offset`, `power` | +| `COPY_SCALE` | `use_x/y/z`, `use_offset`, `use_add`, `use_make_uniform`, `power` | | `COPY_TRANSFORMS` | `mix_mode`, `remove_target_shear` | | `DAMPED_TRACK` | `track_axis` | | `LIMIT_ROTATION` | `use_limit_x/y/z`, `min_x/y/z`, `max_x/y/z`, `euler_order`, `use_transform_limit` | | `LIMIT_LOCATION`, `LIMIT_SCALE` | `use_min_x/y/z`, `use_max_x/y/z`, `min_x/y/z`, `max_x/y/z`, `use_transform_limit` | | `CHILD_OF` | `use_location_x/y/z`, `use_rotation_x/y/z`, `use_scale_x/y/z`, `set_inverse_pending`, `inverse_matrix` (column-major) | +| `ACTION` | `action` (name, see `meta.blend.actions`), `transform_channel` (`"LOCATION_X"` .. `"SCALE_Z"`), `frame_start`, `frame_end`, `min`, `max`, `mix_mode` (`"BEFORE_FULL"`, `"BEFORE"`, `"BEFORE_SPLIT"`, `"AFTER_FULL"`, `"AFTER"`, `"AFTER_SPLIT"`), `use_bone_object_action`, `use_eval_time`, `eval_time` | +| `TRANSFORM` | `map_from`, `map_to` (`"LOCATION"`, `"ROTATION"`, `"SCALE"`), `map_to_x_from` / `_y_` / `_z_` (`"X"`, `"Y"`, `"Z"`), `from_min_x` .. `to_max_z` with `_rot` and `_scale` variants (`from_max_x_rot`, `to_min_y_scale`, ...), `mix_mode`, `mix_mode_rot`, `mix_mode_scale`, `use_motion_extrapolate`, `from_rotation_mode` (`"AUTO"`, euler orders, `"QUATERNION"`, `"SWING_TWIST_X/Y/Z"`), `to_euler_order` | +| `STRETCH_TO` | `rest_length`, `bulge`, `volume` (`"VOLUME_XZX"`, `"VOLUME_X"`, `"VOLUME_Z"`, `"NO_VOLUME"`), `keep_axis` (`"PLANE_X"`, `"PLANE_Z"`, `"SWING_Y"`), `use_bulge_min`, `use_bulge_max`, `bulge_min`, `bulge_max`, `bulge_smooth` | +| `ARMATURE` | `targets`, `use_deform_preserve_volume`, `use_bone_envelopes`, `use_current_location` | +| `FLOOR` | `floor_location`, `offset`, `use_rotation` | +| `LIMIT_DISTANCE` | `distance`, `limit_mode` | +| `TRACK_TO` | `track_axis`, `up_axis`, `use_target_z` | +| `LOCKED_TRACK` | `track_axis`, `lock_axis` | Shape keys: `mesh.extras.blend.shape_keys` lists every key in file order (the basis too) as `{ name, value, slider_min, slider_max, mute, relative_key, vertex_group? }`, and `reference_key` names the basis. Actions on shape key values become `weights` channels (clamped to the slider range). +Joint nodes model the plain parent chain: Blender's inheritance settings (`use_inherit_rotation`, `inherit_scale`, +`use_local_location`) and b-bone deformation are data for an evaluator, not applied to the joints or skins. + +Actions: `scene.meta.blend.actions[name] = { frame_range = { start, end }, curves }` holds every action in the file +(`rawActions = false` skips them), assigned or not, so action constraints can evaluate them at any frame; the +sampled `scene.animations` are unchanged. A curve is `{ data_path, bone?, path, array_index, extrapolation, keys }` +(`bone` and `path` split `pose.bones["name"].location`; other paths keep `path = data_path`; `extrapolation` is +`"CONSTANT"` or `"LINEAR"`), a key `{ co = { frame, value }, interpolation, easing, handle_left, handle_right, +handle_left_type, handle_right_type, back, amplitude, period }` with Blender's interpolation and easing names. Layered +actions (4.4+) give the first layer's first strip's first channel bag; files before 2.5 have IPOs instead (their +object and shape key IPOs are still sampled into `scene.animations`). + ```luau local rig = assert(F.model.load(riggedBlendBytes)) local joint = {} @@ -1037,6 +1057,10 @@ assert(widget.name == "WGT_ring" and widget.node == nil) assert(rig.meshes[widget.mesh].primitives[1].mode == "lines") local tube = rig.meshes[1] assert(tube.extras.targetNames[1] == "Bulge" and tube.extras.blend.shape_keys[2].slider_max == 2) +for name, action in rig.meta.blend.actions do + local curve = action.curves[1] + print(name, action.frame_range[1], action.frame_range[2], curve.bone, curve.path, curve.keys[1].interpolation) +end ``` Anything else in the file is reachable through the container: `F.format("blend").open` parses the blocks and the diff --git a/src/Rosetta/model/blend/Anim.luau b/src/Rosetta/model/blend/Anim.luau index 7d1eebf..2c018a2 100644 --- a/src/Rosetta/model/blend/Anim.luau +++ b/src/Rosetta/model/blend/Anim.luau @@ -61,6 +61,54 @@ local function curve(f: Blend.File, fc: Blend.View): Curve? return { path = path, index = fc:num("array_index") or 0, keys = keys, extend = fc:num("extend") or 0, modifiers = #mods } end +-- an action's f-curves: the legacy list, or (4.4+ layered actions) the channel bags of the strips of every layer whose +-- slot handle matches (handle nil: the first layer's first strip's first channel bag) +local function fcurves(f: Blend.File, act: Blend.View, handle: number?): { Blend.View } + local list: { Blend.View } = act:list("curves", "FCurve") + if #list > 0 or not act:has("layer_array") then + return list + end + local datas = act:pointers("strip_keyframe_data_array", act:num("strip_keyframe_data_array_num")) + for _, la in act:pointers("layer_array", act:num("layer_array_num")) do + local lblk = la and Blend.resolve(f, la, act.block) + local layer = lblk and Blend.struct(f, lblk, 0, "ActionLayer") + if layer then + for _, sa in layer:pointers("strip_array", layer:num("strip_array_num")) do + local sblk = sa and Blend.resolve(f, sa, act.block) + local strip = sblk and Blend.struct(f, sblk, 0, "ActionStrip") + local di = strip and strip:num("data_index") + local dblk = di and datas[di + 1] and Blend.resolve(f, datas[di + 1], act.block) + local kd = dblk and Blend.struct(f, dblk, 0, "ActionStripKeyframeData") + if kd then + for _, ba in kd:pointers("channelbag_array", kd:num("channelbag_array_num")) do + local bblk = ba and Blend.resolve(f, ba, act.block) + local bag = bblk and (Blend.struct(f, bblk, 0, "ActionChannelBag") or Blend.struct(f, bblk, 0, "ActionChannelbag")) + if bag and (handle == nil or (bag:num("slot_handle") or 0) == handle) then + for _, ca in bag:pointers("fcurve_array", bag:num("fcurve_array_num")) do + local cblk = ca and Blend.resolve(f, ca, act.block) + local fc = cblk and Blend.struct(f, cblk, 0, "FCurve") + if fc then + table.insert(list, fc) + end + end + if handle == nil then + return list + end + end + end + end + if handle == nil then + return list + end + end + end + if handle == nil then + return list + end + end + return list +end + function Anim.curves(f: Blend.File, adt: Blend.View?): ({ Curve }?, string?) if not adt then return nil, nil @@ -69,41 +117,8 @@ function Anim.curves(f: Blend.File, adt: Blend.View?): ({ Curve }?, string?) if not act then return nil, nil end - local list: { Blend.View } = act:list("curves", "FCurve") - if #list == 0 and act:has("layer_array") then - local handle = adt:num("slot_handle") or 0 - local datas = act:pointers("strip_keyframe_data_array", act:num("strip_keyframe_data_array_num")) - for _, la in act:pointers("layer_array", act:num("layer_array_num")) do - local lblk = la and Blend.resolve(f, la, act.block) - local layer = lblk and Blend.struct(f, lblk, 0, "ActionLayer") - if layer then - for _, sa in layer:pointers("strip_array", layer:num("strip_array_num")) do - local sblk = sa and Blend.resolve(f, sa, act.block) - local strip = sblk and Blend.struct(f, sblk, 0, "ActionStrip") - local di = strip and strip:num("data_index") - local dblk = di and datas[di + 1] and Blend.resolve(f, datas[di + 1], act.block) - local kd = dblk and Blend.struct(f, dblk, 0, "ActionStripKeyframeData") - if kd then - for _, ba in kd:pointers("channelbag_array", kd:num("channelbag_array_num")) do - local bblk = ba and Blend.resolve(f, ba, act.block) - local bag = bblk and (Blend.struct(f, bblk, 0, "ActionChannelBag") or Blend.struct(f, bblk, 0, "ActionChannelbag")) - if bag and (bag:num("slot_handle") or 0) == handle then - for _, ca in bag:pointers("fcurve_array", bag:num("fcurve_array_num")) do - local cblk = ca and Blend.resolve(f, ca, act.block) - local fc = cblk and Blend.struct(f, cblk, 0, "FCurve") - if fc then - table.insert(list, fc) - end - end - end - end - end - end - end - end - end local out: { Curve } = {} - for _, fc in list do + for _, fc in fcurves(f, act, adt:num("slot_handle") or 0) do local c = curve(f, fc) if c then table.insert(out, c) @@ -112,6 +127,67 @@ function Anim.curves(f: Blend.File, adt: Blend.View?): ({ Curve }?, string?) return out, act:idName() end +-- ------------------------------------------------------------------------------------------------ raw actions +local INTERPOLATION: { [number]: string } = { + [0] = "CONSTANT", [1] = "LINEAR", [2] = "BEZIER", [3] = "BACK", [4] = "BOUNCE", [5] = "CIRC", [6] = "CUBIC", + [7] = "ELASTIC", [8] = "EXPO", [9] = "QUAD", [10] = "QUART", [11] = "QUINT", [12] = "SINE", +} +local EASING: { [number]: string } = { [0] = "AUTO", [1] = "EASE_IN", [2] = "EASE_OUT", [3] = "EASE_IN_OUT" } +local HANDLE: { [number]: string } = { [0] = "FREE", [1] = "AUTO", [2] = "VECTOR", [3] = "ALIGNED", [4] = "AUTO_CLAMPED" } +local ACT_FRAME_RANGE = 0x1000 + +-- an action as Blender's API shows it: frame_range (the manual range, else the keys' span, at least one frame) and +-- every f-curve with its keyframe points +function Anim.raw(f: Blend.File, act: Blend.View): { [string]: any } + local curves: { { [string]: any } } = {} + local lo: number, hi: number = math.huge, -math.huge + for _, fc in fcurves(f, act, nil) do + local path = fc:cstring("rna_path") or "" + local kind, who, rest = Anim.split(path) + local keys: { { [string]: any } } = {} + for _, b in fc:array("bezt", "BezTriple") do + local v = b:vec("vec") + if v and #v >= 9 then + local x: number = v[4] + local k: { [string]: any } = { co = { x, v[5] }, handle_left = { v[1], v[2] }, handle_right = { v[7], v[8] } } + k.interpolation = INTERPOLATION[b:num("ipo") or 2] or "BEZIER" + k.easing = EASING[b:num("easing") or 0] or "AUTO" + k.handle_left_type, k.handle_right_type = HANDLE[b:num("h1") or 0], HANDLE[b:num("h2") or 0] + k.back, k.amplitude, k.period = b:num("back") or 1.70158, b:num("amplitude") or 0.8, b:num("period") or 4.1 + table.insert(keys, k) + lo, hi = math.min(lo, x), math.max(hi, x) + end + end + if #keys == 0 then + for _, p in fc:array("fpt", "FPoint") do + local v = p:vec("vec") + if v and #v >= 2 then + local x: number = v[1] + local k: { [string]: any } = { co = { x, v[2] } } + k.interpolation = "LINEAR" + table.insert(keys, k) + lo, hi = math.min(lo, x), math.max(hi, x) + end + end + end + local entry: { [string]: any } = { data_path = path, path = if kind == "pose.bones" then rest else path, keys = keys } + entry.bone = if kind == "pose.bones" then who else nil + entry.array_index = fc:num("array_index") or 0 + entry.extrapolation = if (fc:num("extend") or 0) == 1 then "LINEAR" else "CONSTANT" + table.insert(curves, entry) + end + if bit32.band(act:num("flag") or 0, ACT_FRAME_RANGE) ~= 0 and act:has("frame_start") then + lo = act:num("frame_start") or 0 + hi = act:num("frame_end") or 0 + elseif lo > hi then + lo, hi = 0, 0 + end + if hi <= lo then + hi = lo + 1 + end + return { frame_range = { lo, hi }, curves = curves } +end + -- pre-2.5 IPO curves (Object.ipo / Key.ipo): the curve's adrcode picks the channel; object rotations are in units of -- 10 degrees; the interpolation and extrapolation (0 constant, 1 linear; cyclic ones as constant) are per curve local OB_ADR: { [number]: { any } } = { diff --git a/src/Rosetta/model/blend/Armature.luau b/src/Rosetta/model/blend/Armature.luau index bc4b32e..d302d24 100644 --- a/src/Rosetta/model/blend/Armature.luau +++ b/src/Rosetta/model/blend/Armature.luau @@ -3,8 +3,10 @@ -- armature space, deform, connect, wire), bone collections (4.x BoneCollection arrays and lists; before 4.0 the layers -- and bone groups converted as Blender 4.0's versioning does), bone colours (BoneColor; bone group colours before 4.0), -- pose bones (custom shapes, locks, rotation mode, IK settings) and constraint stacks (bConstraint and the data structs --- of IK, copy rotation / location / scale / transforms, damped track, limit rotation / location / scale, child of; the --- common fields for the rest). Flags from DNA_armature_types.h, DNA_action_types.h, DNA_constraint_types.h. +-- of IK, copy rotation / location / scale / transforms, damped track, limit rotation / location / scale, child of, +-- action, transform, stretch to, armature, floor, limit distance, track to, locked track; the common fields for the +-- rest), bone inheritance and b-bone settings, the stored pose basis. Flags from DNA_armature_types.h, +-- DNA_action_types.h, DNA_constraint_types.h. local Blend = require("@rosetta/containers/Blend") local Armature = {} @@ -62,6 +64,33 @@ local PCHAN_DRAW_NO_CUSTOM_BONE_SIZE = 1 local LOCK_LOC, LOCK_ROT, LOCK_SCALE, LOCK_ROTW, LOCK_ROT4D = { 1, 2, 4 }, { 8, 16, 32 }, { 64, 128, 256 }, 512, 1024 local IK_NO_DOF, IK_LIMIT = { 1, 2, 4 }, { 8, 16, 32 } local AXES = { "x", "y", "z" } +local XYZ: { [number]: string } = { [0] = "X", [1] = "Y", [2] = "Z" } +-- bActionConstraint.type, .mix_mode +local ACTION_CHANNEL: { [number]: string } = { + [0] = "ROTATION_X", [1] = "ROTATION_Y", [2] = "ROTATION_Z", [10] = "SCALE_X", [11] = "SCALE_Y", [12] = "SCALE_Z", + [20] = "LOCATION_X", [21] = "LOCATION_Y", [22] = "LOCATION_Z", +} +local ACTION_MIX: { [number]: string } = { [0] = "AFTER_FULL", [1] = "AFTER", [2] = "BEFORE", [3] = "BEFORE_FULL", [4] = "BEFORE_SPLIT", [5] = "AFTER_SPLIT" } +local MAP: { [number]: string } = { [0] = "LOCATION", [1] = "ROTATION", [2] = "SCALE" } +-- the driver target rotation modes (DTAR_ROTMODE_*) +local FROM_ROT: { [number]: string } = { + [0] = "AUTO", [1] = "XYZ", [2] = "XZY", [3] = "YXZ", [4] = "YZX", [5] = "ZXY", [6] = "ZYX", [7] = "QUATERNION", + [8] = "SWING_TWIST_X", [9] = "SWING_TWIST_Y", [10] = "SWING_TWIST_Z", +} +local MIX_LOC: { [number]: string } = { [0] = "ADD", [1] = "REPLACE" } +local MIX_ROT: { [number]: string } = { [0] = "ADD", [1] = "REPLACE", [2] = "BEFORE", [3] = "AFTER" } +local MIX_SCALE: { [number]: string } = { [0] = "REPLACE", [1] = "MULTIPLY" } +local VOLUME: { [number]: string } = { [0] = "VOLUME_XZX", [1] = "VOLUME_X", [2] = "VOLUME_Z", [3] = "NO_VOLUME" } +local KEEP_AXIS: { [number]: string } = { [0] = "PLANE_X", [1] = "SWING_Y", [2] = "PLANE_Z" } +local FLOOR: { [number]: string } = { [0] = "FLOOR_X", [1] = "FLOOR_Y", [2] = "FLOOR_Z", [3] = "FLOOR_NEGATIVE_X", [4] = "FLOOR_NEGATIVE_Y", [5] = "FLOOR_NEGATIVE_Z" } +local DIST_MODE: { [number]: string } = { [0] = "LIMITDIST_INSIDE", [1] = "LIMITDIST_OUTSIDE", [2] = "LIMITDIST_ONSURFACE" } +local UP: { [number]: string } = { [0] = "UP_X", [1] = "UP_Y", [2] = "UP_Z" } +local LOCK: { [number]: string } = { [0] = "LOCK_X", [1] = "LOCK_Y", [2] = "LOCK_Z" } +-- Bone.inherit_scale_mode, bbone_prev_type / bbone_next_type, bbone_mapping_mode +local INHERIT_SCALE: { [number]: string } = { [0] = "FULL", [1] = "FIX_SHEAR", [2] = "AVERAGE", [3] = "NONE", [4] = "NONE_LEGACY", [5] = "ALIGNED" } +local HANDLE_TYPE: { [number]: string } = { [0] = "AUTO", [1] = "ABSOLUTE", [2] = "RELATIVE", [3] = "TANGENT" } +local MAPPING: { [number]: string } = { [0] = "STRAIGHT", [1] = "CURVED" } +local BONE_HINGE, BONE_NO_SCALE, BONE_NO_LOCAL_LOCATION, BONE_RELATIVE_PARENTING, BONE_ADD_PARENT_END_ROLL = 0x200, 0x8000, 0x400000, 0x800000, 0x1000000 local function bit(v: number?, mask: number): boolean return bit32.band(v or 0, mask) ~= 0 @@ -236,7 +265,35 @@ function Armature.bone(bone: Blend.View, pc: Blend.View?, pose: Blend.View?): { head_local = vec3(bone, "arm_head"), tail_local = vec3(bone, "arm_tail"), roll = bone:num("arm_roll"), + use_inherit_rotation = not bit(flag, BONE_HINGE), + use_local_location = not bit(flag, BONE_NO_LOCAL_LOCATION), + use_relative_parent = bit(flag, BONE_RELATIVE_PARENTING), } + local ism = bone:num("inherit_scale_mode") + e.inherit_scale = if ism then INHERIT_SCALE[ism] else (if bit(flag, BONE_NO_SCALE) then "NONE_LEGACY" else "FULL") -- BONE_NO_SCALE before 2.81 + e.bbone_segments = bone:num("segments") or 1 + e.bbone_x, e.bbone_z = bone:num("xwidth"), bone:num("zwidth") + e.bbone_easein, e.bbone_easeout = bone:num("ease1") or 1, bone:num("ease2") or 1 + e.bbone_rollin, e.bbone_rollout = bone:num("roll1") or 0, bone:num("roll2") or 0 + e.bbone_curveinx, e.bbone_curveinz = bone:num("curveInX") or 0, bone:num("curveInY") or 0 -- curveInY is the API's z + e.bbone_curveoutx, e.bbone_curveoutz = bone:num("curveOutX") or 0, bone:num("curveOutY") or 0 + for _, side in { "in", "out" } do + local cap = if side == "in" then "In" else "Out" + local v = vec3(bone, "scale_" .. side) + if not v then + -- before 3.0: scaleIn (x) and scale_in_y (z); before 2.8 one value for both + local x = bone:num("scale" .. cap) or 1 + v = { x, 1, bone:num("scale_" .. side .. "_y") or x } + end + e["bbone_scale" .. side] = v + end + e.bbone_handle_type_start = HANDLE_TYPE[bone:num("bbone_prev_type") or 0] + e.bbone_handle_type_end = HANDLE_TYPE[bone:num("bbone_next_type") or 0] + local prev, nxt = bone:deref("bbone_prev", 0, "Bone"), bone:deref("bbone_next", 0, "Bone") + e.bbone_custom_handle_start = if prev then prev:str("name") else nil + e.bbone_custom_handle_end = if nxt then nxt:str("name") else nil + e.use_endroll_as_inroll = if bone:has("bbone_flag") then bit(bone:num("bbone_flag"), 1) else bit(flag, BONE_ADD_PARENT_END_ROLL) + e.bbone_mapping_mode = MAPPING[bone:num("bbone_mapping_mode") or 0] if bone:has("color") then e.color = boneColor(bone) elseif pc and pose then @@ -283,10 +340,72 @@ local function constraintData(e: { [string]: any }, kind: string, d: Blend.View, e.invert_x, e.invert_y, e.invert_z = bit(flag, 16), bit(flag, 32), bit(flag, 64) e.use_offset = bit(flag, 128) elseif kind == "COPY_SCALE" then - -- SIZELIKE_X 1, Y 2, Z 4, OFFSET 8 + -- SIZELIKE_X 1, Y 2, Z 4, OFFSET 8, MULTIPLY 16 (use_add is its inverse), UNIFORM 32 e.use_x, e.use_y, e.use_z = bit(flag, 1), bit(flag, 2), bit(flag, 4) e.use_offset = bit(flag, 8) + e.use_add = not bit(flag, 16) + e.use_make_uniform = bit(flag, 32) e.power = d:num("power") or 1 + elseif kind == "ACTION" then + -- flag: ACTCON_BONE_USE_OBJECT_ACTION 1, ACTCON_USE_EVAL_TIME 2 + local act = d:deref("act", 0, "bAction") + e.action = if act then act:idName() else nil + e.transform_channel = ACTION_CHANNEL[d:num("type") or 20] + e.frame_start, e.frame_end = d:num("start") or 1, d:num("end") or 1 + e.min, e.max = d:num("min") or 0, d:num("max") or 0 + e.mix_mode = ACTION_MIX[d:num("mix_mode") or 0] + e.use_bone_object_action = bit(flag, 1) + e.use_eval_time = bit(flag, 2) + e.eval_time = d:num("eval_time") or 0 + elseif kind == "TRANSFORM" then + e.map_from, e.map_to = MAP[d:num("from") or 0], MAP[d:num("to") or 0] + local map = d.struct.byName.map + for i, a in AXES do + local o = map and d.offset + map.offset + i - 1 + e["map_to_" .. a .. "_from"] = XYZ[if o and o < buffer.len(d.file.buf) then buffer.readu8(d.file.buf, o) else i - 1] + end + e.use_motion_extrapolate = (d:num("expo") or 0) ~= 0 + e.from_rotation_mode = FROM_ROT[d:num("from_rotation_mode") or 0] + e.to_euler_order = EULER_ORDER[d:num("to_euler_order") or 0] + e.mix_mode = MIX_LOC[d:num("mix_mode_loc") or 0] + e.mix_mode_rot = MIX_ROT[d:num("mix_mode_rot") or 0] + e.mix_mode_scale = MIX_SCALE[d:num("mix_mode_scale") or 0] + for _, side in { "from", "to" } do + for _, suffix in { "", "_rot", "_scale" } do + local lo, hi = d:vec(side .. "_min" .. suffix), d:vec(side .. "_max" .. suffix) + for i, a in AXES do + e[side .. "_min_" .. a .. suffix] = lo and lo[i] or 0 + e[side .. "_max_" .. a .. suffix] = hi and hi[i] or 0 + end + end + end + elseif kind == "STRETCH_TO" then + -- STRETCHTOCON_USE_BULGE_MIN 1, MAX 2 + e.rest_length = d:num("orglength") + e.bulge = d:num("bulge") + e.volume = VOLUME[d:num("volmode") or 0] + e.keep_axis = KEEP_AXIS[d:num("plane") or 0] + e.use_bulge_min, e.use_bulge_max = bit(flag, 1), bit(flag, 2) + e.bulge_min, e.bulge_max, e.bulge_smooth = d:num("bulge_min"), d:num("bulge_max"), d:num("bulge_smooth") + elseif kind == "ARMATURE" then + -- CONSTRAINT_ARMATURE_QUATERNION 1, ENVELOPE 2, CUR_LOCATION 4 + e.use_deform_preserve_volume, e.use_bone_envelopes, e.use_current_location = bit(flag, 1), bit(flag, 2), bit(flag, 4) + elseif kind == "FLOOR" then + -- flag: MINMAX_USEROT 4 + e.floor_location = FLOOR[d:num("minmaxflag") or 2] + e.offset = d:num("offset") or 0 + e.use_rotation = bit(flag, 4) + elseif kind == "LIMIT_DISTANCE" then + e.distance = d:num("dist") + e.limit_mode = DIST_MODE[d:num("mode") or 0] + elseif kind == "TRACK_TO" then + -- reserved1 the track axis, reserved2 the up axis; flags TARGET_Z_UP 1 + e.track_axis = TRACK[d:num("reserved1") or 1] + e.up_axis = UP[d:num("reserved2") or 2] + e.use_target_z = bit(d:num("flags"), 1) + elseif kind == "LOCKED_TRACK" then + e.track_axis = TRACK[d:num("trackflag") or 1] + e.lock_axis = LOCK[d:num("lockflag") or 2] elseif kind == "COPY_TRANSFORMS" then e.mix_mode = TRANS_MIX[d:num("mix_mode") or 0] e.remove_target_shear = bit(flag, 1) @@ -399,6 +518,14 @@ function Armature.pose(e: { [string]: any }, pc: Blend.View, resolve: Resolve, s e["ik_stiffness_" .. a] = stiff and stiff[i] or 0 end e.pose_color = if pc:has("color") then boneColor(pc) else nil + -- the stored basis (rotation_quaternion w, x, y, z; rotation_axis_angle angle, x, y, z) + e.location = vec3(pc, "loc", { 0, 0, 0 }) + local q = pc:vec("quat") + e.rotation_quaternion = if q and #q >= 4 then { q[1], q[2], q[3], q[4] } else { 1, 0, 0, 0 } + e.rotation_euler = vec3(pc, "eul", { 0, 0, 0 }) + local axis = vec3(pc, "rotAxis", { 0, 1, 0 }) :: { number } + e.rotation_axis_angle = { pc:num("rotAngle") or 0, axis[1], axis[2], axis[3] } + e.scale = vec3(pc, "size", nil) or vec3(pc, "scale", { 1, 1, 1 }) e.constraints = Armature.constraints(pc, resolve) end diff --git a/src/Rosetta/model/blend/Read.luau b/src/Rosetta/model/blend/Read.luau index e6fb1e0..acc4505 100644 --- a/src/Rosetta/model/blend/Read.luau +++ b/src/Rosetta/model/blend/Read.luau @@ -28,6 +28,7 @@ export type Options = { scene: string?, -- the scene to read (default: the file's current scene) sampleStep: number?, -- frames between animation samples (default 1) animations: boolean?, -- default true + rawActions: boolean?, -- every action's f-curves in meta.blend.actions (default true) resolve: ((uri: string) -> any)?, files: { [string]: any }?, maxVertices: number?, @@ -1013,8 +1014,27 @@ function Read.scene(f: Blend.File, opts: Options?): (Types.Scene?, string?) end end skins(ctx) + local mb: { [string]: any } = {} if next(ctx.armatures) ~= nil then - scene.meta.blend = { widgets = widgetList(ctx), bone_color_sets = Armature.colorSets() } + mb.widgets = widgetList(ctx) + mb.bone_color_sets = Armature.colorSets() + end + -- every action in the file by name (assigned or not: action constraints and the NLA refer to them) + if o.rawActions ~= false then + local acts: { [string]: any } = {} + for _, b in Blend.blocks(f, "AC") do + local act = Blend.struct(f, b, 0, "bAction") + local name = act and act:idName() + if act and name and not acts[name] then + acts[name] = Anim.raw(f, act) + end + end + if next(acts) ~= nil then + mb.actions = acts + end + end + if next(mb) ~= nil then + scene.meta.blend = mb end if o.animations ~= false then animations(ctx) diff --git a/src/Rosetta/model/blend/init.luau b/src/Rosetta/model/blend/init.luau index e62f158..0858d93 100644 --- a/src/Rosetta/model/blend/init.luau +++ b/src/Rosetta/model/blend/init.luau @@ -5,7 +5,8 @@ -- meshes of every storage generation (MFace, MPoly / MLoop, attribute layers, AttributeStorage) with UV maps, colour -- attributes, custom normals, material slots; Principled BSDF materials; packed and external images; cameras; lights; -- armatures, skins (vertex groups, top 4 weights), shape keys (relative keys, vertex groups); actions sampled into --- channels; rig data (bone collections / layers, colours, custom shapes, pose settings, constraint stacks) as extras. +-- channels, and every action's raw f-curves in meta.blend.actions; rig data (bone collections / layers, colours, +-- custom shapes, pose settings, constraint stacks) as extras. -- Not supported: modifiers (listed in meta.source.modifiers), curves / text / metaballs / grease pencil / volumes, -- NLA strips, drivers, constraint evaluation, f-curve modifiers, linked libraries, collection instances. @@ -38,6 +39,7 @@ export type DecodeOptions = { scene: string?, -- a scene by name (default: the file's current scene) sampleStep: number?, -- frames between animation samples (default 1) animations: boolean?, -- default true + rawActions: boolean?, -- every action's f-curves and keys in meta.blend.actions (default true) resolve: ((uri: string) -> any)?, -- external images files: { [string]: any }?, maxBytes: number?, -- decompressed size limit (default 2^31) diff --git a/tests/model/blend.luau b/tests/model/blend.luau index 05b73d4..5fabdd2 100644 --- a/tests/model/blend.luau +++ b/tests/model/blend.luau @@ -178,16 +178,30 @@ local REQUIRED: { [string]: { string } } = { IK = { "chain_count", "pole_target", "pole_subtarget", "pole_angle", "use_tail", "use_stretch", "iterations", "weight" }, COPY_ROTATION = { "use_x", "use_y", "use_z", "invert_x", "invert_y", "invert_z", "mix_mode", "euler_order" }, COPY_LOCATION = { "use_x", "use_y", "use_z", "invert_x", "invert_y", "invert_z", "use_offset", "head_tail" }, - COPY_SCALE = { "use_x", "use_y", "use_z", "use_offset", "power" }, + COPY_SCALE = { "use_x", "use_y", "use_z", "use_offset", "power", "use_add", "use_make_uniform" }, COPY_TRANSFORMS = { "mix_mode", "head_tail" }, DAMPED_TRACK = { "track_axis", "head_tail" }, LIMIT_ROTATION = { "use_limit_x", "use_limit_y", "use_limit_z", "min_x", "max_x", "min_z", "max_z", "use_transform_limit" }, LIMIT_LOCATION = { "use_min_x", "use_max_x", "use_min_z", "use_max_z", "min_x", "max_x", "min_z", "max_z", "use_transform_limit" }, CHILD_OF = { "inverse_matrix", "use_location_x", "use_rotation_y", "use_scale_x", "use_scale_z", "set_inverse_pending" }, + ACTION = { "action", "transform_channel", "frame_start", "frame_end", "min", "max", "mix_mode", "use_bone_object_action", "use_eval_time", "eval_time" }, + TRANSFORM = { "map_from", "map_to", "map_to_x_from", "map_to_y_from", "map_to_z_from", "use_motion_extrapolate", "from_rotation_mode", + "to_euler_order", "mix_mode", "mix_mode_rot", "mix_mode_scale", "from_min_x", "from_max_z", "to_min_y", "to_max_x", + "from_min_y_rot", "from_max_x_rot", "to_min_z_rot", "to_max_y_rot", "from_min_x_scale", "from_max_y_scale", "to_min_x_scale", "to_max_y_scale" }, + STRETCH_TO = { "rest_length", "bulge", "volume", "keep_axis", "use_bulge_min", "use_bulge_max", "bulge_min", "bulge_max", "bulge_smooth" }, + ARMATURE = { "use_deform_preserve_volume", "use_bone_envelopes", "use_current_location", "targets" }, + FLOOR = { "floor_location", "offset", "use_rotation" }, + LIMIT_DISTANCE = { "distance", "limit_mode" }, + TRACK_TO = { "track_axis", "up_axis", "use_target_z" }, + LOCKED_TRACK = { "track_axis", "lock_axis" }, } +local BONE_KEYS = { "inherit_scale", "use_inherit_rotation", "use_local_location", "use_relative_parent", "bbone_segments", + "bbone_x", "bbone_z", "bbone_easein", "bbone_easeout", "bbone_rollin", "bbone_rollout", "bbone_curveinx", "bbone_curveinz", + "bbone_curveoutx", "bbone_curveoutz", "bbone_scalein", "bbone_scaleout", "bbone_handle_type_start", "bbone_handle_type_end", + "bbone_custom_handle_start", "bbone_custom_handle_end", "use_endroll_as_inroll", "bbone_mapping_mode" } local COMMON = { "type", "name", "influence", "mute", "target", "subtarget", "owner_space", "target_space" } -local checked = { rigs = 0, constraints = 0, worlds = 0, meshes = 0, normals = 0, weights = 0, shapes = 0, frames = 0, skinned = 0, curves = 0, materials = 0, cameras = 0, lights = 0 } +local checked = { actions = 0, rigs = 0, constraints = 0, worlds = 0, meshes = 0, normals = 0, weights = 0, shapes = 0, frames = 0, skinned = 0, curves = 0, materials = 0, cameras = 0, lights = 0 } local samples = {} t:check(#Sets.old >= 4, "the old demo files were fetched (" .. #Sets.old .. ")") @@ -544,13 +558,10 @@ for _, tag in { "old", "279", "293", "35", "41", "cur" } do for k, s in scene.skins do t:eq(#s.joints, #gl.skins[k].joints, label .. ": skin joints") end - -- bones at the saved frame (the rest pose here) - for armName, list in ref.armatures do - local aw = W[objects[armName]] - for _, b in list do - local j = bones[b.name] - t:check(j and nearList(W[j], Scene.mul(aw, b["local"]), 1e-4), label .. ": bone " .. b.name) - end + -- bones at the saved frame: the saved pose (constraints muted in the reference) + for key, want in ref.posedBones do + local j = bones[string.match(key, "/(.+)$")] + t:check(j and nearList(W[j], want, 1e-4), label .. ": bone " .. key) end -- rig data against bpy (Blender 5.x reads the old files through its versioning: layers and bone groups as -- collections, bone group colours as bone colours) @@ -567,6 +578,18 @@ for _, tag in { "old", "279", "293", "35", "41", "cur" } do local g = got[k] if k == "target" or k == "pole_target" or k == "custom_shape" then g = nameOf(g) + elseif k == "targets" and type(g) == "table" then + local named = {} + for i, x in g do + named[i] = { target = nameOf(x.target), subtarget = x.subtarget, weight = x.weight } + end + local ok = #named == #want[k] + for i, x in want[k] do + local y = named[i] or {} + ok = ok and y.target == x.target and (y.subtarget or "") == x.subtarget and near(y.weight or -1, x.weight, 1e-5) + end + t:check(ok, what .. " targets") + continue end t:check(same(g, want[k], 1e-5), what .. " " .. k .. ": got " .. tostring(g) .. ", want " .. tostring(want[k])) end @@ -582,7 +605,8 @@ for _, tag in { "old", "279", "293", "35", "41", "cur" } do end local POSE_KEYS = { "custom_shape", "custom_shape_transform", "custom_shape_translation", "custom_shape_rotation_euler", "custom_shape_scale_xyz", "use_custom_shape_bone_size", "lock_location", "lock_rotation", "lock_rotation_w", - "lock_rotations_4d", "lock_scale", "rotation_mode", "ik_stretch" } + "lock_rotations_4d", "lock_scale", "rotation_mode", "ik_stretch", "location", "rotation_quaternion", "rotation_euler", + "rotation_axis_angle", "scale" } for _, a in { "x", "y", "z" } do for _, k in { "lock_ik_", "use_ik_limit_", "ik_min_", "ik_max_", "ik_stiffness_" } do table.insert(POSE_KEYS, k .. a) @@ -605,6 +629,13 @@ for _, tag in { "old", "279", "293", "35", "41", "cur" } do compareColor(e.color, b.color, what) compareColor(e.pose_color, b.pose.color, what .. " pose") compareTable(e, b.pose, POSE_KEYS, what) + local bk = {} + for _, k in BONE_KEYS do + if b.bone[k] ~= nil then + table.insert(bk, k) + end + end + compareTable(e, b.bone, bk, what) t:eq(#e.constraints, #b.pose.constraints, what .. " constraints") for k, rc in b.pose.constraints do local c = e.constraints[k] or {} @@ -653,6 +684,29 @@ for _, tag in { "old", "279", "293", "35", "41", "cur" } do end t:check(next(shapes) == nil, label .. ": every custom shape is listed") end + -- every action, raw: frame range, f-curves, keyframe points (bpy's first layer / strip / channel bag) + for name, ra in if src.version >= 250 then ref.allActions or {} else {} do -- older files: IPOs Blender converts on load + local a = scene.meta.blend and scene.meta.blend.actions and scene.meta.blend.actions[name] + t:check(a and nearList(a.frame_range, ra.frame_range, 1e-5), label .. ": action " .. name .. " frame range") + if not a then + continue + end + t:eq(#a.curves, #ra.curves, label .. ": action " .. name .. " curves") + for k, rc in ra.curves do + local c = a.curves[k] or { keys = {} } + local what = label .. ": action " .. name .. " " .. rc.data_path .. "[" .. rc.array_index .. "]" + t:check(c.data_path == rc.data_path and c.array_index == rc.array_index and c.extrapolation == rc.extrapolation, what) + local bone, prop = string.match(rc.data_path, '^pose%.bones%["(.-)"%]%.([%w_]+)$') + t:check(c.bone == bone and c.path == (prop or rc.data_path), what .. " bone / path") + t:eq(#c.keys, #rc.keys, what .. " keys") + for q, rk in rc.keys do + local ck = c.keys[q] or {} + t:check(nearList(ck.co, rk.co, 1e-5) and nearList(ck.handle_left, rk.handle_left, 1e-4) and nearList(ck.handle_right, rk.handle_right, 1e-4) + and ck.interpolation == rk.interpolation and ck.easing == rk.easing, what .. " key " .. q) + end + checked.actions += 1 + end + end -- f-curves through the evaluator, at every half frame (bezier, linear, constant, extrapolation) local file = assert(Blend.open(buffer.fromstring(c.data))) for _, o in ref.objects do @@ -797,7 +851,7 @@ for _, tag in { "old", "279", "293", "35", "41", "cur" } do end end end -t:note("checked: %d rigs, %d constraints", checked.rigs, checked.constraints) +t:note("checked: %d rigs, %d constraints, %d raw action curves", checked.rigs, checked.constraints, checked.actions) t:note("checked: %d world matrices, %d meshes, %d corner normal sets, %d weight sets, %d shape key sets, %d f-curves, %d posed frames, %d skinned frames, %d materials, %d cameras, %d lights", checked.worlds, checked.meshes, checked.normals, checked.weights, checked.shapes, checked.curves, checked.frames, checked.skinned, checked.materials, checked.cameras, checked.lights) diff --git a/tools/fixtures/_blend_make.py b/tools/fixtures/_blend_make.py index 0de943d..c88fc2f 100644 --- a/tools/fixtures/_blend_make.py +++ b/tools/fixtures/_blend_make.py @@ -11,7 +11,9 @@ # collections and colours (4.x), custom shapes (a hidden widget in the scene, one outside it), # pose-bone constraints (IK, copy rotation / location / transforms, damped track, limit # rotation, child of, stretch to), lock and IK flags; shape keys with slider ranges, mute, -# relative keys, a vertex group, and a shape-key action +# relative keys, a vertex group, and a shape-key action; an unassigned action driven by an +# action constraint; transform / armature / floor / limit distance / track to / locked +# track constraints; bone inheritance and b-bone settings; a saved pose basis import bpy, sys, os, math out = sys.argv[sys.argv.index("--") + 1] @@ -461,6 +463,25 @@ def ctl_file(): b.parent = eb[parent] b.use_connect = connect b.use_deform = deform + up, lo = eb["hand_ik"], eb["lower"] # b-bone settings on a bone that deforms nothing (skinning stays linear) + setp(eb["upper"], "inherit_scale", "ALIGNED") + setp(eb["upper"], "use_inherit_scale", False) + setp(lo, "use_inherit_rotation", False) + setp(lo, "use_local_location", False) + setp(eb["limit"], "use_relative_parent", True) + up.bbone_segments = 4 + up.bbone_x, up.bbone_z = 0.05, 0.08 + setp(up, "bbone_easein", 0.5) + setp(up, "bbone_easeout", 1.5) + setp(up, "bbone_rollin", 0.2) + setp(up, "bbone_curveinx", 0.1) + setp(up, "bbone_curveinz", -0.1) + setp(up, "bbone_curveoutx", 0.3) + setp(up, "bbone_scalein", (1.0, 1.0, 1.2)) + setp(up, "bbone_handle_type_start", "ABSOLUTE") + setp(up, "bbone_custom_handle_start", eb["spine"]) + setp(up, "bbone_handle_type_end", "TANGENT") + setp(up, "bbone_custom_handle_end", eb["pole"]) bpy.ops.object.mode_set(mode="OBJECT") bones = arm_data.bones bones["root"].show_wire = True @@ -587,6 +608,92 @@ def ctl_file(): c = pose["limit"].constraints.new("STRETCH_TO") c.target = tgt c.influence = 0.5 + c.rest_length = 0.75 + c.bulge = 1.5 + c.volume = "VOLUME_X" + c.keep_axis = "PLANE_Z" + setp(c, "use_bulge_min", True) + setp(c, "bulge_min", 0.5) + setp(c, "use_bulge_max", True) + setp(c, "bulge_max", 2.0) + setp(c, "bulge_smooth", 0.3) + c = pose["limit"].constraints.new("TRANSFORM") + c.target = tgt + c.map_from, c.map_to = "ROTATION", "SCALE" + c.map_to_x_from, c.map_to_y_from, c.map_to_z_from = "Z", "X", "Y" + setp(c, "from_max_x_rot", 2.356194) + setp(c, "from_min_y_rot", -0.5) + setp(c, "to_max_y_scale", 0.65) + setp(c, "to_min_x_scale", 0.9) + setp(c, "mix_mode_scale", "MULTIPLY") + setp(c, "from_rotation_mode", "SWING_TWIST_Y") + setp(c, "to_euler_order", "ZXY") + c.use_motion_extrapolate = True + c = pose["limit"].constraints.new("FLOOR") + c.target = tgt + c.floor_location = "FLOOR_NEGATIVE_Y" + c.offset = 0.2 + c.use_rotation = True + c = pose["pole"].constraints.new("TRACK_TO") + c.target, c.subtarget = rig, "upper" + c.track_axis, c.up_axis = "TRACK_NEGATIVE_Y", "UP_X" + c.use_target_z = True + c = pose["root"].constraints.new("LOCKED_TRACK") + c.target = tgt + c.track_axis, c.lock_axis = "TRACK_X", "LOCK_Z" + c = pose["root"].constraints.new("LIMIT_DISTANCE") + c.target = tgt + c.distance = 2.5 + c.limit_mode = "LIMITDIST_OUTSIDE" + c = pose["upper"].constraints["Copy Scale"] + setp(c, "use_make_uniform", True) + setp(c, "use_add", True) + setp(c, "power", 0.5) + if V >= (2, 80): + c = pose["spine"].constraints.new("ARMATURE") + t = c.targets.new() + t.target, t.subtarget, t.weight = rig, "root", 0.75 + c.use_deform_preserve_volume = True + c.use_bone_envelopes = True + c.use_current_location = True + # an action only the action constraint uses: keys on hand_ik / limit, then unassigned + for f, loc, eul in ((1, (0, 0, 0), (0, 0, 0)), (10, (0.5, 0.1, 0), (0.3, 0, -0.2)), (25, (0, 0.4, 0.2), (-0.4, 0.2, 0))): + pose["hand_ik"].location = loc + pose["hand_ik"].keyframe_insert("location", frame=f) + pose["limit"].rotation_euler = eul + pose["limit"].keyframe_insert("rotation_euler", frame=f) + act = rig.animation_data.action + act.name = "CtlAct" + act.use_fake_user = True + curves = act.fcurves if hasattr(act, "fcurves") and V < (5, 0) else [c for l in act.layers for st in l.strips for b in st.channelbags for c in b.fcurves] + for fc in curves: + if fc.data_path.endswith("location"): + for kp in fc.keyframe_points: + kp.interpolation = "LINEAR" + elif fc.array_index == 1: + fc.keyframe_points[1].interpolation = "QUAD" + fc.keyframe_points[1].easing = "EASE_OUT" + fc.extrapolation = "LINEAR" + rig.animation_data.action = None + pose["hand_ik"].location = (0, 0, 0) + pose["limit"].rotation_euler = (0, 0, 0) + c = pose["hand_ik"].constraints.new("ACTION") + c.target, c.subtarget = rig, "pole" + c.action = act + c.transform_channel = "LOCATION_Y" + c.target_space = "LOCAL" + c.frame_start, c.frame_end = 0, 40 + c.min, c.max = -0.05, 0.05 + setp(c, "mix_mode", "AFTER") + setp(c, "use_eval_time", False) + setp(c, "eval_time", 0.25) + c.influence = 0.5 + # a saved pose basis + pose["spine"].location = (0.01, 0.02, 0.03) # no rotation above the hinge bone (not modelled by joint nodes) + pose["pole"].rotation_quaternion = (0.9, 0.1, 0.3, 0.2) + pose["lower"].rotation_euler = (0.1, -0.2, 0.3) + pose["hand_ik"].rotation_axis_angle = (0.4, 0, 0, 1) + pose["limit"].scale = (1, 1.25, 0.8) # shape keys on a mesh parented to the rig fv = [(x * 0.5, 0, z * 0.5) for z in range(3) for x in range(3)] ff = [(0, 1, 4, 3), (1, 2, 5, 4), (3, 4, 7, 6), (4, 5, 8, 7)] diff --git a/tools/fixtures/_blend_ref.py b/tools/fixtures/_blend_ref.py index f8b50be..8db92d4 100644 --- a/tools/fixtures/_blend_ref.py +++ b/tools/fixtures/_blend_ref.py @@ -131,7 +131,7 @@ def rna_value(v): return "" if isinstance(v, bpy.types.ID): return v.name - if isinstance(v, bpy.types.PoseBone): + if isinstance(v, (bpy.types.PoseBone, bpy.types.Bone)): return v.name if isinstance(v, bool): return v @@ -151,8 +151,36 @@ SKIP = {"rna_type", "show_expanded", "active", "is_valid", "is_override_data_edi "error_rotation", "targets", "space_object", "space_subtarget"} +BONE_KEYS = ("inherit_scale", "use_inherit_rotation", "use_local_location", "use_relative_parent", "bbone_segments", + "bbone_x", "bbone_z", "bbone_easein", "bbone_easeout", "bbone_rollin", "bbone_rollout", "bbone_curveinx", + "bbone_curveinz", "bbone_curveoutx", "bbone_curveoutz", "bbone_scalein", "bbone_scaleout", + "bbone_handle_type_start", "bbone_handle_type_end", "bbone_custom_handle_start", "bbone_custom_handle_end", + "use_endroll_as_inroll", "bbone_mapping_mode") + + +def action_fcurves(act): + if V >= (4, 4) and hasattr(act, "layers") and len(act.layers) > 0: + for strip in act.layers[0].strips: + for bag in strip.channelbags: + return list(bag.fcurves) + return [] + return list(act.fcurves) + + +def action_info(act): + curves = [] + for fc in action_fcurves(act): + keys = [{"co": [r6(k.co[0]), r6(k.co[1])], "interpolation": k.interpolation, "easing": k.easing, + "handle_left": [r6(k.handle_left[0]), r6(k.handle_left[1])], + "handle_right": [r6(k.handle_right[0]), r6(k.handle_right[1])]} for k in fc.keyframe_points] + curves.append({"data_path": fc.data_path, "array_index": fc.array_index, "extrapolation": fc.extrapolation, "keys": keys}) + return {"frame_range": [r6(act.frame_range[0]), r6(act.frame_range[1])], "curves": curves} + + def constraint_info(c): out = {} + if c.type == "ARMATURE": + out["targets"] = [{"target": t.target.name if t.target else "", "subtarget": t.subtarget, "weight": r6(t.weight)} for t in c.targets] for prop in c.bl_rna.properties: k = prop.identifier if k in SKIP or prop.type == "COLLECTION": @@ -193,7 +221,13 @@ def rig_info(ob): for a in "xyz": for k in ("lock_ik_", "use_ik_limit_", "ik_min_", "ik_max_", "ik_stiffness_"): pose[k + a] = rna_value(getattr(pb, k + a)) - bones.append({"name": b.name, "head_local": [r6(x) for x in b.head_local], "tail_local": [r6(x) for x in b.tail_local], + for k in ("location", "rotation_quaternion", "rotation_euler", "rotation_axis_angle", "scale"): + pose[k] = rna_value(getattr(pb, k)) + info = {} + for k in BONE_KEYS: + if hasattr(b, k): + info[k] = rna_value(getattr(b, k)) + bones.append({"name": b.name, "head_local": [r6(x) for x in b.head_local], "tail_local": [r6(x) for x in b.tail_local], "bone": info, "roll": r6(roll), "deform": b.use_deform, "use_connect": b.use_connect, "show_wire": b.show_wire, "collections": [c.name for c in b.collections], "color": color_info(b.color), "pose": pose}) cols = [{"name": c.name, "visible": c.is_visible, "parent": c.parent.name if c.parent else ""} for c in arm.collections_all] @@ -226,7 +260,8 @@ def dump(path): ref = {"version": list(bpy.data.version), "fps": sc.render.fps / sc.render.fps_base, "frameStart": sc.frame_start, "frameCurrent": sc.frame_current, "resolution": [sc.render.resolution_x, sc.render.resolution_y], "objects": [], "materials": [], "images": [], "cameras": {}, "lights": {}, "armatures": {}, "actions": {}, - "rigs": {}, "themeBoneColors": theme_colors()} + "rigs": {}, "themeBoneColors": theme_colors(), + "allActions": {a.name: action_info(a) for a in bpy.data.actions}} for ob in obs: o = {"name": ob.name, "type": ob.type, "parent": ob.parent.name if ob.parent else "", "parent_type": ob.parent_type, "parent_bone": ob.parent_bone, "world": [r6(x) for x in mat(ob.matrix_world)], @@ -272,6 +307,9 @@ def dump(path): for pb in ob.pose.bones: for c in pb.constraints: c.mute = True + sc.frame_set(sc.frame_current) + ref["posedBones"] = {ob.name + "/" + pb.name: [r6(x) for x in mat(ob.matrix_world @ pb.matrix)] + for ob in obs if ob.type == "ARMATURE" for pb in ob.pose.bones} poses = [] if ref["actions"]: for f in FRAMES: