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

From Reallusion Wiki!
Jump to: navigation, search
(Created page with "{{TOC}} {{Parent|IC_Python_API:RL_Python_Modules|Modules}} ==Inheritance== This class inherits public member functions from: *RLPy.RIBase ==Detai...")
 
m
 
Line 1: Line 1:
 
{{TOC}}
 
{{TOC}}
 
{{Parent|IC_Python_API:RL_Python_Modules|Modules}}
 
{{Parent|IC_Python_API:RL_Python_Modules|Modules}}
==Inheritance==
+
{{last_modified}}
This class inherits public member functions from:
+
*[[IC_Python_API:RLPy_RIBase|RLPy.RIBase]]
+
==Detailed Description==
+
This class is the interface to the face key in the avatar.
+
<span style="background:#ffcccc">( Experimental Class )</span> <syntaxhighlight lang="Python">
+
# Get face component
+
avatar_list = RLPy.RScene.GetAvatars()
+
avatar = avatar_list[0]
+
face_component = avatar.GetFaceComponent()
+
  
# Add facial clip
+
== Description ==
time = RLPy.RGlobal.GetTime()
+
clip_name = "New Clip"
+
clip_length = RLPy.RTime(50)
+
result = face_component.AddClip(time, clip_name, clip_length)
+
print(result)
+
  
# Get current facial key
+
This class is mainly used to set up the character's facial and head controls. [[IC_Python_API:RLPy_RIFaceComponent|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.
head = RLPy.FloatVector()
+
left_eye = RLPy.FloatVector()
+
right_eye = RLPy.FloatVector()
+
morph = RLPy.FloatVector()
+
custom = RLPy.FloatVector()
+
bone = RLPy.FloatVector()
+
weight = 0.0
+
result = face_component.GetKey(time, head, left_eye, right_eye, morph, custom, bone, weight)
+
print(result[0]) # RStatus: result[0]
+
print(result[1]) # weight: result[1]
+
print(head) # head weight
+
print(left_eye) # left eye weight
+
print(right_eye) # right eye weight
+
print(morph) # morph weight
+
print(custom) # custom weight
+
print(bone) # bone weight
+
  
#Add expression key
+
=== Inheritance ===
morph = RLPy.FloatVector()
+
bone = RLPy.FloatVector()
+
custom = RLPy.FloatVector()
+
morph.resize(60)
+
bone.resize(12)
+
custom.resize(24)
+
result = face_component.AddExpressionKey( RLPy.RTime( 0 ), morph, bone, custom, 1 )
+
print(result)
+
  
#Add eye key
+
[[IC_Python_API:RLPy_RIBase|RIBase]] > [[IC_Python_API:RLPy_RIFaceComponent|RIFaceComponent]]  
eye_l = [ 0.2, 0.2 ] #[ Horizontal, Vertical ]
+
eye_r = [ 0.2, 0.2 ] #[ Horizontal, Vertical ]
+
result = face_component.AddEyeKey( RLPy.RTime( 0 ), eye_l, eye_r )
+
print(result)
+
  
#Add head key
+
== Member Functions ==
result = face_component.AddHeadKey( RLPy.RTime( 0 ), [ 0.1, 0.4, 0.8 ] ) #[ Vertical, Horizontal, Tilt ]
+
print(result)
+
</syntaxhighlight>
+
==Member Functions==
+
===AddClip===
+
<syntaxhighlight lang="Python">
+
RLPy.RIFaceComponent.AddClip ( self, kTime, strName, kLength )
+
</syntaxhighlight>
+
Add facial clip.
+
<span style="background:#ffcccc">( Experimental API )</span>
+
====Parameters====
+
<div style="margin-left: 2em;">
+
  
'''kTime''' [IN] The time at which to add the clip - RLPy.RTime
+
=== AddClip ( self, kTime, strName, kLength ) ===
  
'''strName''' [IN] Clip name - string
+
Create a new expression clip.
  
