IC Python API:RLPy RIFaceComponent

From Reallusion Wiki!
Revision as of 00:54, 21 April 2020 by Chuck (RL) (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Main article: Modules.
Last modified: 04/21/2020

Description

This class is mainly used to set up the character's facial and head controls. RIFaceComponent data include 12 facial bones, 60 facial morphs and 24 custom morphs. You can open the details panel in the Face Puppet interface and press Ctrl+F2 to display more detailed data. The numbered data in the front are the 60 morphs data, the next are 12 facial bones data, while the rest belong to the custom set. A few of the bones within the 12 facial bones have no effect. You can tell if it has no effect, therefore invalid, if the data name is marked "N/A". In addition, an expression clip needs to be set up in order to create expression keys.

Inheritance

RIBase > RIFaceComponent 

Member Functions

AddClip ( self, kTime, strName, kLength )

Create a new expression clip.

See Also: GetKey, AddEyeKey, AddHeadKey, AddExpressionKey

Parameters

kTime [IN] Clip start time - RTime
strName [IN] Clip name - string
kLength [IN] Clip length - RTime

Return

Success - RLPy.RStatus.Success
Failure - RLPy.RStatus.Failure
1 # Add Expression Clip
2 avatar_list = RLPy.RScene.GetAvatars()
3 avatar = avatar_list[0]
4 face_component = avatar.GetFaceComponent()
5 
6 result = face_component.AddClip(RLPy.RTime(0), "Clip", RLPy.RTime(10))
7 print(result)

AddExpressionKey ( self, kTime, kMorph, kBone, kCustom, fStrength )

Create a new expression key at a given time.

See Also: GetKey, AddEyeKey, AddHeadKey

Parameters

kTime [IN] Set the key time - RTime
kMorph [IN] Facial Morph 60 individual parameters - RLPy.FloatVector
kCustom [IN] Custom 24 individual parameters - RLPy.FloatVector
kBone [IN] Facial Bone 12 individual parameters - RLPy.FloatVector
fStrength [IN] Facial part adjustment strength, 0 strength equals no effect - float [0.0,1.0]

Return

Success - RLPy.RStatus.Success
Failure - RLPy.RStatus.Failure
 1 # Add Expression Key
 2 avatar_list = RLPy.RScene.GetAvatars()
 3 avatar = avatar_list[0]
 4 face_component = avatar.GetFaceComponent()
 5 morph  = RLPy.FloatVector()
 6 bone   = RLPy.FloatVector()
 7 custom = RLPy.FloatVector()
 8 morph.resize(60)
 9 bone.resize(12)
10 custom.resize(24)
11 bone[9] = 0.5
12 bone[10] = 0.5
13 weight = 0.99
14 face_component.AddExpressionKey( RLPy.RTime(0), morph, bone, custom, weight )

AddEyeKey ( self, kTime, kLeftEye, kRightEye )

Move the eye vertically/horizontally.

See Also: GetKey, AddHeadKey, AddExpressionKey

Parameters

kTime [IN] Key time - RTime
kLeftEye [IN] Horiztonal and vertical movement of the left eye - RLPy.FloatVector [0.0,1.0]
kRightEye [IN] Horiztonal and vertical movement of the right eye - RLPy.FloatVector [0.0,1.0]

Return

Success - RLPy.RStatus.Success
Failure - RLPy.RStatus.Failure
1 # Add Eye Key
2 avatar_list = RLPy.RScene.GetAvatars()
3 avatar = avatar_list[0]
4 face_component = avatar.GetFaceComponent()
5 eye_l = [ 0.2, 0.2 ] #[ Horizontal, Vertical ]
6 eye_r = [ 0.2, 0.2 ] #[ Horizontal, Vertical ]
7 result = face_component.AddEyeKey( RLPy.RTime( 0 ), eye_l, eye_r )
8 print(result)

AddHeadKey ( self, kTime, kHead )

Controls head rotations.

See Also: GetKey, AddEyeKey, AddExpressionKey

Parameters

kTime [IN] Key time - RTime
kHead [IN] Horizontal and vertical tilt data for the head - float list [0.0,1.0]

Return

Success - RLPy.RStatus.Success
Failure - RLPy.RStatus.Failure
1 # Add Head Key
2 avatar_list = RLPy.RScene.GetAvatars()
3 avatar = avatar_list[0]
4 face_component = avatar.GetFaceComponent()
5 result = face_component.AddHeadKey( RLPy.RTime( 0 ), [ 0.1, 0.4, 0.8 ] ) 
6 #[ Vertical, Horizontal, Tilt ]
7 print(result)

GetKey ( self, kTime, kHead, kLeftEye, kRightEye, kMorph, kBone, kCustom, fStrength )

Get all key data for an expression.

See Also: AddEyeKey, AddHeadKey, AddExpressionKey

Parameters

kTime [IN] Key time - RTime
kHead [OUT] Head horizontal and vertical tilt data - float list
kLeftEye [OUT] Horiztonal and vertical movement of the left eye - RLPy.FloatVector [0.0,1.0]
kRightEye [OUT] Horizontal and vertical movement of the right eye - RLPy.FloatVector [0.0,1.0]
kMorph [IN] Facial Morph 60 parameter values - RLPy.FloatVector
kCustom [IN] Custom 24 parameter values- RLPy.FloatVector
kBone [IN] Facial Bone 12 parameter values - RLPy.FloatVector
fStrength [IN] Face morph strength (0: no change) - float

Return

Success - RLPy.RStatus.Success
Failure - RLPy.RStatus.Failure
 1 # Get facial Key
 2 avatar_list = RLPy.RScene.GetAvatars()
 3 avatar = avatar_list[0]
 4 face_component = avatar.GetFaceComponent()
 5 # Get current facial key
 6 head      = RLPy.FloatVector() # reference variable
 7 left_eye  = RLPy.FloatVector()
 8 right_eye = RLPy.FloatVector()
 9 morph     = RLPy.FloatVector()
10 custom    = RLPy.FloatVector()
11 bone      = RLPy.FloatVector()
12 weight = 0.0
13 result = face_component.GetKey(time, head, left_eye, right_eye, morph, custom, bone, weight)
14 print(result[0]) # RStatus: result[0]
15 print(result[1]) # weight: result[1]
16 print(head)      # head weight
17 print(left_eye)  # left eye weight
18 print(right_eye) # right eye weight
19 print(morph)     # morph weight
20 print(custom)    # custom weight
21 print(bone)      # bone weight