Difference between revisions of "IC Python API:RLPy RIClip"

From Reallusion Wiki!
Jump to: navigation, search
m
Line 1: Line 1:
 
{{TOC}}
 
{{TOC}}
 
{{Parent|IC_Python_API:RL_Python_Modules|Modules}}
 
{{Parent|IC_Python_API:RL_Python_Modules|Modules}}
==Inheritance==
+
{{last_modified}}
This class inherits public member functions from:
+
 
*[[IC_Python_API:RLPy_RIBase|RLPy.RIBase]]
+
== Description ==
==Detailed Description==
+
 
This class is used to access the clip data of the animation.
+
[[File:Rlpy_riclip_img_01.png|left|frame|Animation keys reside in clips.]]
<syntaxhighlight lang="Python">
+
 
 +
An animation clip representes a sequence of connected motions.  Different types of animations can be derived from composing clips and applying various clip operations. Animation clips are recorded for each character bone node or a scene object itself.  One can access an animation clip's transform control via [[IC_Python_API:RLPy_RIClip|RIClip]], to facilitate subsequent key operations.
 +
 
 +
=== Inheritance ===
 +
 
 +
[[IC_Python_API:RLPy_RIBase|RIBase]] > [[IC_Python_API:RLPy_RIClip|RIClip]] {{clear}}
 +
 
 +
== Member Functions ==
 +
 
 +
=== GetControl ( self, st[[IC_Python_API:RLPy_RKey|RKey]] , spNode ) ===
 +
 
 +
Get the transform control for a character's bone node or scene object according to the clip index.  At the present, only "Layer" is supported as the clip key.  If the character's skeleton bone node or the scene object does not have a clip or if the clip index is larger than the total number of clips, return '''None'''.
 +
 
 +
==== Parameters ====
 +
:'''strKey''' [IN] Name for the clip key, currently only "Layer" is supported - string
 +
:'''spNode''' [IN] Character skeleton bone node or the scene object node - [[IC_Python_API:RLPy_RIBase|RIBase]]
 +
 
 +
==== Returns ====
 +
The transform control on a character's skeleton bone node or scene object. - [[IC_Python_API:RLPy_RControl|RControl]]
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
# Get skeleton component
 
avatar_list = RLPy.RScene.GetAvatars()
 
avatar_list = RLPy.RScene.GetAvatars()
 
avatar = avatar_list[0]
 
avatar = avatar_list[0]
 
bone = avatar.GetSkeletonComponent()
 
bone = avatar.GetSkeletonComponent()
clip = bone.GetClip(0)
+
 
+
# Get transform control from bone root
# clip length
+
clip_index = 1
clip.SetLength(RLPy.RTime(5000))
+
clip = bone.GetClip(clip_index)
print(clip.GetLength().GetValue())
+
transform_control = clip.GetControl("Layer", bone.GetRootBone())
+
# get layer control of rootbone
+
control = clip.GetControl("Layer", bone.GetRootBone())
+
+
# convert scene time to clip time
+
system_time = RLPy.RTime(13000)
+
clip_time = clip.SceneTimeToClipTime(system_time)
+
 
</syntaxhighlight>
 
</syntaxhighlight>
==Member Functions==
+
 
===ClipTimeToSceneTime===
+
=== GetLength ( self ) ===
<syntaxhighlight lang="Python">
+
 
RLPy.RIClip.ClipTimeToSceneTime ( self, kClipTime )
+
Get the length of this clip.  If this clip does not contain a key then return RTime(0).
 +
 
 +
==== Returns ====
 +
The length of this clip - [[IC_Python_API:RLPy_RTime|RTime]]
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
# Get skeleton component
 +
avatar_list = RLPy.RScene.GetAvatars()
 +
avatar = avatar_list[0]
 +
bone = avatar.GetSkeletonComponent()
 +
 
 +
# Get clip length
 +
clip_index = 1
 +
clip = bone.GetClip(clip_index)
 +
clip_len = clip.GetLength()
 
</syntaxhighlight>
 
</syntaxhighlight>
Convert clip time to Scene time.
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''kClipTime''' [IN] clip time - RLPy.RTime
+
=== SetLength ( self, kLength ) ===
</div>
+
 
====Returns====
+
Set the length of this clip.
<div style="margin-left: 2em;">Scene time - RLPy.RTime
+
 
</div>
+
==== Parameters ====
-----
+
:'''kLength''' [IN] The desired clip length - [[IC_Python_API:RLPy_RTime|RTime]]
===GetControl===
+
 
<syntaxhighlight lang="Python">
+
==== Return ====
RLPy.RIClip.GetControl ( self, strKey, spNode )
+
:Success - RLPy.RStatus.Success
 +
:Failure - RLPy.RStatus.Failure
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
# Get skeleton component
 +
avatar_list = RLPy.RScene.GetAvatars()
 +
avatar = avatar_list[0]
 +
bone = avatar.GetSkeletonComponent()
 +
 
 +
# Set clip length
 +
clip_index = 1
 +
clip = bone.GetClip(clip_index)
 +
clip_len = RLPy.RTime(2000)
 +
clip.SetLength(clip_len)
 
</syntaxhighlight>
 
</syntaxhighlight>
Get transform control of the bone node.
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''strKey''' [IN] Key of the controller, allowing use "Layer" as the key to retrieve the control of the Motion Layer in the clip - string
+
=== GetLastKeyTime ( self ) ===
  
