Difference between revisions of "IC Python API:RLPy RINode"
Chuck (RL) (Talk | contribs) m |
Chuck (RL) (Talk | contribs) m |
||
(One intermediate revision by the same user not shown) | |||
Line 7: | Line 7: | ||
This class is used to access node parameters in a character skeleton or scene object. Retrievable parameters include name, ID, parent node, list of child nodes, and more. [[#Update ( self )|Update]] to get the world-transform of the bone node for the current point in time. | This class is used to access node parameters in a character skeleton or scene object. Retrievable parameters include name, ID, parent node, list of child nodes, and more. [[#Update ( self )|Update]] to get the world-transform of the bone node for the current point in time. | ||
− | + | === Inheritance === | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | [[IC_Python_API:RLPy_RIBase|RIBase]] > [[IC_Python_API:RLPy_RINode|RINode]] | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
== Member Functions == | == Member Functions == | ||
Line 60: | Line 20: | ||
:Name of the node - str | :Name of the node - str | ||
− | <syntaxhighlight lang=" | + | <syntaxhighlight lang="python" line='line'> |
# Get root bone | # Get root bone | ||
avatar_list = RLPy.RScene.GetAvatars() | avatar_list = RLPy.RScene.GetAvatars() | ||
Line 79: | Line 39: | ||
:ID of the node - int | :ID of the node - int | ||
− | <syntaxhighlight lang=" | + | <syntaxhighlight lang="python" line='line'> |
# Get root bone | # Get root bone | ||
avatar_list = RLPy.RScene.GetAvatars() | avatar_list = RLPy.RScene.GetAvatars() | ||
Line 99: | Line 59: | ||
:No parent node - None | :No parent node - None | ||
− | <syntaxhighlight lang=" | + | <syntaxhighlight lang="python" line='line'> |
# Get root bone | # Get root bone | ||
avatar_list = RLPy.RScene.GetAvatars() | avatar_list = RLPy.RScene.GetAvatars() | ||
Line 121: | Line 81: | ||
:No child nodes - None | :No child nodes - None | ||
− | <syntaxhighlight lang=" | + | <syntaxhighlight lang="python" line='line'> |
# Get root bone | # Get root bone | ||
avatar_list = RLPy.RScene.GetAvatars() | avatar_list = RLPy.RScene.GetAvatars() | ||
Line 142: | Line 102: | ||
:Node local-transform - [[IC_Python_API:RLPy_RTransform|RTransform]] | :Node local-transform - [[IC_Python_API:RLPy_RTransform|RTransform]] | ||
− | <syntaxhighlight lang=" | + | <syntaxhighlight lang="python" line='line'> |
# Get root bone | # Get root bone | ||
avatar_list = RLPy.RScene.GetAvatars() | avatar_list = RLPy.RScene.GetAvatars() | ||
Line 163: | Line 123: | ||
:Node world-transform - [[IC_Python_API:RLPy_RTransform|RTransform]] | :Node world-transform - [[IC_Python_API:RLPy_RTransform|RTransform]] | ||
− | <syntaxhighlight lang=" | + | <syntaxhighlight lang="python" line='line'> |
# Get root bone | # Get root bone | ||
avatar_list = RLPy.RScene.GetAvatars() | avatar_list = RLPy.RScene.GetAvatars() | ||
Line 182: | Line 142: | ||
==== Parameters ==== | ==== Parameters ==== | ||
− | :kWorldMatrix [IN] Node world-transform matrix - [[IC_Python_API:RLPy_RMatrix4|RMatrix4]] | + | :'''kWorldMatrix''' [IN] Node world-transform matrix - [[IC_Python_API:RLPy_RMatrix4|RMatrix4]] |
==== Returns ==== | ==== Returns ==== | ||
:Node local-transform matrix - [[IC_Python_API:RLPy_RMatrix4|RMatrix4]] | :Node local-transform matrix - [[IC_Python_API:RLPy_RMatrix4|RMatrix4]] | ||
− | <syntaxhighlight lang=" | + | <syntaxhighlight lang="python" line='line'> |
# Get root bone | # Get root bone | ||
avatar_list = RLPy.RScene.GetAvatars() | avatar_list = RLPy.RScene.GetAvatars() | ||
Line 208: | Line 168: | ||
==== Parameters ==== | ==== Parameters ==== | ||
− | :kLocalMatrix [IN] Node local-transform matrix - [[IC_Python_API:RLPy_RMatrix4|RMatrix4]] | + | :'''kLocalMatrix''' [IN] Node local-transform matrix - [[IC_Python_API:RLPy_RMatrix4|RMatrix4]] |
==== Returns ==== | ==== Returns ==== | ||
:Node local-transform matrix - [[IC_Python_API:RLPy_RMatrix4|RMatrix4]] | :Node local-transform matrix - [[IC_Python_API:RLPy_RMatrix4|RMatrix4]] | ||
− | <syntaxhighlight lang=" | + | <syntaxhighlight lang="python" line='line'> |
# Transfer root bone local transform matrix to world transform matrix | # Transfer root bone local transform matrix to world transform matrix | ||
local_transform = root_bone.LocalTransform() | local_transform = root_bone.LocalTransform() | ||
Line 223: | Line 183: | ||
=== Update ( self ) === | === Update ( self ) === | ||
− | Update the Transform Control for a node in a character skeleton or scene object and update the scene. After the | + | Update the Transform Control for a node in a character skeleton or scene object and update the scene. After the [[#Update ( self )|Update]], the Transform Control's key values will reflect the world-transform values of the node for the current point in time. |
− | <syntaxhighlight lang=" | + | <syntaxhighlight lang="python" line='line'> |
# Get root bone | # Get root bone | ||
avatar_list = RLPy.RScene.GetAvatars() | avatar_list = RLPy.RScene.GetAvatars() |
Latest revision as of 22:42, 14 April 2020
- Main article: Modules.
- Last modified: 04/14/2020
Description
This class is used to access node parameters in a character skeleton or scene object. Retrievable parameters include name, ID, parent node, list of child nodes, and more. Update to get the world-transform of the bone node for the current point in time.
Inheritance
RIBase > RINode
Member Functions
GetName ( self )
Get the name of the node in a character skeleton or scene object.
Returns
- Name of the node - str
1 # Get root bone
2 avatar_list = RLPy.RScene.GetAvatars()
3 avatar = avatar_list[0]
4 skeleton_component = avatar.GetSkeletonComponent()
5 root_bone = skeleton_component.GetRootBone()
6
7 # Get root bone node name
8 node_name = root_bone.GetName()
9 print(node_name)
GetID ( self )
Get the ID of the node in a character skeleton or scene object.
Returns
- ID of the node - int
1 # Get root bone
2 avatar_list = RLPy.RScene.GetAvatars()
3 avatar = avatar_list[0]
4 skeleton_component = avatar.GetSkeletonComponent()
5 root_bone = skeleton_component.GetRootBone()
6
7 # Get root bone node ID
8 node_id = root_bone.GetID()
9 print(node_id)
GetParent ( self )
Get the parent node of the bone node in a character skeleton or scene object. If a parent does not exist, then return None.
Returns
- Parent node - RINode
- No parent node - None
1 # Get root bone
2 avatar_list = RLPy.RScene.GetAvatars()
3 avatar = avatar_list[0]
4 skeleton_component = avatar.GetSkeletonComponent()
5 root_bone = skeleton_component.GetRootBone()
6
7 # Get root bone parent node
8 parent_node = root_bone.GetParent()
9 print(parent_node)
GetChildren ( self )
Get a list of child nodes for a node in a character skeleton or scene object. If this node does not have child nodes, then return None.
See Also: GetParent
Returns
- List of child nodes - RINode list
- No child nodes - None
1 # Get root bone
2 avatar_list = RLPy.RScene.GetAvatars()
3 avatar = avatar_list[0]
4 skeleton_component = avatar.GetSkeletonComponent()
5 root_bone = skeleton_component.GetRootBone()
6
7 # Get root bone children node list
8 children_node_list = root_bone.GetChildren()
9 print(children_node_list)
LocalTransform ( self )
Get the local-transform for a node in a character skeleton or scene object.
See Also: WorldTransform
Returns
- Node local-transform - RTransform
1 # Get root bone
2 avatar_list = RLPy.RScene.GetAvatars()
3 avatar = avatar_list[0]
4 skeleton_component = avatar.GetSkeletonComponent()
5 root_bone = skeleton_component.GetRootBone()
6
7 # Get root bone local transform
8 local_transform = root_bone.LocalTransform()
9 print(local_transform)
WorldTransform ( self )
Get the world-transform for a node in a character skeleton or scene object.
See Also: LocalTransform
Returns
- Node world-transform - RTransform
1 # Get root bone
2 avatar_list = RLPy.RScene.GetAvatars()
3 avatar = avatar_list[0]
4 skeleton_component = avatar.GetSkeletonComponent()
5 root_bone = skeleton_component.GetRootBone()
6
7 # Get root bone world transform
8 world_transform = root_bone.WorldTransform()
9 print(world_transform)
WorldToLocal ( self, kWorldMatrix )
Convert the world-transform matrix for a node in a character skeleton or scene object to local-transform matrix.
See Also: LocalToWorld
Parameters
- kWorldMatrix [IN] Node world-transform matrix - RMatrix4
Returns
- Node local-transform matrix - RMatrix4
1 # Get root bone
2 avatar_list = RLPy.RScene.GetAvatars()
3 avatar = avatar_list[0]
4 skeleton_component = avatar.GetSkeletonComponent()
5 root_bone = skeleton_component.GetRootBone()
6
7 # Transfer root bone world transform matrix to local transform matrix
8 world_transform = root_bone.WorldTransform()
9 world_matrix = world_transform.Matrix()
10 world_to_local = bone.WorldToLocal(world_matrix)
11 print(world_to_local)
LocalToWorld ( self, kLocalMatrix )
Convert the local-transform matrix for a node in a character skeleton or scene object to world-transform matrix.
See Also: WorldToLocal
Parameters
- kLocalMatrix [IN] Node local-transform matrix - RMatrix4
Returns
- Node local-transform matrix - RMatrix4
1 # Transfer root bone local transform matrix to world transform matrix
2 local_transform = root_bone.LocalTransform()
3 local_matrix = local_transform.Matrix()
4 local_to_world = bone.LocalToWorld(local_matrix)
5 print(local_to_world)
Update ( self )
Update the Transform Control for a node in a character skeleton or scene object and update the scene. After the Update, the Transform Control's key values will reflect the world-transform values of the node for the current point in time.
1 # Get root bone
2 avatar_list = RLPy.RScene.GetAvatars()
3 avatar = avatar_list[0]
4 skeleton_component = avatar.GetSkeletonComponent()
5 root_bone = skeleton_component.GetRootBone()
6
7 # Get root bone child node world transform rotation x-axis value
8 motion_bones = skeleton_component.GetMotionBones()
9 child = motion_bones[1]
10 child_world = child.WorldTransform()
11 child_rot_x = child_world.R().x
12
13 # Set float control rotation x-axis value
14 RLPy.RGlobal.SetTime(RLPy.RTime(0))
15 animation_clip = skeleton_component.GetClip(0)
16 root_control = animation_clip.GetControl("Layer", root_bone)
17 data_block = root_control.GetDataBlock()
18 float_control_rotate_x = data_block.GetControl("Rotation/RotationX")
19 float_control_rotate_x.SetValue(RLPy.RGlobal.GetTime(), math.radians(60))
20
21 # Update root bone with float control
22 root_bone.Update()
23
24 # Get root bone child node world transform rotation x-axis value after updated
25 new_child_world = child.WorldTransform()
26 after_update_child_rot_x = new_child_world.R().x