IC8 Python API:RLPy RINode
Contents
- 1 Description
- 2 Class Methods
- 2.1 RLPy.RINode.GetChildren(self, bWithSameCustomID = False)
- 2.2 RLPy.RINode.GetDataBlock(self, strId)
- 2.3 RLPy.RINode.GetID(self)
- 2.4 RLPy.RINode.GetName(self)
- 2.5 RLPy.RINode.GetParent(self)
- 2.6 RLPy.RINode.LocalToWorld(self, kLocalMatrix)
- 2.7 RLPy.RINode.LocalTransform(self)
- 2.8 RLPy.RINode.RemoveDataBlock(self, strId)
- 2.9 RLPy.RINode.SetDataBlock(self, strId, spDataBlock)
- 2.10 RLPy.RINode.Update(self)
- 2.11 RLPy.RINode.WorldToLocal(self, kWorldMatrix)
- 2.12 RLPy.RINode.WorldTransform(self)
- Main article: iC8 Modules.
- Last modified: 01/3/2023
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.
Class Methods
RLPy.RINode.GetChildren(self, bWithSameCustomID = False)
Get children of the node.
Parameters
- bWithSameCustomID[IN] is child need to have the same custom ID - bool
Returns
Child nodes - list
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)
RLPy.RINode.GetDataBlock(self, strId)
Provide node to get data block.
Experimental API
Parameters
- strId[IN] DataBlock Id - string
Returns
data block - RLPy. RDataBlock
1 # No example
RLPy.RINode.GetID(self)
Get unique id of the node.
Returns
node id - 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)
RLPy.RINode.GetName(self)
Get name of the node.
Returns
Name of the node - string
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)
RLPy.RINode.GetParent(self)
Get parent of the node.
Returns
Parent node. It will return null while the node is root - RLPy. RINode
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)
RLPy.RINode.LocalToWorld(self, kLocalMatrix)
Transforms matrix from local space into world space.
Experimental API
Parameters
- kWorldMatrix[IN] local space matrix
Returns
RMatrix4 world space matrix - RLPy.RMatrix4f
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
6 print(local_to_world)
RLPy.RINode.LocalTransform(self)
Transform relative to the parent transform.
Returns
Transform - RLPy.RTransformf
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)
RLPy.RINode.RemoveDataBlock(self, strId)
Remove data block from node.
Experimental API
Parameters
- strId[IN] DataBlock Id - string
Returns
- RLPy.RStatus.Success - Succeed
- RLPy.RStatus.Failure - Fail
1 # No example
RLPy.RINode.SetDataBlock(self, strId, spDataBlock)
Provide node to store data through data block.
Experimental API
Parameters
- strId[IN] DataBlock Id - string
- spDataBlock[IN] Store data - RLPy.RDataBlock
Returns
- RLPy.RStatus.Success - Succeed
- RLPy.RStatus.Failure - Fail
1 # No example
RLPy.RINode.Update(self)
In iClone's 3D animation world, it works based on adding keys, so when you add a key, you need to call Update function when you need to update the key value to the object.
Experimental API
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
RLPy.RINode.WorldToLocal(self, kWorldMatrix)
Transforms matrix from world space into local space.
Experimental API
Parameters
- kWorldMatrix[IN] world space matrix - RLPy.RMatrix4f
Returns
RMatrix4 local space matrix - RLPy.RMatrix4f
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)
RLPy.RINode.WorldTransform(self)
The world transform of node.
Experimental API
Returns
Transform - RLPy.RTransformf
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)