'''spNode''' [IN] Specifies the corresponding node to get the control - RLPy.RIBase
+
Get the final key time on a scene object clip.
</div>
+
 
====Returns====
+
==== Returns ====
<div style="margin-left: 2em;">Return the controller of the specified key. It will return null while not found or the key is invalid - RLPy.RControl
+
Time of the final key - [[IC_Python_API:RLPy_RTime|RTime]]
</div>
+
 
-----
+
<syntaxhighlight lang="python" line='line'>
===GetLastKeyTime===
+
# Get skeleton component
<syntaxhighlight lang="Python">
+
avatar_list = RLPy.RScene.GetAvatars()
RLPy.RIClip.GetLastKeyTime ( self )
+
avatar = avatar_list[0]
</syntaxhighlight>
+
bone = avatar.GetSkeletonComponent()
Get time of the last key in the clip.
+
 
====Returns====
+
# Get last key time
<div style="margin-left: 2em;">Time of the last key in the clip - RLPy.RTime
+
clip_index = 1
</div>
+
clip = bone.GetClip(clip_index)
-----
+
last_key_time = clip.GetLastKeyTime()
===GetLength===
+
<syntaxhighlight lang="Python">
+
RLPy.RIClip.GetLength ( self )
+
 
</syntaxhighlight>
 
</syntaxhighlight>
Get length of the clip.
 
====Returns====
 
<div style="margin-left: 2em;">Clip length - RLPy.RTime
 
</div>
 
-----
 
===SceneTimeToClipTime===
 
<syntaxhighlight lang="Python">
 
RLPy.RIClip.SceneTimeToClipTime ( self, kSceneTime )
 
</syntaxhighlight>
 
Convert Scene time to clip time.
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''kSceneTime''' [IN] Scene time - RLPy.RTime
+
=== SceneTimeToClipTime ( self, kSceneTime ) ===
</div>
+
 
====Returns====
+
Convert a point in time within the scene to clip time.  If a given object does not have a clip or if the clip index exceeds the total number of clips, then return scene time instead.
<div style="margin-left: 2em;">Clip time - RLPy.RTime
+
 
</div>
+
See Also: [[#ClipTimeToSceneTime ( self, kClipTime )|ClipTimeToSceneTime]]
-----
+
 
===SetLength===
+
==== Parameters ====
<syntaxhighlight lang="Python">
+
:'''kSceneTime''' [IN] Project scene time - [[IC_Python_API:RLPy_RTime|RTime]]
RLPy.RIClip.SetLength ( self, kLength )
+
 
 +
==== Returns ====
 +
Clip time at the corresponding scene time - [[IC_Python_API:RLPy_RTime|RTime]]
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
# Get skeleton component
 +
avatar_list = RLPy.RScene.GetAvatars()
 +
avatar = avatar_list[0]
 +
bone = avatar.GetSkeletonComponent()
 +
 
 +
# Scene time to clip time
 +
clip_index = 1
 +
clip = bone.GetClip(clip_index)
 +
scene_time = RLPy.RTime(13000)
 +
clip_time = clip.SceneTimeToClipTime(scene_time)
 
</syntaxhighlight>
 
</syntaxhighlight>
Set length of the clip.
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''kLength''' [IN] clip length - RLPy.RTime
+
=== ClipTimeToSceneTime ( self, kClipTime ) ===
</div>
+
====Return Values====
+
<div style="margin-left: 2em;">
+
  
'''RLPy.RStatus.Success''' Success
+
Convert a point in time within this clip to scene time. If a given object does not have a clip or if the clip index exceeds the total number of clips, then return the clip time instead.
  
