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

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.RIObject *...")
 
m
 
(6 intermediate revisions by the same user not shown)
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_RIObject|RLPy.RIObject]]
+
== Description ==
*[[IC_Python_API:RLPy_RIBase|RLPy.RIBase]]
+
 
==Detailed Description==
+
This class provides methods to access all components of a character, for example: [[IC_Python_API:RLPy_RISkeletonComponent|RISkeletonComponent]], [[IC_Python_API:RLPy_RIVisemeComponent|RIVisemeComponent]], [[IC_Python_API:RLPy_RIFaceComponent|RIFaceComponent]], etc.  Retrieved component operations are thus available for usage.
This class is the interface to avatars in the scene.
+
 
It provides methods to access various parts of an avatar such as its
+
=== Inheritance ===
name, bones, etc. All methods of this class are implemented by the
+
 
system. <syntaxhighlight lang="Python">
+
[[IC_Python_API:RLPy_RINode|RINode]] > [[IC_Python_API:RLPy_RIObject|RIObject]] > [[IC_Python_API:RLPy_RIAvatar|RIAvatar]]
 +
 
 +
=== Examples ===
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 
avatar = RLPy.RScene.FindObject( RLPy.EObjectType_Avatar, "Jade" )
 
avatar = RLPy.RScene.FindObject( RLPy.EObjectType_Avatar, "Jade" )
  
# set name
+
# set the name of the character
 
avatar.SetName("new_name")
 
avatar.SetName("new_name")
  
# get Name
+
# Get the name of the character
 
avatar_name = avatar.GetName()
 
avatar_name = avatar.GetName()
 
print(avatar_name) # Jade
 
print(avatar_name) # Jade
 
 
# set Transform key
+
# Set a Transform key
 
control = avatar.GetControl("Transform")
 
control = avatar.GetControl("Transform")
 
transform = RLPy.RTransform.IDENTITY
 
transform = RLPy.RTransform.IDENTITY
Line 26: Line 30:
 
transform.T().z = 100.0
 
transform.T().z = 100.0
 
control.SetValue(RLPy.RTime(0), transform)
 
control.SetValue(RLPy.RTime(0), transform)
 
# get component
 
skeleton = avatar.GetSkeletonComponent()
 
print(skeleton.GetClipCount())
 
 
# set visible key
 
avatar.SetVisible(RLPy.RTime(600), False)
 
  
 +
# Link and unlink to other objects; iClone Avatar can't set Parent
 
prop2 = RLPy.RScene.FindObject(RLPy.EObjectType_Prop, "Box2")
 
prop2 = RLPy.RScene.FindObject(RLPy.EObjectType_Prop, "Box2")
# iClone Avatar can't set Parent
 
 
# link to & unlink
 
 
result = avatar.LinkTo(prop2, RLPy.RTime(0))
 
result = avatar.LinkTo(prop2, RLPy.RTime(0))
 
result = avatar.UnLink(RLPy.RTime(0))
 
result = avatar.UnLink(RLPy.RTime(0))
  
#get bound
+
# Get the bounds
 
ret_max = RLPy.RVector3()
 
ret_max = RLPy.RVector3()
 
ret_center = RLPy.RVector3()
 
ret_center = RLPy.RVector3()
Line 48: Line 43:
 
print(ret)
 
print(ret)
  
#get pivot
+
# Get the pivot point
 
ret_pos = RLPy.RVector3()
 
ret_pos = RLPy.RVector3()
 
ret_rot = RLPy.RVector3()
 
ret_rot = RLPy.RVector3()
Line 54: Line 49:
 
print(ret)
 
print(ret)
  
#clone object
+
# Clone the character
 
clone_avatar = avatar.Clone()
 
clone_avatar = avatar.Clone()
 
print( clone_avatar )
 
print( clone_avatar )
  
#is selected
+
# Check character selection
 
RLPy.RScene.SelectObject(avatar)
 
RLPy.RScene.SelectObject(avatar)
 
print(avatar.IsSelected()) #True
 
