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

From Reallusion Wiki!
Jump to: navigation, search
(Created page with "{{TOC}} {{Parent|IC_Python_API:RL_Python_Modules|Modules}} ==Detailed Description== This class is the base class of all controllers. RControl is the class from which you may d...")
 
m
Line 1: Line 1:
 
{{TOC}}
 
{{TOC}}
 
{{Parent|IC_Python_API:RL_Python_Modules|Modules}}
 
{{Parent|IC_Python_API:RL_Python_Modules|Modules}}
==Detailed Description==
+
{{last_modified}}
This class is the base class of all controllers.
+
 
RControl
+
== Description ==
is the class from which you may derive controller objects to control
+
 
the animation result. Controllers come in different types based on the
+
Controllers are used to manage animations and create animation effects, which will give a key value when fed a time. This is the base class for all controller related classes which are distinquished according to different data types that they record and deal with: [[IC_Python_API:RLPy_RTransformControl|RTransformControl]]  dealing with transform data types and [[IC_Python_API:RLPy_RFloatControl|RFloatControl]] for float data types.  Controllers mainly use keyframes to record animations and create keys; and has the ability to interpolate values between keys.
type of data they control. For example, RTransformControl controls the RTS used to define the position of objects in the scene. RFloatControl controls simple floating point values. <syntaxhighlight lang="Python">
+
 