'''RLPy.RStatus.Failure''' Fail
+
See Also: [[#SceneTimeToClipTime ( self, kSceneTime )|SceneTimeToClipTime]]
</div>
+
 
 +
==== Parameters ====
 +
:'''kClipTime''' [IN] Clip time - [[IC_Python_API:RLPy_RTime|RTime]]
 +
 
 +
==== Returns ====
 +
Clip time converted to scene time - [[IC_Python_API:RLPy_RTime|RTime]]
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
# Get skeleton component
 +
avatar_list = RLPy.RScene.GetAvatars()
 +
avatar = avatar_list[0]
 +
bone = avatar.GetSkeletonComponent()
 +
 
 +
# Clip time to scene time
 +
clip_index = 1
 +
clip = bone.GetClip(clip_index)
 +
clip_time = RLPy.RTime(2000)
 +
scene_time = clip.ClipTimeToSceneTime(clip_time)
 +
</syntaxhighlight>

Revision as of 20:02, 12 April 2020

Main article: Modules.
Last modified: 04/12/2020

Description

Animation keys reside in clips.

An animation clip representes a sequence of connected motions. Different types of animations can be derived from composing clips and applying various clip operations. Animation clips are recorded for each character bone node or a scene object itself. One can access an animation clip's transform control via RIClip, to facilitate subsequent key operations.

Inheritance

RIBase > RIClip

Member Functions

GetControl ( self, stRKey , spNode )

Get the transform control for a character's bone node or scene object according to the clip index. At the present, only "Layer" is supported as the clip key. If the character's skeleton bone node or the scene object does not have a clip or if the clip index is larger than the total number of clips, return None.

Parameters

strKey [IN] Name for the clip key, currently only "Layer" is supported - string
spNode [IN] Character skeleton bone node or the scene object node - RIBase

Returns

The transform control on a character's skeleton bone node or scene object. - RControl

1 # Get skeleton component
2 avatar_list = RLPy.RScene.GetAvatars()
3 avatar = avatar_list[0]
4 bone = avatar.GetSkeletonComponent()
5 
6 # Get transform control from bone root
7 clip_index = 1
8 clip = bone.GetClip(clip_index)
9 transform_control = clip.GetControl("Layer", bone.GetRootBone())

GetLength ( self )

Get the length of this clip. If this clip does not contain a key then return RTime(0).

Returns

The length of this clip - RTime

1 # Get skeleton component
2 avatar_list = RLPy.RScene.GetAvatars()
3 avatar = avatar_list[0]
4 bone = avatar.GetSkeletonComponent()
5 
6 # Get clip length
7 clip_index = 1
8 clip = bone.GetClip(clip_index)
9 clip_len = clip.GetLength()

SetLength ( self, kLength )

Set the length of this clip.

Parameters

kLength [IN] The desired clip length - RTime

Return

Success - RLPy.RStatus.Success
Failure - RLPy.RStatus.Failure
 1 # Get skeleton component
 2 avatar_list = RLPy.RScene.GetAvatars()
 3 avatar = avatar_list[0]
 4 bone = avatar.GetSkeletonComponent()
 5 
 6 # Set clip length
 7 clip_index = 1
 8 clip = bone.GetClip(clip_index)
 9 clip_len = RLPy.RTime(2000)
10 clip.SetLength(clip_len)

GetLastKeyTime ( self )

Get the final key time on a scene object clip.

Returns

Time of the final key - RTime

1 # Get skeleton component
2 avatar_list = RLPy.RScene.GetAvatars()
3 avatar = avatar_list[0]
4 bone = avatar.GetSkeletonComponent()
5 
6 # Get last key time
7 clip_index = 1
8 clip = bone.GetClip(clip_index)
9 last_key_time = clip.GetLastKeyTime()

SceneTimeToClipTime ( self, kSceneTime )

Convert a point in time within the scene to clip time. If a given object does not have a clip or if the clip index exceeds the total number of clips, then return scene time instead.

See Also: ClipTimeToSceneTime

Parameters

kSceneTime [IN] Project scene time - RTime

Returns

Clip time at the corresponding scene time - RTime

 1 # Get skeleton component
 2 avatar_list = RLPy.RScene.GetAvatars()
 3 avatar = avatar_list[0]
 4 bone = avatar.GetSkeletonComponent()
 5 
 6 # Scene time to clip time
 7 clip_index = 1
 8 clip = bone.GetClip(clip_index)
 9 scene_time = RLPy.RTime(13000)
10 clip_time = clip.SceneTimeToClipTime(scene_time)

ClipTimeToSceneTime ( self, kClipTime )

Convert a point in time within this clip to scene time. If a given object does not have a clip or if the clip index exceeds the total number of clips, then return the clip time instead.

See Also: SceneTimeToClipTime

Parameters

kClipTime [IN] Clip time - RTime

Returns

Clip time converted to scene time - RTime

 1 # Get skeleton component
 2 avatar_list = RLPy.RScene.GetAvatars()
 3 avatar = avatar_list[0]
 4 bone = avatar.GetSkeletonComponent()
 5 
 6 # Clip time to scene time
 7 clip_index = 1
 8 clip = bone.GetClip(clip_index)
 9 clip_time = RLPy.RTime(2000)
10 scene_time = clip.ClipTimeToSceneTime(clip_time)