Difference between revisions of "IC Python API:RLPy RIObject"
Chuck (RL) (Talk | contribs) m |
Chuck (RL) (Talk | contribs) m |
||
Line 1: | Line 1: | ||
{{TOC}} | {{TOC}} | ||
{{Parent|IC_Python_API:RL_Python_Modules|Modules}} | {{Parent|IC_Python_API:RL_Python_Modules|Modules}} | ||
− | == | + | {{last_modified}} |
− | This class | + | |
− | + | == Description == | |
− | + | ||
− | + | This class is used to access the bone node parameters for a character skeleton or object. Retrievable parameters include name, ID, parent node, child nodes (list), etc. Use [[#Update ( self )|Update]] to get the world transform values for the bone node for the current point in time. | |
+ | |||
<syntaxhighlight lang="Python"> | <syntaxhighlight lang="Python"> | ||
+ | # Get root bone node | ||
avatar_list = RLPy.RScene.GetAvatars() | avatar_list = RLPy.RScene.GetAvatars() | ||
avatar = avatar_list[0] | avatar = avatar_list[0] | ||
− | + | skeleton_component = avatar.GetSkeletonComponent() | |
− | + | bone_node = skeleton_component.GetRootBone() | |
− | + | </syntaxhighlight> | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | == Member Functions == | |
− | + | ||
− | + | === GetName ( self ) === | |
+ | |||
+ | Get the name of the bone node of a character skeleton or scene object. | ||
+ | |||
+ | ==== Returns ==== | ||
+ | :Name of the bone node - str | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
<syntaxhighlight lang="Python"> | <syntaxhighlight lang="Python"> | ||
− | RLPy. | + | # Get root bone node |
+ | avatar_list = RLPy.RScene.GetAvatars() | ||
+ | avatar = avatar_list[0] | ||
+ | skeleton_component = avatar.GetSkeletonComponent() | ||
+ | bone_node = skeleton_component.GetRootBone() | ||
+ | |||
+ | # Get root bone name | ||
+ | bone_name = bone_node.GetName() | ||
+ | print(bone_name) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
− | |||
− | |||
− | |||
− | + | === GetID ( self ) === | |
− | + | ||
− | + | Get the ID of the bone node of a character skeleton or scene object. | |
− | === | + | |
+ | ==== Returns ==== | ||
+ | :ID of the bone node - int | ||
+ | |||
<syntaxhighlight lang="Python"> | <syntaxhighlight lang="Python"> | ||
− | RLPy. | + | # Get root bone node |
+ | avatar_list = RLPy.RScene.GetAvatars() | ||
+ | avatar = avatar_list[0] | ||
+ | skeleton_component = avatar.GetSkeletonComponent() | ||
+ | bone_node = skeleton_component.GetRootBone() | ||
+ | |||
+ | # Get root bone ID | ||
+ | bone_id = bone_node.GetID() | ||
+ | print(bone_id) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
− | |||
− | |||
− | |||
− | + | === GetParent ( self ) === | |
− | + | Get the parent bone of the bone node of a character skeleton or scene object. | |
− | + | See Also: [[#GetChildren ( self )|GetChildren]] | |
− | + | ||
− | + | ||
− | + | ||
− | + | ==== Returns ==== | |
+ | :Parent bone node - [[IC_Python_API:RLPy_RINode|RINode]] | ||
− | |||
− | |||
− | |||
− | |||
<syntaxhighlight lang="Python"> | <syntaxhighlight lang="Python"> | ||
− | RLPy. | + | # Get root bone node |
− | + | avatar_list = RLPy.RScene.GetAvatars() | |
− | + | avatar = avatar_list[0] | |
− | = | + | skeleton_component = avatar.GetSkeletonComponent() |
− | + | bone_node = skeleton_component.GetRootBone() | |
− | + | # Get root bone parent bone | |
− | + | parent_bone = bone_node.GetParent() | |
− | + | print(parent_bone) | |
− | + | ||
− | + | ||
− | + | ||
− | = | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | === GetChildren ( self ) === | |
− | + | Get a list of child bones for a bone node of a character skeleton or scene object. | |
− | + | ||
− | + | ||
− | + | ||
− | + | See Also: [[#GetParent ( self )|GetParent]] | |
+ | |||
+ | ==== Returns ==== | ||
+ | :List of child bone nodes - [[IC_Python_API:RLPy_RINode|RINode]] list | ||
− | |||
− | |||
− | |||
− | |||
<syntaxhighlight lang="Python"> | <syntaxhighlight lang="Python"> | ||
− | RLPy. | + | # Get root bone node |
+ | avatar_list = RLPy.RScene.GetAvatars() | ||
+ | avatar = avatar_list[0] | ||
+ | skeleton_component = avatar.GetSkeletonComponent() | ||
+ | bone_node = skeleton_component.GetRootBone() | ||
+ | |||
+ | # Get root bone children bone list | ||
+ | children_bone_list = bone_node.GetChildren() | ||
+ | print(children_bone_list) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | === LocalTransform ( self ) === | |
− | + | ||
− | - | + | Get the local-transform for a bone node of a character skeleton or scene object. |
− | === | + | |
+ | See Also: [[#WorldTransform ( self )|WorldTransform]] | ||
+ | |||
+ | ==== Returns ==== | ||
+ | :Bone node local-transform - [[IC_Python_API:RLPy_RTransform|RTransform]] | ||
+ | |||
<syntaxhighlight lang="Python"> | <syntaxhighlight lang="Python"> | ||
− | RLPy. | + | # Get root bone node |
+ | avatar_list = RLPy.RScene.GetAvatars() | ||
+ | avatar = avatar_list[0] | ||
+ | skeleton_component = avatar.GetSkeletonComponent() | ||
+ | bone_node = skeleton_component.GetRootBone() | ||
+ | |||
+ | # Get root bone local transform | ||
+ | local_transform = bone_node.LocalTransform() | ||
+ | print(local_transform) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | === WorldTransform ( self ) === | |
− | + | Get the world-transform for a bone node of a character skeleton or scene object. | |
− | + | ||
− | + | ||
− | + | ||
− | + | See Also: [[#LocalTransform ( self )|LocalTransform]] | |
+ | |||
+ | ==== Returns ==== | ||
+ | :Bone node world-transform - [[IC_Python_API:RLPy_RTransform|RTransform]] | ||
− | |||
− | |||
− | |||
− | |||
<syntaxhighlight lang="Python"> | <syntaxhighlight lang="Python"> | ||
− | RLPy. | + | # Get root bone node |
+ | avatar_list = RLPy.RScene.GetAvatars() | ||
+ | avatar = avatar_list[0] | ||
+ | skeleton_component = avatar.GetSkeletonComponent() | ||
+ | bone_node = skeleton_component.GetRootBone() | ||
+ | |||
+ | # Get root bone world transform | ||
+ | world_transform = bone_node.WorldTransform() | ||
+ | print(world_transform) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | === WorldToLocal ( self, kWorldMatrix ) === | |
− | + | ||
− | ==== | + | |
− | + | ||
− | + | Convert the world-transform matrix for a bone node of a character skeleton or scene object to local-transform matrix. | |
+ | |||
+ | See Also: [[#LocalToWorld ( self, kLocalMatrix )|LocalToWorld]] | ||
+ | |||
+ | ==== Parameters ==== | ||
+ | :kWorldMatrix [IN] Character bone node world-transform matrix - [[IC_Python_API:RLPy_RMatrix4|RMatrix4]] | ||
+ | |||
+ | ==== Returns ==== | ||
+ | :Bone node local-transform matrix - [[IC_Python_API:RLPy_RMatrix4|RMatrix4]] | ||
− | |||
− | |||
− | |||
− | |||
<syntaxhighlight lang="Python"> | <syntaxhighlight lang="Python"> | ||
− | RLPy. | + | # Get root bone node |
+ | avatar_list = RLPy.RScene.GetAvatars() | ||
+ | avatar = avatar_list[0] | ||
+ | skeleton_component = avatar.GetSkeletonComponent() | ||
+ | bone_node = skeleton_component.GetRootBone() | ||
+ | |||
+ | # Transfer root bone world transform matrix to local transform matrix | ||
+ | world_transform = bone_node.WorldTransform() | ||
+ | world_matrix = world_transform.Matrix() | ||
+ | world_to_local = bone.WorldToLocal(world_matrix) | ||
+ | print(world_to_local) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
− | |||
− | |||
− | + | === LocalToWorld ( self, kLocalMatrix ) === | |
− | + | ||
− | ==== | + | Convert the local-transform matrix for a bone node of a character skeleton or scene object to world-transform matrix. |
− | + | ||
− | + | See Also: [[#WorldToLocal ( self, kWorldMatrix )|WorldToLocal]] | |
− | + | ||
− | === | + | ==== Parameters ==== |
+ | :kLocalMatrix [IN] Character bone node local-transform matrix - [[IC_Python_API:RLPy_RMatrix4|RMatrix4]] | ||
+ | |||
+ | ==== Returns ==== | ||
+ | :Bone node world-transform matrix - [[IC_Python_API:RLPy_RMatrix4|RMatrix4]] | ||
+ | |||
<syntaxhighlight lang="Python"> | <syntaxhighlight lang="Python"> | ||
− | RLPy. | + | # Get root bone node |
+ | avatar_list = RLPy.RScene.GetAvatars() | ||
+ | avatar = avatar_list[0] | ||
+ | skeleton_component = avatar.GetSkeletonComponent() | ||
+ | bone_node = skeleton_component.GetRootBone() | ||
+ | |||
+ | # Transfer root bone local transform matrix to world transform matrix | ||
+ | local_transform = bone_node.LocalTransform() | ||
+ | local_matrix = local_transform.Matrix() | ||
+ | local_to_world = bone.LocalToWorld(local_matrix) | ||
+ | print(local_to_world) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
− | |||
− | |||
− | |||
− | + | === Update ( self ) === | |
− | + | ||
− | ==== | + | |
− | + | ||
− | ' | + | Update the Transform Control for a bone node of a character skelecton or scene object. After the update, the Transform Control's key value will reflect the world-transform values of the bone node for the current point in time. |
− | |||
− | |||
− | |||
− | |||
<syntaxhighlight lang="Python"> | <syntaxhighlight lang="Python"> | ||
− | RLPy. | + | # Get root bone node |
+ | avatar_list = RLPy.RScene.GetAvatars() | ||
+ | avatar = avatar_list[0] | ||
+ | skeleton_component = avatar.GetSkeletonComponent() | ||
+ | bone_node = skeleton_component.GetRootBone() | ||
+ | |||
+ | # Get root bone child node world transform rotation x-axis value | ||
+ | motion_bones = skeleton_component.GetMotionBones() | ||
+ | child = motion_bones[1] | ||
+ | child_world = child.WorldTransform() | ||
+ | child_rot_x = child_world.R().x | ||
+ | |||
+ | # Set float control rotation x-axis value | ||
+ | RLPy.RGlobal.SetTime(RLPy.RTime(0)) | ||
+ | animation_clip = skeleton_component.GetClip(0) | ||
+ | root_control = animation_clip.GetControl("Layer", root) | ||
+ | data_block = root_control.GetDataBlock() | ||
+ | float_control_rotate_x = data_block.GetControl("Rotation/RotationX") | ||
+ | float_control_rotate_x.SetValue(RLPy.RGlobal.GetTime(), math.radians(60)) | ||
+ | |||
+ | # Update root bone with float control | ||
+ | bone_node.Update() | ||
+ | |||
+ | # Get root bone child node world transform rotation x-axis value after updated | ||
+ | new_child_world = child.WorldTransform() | ||
+ | after_update_child_rot_x = new_child_world.R().x | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
− | |||
− | |||
− | |||
− |
Revision as of 23:02, 31 March 2020
- Main article: Modules.
- Last modified: 03/31/2020
Description
This class is used to access the bone node parameters for a character skeleton or object. Retrievable parameters include name, ID, parent node, child nodes (list), etc. Use Update to get the world transform values for the bone node for the current point in time.
# Get root bone node
avatar_list = RLPy.RScene.GetAvatars()
avatar = avatar_list[0]
skeleton_component = avatar.GetSkeletonComponent()
bone_node = skeleton_component.GetRootBone()
Member Functions
GetName ( self )
Get the name of the bone node of a character skeleton or scene object.
Returns
- Name of the bone node - str
# Get root bone node
avatar_list = RLPy.RScene.GetAvatars()
avatar = avatar_list[0]
skeleton_component = avatar.GetSkeletonComponent()
bone_node = skeleton_component.GetRootBone()
# Get root bone name
bone_name = bone_node.GetName()
print(bone_name)
GetID ( self )
Get the ID of the bone node of a character skeleton or scene object.
Returns
- ID of the bone node - int
# Get root bone node
avatar_list = RLPy.RScene.GetAvatars()
avatar = avatar_list[0]
skeleton_component = avatar.GetSkeletonComponent()
bone_node = skeleton_component.GetRootBone()
# Get root bone ID
bone_id = bone_node.GetID()
print(bone_id)
GetParent ( self )
Get the parent bone of the bone node of a character skeleton or scene object.
See Also: GetChildren
Returns
- Parent bone node - RINode
# Get root bone node
avatar_list = RLPy.RScene.GetAvatars()
avatar = avatar_list[0]
skeleton_component = avatar.GetSkeletonComponent()
bone_node = skeleton_component.GetRootBone()
# Get root bone parent bone
parent_bone = bone_node.GetParent()
print(parent_bone)
GetChildren ( self )
Get a list of child bones for a bone node of a character skeleton or scene object.
See Also: GetParent
Returns
- List of child bone nodes - RINode list
# Get root bone node
avatar_list = RLPy.RScene.GetAvatars()
avatar = avatar_list[0]
skeleton_component = avatar.GetSkeletonComponent()
bone_node = skeleton_component.GetRootBone()
# Get root bone children bone list
children_bone_list = bone_node.GetChildren()
print(children_bone_list)
LocalTransform ( self )
Get the local-transform for a bone node of a character skeleton or scene object.
See Also: WorldTransform
Returns
- Bone node local-transform - RTransform
# Get root bone node
avatar_list = RLPy.RScene.GetAvatars()
avatar = avatar_list[0]
skeleton_component = avatar.GetSkeletonComponent()
bone_node = skeleton_component.GetRootBone()
# Get root bone local transform
local_transform = bone_node.LocalTransform()
print(local_transform)
WorldTransform ( self )
Get the world-transform for a bone node of a character skeleton or scene object.
See Also: LocalTransform
Returns
- Bone node world-transform - RTransform
# Get root bone node
avatar_list = RLPy.RScene.GetAvatars()
avatar = avatar_list[0]
skeleton_component = avatar.GetSkeletonComponent()
bone_node = skeleton_component.GetRootBone()
# Get root bone world transform
world_transform = bone_node.WorldTransform()
print(world_transform)
WorldToLocal ( self, kWorldMatrix )
Convert the world-transform matrix for a bone node of 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
# Get root bone node
avatar_list = RLPy.RScene.GetAvatars()
avatar = avatar_list[0]
skeleton_component = avatar.GetSkeletonComponent()
bone_node = skeleton_component.GetRootBone()
# Transfer root bone world transform matrix to local transform matrix
world_transform = bone_node.WorldTransform()
world_matrix = world_transform.Matrix()
world_to_local = bone.WorldToLocal(world_matrix)
print(world_to_local)
LocalToWorld ( self, kLocalMatrix )
Convert the local-transform matrix for a bone node of 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
# Get root bone node
avatar_list = RLPy.RScene.GetAvatars()
avatar = avatar_list[0]
skeleton_component = avatar.GetSkeletonComponent()
bone_node = skeleton_component.GetRootBone()
# Transfer root bone local transform matrix to world transform matrix
local_transform = bone_node.LocalTransform()
local_matrix = local_transform.Matrix()
local_to_world = bone.LocalToWorld(local_matrix)
print(local_to_world)
Update ( self )
Update the Transform Control for a bone node of a character skelecton or scene object. After the update, the Transform Control's key value will reflect the world-transform values of the bone node for the current point in time.
# Get root bone node
avatar_list = RLPy.RScene.GetAvatars()
avatar = avatar_list[0]
skeleton_component = avatar.GetSkeletonComponent()
bone_node = skeleton_component.GetRootBone()
# Get root bone child node world transform rotation x-axis value
motion_bones = skeleton_component.GetMotionBones()
child = motion_bones[1]
child_world = child.WorldTransform()
child_rot_x = child_world.R().x
# Set float control rotation x-axis value
RLPy.RGlobal.SetTime(RLPy.RTime(0))
animation_clip = skeleton_component.GetClip(0)
root_control = animation_clip.GetControl("Layer", root)
data_block = root_control.GetDataBlock()
float_control_rotate_x = data_block.GetControl("Rotation/RotationX")
float_control_rotate_x.SetValue(RLPy.RGlobal.GetTime(), math.radians(60))
# Update root bone with float control
bone_node.Update()
# Get root bone child node world transform rotation x-axis value after updated
new_child_world = child.WorldTransform()
after_update_child_rot_x = new_child_world.R().x