print(avatar.IsSelected()) #True
 
</syntaxhighlight>
 
</syntaxhighlight>
==Operators==
+
 
This class supports the following operators:
+
== Member Functions ==
{| class="wikitable"
+
 
!Member
+
=== SetVisible (self, kTime, bVisible ) ===
!Operation
+
 
!Syntax
+
Set a visibility key by a given time.
!Description
+
 
!Example
+
==== Parameters ====
|-
+
:'''kTime''' [IN] Time at which to change visibility - [[IC_Python_API:RLPy_RTime|RTime]]
! scope="row"|__eq__
+
:'''bVisible''' [IN] Visibility status - bool
|Equality
+
 
|a == b
+
==== Returns ====
|If the values of two operands are equal, then the condition becomes true.
+
:Success - RLPy.RStatus.Success
|(a == b) is not true.
+
:Failure - RLPy.RStatus.Failure
|}
+
 
==Member Functions==
+
<syntaxhighlight lang="python" line='line'>
===GetFaceComponent===
+
avatar_list = RLPy.RScene.GetAvatars()
<syntaxhighlight lang="Python">
+
avatar = avatar_list[0]   
RLPy.RIAvatar.GetFaceComponent ( self )
+
avatar.SetVisible(RLPy.RTime(0), True)
 +
avatar.SetVisible(RLPy.RTime(10), False)
 
</syntaxhighlight>
 
</syntaxhighlight>
Get face component of the object.
+
 
<span style="background:#ffcccc">( Experimental API )</span>
+
=== GetSkeletonComponent (self) ===
====Returns====
+
 
<div style="margin-left: 2em;">Pointer of the RIFaceComponent object - RLPy.RIFaceComponent
+
Get the character's Skeleton Component, used for retrieving the entire skeleton.
</div>
+
 
-----
+
See Also: [[IC_Python_API:RLPy_RISkeletonComponent|RISkeletonComponent]]
===GetHikEffectorComponent===
+
 
<syntaxhighlight lang="Python">
+
==== Returns ====
RLPy.RIAvatar.GetHikEffectorComponent ( self )
+
:Pointer to the Skeleton Component object - [[IC_Python_API:RLPy_RISkeletonComponent|RISkeletonComponent]]
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
avatar_list = RLPy.RScene.GetAvatars()
 +
avatar = avatar_list[0]   
 +
skeleton_component = avatar.GetSkeletonComponent()
 +
print(type(_component).__name__)
 +
print(skeleton.GetClipCount())
 
</syntaxhighlight>
 
</syntaxhighlight>
Get human IK effector component of the object.
+
 
====Returns====
+
=== GetVisemeComponent (self) ===
<div style="margin-left: 2em;">Pointer of the RIHikEffectorComponent object - RLPy.RIHikEffectorComponent
+
 
</div>
+
Get the character's Viseme Component, which provides operations related to lip-syncing.
-----
+
 
===GetMaterialComponent===
+
See Also: [[IC_Python_API:RLPy_RIVisemeComponent|RIVisemeComponent]]
<syntaxhighlight lang="Python">
+
 
RLPy.RIAvatar.GetMaterialComponent ( self )
+
==== Returns ====
 +
:Pointer to the Viseme Component object - [[IC_Python_API:RLPy_RIVisemeComponent|RIVisemeComponent]]
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
avatar_list = RLPy.RScene.GetAvatars()
 +
avatar = avatar_list[0]   
 +
viseme_component  = avatar.GetVisemeComponent()
 +
print(type(viseme_component).__name__)
 
</syntaxhighlight>
 
</syntaxhighlight>
Get material component of the object.
+
 
====Returns====
+
=== GetMorphComponent (self) ===
<div style="margin-left: 2em;">Pointer of the RIMaterialComponent object - RLPy.RIMaterialComponent
+
 
</div>
+
Get the character's Morph Component, used to edit Morph Animation Keys or retrieve the current morph weighting.
-----
+
 
===GetMorphComponent===
+
See Also: [[IC_Python_API:RLPy_RIMorphComponent|RIMorphComponent]]
<syntaxhighlight lang="Python">
+
 
