IC Python API:RLPy RControl
Contents
- 1 Description
- 2 Member Functions
- 2.1 AddKey ( self, pKey, fFps )
- 2.2 ClearKeys ( self )
- 2.3 Clone ( self )
- 2.4 GetDataBlock ( self )
- 2.5 GetKeyCount ( self )
- 2.6 GetKeyIndex ( self, kTime, nIndex )
- 2.7 GetKeyTimeAt ( self, uIndex, kTime )
- 2.8 GetKeyTransitionStrength ( self, kTime )
- 2.9 GetKeyTransitionType ( self, kTime )
- 2.10 HasKeys ( self )
- 2.11 MaxControlTime ( self )
- 2.12 MoveKey ( self, kTime, kOffsetTime )
- 2.13 RemoveKey ( self, kTime )
- 2.14 RemoveKeyAt ( self, nIndex )
- 2.15 SetKeyTransition ( self, kTime, eType, fStrength )
- 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
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)