Difference between revisions of "IC Python API:RLPy RIObject"
Chuck (RL) (Talk | contribs) m |
Chuck (RL) (Talk | contribs) m |
||
(5 intermediate revisions by the same user not shown) | |||
Line 5: | Line 5: | ||
== Description == | == Description == | ||
− | This class is used to access the bone node parameters | + | This class is used to access the bone node parameters in a character skeleton or object. Retrievable parameters include name, ID, parent node, list of child nodes, and more. Use [[#Update ( self )|Update]] to get the world-transform values of the bone node for the current point in time. |
− | <syntaxhighlight lang=" | + | === Inheritance === |
+ | |||
+ | [[IC_Python_API:RLPy_RIBase|RIBase]] > [[IC_Python_API:RLPy_RIObject|RIObject]] > [[IC_Python_API:RLPy_RIAvatar|RIAvatar]] | [[IC_Python_API:RLPy_RICamera|RICamera]] | [[IC_Python_API:RLPy_RIParticle|RIParticle]] | [[IC_Python_API:RLPy_RIProp|RIProp]] | ||
+ | [[IC_Python_API:RLPy_RIObject|RIObject]] > [[IC_Python_API:RLPy_RILight|RILight]] > [[IC_Python_API:RLPy_RISpotLight|RISpotLight]] | [[IC_Python_API:RLPy_RIPointLight|RIPointLight]] | [[IC_Python_API:RLPy_RIDirectionalLight|RIDirectionalLight]] | ||
+ | |||
+ | === Examples === | ||
+ | |||
+ | <syntaxhighlight lang="python" line='line'> | ||
# Get root bone node | # Get root bone node | ||
avatar_list = RLPy.RScene.GetAvatars() | avatar_list = RLPy.RScene.GetAvatars() | ||
Line 19: | Line 26: | ||
=== GetName ( self ) === | === GetName ( self ) === | ||
− | Get the name of the bone node | + | Get the name of the bone node in a character skeleton or scene object. |
==== Returns ==== | ==== Returns ==== | ||
:Name of the bone node - str | :Name of the bone node - str | ||
− | <syntaxhighlight lang=" | + | <syntaxhighlight lang="python" line='line'> |
# Get root bone node | # Get root bone node | ||
avatar_list = RLPy.RScene.GetAvatars() | avatar_list = RLPy.RScene.GetAvatars() | ||
Line 38: | Line 45: | ||
=== GetID ( self ) === | === GetID ( self ) === | ||
− | Get the ID of the bone node | + | Get the ID of the bone node in a character skeleton or scene object. |
==== Returns ==== | ==== Returns ==== | ||
:ID of the bone node - int | :ID of the bone node - int | ||
− | <syntaxhighlight lang=" | + | <syntaxhighlight lang="python" line='line'> |
# Get root bone node | # Get root bone node | ||
avatar_list = RLPy.RScene.GetAvatars() | avatar_list = RLPy.RScene.GetAvatars() | ||
Line 57: | Line 64: | ||
=== GetParent ( self ) === | === GetParent ( self ) === | ||
− | Get the parent bone of the bone node | + | Get the parent bone of the bone node in a character skeleton or scene object. If a parent does not exist, then return '''None'''. |
See Also: [[#GetChildren ( self )|GetChildren]] | See Also: [[#GetChildren ( self )|GetChildren]] | ||
Line 63: | Line 70: | ||
==== Returns ==== | ==== Returns ==== | ||
:Parent bone node - [[IC_Python_API:RLPy_RINode|RINode]] | :Parent bone node - [[IC_Python_API:RLPy_RINode|RINode]] | ||
+ | :No parent bone node - None | ||
− | <syntaxhighlight lang=" | + | <syntaxhighlight lang="python" line='line'> |
# Get root bone node | # Get root bone node | ||
avatar_list = RLPy.RScene.GetAvatars() | avatar_list = RLPy.RScene.GetAvatars() | ||
Line 78: | Line 86: | ||
=== GetChildren ( self ) === | === GetChildren ( self ) === | ||
− | Get a list of child bones for a bone node | + | Get a list of child bones for a bone node in a character skeleton or scene object. If this bone node does not have child bones, then return '''None'''. |
See Also: [[#GetParent ( self )|GetParent]] | See Also: [[#GetParent ( self )|GetParent]] | ||
Line 84: | Line 92: | ||
==== Returns ==== | ==== Returns ==== | ||
:List of child bone nodes - [[IC_Python_API:RLPy_RINode|RINode]] list | :List of child bone nodes - [[IC_Python_API:RLPy_RINode|RINode]] list | ||
+ | :No child bones - None | ||
− | <syntaxhighlight lang=" | + | <syntaxhighlight lang="python" line='line'> |
# Get root bone node | # Get root bone node | ||
avatar_list = RLPy.RScene.GetAvatars() | avatar_list = RLPy.RScene.GetAvatars() | ||
Line 99: | Line 108: | ||
=== LocalTransform ( self ) === | === LocalTransform ( self ) === | ||
− | Get the local-transform for a bone node | + | Get the local-transform for a bone node in a character skeleton or scene object. |
See Also: [[#WorldTransform ( self )|WorldTransform]] | See Also: [[#WorldTransform ( self )|WorldTransform]] | ||
Line 106: | Line 115: | ||
:Bone node local-transform - [[IC_Python_API:RLPy_RTransform|RTransform]] | :Bone node local-transform - [[IC_Python_API:RLPy_RTransform|RTransform]] | ||
− | <syntaxhighlight lang=" | + | <syntaxhighlight lang="python" line='line'> |
# Get root bone node | # Get root bone node | ||
avatar_list = RLPy.RScene.GetAvatars() | avatar_list = RLPy.RScene.GetAvatars() | ||
Line 120: | Line 129: | ||
=== WorldTransform ( self ) === | === WorldTransform ( self ) === | ||
− | Get the world-transform for a bone node | + | Get the world-transform for a bone node in a character skeleton or scene object. |
See Also: [[#LocalTransform ( self )|LocalTransform]] | See Also: [[#LocalTransform ( self )|LocalTransform]] | ||
Line 127: | Line 136: | ||
:Bone node world-transform - [[IC_Python_API:RLPy_RTransform|RTransform]] | :Bone node world-transform - [[IC_Python_API:RLPy_RTransform|RTransform]] | ||
− | <syntaxhighlight lang=" | + | <syntaxhighlight lang="python" line='line'> |
# Get root bone node | # Get root bone node | ||
avatar_list = RLPy.RScene.GetAvatars() | avatar_list = RLPy.RScene.GetAvatars() | ||
Line 141: | Line 150: | ||
=== WorldToLocal ( self, kWorldMatrix ) === | === WorldToLocal ( self, kWorldMatrix ) === | ||
− | Convert the world-transform matrix for a bone node | + | Convert the world-transform matrix for a bone node in a character skeleton or scene object to local-transform matrix. |
See Also: [[#LocalToWorld ( self, kLocalMatrix )|LocalToWorld]] | See Also: [[#LocalToWorld ( self, kLocalMatrix )|LocalToWorld]] | ||
==== Parameters ==== | ==== Parameters ==== | ||
− | :kWorldMatrix [IN] Character bone node world-transform matrix - [[IC_Python_API:RLPy_RMatrix4|RMatrix4]] | + | :'''kWorldMatrix''' [IN] Character bone node world-transform matrix - [[IC_Python_API:RLPy_RMatrix4|RMatrix4]] |
==== Returns ==== | ==== Returns ==== | ||
:Bone node local-transform matrix - [[IC_Python_API:RLPy_RMatrix4|RMatrix4]] | :Bone node local-transform matrix - [[IC_Python_API:RLPy_RMatrix4|RMatrix4]] | ||
− | <syntaxhighlight lang=" | + | <syntaxhighlight lang="python" line='line'> |
# Get root bone node | # Get root bone node | ||
avatar_list = RLPy.RScene.GetAvatars() | avatar_list = RLPy.RScene.GetAvatars() | ||
Line 167: | Line 176: | ||
=== LocalToWorld ( self, kLocalMatrix ) === | === LocalToWorld ( self, kLocalMatrix ) === | ||
− | Convert the local-transform matrix for a bone node | + | Convert the local-transform matrix for a bone node in a character skeleton or scene object to world-transform matrix. |
See Also: [[#WorldToLocal ( self, kWorldMatrix )|WorldToLocal]] | See Also: [[#WorldToLocal ( self, kWorldMatrix )|WorldToLocal]] | ||
==== Parameters ==== | ==== Parameters ==== | ||
− | :kLocalMatrix [IN] Character bone node local-transform matrix - [[IC_Python_API:RLPy_RMatrix4|RMatrix4]] | + | :'''kLocalMatrix''' [IN] Character bone node local-transform matrix - [[IC_Python_API:RLPy_RMatrix4|RMatrix4]] |
==== Returns ==== | ==== Returns ==== | ||
:Bone node world-transform matrix - [[IC_Python_API:RLPy_RMatrix4|RMatrix4]] | :Bone node world-transform matrix - [[IC_Python_API:RLPy_RMatrix4|RMatrix4]] | ||
− | <syntaxhighlight lang=" | + | <syntaxhighlight lang="python" line='line'> |
# Get root bone node | # Get root bone node | ||
avatar_list = RLPy.RScene.GetAvatars() | avatar_list = RLPy.RScene.GetAvatars() | ||
Line 193: | Line 202: | ||
=== Update ( self ) === | === Update ( self ) === | ||
− | Update the Transform Control for a bone node | + | Update the Transform Control for a bone node in a character skelecton 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 bone node for the current point in time. |
− | <syntaxhighlight lang=" | + | <syntaxhighlight lang="python" line='line'> |
# Get root bone node | # Get root bone node | ||
avatar_list = RLPy.RScene.GetAvatars() | avatar_list = RLPy.RScene.GetAvatars() |
Latest revision as of 23:56, 14 April 2020
- Main article: Modules.
- Last modified: 04/14/2020
Description
This class is used to access the bone node parameters in a character skeleton or object. Retrievable parameters include name, ID, parent node, list of child nodes, and more. Use Update to get the world-transform values of the bone node for the current point in time.
Inheritance
RIBase > RIObject > RIAvatar | RICamera | RIParticle | RIProp RIObject > RILight > RISpotLight | RIPointLight | RIDirectionalLight
Examples
1 # Get root bone node
2 avatar_list = RLPy.RScene.GetAvatars()
3 avatar = avatar_list[0]
4 skeleton_component = avatar.GetSkeletonComponent()
5 bone_node = skeleton_component.GetRootBone()
Member Functions
GetName ( self )
Get the name of the bone node in a character skeleton or scene object.
Returns
- Name of the bone node - str
1 # Get root bone node
2 avatar_list = RLPy.RScene.GetAvatars()
3 avatar = avatar_list[0]
4 skeleton_component = avatar.GetSkeletonComponent()
5 bone_node = skeleton_component.GetRootBone()
6
7 # Get root bone name
8 bone_name = bone_node.GetName()
9 print(bone_name)
GetID ( self )
Get the ID of the bone node in a character skeleton or scene object.
Returns
- ID of the bone node - int
1 # Get root bone node
2 avatar_list = RLPy.RScene.GetAvatars()
3 avatar = avatar_list[0]
4 skeleton_component = avatar.GetSkeletonComponent()
5 bone_node = skeleton_component.GetRootBone()
6
7 # Get root bone ID
8 bone_id = bone_node.GetID()
9 print(bone_id)
GetParent ( self )
Get the parent bone of the bone node in a character skeleton or scene object. If a parent does not exist, then return None.
See Also: GetChildren
Returns
- Parent bone node - RINode
- No parent bone node - None
1 # Get root bone node
2 avatar_list = RLPy.RScene.GetAvatars()
3 avatar = avatar_list[0]
4 skeleton_component = avatar.GetSkeletonComponent()
5 bone_node = skeleton_component.GetRootBone()
6
7 # Get root bone parent bone
8 parent_bone = bone_node.GetParent()
9 print(parent_bone)
GetChildren ( self )
Get a list of child bones for a bone node in a character skeleton or scene object. If this bone node does not have child bones, then return None.
See Also: GetParent
Returns
- List of child bone nodes - RINode list
- No child bones - None
1 # Get root bone node
2 avatar_list = RLPy.RScene.GetAvatars()
3 avatar = avatar_list[0]
4 skeleton_component = avatar.GetSkeletonComponent()
5 bone_node = skeleton_component.GetRootBone()
6
7 # Get root bone children bone list
8 children_bone_list = bone_node.GetChildren()
9 print(children_bone_list)
LocalTransform ( self )
Get the local-transform for a bone node in a character skeleton or scene object.
See Also: WorldTransform
Returns
- Bone node local-transform - RTransform
1 # Get root bone node
2 avatar_list = RLPy.RScene.GetAvatars()
3 avatar = avatar_list[0]
4 skeleton_component = avatar.GetSkeletonComponent()
5 bone_node = skeleton_component.GetRootBone()
6
7 # Get root bone local transform
8 local_transform = bone_node.LocalTransform()
9 print(local_transform)
WorldTransform ( self )
Get the world-transform for a bone node in a character skeleton or scene object.
See Also: LocalTransform
Returns
- Bone node world-transform - RTransform
1 # Get root bone node
2 avatar_list = RLPy.RScene.GetAvatars()
3 avatar = avatar_list[0]
4 skeleton_component = avatar.GetSkeletonComponent()
5 bone_node = skeleton_component.GetRootBone()
6
7 # Get root bone world transform
8 world_transform = bone_node.WorldTransform()
9 print(world_transform)
WorldToLocal ( self, kWorldMatrix )
Convert the world-transform matrix for a bone node in a character skeleton or scene object to local-transform matrix.
See Also: LocalToWorld
Parameters
- kWorldMatrix [IN] Character bone node world-transform matrix - RMatrix4
Returns
- Bone node local-transform matrix - RMatrix4
1 # Get root bone node
2 avatar_list = RLPy.RScene.GetAvatars()
3 avatar = avatar_list[0]
4 skeleton_component = avatar.GetSkeletonComponent()
5 bone_node = skeleton_component.GetRootBone()
6
7 # Transfer root bone world transform matrix to local transform matrix
8 world_transform = bone_node.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 bone node in a character skeleton or scene object to world-transform matrix.
See Also: WorldToLocal
Parameters
- kLocalMatrix [IN] Character bone node local-transform matrix - RMatrix4
Returns
- Bone node world-transform matrix - RMatrix4
1 # Get root bone node
2 avatar_list = RLPy.RScene.GetAvatars()
3 avatar = avatar_list[0]
4 skeleton_component = avatar.GetSkeletonComponent()
5 bone_node = skeleton_component.GetRootBone()
6
7 # Transfer root bone local transform matrix to world transform matrix
8 local_transform = bone_node.LocalTransform()
9 local_matrix = local_transform.Matrix()
10 local_to_world = bone.LocalToWorld(local_matrix)
11 print(local_to_world)
Update ( self )
Update the Transform Control for a bone node in a character skelecton or scene object and update the scene. After the Update, the Transform Control's key values will reflect the world-transform values of the bone node for the current point in time.
1 # Get root bone node
2 avatar_list = RLPy.RScene.GetAvatars()
3 avatar = avatar_list[0]
4 skeleton_component = avatar.GetSkeletonComponent()
5 bone_node = 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)
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 bone_node.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