Module b3d_nodes
allows you to get information about nodes (bones or meshes) within a b3d table (generated with b3d_reader
)
This is apart of the LEEF-b3d module
WARNING! This LEEF-b3d submodule depends on the LEEF-math
Functions
get_node_by_name (self, node_name, is_bone) | get a node by it's name |
get_animated_local_trs (node, target_frame) | get the local "TRS" (translation, rotation, scale) of a bone in animation. |
get_node_global_transform (node, frame, outputs) | get a node's global mat4 transform and rotation. |
get_node_global_position (self, node, is_bone, frame) | find the position of a node in global model space. |
get_node_rotation (self, node, is_bone, frame) | find the global rotation of a node in model space. |
Functions
- 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)
- 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 math 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 fromleef_math
: (example) {w=0,x=0,y=0,z=1} -
scale
ordered table: {x, y, z} outputs need cleaning up.
- 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 "1" or "2" where 1 will output the transform alone and 2 will output the rotation alone. Set to nil to return both.
Returns:
-
global_transform
, a matrix 4x4, note that leef.math's tranforms are column major (i.e. 1st column is 1, 2, 3, 4). (seeleef_math
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
- 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
- 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)