Module b3d_nodes
allows you to get information about nodes (bones or meshes) within a b3d table (generated with b3d_reader
)
located in mtul.b3d_nodes
.
WARNING! mtul-cpml must be present for this module to run!
Functions
mtul.b3d_nodes.get_node_by_name (self, node_name, is_bone) | get a node by it's name |
mtul.b3d_nodes.get_animated_local_trs (node, target_frame) | get the local "TRS" (translation, rotation, scale) of a bone in animation. |
mtul.b3d_nodes.get_node_global_transform (node, frame, outputs) | get a node's global mat4 transform and rotation. |
mtul.b3d_nodes.get_node_global_position (self, node, is_bone, frame) | find the position of a node in global model space. |
mtul.b3d_nodes.get_node_rotation (self, node, is_bone, frame) | find the global rotation of a node in model space. |
Functions
- mtul.b3d_nodes.get_node_by_name (self, node_name, is_bone)
-
get a node by it's name
Parameters:
- self the b3d table (from b3d_reader)
- node_name the name of the node to fine
- is_bone (optional) bool to indicate wether the node is a bone or not (incase there's a mesh named the same thing). False will only return meshes and pivots, true will only return bones. Nil will return any.
Returns:
-
node (from b3d table, documentation needed)
- mtul.b3d_nodes.get_animated_local_trs (node, target_frame)
-
get the local "TRS" (translation, rotation, scale) of a bone in animation. This is used for global transformation calculations.
quaternion is returned as a string indexed table because it needs to be a cpml object to be interpolated, also has to be usable anyway.
Parameters:
- node table, the node from within a b3d table to read (as outputed by b3d_reader).
- target_frame float, the frame to find the TRS in, can be inbetween frames/keyframes (of course).
Returns:
-
position
ordered table: {x, y, z} -
rotation
quat frommtul_cpml
: (example) {w=0,x=0,y=0,z=1} -
scale
ordered table: {x, y, z} outputs need cleaning up.
- mtul.b3d_nodes.get_node_global_transform (node, frame, outputs)
-
get a node's global mat4 transform and rotation.
Parameters:
- node
table, the node from within a b3d table to read (as outputed by
b3d_reader
). - frame float, the frame to find the transform and rotation in.
- outputs (optional) string, either "rotation" or "transform". Set to nil to return both.
Returns:
-
global_transform
, a matrix 4x4, note that CPML's tranforms are column major (i.e. 1st column is 1, 2, 3, 4). (seemtul_cpml
docs) -
rotation quat
, the quaternion rotation in global space. (cannot be assumed to be normalized, this uses raw interpolated data from the b3d reader)
- node
table, the node from within a b3d table to read (as outputed by
- mtul.b3d_nodes.get_node_global_position (self, node, is_bone, frame)
-
find the position of a node in global model space.
Parameters:
- self b3d table, (optional if node is a node table and not name)
- node string or table, either the node from b3d table or a the name of the node to find.
- is_bone
(optional) if node is string, this is used to find it (see
get_node_by_name
) - frame the frame to find the global position of the node at.
Returns:
-
x
-
y
-
z
- mtul.b3d_nodes.get_node_rotation (self, node, is_bone, frame)
-
find the global rotation of a node in model space.
Parameters:
- self b3d table, (optional if node is a node table and not name)
- node string or table, either the node from b3d table or a the name of the node to find.
- is_bone
(optional) if node is string, this is used to find it (see
get_node_by_name
) - frame the frame to find the global rotation of the node at.
Returns:
rotation
quaternion rotation of the node (may not be normalized)