avatar_list = RLPy.RScene.GetAvatars()
+
Use [[#GetKeyCount ( self )|GetKeyCount]], [[#GetKeyIndex ( self, kTime, nIndex )|GetKeyIndex]], [[#GetKeyTimeAt ( self, uIndex, kTime )|GetKeyTimeAt]], and [[#MaxControlTime ( self )|MaxControlTime]] to retrieve key data within controllers. Use [[#AddKey ( self, pKey, fFps )|AddKey]], [[#ClearKeys ( self )|ClearKeys]], [[#MoveKey ( self, kTime, kOffsetTime )|MoveKey]], [[#RemoveKey ( self, kTime )|RemoveKey]], and [[#RemoveKeyAt ( self, nIndex )|RemoveKeyAt]] to delete or change key data. Additional functions are available for managing key transition data.
avatar = avatar_list[0]
+
 
+
See Also: [[IC_Python_API:RLPy_RTransformControl|RTransformControl]], [[IC_Python_API:RLPy_RFloatControl|RFloatControl]]
 +
 
 +
=== Inheritance ===
 +
 
 +
[[IC_Python_API:RLPy_RControl|RControl]] > [[IC_Python_API:RLPy_RFloatControl|RFloatControl]] | [[IC_Python_API:RLPy_RTransformControl|RTransformControl]]
 +
 
 +
== Member Functions ==
 +
 
 +
=== AddKey ( self, pKey, fFps ) ===
 +
 
 +
Create a new key data at the designated time. If a key already exists at the given time, then it is replaced.
 +
 
 +
See Also: [[#ClearKeys ( self )|ClearKeys]], [[#RemoveKey ( self, kTime )|RemoveKey]], [[#RemoveKeyAt ( self, nIndex )|RemoveKeyAt]]
 +
 
 +
==== Parameters ====
 +
:'''pKey''' [IN] Data for the new Key - [[IC_Python_API:RLPy_RKey|RKey]]  
 +
:'''fFps''' [IN] Frame per second - float
 +
 
 +
==== Return ====
 +
:Success - RLPy.RStatus.Success
 +
:Failure - RLPy.RStatus.Failure
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 
# add key
 
# add key
control = avatar.GetControl("Transform")
+
control = avatar.GetControl("Transform")  
transform = RLPy.RTransform.IDENTITY
+
transform.T().x = 100
+
transform.T().y = 100
+
transform.T().z = 100
+
 
key = RLPy.RTransformKey()
 
key = RLPy.RTransformKey()
 
key.SetTime(RLPy.RTime(0))
 
key.SetTime(RLPy.RTime(0))
key.SetTransform(transform)
+
key.SetTransform(RLPy.RTransform.IDENTITY)
 
control.AddKey(key, RLPy.RGlobal.GetFps())
 
control.AddKey(key, RLPy.RGlobal.GetFps())
+
</syntaxhighlight>
transform.T().x = 0
+
transform.T().y = 0
+
transform.T().z = 0
+
key = RLPy.RTransformKey()
+
key.SetTime(RLPy.RTime(1000))
+
key.SetTransform(transform)
+
control.AddKey(key, RLPy.RGlobal.GetFps())
+
+
print(control.HasKeys()) # true
+
print(control.GetKeyCount()) # 2
+
print(control.MaxControlTime().GetValue()) # 1000.0
+
  
# get transition type
+
=== ClearKeys ( self ) ===
type = control.GetKeyTransitionType(RLPy.RTime(1000))
+
print(type) #RLPy.ETransitionType_Linear
+
  
# change transition type
+
Remove all keys on this controller.
control.SetKeyTransition(RLPy.RTime(1000), RLPy.ETransitionType_Step, 1.0)
+
  
# get key time and index
+
See Also: [[#RemoveKey ( self, kTime )|RemoveKey]], [[#RemoveKeyAt ( self, nIndex )|RemoveKeyAt]], [[#AddKey ( self, pKey, fFps )|AddKey]]
time = RLPy.RTime()
+
 
control.GetKeyTimeAt(1, time)
+
==== Returns ====
print(time.GetValue()) # 1000
+
:Success - RLPy.RStatus.Success
+
:Failure - RLPy.RStatus.Failure
key_index = -1
+
 
ret_list = control.GetKeyIndex(RLPy.RTime(1000), key_index)
+
<syntaxhighlight lang="python" line='line'>
key_index = ret_list[1]
+
# clear key
print(key_index) # 1
+
control = avatar.GetControl("Transform")  
+
# get key by index
+
key1 = RLPy.RTransformKey().Clone()
+
ret_list = control.GetKeyAt(0, key1)
+
print(key1.GetTime().GetValue()) #0
+
+
# move key
+
control.MoveKey(RLPy.RTime(0), RLPy.RTime(100))
+
control.GetKeyAt(0, key1)
+
print(key1.GetTime().GetValue()) #100
+
+
# clear keys
+
control.RemoveKey(RLPy.RTime(1000))
+
print(control.GetKeyCount()) # 1
+
 
control.ClearKeys()
 
control.ClearKeys()
print(control.HasKeys()) # False
+
print(control.HasKeys())       # False
 
</syntaxhighlight>
 
</syntaxhighlight>
==Member Functions==
+
 
===AddKey===
+
=== Clone ( self ) ===
<syntaxhighlight lang="Python">
+
 
RLPy.RControl.AddKey ( self, pKey, fFps )
+
Copy this controller and return a duplicate.
 +
 
 +
==== Returns ====
 +
:The duplicated controller - RLPy. [[IC_Python_API:RLPy_RControl|RControl]]
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
# clone control
 +
control = avatar.GetControl("Transform")
 +
cloned_control = control.Clone()
 
</syntaxhighlight>
 
</syntaxhighlight>
Add one key.
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''pKey''' [IN] The key to be added - RLPy.RKey
+
=== GetDataBlock ( self ) ===
  
'''fFps''' [IN] Frame per second - float
+
Get the data block on this controller.
</div>
+
====Return Values====
+
<div style="margin-left: 2em;">
+
  
'''RLPy.RStatus.Success''' Success
+
==== Returns ====
 +
:The controller's data block - [[IC_Python_API:RLPy_RDataBlock|RDataBlock]]
  
'''RLPy.RStatus.Failure''' Fail
+
<syntaxhighlight lang="python" line='line'>
</div>
+
# get datablock
-----
+
control = avatar.GetControl("Transform")
===ClearKeys===
+
datablock = control.GetDataBlock()
<syntaxhighlight lang="Python">
+
RLPy.RControl.ClearKeys ( self )
+
 
</syntaxhighlight>
 
</syntaxhighlight>
Clear (remove) all keys.
 
====Return Values====
 
<div style="margin-left: 2em;">
 
  
'''RLPy.RStatus.Success''' Success
+
=== GetKeyCount ( self ) ===
  
'''RLPy.RStatus.Failure''' Fail
+
Get the total number of keys in this controller. To check for existence of a key use Haskey() instead.
</div>
+
 
-----
+
See Also: [[#HasKeys ( self )|HasKeys]]
===Clone===
+
 
<syntaxhighlight lang="Python">
+
==== Returns ====
RLPy.RControl.Clone ( self )
+
:Total number of keys in this controller - int
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
# get key count
 +
control = avatar.GetControl("Transform")
 +
key_count = control.GetKeyCount();
 
</syntaxhighlight>
 
</syntaxhighlight>
Clone the control.
+
 
Supports cloning, which creates a new instance of a class with the same value as an existing instance.
+
=== GetKeyIndex ( self, kTime, nIndex ) ===
====Returns====
+
 
<div style="margin-left: 2em;">Pointer to RControl - RLPy. RControl
+
Get the key index at a given time (starting from 0).  If the controller does not contain key data or the corresponding key is not found then return '''RStatus.Failure'''.
</div>
+
 
-----
+
See Also: [[#GetKeyTimeAt ( self, uIndex, kTime )|GetKeyTimeAt]]
===GetDataBlock===
+
 
<syntaxhighlight lang="Python">
+
==== Parameters ====
RLPy.RControl.GetDataBlock ( self )
+
:'''kTime''' [IN] The specified time - [[IC_Python_API:RLPy_RTime|RTime]]
</syntaxhighlight>
+
:'''nIdx''' [OUT] Returns the Key index - int
Get data block from the control.
+
 
====Returns====
+
==== Returns ====
<div style="margin-left: 2em;">Pointer to data block of the control - RLPy.RDataBlock
+
:Success - RLPy.RStatus.Success
</div>
+
:Failure - RLPy.RStatus.Failure
-----
+
 
===GetKeyCount===
+
<syntaxhighlight lang="python" line='line'>
<syntaxhighlight lang="Python">
+
# get key count
RLPy.RControl.GetKeyCount ( self )
+
control = avatar.GetControl("Transform")
</syntaxhighlight>
+
key_index = -1
Get the number of keys of the control.
+
ret_list = control.GetKeyIndex(RLPy.RTime(1000), key_index)
====Returns====
+
key_index = ret_list[1]
<div style="margin-left: 2em;">The number of keys of the control - int
+
print(key_index)
</div>
+
-----
+
===GetKeyIndex===
+
<syntaxhighlight lang="Python">
+
RLPy.RControl.GetKeyIndex ( self, kTime, nIdx )
+
 
</syntaxhighlight>
 
</syntaxhighlight>
Get key index by time.
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''kTime''' [IN] Specifies the time to get key index - RLPy.RTime
+
=== GetKeyTimeAt ( self, uIndex, kTime ) ===
  
'''nIdx''' [OUT] Index of the key - int
+
Get the key time at a given key index.
</div>
+
====Return Values====
+
<div style="margin-left: 2em;">
+
  
'''RLPy.RStatus.Success''' Success
+
See Also: [[#GetKeyIndex ( self, kTime, nIndex )|GetKeyIndex]]
  
'''RLPy.RStatus.Failure''' Fail
+
==== Parameters ====
</div>
+
:'''uIndex''' [IN] Key Index (Index value starts from zero) - int
-----
+
:'''kTime''' [OUT] Return the Key’s time value - [[IC_Python_API:RLPy_RTime|RTime]]
===GetKeyTimeAt===
+
 
<syntaxhighlight lang="Python">
+
==== Returns ====
RLPy.RControl.GetKeyTimeAt ( self, uIndex, kTime )
+
:Success - RLPy.RStatus.Success
 +
:Failure - RLPy.RStatus.Failure
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
# get key time
 +
control = avatar.GetControl("Transform")
 +
time = RLPy.RTime()
 +
control.GetKeyTimeAt(1, time)
 +
print(time.GetValue())
 
</syntaxhighlight>
 
</syntaxhighlight>
Get key's time by index.
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''uIndex''' [IN] Index of the key. (starting from zero) - int
+
=== GetKeyTransitionStrength ( self, kTime ) ===
 +
 
 +
Get the transition strength on this controller at a given time.
 +
 
 +
See Also: [[#GetKeyTransitionStrength ( self, kTime )|GetKeyTransitionStrength]], [[IC_Python_API:RLPy_RKey#SetTransitionStrength|RKey.SetTransitionStrength()]]
  
'''kTime''' [OUT] Time of the key specified by uIndex - RLPy.RTime
+
==== Parameters ====
</div>
+
:'''kTime''' [IN] Specified time - [[IC_Python_API:RLPy_RTime|RTime]]
====Return Values====
+
<div style="margin-left: 2em;">
+
  
'''RLPy.RStatus.Success''' Success
+
==== Returns ====
 +
:Key transition strength (default:50) - float [0,100]
  
'''RLPy.RStatus.Failure''' Fail
+
<syntaxhighlight lang="python" line='line'>
</div>
+
# get transition strength
-----
+
control = avatar.GetControl("Transform")
===GetKeyTransitionStrength===
+
Strength = control.GetKeyTransitionStrength(RLPy.RTime(0))
<syntaxhighlight lang="Python">
+
RLPy.RControl.GetKeyTransitionStrength ( self, kTime )
+
 
</syntaxhighlight>
 
</syntaxhighlight>
Get transition strength of the key.
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''kTime''' [IN] Specifies the time to get transition strength - RLPy.RTime
+
=== GetKeyTransitionType ( self, kTime ) ===
</div>
+
====Returns====
+
<div style="margin-left: 2em;">Transition strength of the key. The strength range is from 0 to 100, 50 is default value - float
+
</div>
+
-----
+
===GetKeyTransitionType===
+
<syntaxhighlight lang="Python">
+
RLPy.RControl.GetKeyTransitionType ( self, kTime )
+
</syntaxhighlight>
+
Get transition type of the key.
+
====Parameters====
+
<div style="margin-left: 2em;">
+
  
'''kTime''' [IN] Specifies the time to get transition type - RLPy.RTime
+
Get the transition type on this controller at a given time.
</div>
+
 
====Returns====
+
See Also: [[#SetKeyTransition ( self, kTime, eType, fStrength )|SetKeyTransition]], [[#IC_Python_API:RLPy_RKey#GetTransitionType|RKey.GetTransitionType()]]
<div style="margin-left: 2em;">Transition type of the key - RLPy.ETransitionType
+
 
*'''RLPy.ETransitionType_Invalid Invalid value.
+
==== Parameters ====
*'''RLPy.ETransitionType_None None.
+
:'''kTime''' [IN] Specified time - [[IC_Python_API:RLPy_RTime|RTime]]
*'''RLPy.ETransitionType_Linear Linear.
+
 
*'''RLPy.ETransitionType_Step Step.
+
==== Returns ====
*'''RLPy.ETransitionType_Ease_Out Ease out.
+
:Returns the Transition type - RLPy.ETransitionType
*'''RLPy.ETransitionType_Ease_In Ease in.
+
 
*'''RLPy.ETransitionType_Ease_Out_In Ease out in.
+
<syntaxhighlight lang="python" line='line'>
*'''RLPy.ETransitionType_Ease_In_Out Ease in out.
+
# get transition type
*'''RLPy.ETransitionType_Ease_In_Sine Ease in sine.
+
control = avatar.GetControl("Transform")
*'''RLPy.ETransitionType_Ease_Out_Sine Ease out sine.
+
transition_type = control.GetKeyTransitionType(RLPy.RTime(0))
*'''RLPy.ETransitionType_Ease_In_Out_Sine Ease in out sine.
+
if transition_type == RLPy.ETransitionType_Step:
*'''RLPy.ETransitionType_Ease_In_Quad Ease in quad.
+
    print("Transition Type: Step")
*'''RLPy.ETransitionType_Ease_Out_Quad Ease out quad.
+
*'''RLPy.ETransitionType_Ease_In_Out_Quad Ease in out quad.
+
*'''RLPy.ETransitionType_Ease_In_Cubic Ease in cubic.
+
*'''RLPy.ETransitionType_Ease_Out_Cubic Ease in out cubic.
+
*'''RLPy.ETransitionType_Ease_In_Out_Cubic Ease in out cubic.
+
*'''RLPy.ETransitionType_Ease_In_Quart Ease in quart.
+
*'''RLPy.ETransitionType_Ease_Out_Quart Ease out quart.
+
*'''RLPy.ETransitionType_Ease_In_Out_Quart Ease in out quart.
+
*'''RLPy.ETransitionType_Ease_In_Quint Ease in quint.
+
*'''RLPy.ETransitionType_Ease_Out_Quint Ease out quint.
+
*'''RLPy.ETransitionType_Ease_In_Out_Quint Ease in out quint.
+
*'''RLPy.ETransitionType_Ease_In_Expo Ease in expo.
+
*'''RLPy.ETransitionType_Ease_Out_Expo Ease out expo.
+
*'''RLPy.ETransitionType_Ease_In_Out_Expo Ease in out expo.
+
*'''RLPy.ETransitionType_Ease_In_Circ Ease in circ.
+
*'''RLPy.ETransitionType_Ease_Out_Circ Ease out circ.
+
*'''RLPy.ETransitionType_Ease_In_Out_Circ Ease in out circ.
+
*'''RLPy.ETransitionType_Ease_In_Back Ease in back.
+
*'''RLPy.ETransitionType_Ease_Out_Back Ease out back.
+
*'''RLPy.ETransitionType_Ease_In_Out_Back Ease in out back.
+
*'''RLPy.ETransitionType_Ease_In_Elastic Ease in elastic.
+
*'''RLPy.ETransitionType_Ease_Out_Elastic Ease out elastic.
+
*'''RLPy.ETransitionType_Ease_In_Out_Elastic Ease in out elastic.
+
*'''RLPy.ETransitionType_Ease_In_Bounce Ease in bounce.
+
*'''RLPy.ETransitionType_Ease_Out_Bounce Ease out bounce.
+
*'''RLPy.ETransitionType_Ease_In_Out_Bounce Ease in out bounce.
+
*'''RLPy.ETransitionType_Last Last.
+
*'''RLPy.ETransitionType_Count'''
+
</div>
+
-----
+
===HasKeys===
+
<syntaxhighlight lang="Python">
+
RLPy.RControl.HasKeys ( self )
+
 
</syntaxhighlight>
 
</syntaxhighlight>
Check whether the control has key.
 
====Return Values====
 
<div style="margin-left: 2em;">
 
  
'''true''' Control has at least one key.
+
=== HasKeys ( self ) ===
  
'''false''' Control has no key.
+
Check if this controller has a key.
</div>
+
 
-----
+
See Also: [[#GetKeyCount ( self )|GetKeyCount]]
===MaxControlTime===
+
 
<syntaxhighlight lang="Python">
+
==== Returns ====
RLPy.RControl.MaxControlTime ( self )
+
:'''True''' if the control has at least one key, else '''False'''.
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
# get transition strength
 +
control = avatar.GetControl("Transform")
 +
has_key = control.HasKeys();
 
</syntaxhighlight>
 
</syntaxhighlight>
Get maximum time of the control.
+
 
====Returns====
+
=== MaxControlTime ( self ) ===
<div style="margin-left: 2em;">The maximum time of the control - RLPy.RTime
+
 
</div>
+
Get this controller's final key time. If a key does not exist then return 0.
-----
+
 
===MoveKey===
+
==== Returns ====
<syntaxhighlight lang="Python">
+
:The maximum time of the control - [[IC_Python_API:RLPy_RTime|RTime]]
RLPy.RControl.MoveKey ( self, kTime, kOffsetTime )
+
 
 +
<syntaxhighlight lang="python" line='line'>
 +
# get last key time
 +
control = avatar.GetControl("Transform")
 +
key_time = control.MaxControlTime();
 
</syntaxhighlight>
 
</syntaxhighlight>
Move one key by an offset time.
 
If there is a key in target time (kTime + kOffstTime) already, it will be replaced by the key in source time (kTime).
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''kTime''' [IN] Specifies the time to move key - RLPy.RTime
+
=== MoveKey ( self, kTime, kOffsetTime ) ===
  
'''kOffsetTime''' [IN] The offset time - RLPy.RTime
+
Offset an animation key at a given time by a duration. The offset key will replace any existing key at the new position.
</div>
+
====Return Values====
+
<div style="margin-left: 2em;">
+
  
'''RLPy.RStatus.Success''' Success
+
==== Parameters ====
 +
:'''kTime''' [IN] Specified time - [[IC_Python_API:RLPy_RTime|RTime]]
 +
:'''kOffsetTime''' [IN] Offset the Key by a specified time - [[IC_Python_API:RLPy_RTime|RTime]]
  
'''RLPy.RStatus.Failure''' Fail
+
==== Returns ====
</div>
+
:Success - RLPy.RStatus.Success
-----
+
:Failure - RLPy.RStatus.Failure
===RemoveKey===
+
 
<syntaxhighlight lang="Python">
+
<syntaxhighlight lang="python" line='line'>
RLPy.RControl.RemoveKey ( self, kTime )
+
# move key
 +
control = avatar.GetControl("Transform")
 +
 
 +
control.MoveKey(RLPy.RTime(0), RLPy.RTime(100))
 +
control.GetKeyAt(0, key1)
 +
print(key1.GetTime().GetValue())   #100
 
</syntaxhighlight>
 
</syntaxhighlight>
Remove one key from the control by time.
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''kTime''' [IN] Specifies the time to remove key - RLPy.RTime
+
=== RemoveKey ( self, kTime ) ===
</div>
+
 
====Return Values====
+
Remove an animation key at a given time.
<div style="margin-left: 2em;">
+
 
 +
See Also: [[#ClearKeys ( self )|ClearKeys]], [[#RemoveKeyAt ( self, nIndex )|RemoveKeyAt]]
 +
 
 +
==== Parameters ====
 +
:'''kTime''' [IN] Specified time - [[IC_Python_API:RLPy_RTime|RTime]]
  
'''RLPy.RStatus.Success''' Success
+
==== Returns ====
 +
:Success - RLPy.RStatus.Success
 +
:Failure - RLPy.RStatus.Failure
  
'''RLPy.RStatus.Failure''' Fail
+
<syntaxhighlight lang="python" line='line'>
</div>
+
# remove key
-----
+
control = avatar.GetControl("Transform")
===RemoveKeyAt===
+
control.RemoveKey(RLPy.RTime(100))
<syntaxhighlight lang="Python">
+
print(control.GetKeyCount())
RLPy.RControl.RemoveKeyAt ( self, nIndex )
+
 
</syntaxhighlight>
 
</syntaxhighlight>
Remove one key by index.
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''nIndex''' [IN] Index of the key. (starting from zero) - int
+
=== RemoveKeyAt ( self, nIndex ) ===
</div>
+
====Return Values====
+
<div style="margin-left: 2em;">
+
  
'''RLPy.RStatus.Success''' Success
+
Remove an animation key by index.
  
'''RLPy.RStatus.Failure''' Fail
+
See Also: [[#ClearKeys ( self )|ClearKeys]], [[#RemoveKey ( self, kTime )|RemoveKey]]
</div>
+
 
-----
+
==== Parameters ====
===SetKeyTransition===
+
:'''nIndex''' [IN] Key index (starts from 0) - int
<syntaxhighlight lang="Python">
+
 
RLPy.RControl.SetKeyTransition ( self, kTime, eType, fStrength )
+
==== Returns ====
 +
:Success - RLPy.RStatus.Success
 +
:Failure - RLPy.RStatus.Failure
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
# remove key
 +
control = avatar.GetControl("Transform")
 +
control.RemoveKey(RLPy.RTime(100))
 
</syntaxhighlight>
 
</syntaxhighlight>
Set transition type and strength of the key.
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''kTime''' [IN] Specifies the time to set transition type - RLPy.RTime
+
=== SetKeyTransition ( self, kTime, eType, fStrength ) ===
  
'''eType''' [IN] Transition type of the key - RLPy.ETransitionType
+
Set the transition type and strength of a key at a given time.
*'''RLPy.ETransitionType_Invalid Invalid value.
+
*'''RLPy.ETransitionType_None None.
+
*'''RLPy.ETransitionType_Linear Linear.
+
*'''RLPy.ETransitionType_Step Step.
+
*'''RLPy.ETransitionType_Ease_Out Ease out.
+
*'''RLPy.ETransitionType_Ease_In Ease in.
+
*'''RLPy.ETransitionType_Ease_Out_In Ease out in.
+
*'''RLPy.ETransitionType_Ease_In_Out Ease in out.
+
*'''RLPy.ETransitionType_Ease_In_Sine Ease in sine.
+
*'''RLPy.ETransitionType_Ease_Out_Sine Ease out sine.
+
*'''RLPy.ETransitionType_Ease_In_Out_Sine Ease in out sine.
+
*'''RLPy.ETransitionType_Ease_In_Quad Ease in quad.
+
*'''RLPy.ETransitionType_Ease_Out_Quad Ease out quad.
+
*'''RLPy.ETransitionType_Ease_In_Out_Quad Ease in out quad.
+
*'''RLPy.ETransitionType_Ease_In_Cubic Ease in cubic.
+
*'''RLPy.ETransitionType_Ease_Out_Cubic Ease in out cubic.
+
*'''RLPy.ETransitionType_Ease_In_Out_Cubic Ease in out cubic.
+
*'''RLPy.ETransitionType_Ease_In_Quart Ease in quart.
+
*'''RLPy.ETransitionType_Ease_Out_Quart Ease out quart.
+
*'''RLPy.ETransitionType_Ease_In_Out_Quart Ease in out quart.
+
*'''RLPy.ETransitionType_Ease_In_Quint Ease in quint.
+
*'''RLPy.ETransitionType_Ease_Out_Quint Ease out quint.
+
*'''RLPy.ETransitionType_Ease_In_Out_Quint Ease in out quint.
+
*'''RLPy.ETransitionType_Ease_In_Expo Ease in expo.
+
*'''RLPy.ETransitionType_Ease_Out_Expo Ease out expo.
+
*'''RLPy.ETransitionType_Ease_In_Out_Expo Ease in out expo.
+
*'''RLPy.ETransitionType_Ease_In_Circ Ease in circ.
+
*'''RLPy.ETransitionType_Ease_Out_Circ Ease out circ.
+
*'''RLPy.ETransitionType_Ease_In_Out_Circ Ease in out circ.
+
*'''RLPy.ETransitionType_Ease_In_Back Ease in back.
+
*'''RLPy.ETransitionType_Ease_Out_Back Ease out back.
+
*'''RLPy.ETransitionType_Ease_In_Out_Back Ease in out back.
+
*'''RLPy.ETransitionType_Ease_In_Elastic Ease in elastic.
+
*'''RLPy.ETransitionType_Ease_Out_Elastic Ease out elastic.
+
*'''RLPy.ETransitionType_Ease_In_Out_Elastic Ease in out elastic.
+
*'''RLPy.ETransitionType_Ease_In_Bounce Ease in bounce.
+
*'''RLPy.ETransitionType_Ease_Out_Bounce Ease out bounce.
+
*'''RLPy.ETransitionType_Ease_In_Out_Bounce Ease in out bounce.
+
*'''RLPy.ETransitionType_Last Last.
+
*'''RLPy.ETransitionType_Count'''
+
  
'''fStrength''' [IN] Transition strength of the key. The strength range is from 0 to 100, 50 is default value - float
+
See Also: [[#GetKeyTransitionType ( self, kTime )|GetKeyTransitionType]], [[#GetKeyTransitionStrength ( self, kTime )|GetKeyTransitionStrength]]
</div>
+
====Return Values====
+
<div style="margin-left: 2em;">
+
  
'''RLPy.RStatus.Success''' Success
+
==== Parameters ====
 +
:'''kTime''' [IN] Specified time - [[IC_Python_API:RLPy_RTime|RTime]]
 +
:'''eType''' [IN] Transition Type.
 +
:'''fStrength''' [IN] Transition strength (default: 50) - float [0,100]
  
'''RLPy.RStatus.Failure''' Fail
+
==== Returns ====
</div>
+
:Success - RLPy.RStatus.Success
 +
:Failure - RLPy.RStatus.Failure
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
# set transition
 +
control = avatar.GetControl("Transform")
 +
control.SetKeyTransition(RLPy.RTime(1000), RLPy.ETransitionType_Step, 1.0)
 +
</syntaxhighlight>

Revision as of 22:29, 20 April 2020

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

Description

Controllers are used to manage animations and create animation effects, which will give a key value when fed a time. This is the base class for all controller related classes which are distinquished according to different data types that they record and deal with: RTransformControl dealing with transform data types and RFloatControl for float data types. Controllers mainly use keyframes to record animations and create keys; and has the ability to interpolate values between keys.

Use GetKeyCount, GetKeyIndex, GetKeyTimeAt, and MaxControlTime to retrieve key data within controllers. Use AddKey, ClearKeys, MoveKey, RemoveKey, and RemoveKeyAt to delete or change key data. Additional functions are available for managing key transition data.

See Also: RTransformControl, RFloatControl

Inheritance

RControl > RFloatControl | RTransformControl 

Member Functions

AddKey ( self, pKey, fFps )

Create a new key data at the designated time. If a key already exists at the given time, then it is replaced.

See Also: ClearKeys, RemoveKey, RemoveKeyAt

Parameters

pKey [IN] Data for the new Key - RKey
fFps [IN] Frame per second - float

Return

Success - RLPy.RStatus.Success
Failure - RLPy.RStatus.Failure
1 # add key
2 control = avatar.GetControl("Transform") 
3 key = RLPy.RTransformKey()
4 key.SetTime(RLPy.RTime(0))
5 key.SetTransform(RLPy.RTransform.IDENTITY)
6 control.AddKey(key, RLPy.RGlobal.GetFps())

ClearKeys ( self )

Remove all keys on this controller.

See Also: RemoveKey, RemoveKeyAt, AddKey

Returns

Success - RLPy.RStatus.Success
Failure - RLPy.RStatus.Failure
1 # clear key
2 control = avatar.GetControl("Transform") 
3 control.ClearKeys()
4 print(control.HasKeys())        # False

Clone ( self )

Copy this controller and return a duplicate.

Returns

The duplicated controller - RLPy. RControl
1 # clone control
2 control = avatar.GetControl("Transform") 
3 cloned_control = control.Clone()

GetDataBlock ( self )

Get the data block on this controller.

Returns

The controller's data block - RDataBlock
1 # get datablock
2 control = avatar.GetControl("Transform") 
3 datablock = control.GetDataBlock()

GetKeyCount ( self )

Get the total number of keys in this controller. To check for existence of a key use Haskey() instead.

See Also: HasKeys

Returns

Total number of keys in this controller - int
1 # get key count
2 control = avatar.GetControl("Transform") 
3 key_count = control.GetKeyCount();

GetKeyIndex ( self, kTime, nIndex )

Get the key index at a given time (starting from 0). If the controller does not contain key data or the corresponding key is not found then return RStatus.Failure.

See Also: GetKeyTimeAt

Parameters

kTime [IN] The specified time - RTime
nIdx [OUT] Returns the Key index - int

Returns

Success - RLPy.RStatus.Success
Failure - RLPy.RStatus.Failure
1 # get key count
2 control = avatar.GetControl("Transform") 
3 key_index = -1
4 ret_list = control.GetKeyIndex(RLPy.RTime(1000), key_index)
5 key_index = ret_list[1]
6 print(key_index)

GetKeyTimeAt ( self, uIndex, kTime )

Get the key time at a given key index.

See Also: GetKeyIndex

Parameters

uIndex [IN] Key Index (Index value starts from zero) - int
kTime [OUT] Return the Key’s time value - RTime

Returns

Success - RLPy.RStatus.Success
Failure - RLPy.RStatus.Failure
1 # get key time
2 control = avatar.GetControl("Transform") 
3 time = RLPy.RTime()
4 control.GetKeyTimeAt(1, time)
5 print(time.GetValue())

GetKeyTransitionStrength ( self, kTime )

Get the transition strength on this controller at a given time.

See Also: GetKeyTransitionStrength, RKey.SetTransitionStrength()

Parameters

kTime [IN] Specified time - RTime

Returns

Key transition strength (default:50) - float [0,100]
1 # get transition strength
2 control = avatar.GetControl("Transform") 
3 Strength = control.GetKeyTransitionStrength(RLPy.RTime(0))

GetKeyTransitionType ( self, kTime )

Get the transition type on this controller at a given time.

See Also: SetKeyTransition, RKey.GetTransitionType()

Parameters

kTime [IN] Specified time - RTime

Returns

Returns the Transition type - RLPy.ETransitionType
1 # get transition type
2 control = avatar.GetControl("Transform") 
3 transition_type = control.GetKeyTransitionType(RLPy.RTime(0))
4 if transition_type == RLPy.ETransitionType_Step:
5     print("Transition Type: Step")

HasKeys ( self )

Check if this controller has a key.

See Also: GetKeyCount

Returns

True if the control has at least one key, else False.
1 # get transition strength
2 control = avatar.GetControl("Transform") 
3 has_key = control.HasKeys();

MaxControlTime ( self )

Get this controller's final key time. If a key does not exist then return 0.

Returns

The maximum time of the control - RTime
1 # get last key time
2 control = avatar.GetControl("Transform") 
3 key_time = control.MaxControlTime();

MoveKey ( self, kTime, kOffsetTime )

Offset an animation key at a given time by a duration. The offset key will replace any existing key at the new position.

Parameters

kTime [IN] Specified time - RTime
kOffsetTime [IN] Offset the Key by a specified time - RTime

Returns

Success - RLPy.RStatus.Success
Failure - RLPy.RStatus.Failure
1 # move key
2 control = avatar.GetControl("Transform") 
3 
4 control.MoveKey(RLPy.RTime(0), RLPy.RTime(100))
5 control.GetKeyAt(0, key1)
6 print(key1.GetTime().GetValue())    #100

RemoveKey ( self, kTime )

Remove an animation key at a given time.

See Also: ClearKeys, RemoveKeyAt

Parameters

kTime [IN] Specified time - RTime

Returns

Success - RLPy.RStatus.Success
Failure - RLPy.RStatus.Failure
1 # remove key
2 control = avatar.GetControl("Transform") 
3 control.RemoveKey(RLPy.RTime(100))
4 print(control.GetKeyCount())

RemoveKeyAt ( self, nIndex )

Remove an animation key by index.

See Also: ClearKeys, RemoveKey

Parameters

nIndex [IN] Key index (starts from 0) - int

Returns

Success - RLPy.RStatus.Success
Failure - RLPy.RStatus.Failure
1 # remove key
2 control = avatar.GetControl("Transform") 
3 control.RemoveKey(RLPy.RTime(100))

SetKeyTransition ( self, kTime, eType, fStrength )

Set the transition type and strength of a key at a given time.

See Also: GetKeyTransitionType, GetKeyTransitionStrength

Parameters

kTime [IN] Specified time - RTime
eType [IN] Transition Type.
fStrength [IN] Transition strength (default: 50) - float [0,100]

Returns

Success - RLPy.RStatus.Success
Failure - RLPy.RStatus.Failure
1 # set transition
2 control = avatar.GetControl("Transform") 
3 control.SetKeyTransition(RLPy.RTime(1000), RLPy.ETransitionType_Step, 1.0)