'''kLength''' [IN] Clip length - RLPy.RTime
+
See Also: [[#GetKey ( self, kTime, kHead, kLeftEye, kRightEye, kMorph, kBone, kCustom, fStrength )|GetKey]], [[#AddEyeKey ( self, kTime, kLeftEye, kRightEye )|AddEyeKey]], [[#AddHeadKey ( self, kTime, kHead )|AddHeadKey]], [[#AddExpressionKey ( self, kTime, kMorph, kBone, kCustom, fStrength )|AddExpressionKey]]
</div>
+
====Return Values====
+
<div style="margin-left: 2em;">
+
  
'''RLPy.RStatus.Success''' Success
+
==== Parameters ====
 +
:'''kTime''' [IN] Clip start time - [[IC_Python_API:RLPy_RTime|RTime]]
 +
:'''strName''' [IN] Clip name - string
 +
:'''kLength''' [IN] Clip length - [[IC_Python_API:RLPy_RTime|RTime]]
  
'''RLPy.RStatus.Failure''' Fail
+
==== Return ====
</div>
+
:Success - RLPy.RStatus.Success
-----
+
:Failure - RLPy.RStatus.Failure
===AddExpressionKey===
+
<syntaxhighlight lang="Python">
+
RLPy.RIFaceComponent.AddExpressionKey ( self, kTime, kMorph, kBone, kCustom, fStrength )
+
</syntaxhighlight>
+
Add an head key in Facial Layer.
+
<span style="background:#ffcccc">( Experimental API )</span>
+
====Parameters====
+
<div style="margin-left: 2em;">
+
  
'''kTime''' [IN] The time at which to add the key - RLPy.RTime
+
<syntaxhighlight lang="python" line='line'>
 +
# Add Expression Clip
 +
avatar_list = RLPy.RScene.GetAvatars()
 +
avatar = avatar_list[0]
 +
face_component = avatar.GetFaceComponent()
  
'''kMorph''' [IN] Morph weight - float
+
result = face_component.AddClip(RLPy.RTime(0), "Clip", RLPy.RTime(10))
 +
print(result)
 +
</syntaxhighlight>
  
'''kCustom''' [IN] Custom weight - float
+
=== AddExpressionKey ( self, kTime, kMorph, kBone, kCustom, fStrength ) ===
  
'''kBone''' [IN] Bone weight - float
+
Create a new expression key at a given time.
  
'''fStrength''' [IN] The strength of expression - float
+
See Also: [[#GetKey ( self, kTime, kHead, kLeftEye, kRightEye, kMorph, kBone, kCustom, fStrength )|GetKey]], [[#AddEyeKey ( self, kTime, kLeftEye, kRightEye )|AddEyeKey]], [[#AddHeadKey ( self, kTime, kHead )|AddHeadKey]]
</div>
+
====Return Values====
+
<div style="margin-left: 2em;">
+
  
'''RLPy.RStatus.Success''' Success
+
==== Parameters ====
 +
:'''kTime''' [IN] Set the key time - [[IC_Python_API:RLPy_RTime|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]
  
'''RLPy.RStatus.Failure''' Fail
+
==== Return ====
</div>
+
:Success - RLPy.RStatus.Success
-----
+
:Failure - RLPy.RStatus.Failure
===AddEyeKey===
+
 
<syntaxhighlight lang="Python">
+
<syntaxhighlight lang="python" line='line'>
RLPy.RIFaceComponent.AddEyeKey ( self, kTime, kLeftEye, kRightEye )
+
# Add Expression Key
 +
avatar_list = RLPy.RScene.GetAvatars()
 +
avatar = avatar_list[0]
 +
face_component = avatar.GetFaceComponent()
 +
morph  = RLPy.FloatVector()
 +
bone  = RLPy.FloatVector()
 +
custom = RLPy.FloatVector()
 +
morph.resize(60)
 +
bone.resize(12)
 +
custom.resize(24)
 +
bone[9] = 0.5
 +
bone[10] = 0.5
 +
weight = 0.99
 +
face_component.AddExpressionKey( RLPy.RTime(0), morph, bone, custom, weight )
 
</syntaxhighlight>
 
</syntaxhighlight>
Add an eye key in Facial Layer.
 
<span style="background:#ffcccc">( Experimental API )</span>
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''kTime''' [IN] The time at which to add the key - RLPy.RTime
+
=== AddEyeKey ( self, kTime, kLeftEye, kRightEye ) ===
  
'''kLeftEye''' [IN] Left eye weight - float
+
Move the eye vertically/horizontally.
  
'''kRightEye''' [IN] Right eye weight - float
+
See Also: [[#GetKey ( self, kTime, kHead, kLeftEye, kRightEye, kMorph, kBone, kCustom, fStrength )|GetKey]], [[#AddHeadKey ( self, kTime, kHead )|AddHeadKey]], [[#AddExpressionKey ( self, kTime, kMorph, kBone, kCustom, fStrength )|AddExpressionKey]]
</div>
+
====Return Values====
+
<div style="margin-left: 2em;">
+
  
'''RLPy.RStatus.Success''' Success
+
==== Parameters ====
 +
:'''kTime''' [IN] Key time - [[IC_Python_API:RLPy_RTime|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]
  
'''RLPy.RStatus.Failure''' Fail
+
==== Return ====
</div>
+
:Success - RLPy.RStatus.Success
-----
+
:Failure - RLPy.RStatus.Failure
===AddHeadKey===
+
 
<syntaxhighlight lang="Python">
+
<syntaxhighlight lang="python" line='line'>
RLPy.RIFaceComponent.AddHeadKey ( self, kTime, kHead )
+
# Add Eye Key
 +
avatar_list = RLPy.RScene.GetAvatars()
 +
avatar = avatar_list[0]
 +
face_component = avatar.GetFaceComponent()
 +
eye_l = [ 0.2, 0.2 ] #[ Horizontal, Vertical ]
 +
eye_r = [ 0.2, 0.2 ] #[ Horizontal, Vertical ]
 +
result = face_component.AddEyeKey( RLPy.RTime( 0 ), eye_l, eye_r )
 +
print(result)
 
</syntaxhighlight>
 
</syntaxhighlight>
Add an head key in Facial Layer.
 
<span style="background:#ffcccc">( Experimental API )</span>
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''kTime''' [IN] The time at which to add the key - RLPy.RTime
+
=== AddHeadKey ( self, kTime, kHead ) ===
  
'''kHead''' [IN] Head rotate weight - float
+
Controls head rotations.
</div>
+
====Return Values====
+
<div style="margin-left: 2em;">
+
  
'''RLPy.RStatus.Success''' Success
+
See Also: [[#GetKey ( self, kTime, kHead, kLeftEye, kRightEye, kMorph, kBone, kCustom, fStrength )|GetKey]], [[#AddEyeKey ( self, kTime, kLeftEye, kRightEye )|AddEyeKey]], [[#AddExpressionKey ( self, kTime, kMorph, kBone, kCustom, fStrength )|AddExpressionKey]]
  
'''RLPy.RStatus.Failure''' Fail
+
==== Parameters ====
</div>
+
:'''kTime''' [IN] Key time - [[IC_Python_API:RLPy_RTime|RTime]]
-----
+
:'''kHead''' [IN] Horizontal and vertical tilt data for the head - float list [0.0,1.0]
===GetKey===
+
<syntaxhighlight lang="Python">
+
RLPy.RIFaceComponent.GetKey ( self, kTime, kHead, kLeftEye, kRightEye, kMorph, kBone, kCustom, fStrength )
+
</syntaxhighlight>
+
Get facial key with expressiveness.
+
<span style="background:#ffcccc">( Experimental API )</span>
+
====Parameters====
+
<div style="margin-left: 2em;">
+
  
'''kTime''' [IN] The time at which to get the key - RLPy.RTime
+
==== Return ====
 +
:Success - RLPy.RStatus.Success
 +
:Failure - RLPy.RStatus.Failure
  
'''kHead''' [OUT] Head weight - float
+
<syntaxhighlight lang="python" line='line'>
 +
# Add Head Key
 +
avatar_list = RLPy.RScene.GetAvatars()
 +
avatar = avatar_list[0]
 +
face_component = avatar.GetFaceComponent()
 +
result = face_component.AddHeadKey( RLPy.RTime( 0 ), [ 0.1, 0.4, 0.8 ] )
 +
#[ Vertical, Horizontal, Tilt ]
 +
print(result)
 +
</syntaxhighlight>
  
'''kLeftEye''' [OUT] Left eye weight - float
+
=== GetKey ( self, kTime, kHead, kLeftEye, kRightEye, kMorph, kBone, kCustom, fStrength ) ===
  
'''kRightEye''' [OUT] Right eye weight - float
+
Get all key data for an expression.
  
'''kMorph''' [INOUT Morph weight - float
+
See Also: [[#AddEyeKey ( self, kTime, kLeftEye, kRightEye )|AddEyeKey]], [[#AddHeadKey ( self, kTime, kHead )|AddHeadKey]], [[#AddExpressionKey ( self, kTime, kMorph, kBone, kCustom, fStrength )|AddExpressionKey]]
  
'''kBone''' [OUT] Bone weight - float
+
==== Parameters ====
 +
:'''kTime''' [IN] Key time - [[IC_Python_API:RLPy_RTime|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
  
'''kCustom''' [OUT] Custom weight - float
+
==== Return ====
 +
:Success - RLPy.RStatus.Success
 +
:Failure - RLPy.RStatus.Failure
  
'''fStrength''' [OUT] The strength of expression - float
+
<syntaxhighlight lang="python" line='line'>
</div>
+
# Get facial Key
====Return Values====
+
avatar_list = RLPy.RScene.GetAvatars()
<div style="margin-left: 2em;">
+
avatar = avatar_list[0]
 
+
face_component = avatar.GetFaceComponent()
'''RLPy.RStatus.Success''' Success
+
# Get current facial key
 
+
head      = RLPy.FloatVector() # reference variable
'''RLPy.RStatus.Failure''' Fail
+
left_eye  = RLPy.FloatVector()
</div>
+
right_eye = RLPy.FloatVector()
 +
morph    = RLPy.FloatVector()
 +
custom    = RLPy.FloatVector()
 +
bone      = RLPy.FloatVector()
 +
weight = 0.0
 +
result = face_component.GetKey(time, head, left_eye, right_eye, morph, custom, bone, weight)
 +
print(result[0]) # RStatus: result[0]
 +
print(result[1]) # weight: result[1]
 +
print(head)      # head weight
 +
print(left_eye)  # left eye weight
 +
print(right_eye) # right eye weight
 +
print(morph)    # morph weight
 +
print(custom)    # custom weight
 +
print(bone)      # bone weight
 +
</syntaxhighlight>

Latest revision as of 00:54, 21 April 2020

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