RLPy.RIAvatar.GetMorphComponent ( self )
+
==== Returns ====
 +
:Pointer to the Morph Component object - [[IC_Python_API:RLPy_RIMorphComponent|RIMorphComponent]]
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
avatar_list = RLPy.RScene.GetAvatars()
 +
avatar = avatar_list[0]   
 +
morph_component  = avatar.GetMorphComponent()
 +
print(type(morph_component).__name__)
 
</syntaxhighlight>
 
</syntaxhighlight>
Get morph component of the object.
+
 
====Returns====
+
=== GetMaterialComponent (self) ===
<div style="margin-left: 2em;">Pointer of the RIMorphComponent object - RLPy.RIMorphComponent
+
 
</div>
+
Get the character's Material Component, used for setting material related parameter values.
-----
+
 
===GetSkeletonComponent===
+
See Also: [[IC_Python_API:RLPy_RIMaterialComponent|RIMaterialComponent]]
<syntaxhighlight lang="Python">
+
 
RLPy.RIAvatar.GetSkeletonComponent ( self )
+
==== Returns ====
 +
:Pointer to the Material Component object - [[IC_Python_API:RLPy_RIMaterialComponent|RIMaterialComponent]]
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
avatar_list = RLPy.RScene.GetAvatars()
 +
avatar = avatar_list[0]   
 +
material_component  = avatar.GetMaterialComponent()
 +
print(type(material_component).__name__)
 
</syntaxhighlight>
 
</syntaxhighlight>
Get bone component of the object.
+
 
====Returns====
+
=== GetHikEffectorComponent (self) ===
<div style="margin-left: 2em;">Pointer of the RISkeletonComponent object - RLPy.RISkeletonComponent
+
 
</div>
+
Get the character's HIK Effector Component, used for controlling and managing the IK skeleton.
-----
+
 
===GetVisemeComponent===
+
See Also: [[IC_Python_API:RLPy_RIHikEffectorComponent|RIHikEffectorComponent]]
<syntaxhighlight lang="Python">
+
 
RLPy.RIAvatar.GetVisemeComponent ( self )
+
==== Returns ====
 +
:Pointer to the HIK Effector Component object - [[IC_Python_API:RLPy_RIHikEffectorComponent|RIHikEffectorComponent]]
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
avatar_list = RLPy.RScene.GetAvatars()
 +
avatar = avatar_list[0]   
 +
material_component  = avatar.GetMaterialComponent()
 +
print(type(material_component).__name__)
 
</syntaxhighlight>
 
</syntaxhighlight>
Get viseme component of the object.
+
 
====Returns====
+
=== GetFaceComponent (self) ===
<div style="margin-left: 2em;">Pointer of the RIVisemeComponent object - RLPy.RIVisemeComponent
+
 
</div>
+
Get the Face Component for the character. Face Component is used to control the facial and head settings for the character.
-----
+
 
===SetVisible===
+
See Also: [[IC_Python_API:RLPy_RIFaceComponent|RIFaceComponent]]
<syntaxhighlight lang="Python">
+
 
RLPy.RIAvatar.SetVisible ( self, kTime, bVisible )
+
==== Returns ====
 +
:Pointer to the Face Component object - [[IC_Python_API:RLPy_RIFaceComponent|RIFaceComponent]]
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
avatar_list = RLPy.RScene.GetAvatars()
 +
avatar = avatar_list[0]   
 +
face_component  = avatar.GetFaceComponent()
 +
print(type(face_component).__name__)
 
</syntaxhighlight>
 
