IC8 Python API:RLPy RControl

From Reallusion Wiki!
Jump to: navigation, search
Main article: iC8 Modules.
Last modified: 01/3/2023

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 distinguished 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 key-frames 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.

Class Methods

RLPy.RControl.AddKey(self, pKey)

Add one key.

Parameters

pKey[IN] The key to be added - RLPy.RKey
fFps[IN] Frame per second.

Returns

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

RLPy.RControl.ClearKeys(self)

Clear (remove) all keys.

Returns

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

RLPy.RControl.Clone(self)

Clone the control.

Supports cloning, which creates a new instance of a class with the same value as an existing instance.

Returns

Pointer to RControl - RLPy. RControl

1 # clone control
2 control = avatar.GetControl("Transform") 
3 cloned_control = control.Clone()

RLPy.RControl.GetDataBlock(self)

Get data block from the control.

Returns

Pointer to data block of the control - RLPy.RDataBlock

1 # get datablock
2 control = avatar.GetControl("Transform") 
3 datablock = control.GetDataBlock()

RLPy.RControl.GetKeyCount(self)

Get the number of keys of the control.

Returns

The number of keys of the control - int

1 # get key count
2 control = avatar.GetControl("Transform") 
3 key_count = control.GetKeyCount();

RLPy.RControl.GetKeyIndex(self, kTick, nIdx)

Get key index by time.

Parameters

kTime[IN] Specifies the time to get key index.

nIdx[OUT] Index of the key - int

Returns

RLPy.RStatus.Success - Succeed
RLPy.RStatus.Failure - Fail
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)

RLPy.RControl.GetKeyTimeAt(self, uIndex, kTick)

Get key's time by index.

Parameters

uIndex[IN] Index of the key. (starting from zero) - int

kTime[OUT] Time of the key specified by uIndex.

Returns

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

RLPy.RControl.HasKeys(self)

Check whether the control has key.

Returns

trueControl has at least one key. falseControl has no key.

1 # get transition strength
2 control = avatar.GetControl("Transform") 
3 has_key = control.HasKeys();

RLPy.RControl.MaxControlTime(self)

Get maximum time of the control.

Returns

The maximum time of the control - RLPy.RLTime

1 # get last key time
2 control = avatar.GetControl("Transform") 
3 key_time = control.MaxControlTime();

RLPy.RControl.MoveKey(self, kTick, kOffsetTick)

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

kTime[IN] Specifies the time to move key.
kOffsetTime[IN] The offset time.

Returns

RLPy.RStatus.Success - Succeed
RLPy.RStatus.Failure - Fail
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

RLPy.RControl.RemoveKey(self, kTick)

Remove one key from the control by time.

Parameters

kTime[IN] Specifies the time to remove key.

Returns

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

RLPy.RControl.RemoveKeyAt(self, nIndex)

Remove one key by index.

Parameters

nIndex[IN] Index of the key. (starting from zero) - int

Returns

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

RLPy.RControl.SetKeyTransition(self, kTick, eType, fStrength)

Set transition type and strength of the key.

Parameters

kTime[IN] Specifies the time to set transition type.
eType[IN] Transition type of the key - RLPy.ETransitionType
  • 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

Returns

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