From bedef1c7f72147fc23b7a8f7dddac587c82a62d4 Mon Sep 17 00:00:00 2001 From: FatalErr42O <58855799+FatalError42O@users.noreply.github.com> Date: Wed, 30 Aug 2023 15:24:42 -0700 Subject: [PATCH] moved modlib and it's properties into a seperate file for licensing reasons --- init.lua | 9 ++-- License.txt => modlib/License.txt | 0 read_b3d.lua => modlib/read_b3d.lua | 0 to_gltf.lua => modlib/to_gltf.lua | 0 write_b3d.lua => modlib/write_b3d.lua | 0 read_b3d_bone.lua | 62 ++------------------------- 6 files changed, 9 insertions(+), 62 deletions(-) rename License.txt => modlib/License.txt (100%) rename read_b3d.lua => modlib/read_b3d.lua (100%) rename to_gltf.lua => modlib/to_gltf.lua (100%) rename write_b3d.lua => modlib/write_b3d.lua (100%) diff --git a/init.lua b/init.lua index 2bb9f8d..c9c2897 100644 --- a/init.lua +++ b/init.lua @@ -2,8 +2,11 @@ mtul.b3d = {} local modpath = minetest.get_modpath("mtul_b3d") -dofile(modpath.."/read_b3d.lua") -dofile(modpath.."/write_b3d.lua") +--placed in a seperate directory for the license +dofile(modpath.."/modlib/read_b3d.lua") +dofile(modpath.."/modlib/write_b3d.lua") --this is untested, could be very broken. --these modules are disabled, refactoring is needed. ---dofile(modpath.."/read_b3d_bone.lua") +if mtul.math.cpml_loaded then + dofile(modpath.."/read_b3d_bone") +end --dofile(modpath.."/read_b3d_bone.lua" \ No newline at end of file diff --git a/License.txt b/modlib/License.txt similarity index 100% rename from License.txt rename to modlib/License.txt diff --git a/read_b3d.lua b/modlib/read_b3d.lua similarity index 100% rename from read_b3d.lua rename to modlib/read_b3d.lua diff --git a/to_gltf.lua b/modlib/to_gltf.lua similarity index 100% rename from to_gltf.lua rename to modlib/to_gltf.lua diff --git a/write_b3d.lua b/modlib/write_b3d.lua similarity index 100% rename from write_b3d.lua rename to modlib/write_b3d.lua diff --git a/read_b3d_bone.lua b/read_b3d_bone.lua index 97f2e47..5e1a2b2 100644 --- a/read_b3d_bone.lua +++ b/read_b3d_bone.lua @@ -8,63 +8,7 @@ local binary_search_frame = modlib.table.binary_search_comparator(function(a, b) end) --> list of { bone_name = string, parent_bone_name = string, position = vector, rotation = quaternion, scale = vector } -function get_animated_bone_properties(self, keyframe, interpolate) - local function get_frame_values(keys) - local values = keys[keyframe] - if values and values.frame == keyframe then - return { - position = values.position, - rotation = values.rotation, - scale = values.scale - } - end - local index = binary_search_frame(keys, keyframe) - if index > 0 then - return keys[index] - end - index = -index - assert(index > 1 and index <= #keys) - local a, b = keys[index - 1], keys[index] - if not interpolate then - return a - end - local ratio = (keyframe - a.frame) / (b.frame - a.frame) - return { - position = (a.position and b.position and modlib.vector.interpolate(a.position, b.position, ratio)) or a.position or b.position, - rotation = (a.rotation and b.rotation and modlib.quaternion.slerp(a.rotation, b.rotation, ratio)) or a.rotation or b.rotation, - scale = (a.scale and b.scale and modlib.vector.interpolate(a.scale, b.scale, ratio)) or a.scale or b.scale, - } - end - local bone_properties = {} - local function get_props(node, parent_bone_name) - local properties = {parent_bone_name = parent_bone_name} +function mtul.b3d:get_bone_global_transform(self, node_name) - if keyframe > 0 and node.keys and next(node.keys) ~= nil then - modlib.table.add_all(properties, get_frame_values(node.keys)) - end - - if not properties.position then -- animation not present, fall back to node position - properties.position = modlib.table.copy(node.position) - end - - if properties.rotation then -- animation is relative to node rotation - properties.rotation = modlib.quaternion.compose(node.rotation, properties.rotation) - else - properties.rotation = modlib.table.copy(node.rotation) - end - - if not properties.scale then -- animation not present, fall back to node scale - properties.scale = modlib.table.copy(node.scale) - end - - if node.bone then - properties.bone_name = node.name - table.insert(bone_properties, properties) - end - for _, child in pairs(node.children or {}) do - get_props(child, properties.bone_name) - end - end - get_props(self.node) - return bone_properties -end \ No newline at end of file +end +function mtul.b3d:get_bone \ No newline at end of file