</syntaxhighlight>
( Experimental Function ) Set visible status
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''kTime''' [IN] Specifies the time to set visible - RLPy.RTime
+
=== GetGeneration (self) ===
  
'''bVisible''' [IN] Visible status - bool
+
Get the CC avatar standard generation for the character.
</div>
+
====Return Values====
+
<div style="margin-left: 2em;">
+
  
'''RLPy.RStatus.Success''' Success
+
==== Returns ====
 +
:Character Creator Avatar generation - enum
 +
:*RLPy.EAvatarGeneration_None  =  0
 +
:*RLPy.EAvatarGeneration_CC_G1_Avatar = 1
 +
:*RLPy.EAvatarGeneration_CC_G3_Avatar = 2
 +
:*RLPy.EAvatarGeneration_CC_Game_Base_One = 3
 +
:*RLPy.EAvatarGeneration_CC_Game_Base_Multi = 4
  
'''RLPy.RStatus.Failure''' Fail
+
<syntaxhighlight lang="python" line='line'>
</div>
+
avatar_list = RLPy.RScene.GetAvatars()
 +
avatar = avatar_list[0]   
 +
avatar_generation = avatar.GetGeneration()
 +
print(avatar_generation)
 +
</syntaxhighlight>
 +
 
 +
=== GetAvatarType (self) ===
 +
 
 +
Get the character's avatar type.
 +
 
 +
==== Returns ====
 +
:Avatar Type - enum
 +
:*RLPy.EAvatarType_None = 0
 +
:*RLPy.EAvatarType_Standard = 1
 +
:*RLPy.EAvatarType_NonStandard = 2
 +
:*RLPy.EAvatarType_NonHuman = 3
 +
:*RLPy.EAvatarType_StandardSeries = 4
 +
:*RLPy.EAvatarType_All = 5
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
avatar_list = RLPy.RScene.GetAvatars()
 +
avatar = avatar_list[0]   
 +
avatr_type = avatar.GetAvatarType()
 +
print(avatr_type == RLPy.EAvatarType_StandardSeries)
 +
</syntaxhighlight>

Latest revision as of 23:34, 14 April 2020

Main article: Modules.
Last modified: 04/14/2020

Description

This class provides methods to access all components of a character, for example: RISkeletonComponent, RIVisemeComponent, RIFaceComponent, etc. Retrieved component operations are thus available for usage.

Inheritance

RINode > RIObject > RIAvatar

Examples

 1 avatar = RLPy.RScene.FindObject( RLPy.EObjectType_Avatar, "Jade" )
 2 
 3 # set the name of the character
 4 avatar.SetName("new_name")
 5 
 6 # Get the name of the character
 7 avatar_name = avatar.GetName()
 8 print(avatar_name) # Jade
 9 
10 # Set a Transform key
11 control = avatar.GetControl("Transform")
12 transform = RLPy.RTransform.IDENTITY
13 transform.T().x = 100.0
14 transform.T().y = 100.0
15 transform.T().z = 100.0
16 control.SetValue(RLPy.RTime(0), transform)
17 
18 # Link and unlink to other objects; iClone Avatar can't set Parent
19 prop2 = RLPy.RScene.FindObject(RLPy.EObjectType_Prop, "Box2")
20 result = avatar.LinkTo(prop2, RLPy.RTime(0))
21 result = avatar.UnLink(RLPy.RTime(0))
22 
23 # Get the bounds
24 ret_max = RLPy.RVector3()
25 ret_center = RLPy.RVector3()
26 ret_min = RLPy.RVector3()
27 ret = avatar.GetBounds( ret_max, ret_center, ret_min )
28 print(ret)
29 
30 # Get the pivot point
31 ret_pos = RLPy.RVector3()
32 ret_rot = RLPy.RVector3()
33 avatar.GetPivot( ret_pos, ret_rot )
34 print(ret)
35 
36 # Clone the character
37 clone_avatar = avatar.Clone()
38 print( clone_avatar )
39 
40 # Check character selection
41 RLPy.RScene.SelectObject(avatar)
42 print(avatar.IsSelected()) #True

Member Functions

SetVisible (self, kTime, bVisible )

Set a visibility key by a given time.

Parameters

kTime [IN] Time at which to change visibility - RTime
bVisible [IN] Visibility status - bool

Returns

Success - RLPy.RStatus.Success
Failure - RLPy.RStatus.Failure
1 avatar_list = RLPy.RScene.GetAvatars()
2 avatar = avatar_list[0]    
3 avatar.SetVisible(RLPy.RTime(0), True)
4 avatar.SetVisible(RLPy.RTime(10), False)

GetSkeletonComponent (self)

Get the character's Skeleton Component, used for retrieving the entire skeleton.

See Also: RISkeletonComponent

Returns

Pointer to the Skeleton Component object - RISkeletonComponent
1 avatar_list = RLPy.RScene.GetAvatars()
2 avatar = avatar_list[0]    
3 skeleton_component = avatar.GetSkeletonComponent()
4 print(type(_component).__name__)
5 print(skeleton.GetClipCount())

GetVisemeComponent (self)

Get the character's Viseme Component, which provides operations related to lip-syncing.

See Also: RIVisemeComponent

Returns

Pointer to the Viseme Component object - RIVisemeComponent
1 avatar_list = RLPy.RScene.GetAvatars()
2 avatar = avatar_list[0]    
3 viseme_component  = avatar.GetVisemeComponent()
4 print(type(viseme_component).__name__)

GetMorphComponent (self)

Get the character's Morph Component, used to edit Morph Animation Keys or retrieve the current morph weighting.

See Also: RIMorphComponent

Returns

Pointer to the Morph Component object - RIMorphComponent
1 avatar_list = RLPy.RScene.GetAvatars()
2 avatar = avatar_list[0]    
3 morph_component  = avatar.GetMorphComponent()
4 print(type(morph_component).__name__)

GetMaterialComponent (self)

Get the character's Material Component, used for setting material related parameter values.

See Also: RIMaterialComponent

Returns

Pointer to the Material Component object - RIMaterialComponent
1 avatar_list = RLPy.RScene.GetAvatars()
2 avatar = avatar_list[0]    
3 material_component  = avatar.GetMaterialComponent()
4 print(type(material_component).__name__)

GetHikEffectorComponent (self)

Get the character's HIK Effector Component, used for controlling and managing the IK skeleton.

See Also: RIHikEffectorComponent

Returns

Pointer to the HIK Effector Component object - RIHikEffectorComponent
1 avatar_list = RLPy.RScene.GetAvatars()
2 avatar = avatar_list[0]    
3 material_component  = avatar.GetMaterialComponent()
4 print(type(material_component).__name__)

GetFaceComponent (self)

Get the Face Component for the character. Face Component is used to control the facial and head settings for the character.

See Also: RIFaceComponent

Returns

Pointer to the Face Component object - RIFaceComponent
1 avatar_list = RLPy.RScene.GetAvatars()
2 avatar = avatar_list[0]    
3 face_component  = avatar.GetFaceComponent()
4 print(type(face_component).__name__)

GetGeneration (self)

Get the CC avatar standard generation for the character.

Returns

Character Creator Avatar generation - enum
  • RLPy.EAvatarGeneration_None = 0
  • RLPy.EAvatarGeneration_CC_G1_Avatar = 1
  • RLPy.EAvatarGeneration_CC_G3_Avatar = 2
  • RLPy.EAvatarGeneration_CC_Game_Base_One = 3
  • RLPy.EAvatarGeneration_CC_Game_Base_Multi = 4
1 avatar_list = RLPy.RScene.GetAvatars()
2 avatar = avatar_list[0]    
3 avatar_generation = avatar.GetGeneration()
4 print(avatar_generation)

GetAvatarType (self)

Get the character's avatar type.

Returns

Avatar Type - enum
  • RLPy.EAvatarType_None = 0
  • RLPy.EAvatarType_Standard = 1
  • RLPy.EAvatarType_NonStandard = 2
  • RLPy.EAvatarType_NonHuman = 3
  • RLPy.EAvatarType_StandardSeries = 4
  • RLPy.EAvatarType_All = 5
1 avatar_list = RLPy.RScene.GetAvatars()
2 avatar = avatar_list[0]    
3 avatr_type = avatar.GetAvatarType()
4 print(avatr_type == RLPy.EAvatarType_StandardSeries)