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

From Reallusion Wiki!
Jump to: navigation, search
m
m
Line 8: Line 8:
  
 
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.
 
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.
 
See Also: [[IC_Python_API:RLPy_RTransformControl|RTransformControl]], [[IC_Python_API:RLPy_RFloatControl|RFloatControl]]
 
  
 
=== Inheritance ===
 
=== Inheritance ===
Line 62: Line 60:
  
 
==== Returns ====
 
==== Returns ====
:The duplicated controller - RLPy. [[IC_Python_API:RLPy_RControl|RControl]]  
+
:The duplicated controller - [[IC_Python_API:RLPy_RControl|RControl]]  
  
 
<syntaxhighlight lang="python" line='line'>
 
<syntaxhighlight lang="python" line='line'>
Line 90: Line 88:
  
 
==== Returns ====
 
==== Returns ====
:Total number of keys in this controller - int
+
:Total number of keys in this controller - integer
  
 
<syntaxhighlight lang="python" line='line'>
 
<syntaxhighlight lang="python" line='line'>
Line 106: Line 104:
 
==== Parameters ====
 
==== Parameters ====
 
:'''kTime''' [IN] The specified time - [[IC_Python_API:RLPy_RTime|RTime]]  
 
:'''kTime''' [IN] The specified time - [[IC_Python_API:RLPy_RTime|RTime]]  
:'''nIdx''' [OUT] Returns the Key index - int
+
:'''nIdx''' [OUT] Returns the Key index - integer
  
 
==== Returns ====
 
==== Returns ====
Line 128: Line 126:
  
 
==== Parameters ====
 
==== Parameters ====
:'''uIndex''' [IN] Key Index (Index value starts from zero) - int
+
:'''uIndex''' [IN] Key Index (Index value starts from zero) - integer
 
:'''kTime''' [OUT] Return the Key’s time value - [[IC_Python_API:RLPy_RTime|RTime]]  
 
:'''kTime''' [OUT] Return the Key’s time value - [[IC_Python_API:RLPy_RTime|RTime]]  
  
Line 171: Line 169:
  
 
==== Returns ====
 
==== Returns ====
:Returns the Transition type - RLPy.ETransitionType
+
:Returns the Transition type - [[IC_Python_API:Enums#RLPy.ETransitionType|RLPy.ETransitionType]]
  
 
<syntaxhighlight lang="python" line='line'>
 
<syntaxhighlight lang="python" line='line'>
Line 257: Line 255:
  
 
==== Parameters ====
 
==== Parameters ====
:'''nIndex''' [IN] Key index (starts from 0) - int
+
:'''nIndex''' [IN] Key index (starts from 0) - integer
  
 
==== Returns ====
 
==== Returns ====

Revision as of 20:55, 5 May 2020

Main article: Modules.
Last modified: 05/5/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.

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 - 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 - integer
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 - integer

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) - integer
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) - integer

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)