IC Python API:RLPy RIMaterialComponent

From Reallusion Wiki!
Revision as of 00:43, 28 March 2019 by Chuck (RL) (Talk | contribs) (Created page with "{{TOC}} {{Parent|IC_Python_API:RL_Python_Modules|Modules}} ==Inheritance== This class inherits public member functions from: *RLPy.RIBase ==Detai...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Main article: Modules.

Inheritance

This class inherits public member functions from:

Detailed Description

RIMaterialComponent.

( Experimental Class )
# Get Object mesh and material
avatar_list = RLPy.RScene.GetAvatars()
avatar = avatar_list[0]
material_component = avatar.GetMaterialComponent()

mesh_list = avatar.GetMeshNames()
mesh_name = mesh_list[0]

material_list = material_component.GetMaterialNames(mesh_name)
material_name = material_list[0]

# Modify material light
ambient_color = RLPy.RRgb.RED
diffuse_color = RLPy.RRgb.GREEN
specular_color = RLPy.RRgb.BLUE

# Create Key
key = RLPy.RKey()
key.SetTime(RLPy.RTime(1200))
key.SetTransitionType(RLPy.ETransitionType_Linear)
key.SetTransitionStrength(50)

material_component.AddAmbientKey(key, mesh_name, material_name, ambient_color)
print(material_component.GetAmbientColor(mesh_name, material_name))

material_component.AddDiffuseKey(key, mesh_name, material_name, diffuse_color)
print(material_component.GetDiffuseColor(mesh_name, material_name))

material_component.AddSpecularKey(key, mesh_name, material_name, specular_color)
print(material_component.GetSpecularColor(mesh_name, material_name))

glossiness = 70
specular = 300
self_illumination = 60
opacity = 45
material_component.AddGlossinessKey(key, mesh_name, material_name, glossiness)
print(material_component.GetGlossinessWeight(mesh_name, material_name))

material_component.AddSpecularKey(key, mesh_name, material_name, specular)
print(material_component.GetSpecularWeight(mesh_name, material_name))

material_component.AddSelfIlluminationKey(key, mesh_name, material_name, self_illumination)
print(material_component.GetSelfIlluminationWeight(mesh_name, material_name))

material_component.AddOpacityKey(key, mesh_name, material_name, opacity)
print(material_component.GetOpacity(mesh_name, material_name))

# Modify texture weight
texture_channel = RLPy.EMaterialTextureChannel_Diffuse
diffuse_weight = 0.0
material_component.AddTextureWeightKey(key, mesh_name, material_name,
     texture_channel, diffuse_weight)
    
temp_texture_weight_list = material_component.GetTextureWeights(mesh_name, material_name)
print(temp_texture_weight_list[int(texture_channel)])

# Modify uv data
texture_channel = RLPy.EMaterialTextureChannel_Bump
uv_offset = RLPy.RVector2(0.1, 0)
uv_tile = RLPy.RVector2(1, 1)
uv_rotate = 3.14
material_component.AddUvDataKey(key, mesh_name, material_name,
     texture_channel, uv_offset, uv_tile, uv_rotate)
    
temp_uv_offset = RLPy.RVector2()
temp_uv_tile = RLPy.RVector2()
temp_uv_data = material_component.GetUvData(mesh_name, material_name, texture_channel,
     temp_uv_offset, temp_uv_tile, uv_rotate)
print(temp_uv_data[1]) # uv rotate
print(temp_uv_offset) # uv offset
print(temp_uv_tile) # uv tile
material_component.RemoveUvDataKey(key, mesh_name, material_name, texture_channel)
    
# Load video to material channel
texture_channel = RLPy.EMaterialTextureChannel_Bump
video_file = "C://MaterialVideoTest.mp4"
video_volume = 50
is_mute = False
material_component.LoadVideoToTexture(key, mesh_name, material_name,
     texture_channel, video_file)
material_component.AddVideoVolumeKey(key, mesh_name, material_name,
     texture_channel, video_volume, is_mute)
    
print(material_component.GetVideoVolume(mesh_name, material_name, texture_channel))

#Load image to material channel
texture_channel = RLPy.EMaterialTextureChannel_Diffuse
image_file = "C://diffuse.png"
result = material_component.LoadImageToTexture(mesh_name, material_name, texture_channel, image_file)

Member Functions

AddAmbientKey

RLPy.RIMaterialComponent.AddAmbientKey ( self, kKey, strMeshName, strMaterialName, kColor )

Add an ambient color key. ( Experimental API )

Parameters

kKey [IN] The key for time and transition control - RLPy.RKey

strMeshName [IN] The name for mesh - string

strMaterialName [IN] The name for material of mesh - string

kColor [IN] The color for ambient - RLPy.RRgb

Return Values

RLPy.RStatus.Success Success

RLPy.RStatus.Failure Fail


AddDiffuseKey

RLPy.RIMaterialComponent.AddDiffuseKey ( self, kKey, strMeshName, strMaterialName, kColor )

Add a diffuse color key. ( Experimental API )

Parameters

kKey [IN] The key for time and transition control - RLPy.RKey

strMeshName [IN] The name for mesh - string

strMaterialName [IN] The name for material of mesh - string

kColor [IN] The color for diffuse - RLPy.RRgb

Return Values

RLPy.RStatus.Success Success

RLPy.RStatus.Failure Fail


AddGlossinessKey

RLPy.RIMaterialComponent.AddGlossinessKey ( self, kKey, strMeshName, strMaterialName, fWeight )

Add a glossiness weight key. ( Experimental API )

Parameters

kKey [IN] The key for time and transition control - RLPy.RKey

strMeshName [IN] The name for mesh - string

strMaterialName [IN] The name for material of mesh - string

fWeight [IN] The weight for glossiness - float

Return Values

RLPy.RStatus.Success Success

RLPy.RStatus.Failure Fail


AddOpacityKey

RLPy.RIMaterialComponent.AddOpacityKey ( self, kKey, strMeshName, strMaterialName, fWeight )

Add an opacity key. ( Experimental API )

Parameters

kKey [IN] The key for time and transition control - RLPy.RKey

strMeshName [IN] The name for mesh - string

strMaterialName [IN] The name for material of mesh - string

fWeight [IN] The weight for opacity - float

Return Values

RLPy.RStatus.Success Success

RLPy.RStatus.Failure Fail


AddSelfIlluminationKey

RLPy.RIMaterialComponent.AddSelfIlluminationKey ( self, kKey, strMeshName, strMaterialName, fWeight )

Add a self-illumination weight key. ( Experimental API )

Parameters

kKey [IN] The key for time and transition control - RLPy.RKey

strMeshName [IN] The name for mesh - string

strMaterialName [IN] The name for material of mesh - string

fWeight [IN] The weight for self-illumination - float

Return Values

RLPy.RStatus.Success Success

RLPy.RStatus.Failure Fail


AddSpecularKey

RLPy.RIMaterialComponent.AddSpecularKey ( self, args )

Add a specular weight key. ( Experimental API )

Parameters

kKey [IN] The key for time and transition control - RLPy.RKey

strMeshName [IN] The name for mesh - string

strMaterialName [IN] The name for material of mesh - string

fWeight [IN] The weight for specular - float

Return Values

RLPy.RStatus.Success Success

RLPy.RStatus.Failure Fail


AddTextureWeightKey

RLPy.RIMaterialComponent.AddTextureWeightKey ( self, kKey, strMeshName, strMaterialName, eChannel, fWeight )

Add a texture weight key. ( Experimental API )

Parameters

kKey [IN] The key for time and transition control - RLPy.RKey

strMeshName [IN] The name for mesh - string

strMaterialName [IN] The name for material of mesh - string

eChannel [IN] The channel of texture - RLPy.EMaterialTextureChannel

  • RLPy.EMaterialTextureChannel_Metallic
  • RLPy.EMaterialTextureChannel_Diffuse
  • RLPy.EMaterialTextureChannel_Specular
  • RLPy.EMaterialTextureChannel_Shininess
  • RLPy.EMaterialTextureChannel_Glow
  • RLPy.EMaterialTextureChannel_Displacement
  • RLPy.EMaterialTextureChannel_Opacity
  • RLPy.EMaterialTextureChannel_DiffuseBlend
  • RLPy.EMaterialTextureChannel_Bump
  • RLPy.EMaterialTextureChannel_Reflection
  • RLPy.EMaterialTextureChannel_Refraction
  • RLPy.EMaterialTextureChannel_Cube
  • RLPy.EMaterialTextureChannel_AmbientOcclusion
  • RLPy.EMaterialTextureChannel_Quantity

fWeight [IN] The weight for channel - float

Return Values

RLPy.RStatus.Success Success

RLPy.RStatus.Failure Fail


AddUvDataKey

RLPy.RIMaterialComponent.AddUvDataKey ( self, kKey, strMeshName, strMaterialName, eChannel, kUvOffset, kUvTile, fUvRotate )

Add an uv data key. ( Experimental API )

Parameters

kKey [IN] The key for time and transition control - RLPy.RKey

strMeshName [IN] The name for mesh - string

strMaterialName [IN] The name for material of mesh - string

eChannel [IN] The channel of texture - RLPy.EMaterialTextureChannel

  • RLPy.EMaterialTextureChannel_Metallic
  • RLPy.EMaterialTextureChannel_Diffuse
  • RLPy.EMaterialTextureChannel_Specular
  • RLPy.EMaterialTextureChannel_Shininess
  • RLPy.EMaterialTextureChannel_Glow
  • RLPy.EMaterialTextureChannel_Displacement
  • RLPy.EMaterialTextureChannel_Opacity
  • RLPy.EMaterialTextureChannel_DiffuseBlend
  • RLPy.EMaterialTextureChannel_Bump
  • RLPy.EMaterialTextureChannel_Reflection
  • RLPy.EMaterialTextureChannel_Refraction
  • RLPy.EMaterialTextureChannel_Cube
  • RLPy.EMaterialTextureChannel_AmbientOcclusion
  • RLPy.EMaterialTextureChannel_Quantity

kUvOffset [IN] The uv's offset for channel - RLPy.RVector2f

kUvTile [IN] The uv's tile for channel - RLPy.RVector2f

fUvRotate [IN] The uv's rotate for channel ( -3.14 ~ 3.14 ) - float

Return Values

RLPy.RStatus.Success Success

RLPy.RStatus.Failure Fail


AddVideoVolumeKey

RLPy.RIMaterialComponent.AddVideoVolumeKey ( self, kKey, strMeshName, strMaterialName, eChannel, fVol, bMute )

Remove an uv key. ( Experimental API )

Parameters

kKey [IN] The key for time and transition control - RLPy.RKey

strMeshName [IN] The name for mesh - string

strMaterialName [IN] The name for material of mesh - string

eChannel [IN] The channel of texture - RLPy.EMaterialTextureChannel

  • RLPy.EMaterialTextureChannel_Metallic
  • RLPy.EMaterialTextureChannel_Diffuse
  • RLPy.EMaterialTextureChannel_Specular
  • RLPy.EMaterialTextureChannel_Shininess
  • RLPy.EMaterialTextureChannel_Glow
  • RLPy.EMaterialTextureChannel_Displacement
  • RLPy.EMaterialTextureChannel_Opacity
  • RLPy.EMaterialTextureChannel_DiffuseBlend
  • RLPy.EMaterialTextureChannel_Bump
  • RLPy.EMaterialTextureChannel_Reflection
  • RLPy.EMaterialTextureChannel_Refraction
  • RLPy.EMaterialTextureChannel_Cube
  • RLPy.EMaterialTextureChannel_AmbientOcclusion
  • RLPy.EMaterialTextureChannel_Quantity

fVol [IN] The volume of video ( 0-100 ) - float

Return Values

RLPy.RStatus.Success Success

RLPy.RStatus.Failure Fail


GetAmbientColor

RLPy.RIMaterialComponent.GetAmbientColor ( self, strMeshName, strMaterialName )

Get ambient color. ( Experimental API )

Parameters

strMeshName [IN] The name for mesh - string

strMaterialName [IN] The name for material of mesh - string

Returns

Ambient color - RLPy.RRgb

GetDiffuseColor

RLPy.RIMaterialComponent.GetDiffuseColor ( self, strMeshName, strMaterialName )

Get diffuse color. ( Experimental API )

Parameters

strMeshName [IN] The name for mesh - string

strMaterialName [IN] The name for material of mesh - string

Returns

Diffuse color - RLPy.RRgb

GetGlossinessWeight

RLPy.RIMaterialComponent.GetGlossinessWeight ( self, strMeshName, strMaterialName )

Get glossiness wight. ( Experimental API )

Parameters

strMeshName [IN] The name for mesh - string

strMaterialName [IN] The name for material of mesh - string

Returns

Weight of specular - float

GetMaterialNames

RLPy.RIMaterialComponent.GetMaterialNames ( self, strMeshName )

Get material names. ( Experimental API )

Parameters

strMeshName [IN] The name for mesh - string

Return Values

std::vector< std::wstring > material namse.


GetOpacity

RLPy.RIMaterialComponent.GetOpacity ( self, strMeshName, strMaterialName )

Get opacity. ( Experimental API )

Parameters

strMeshName [IN] The name for mesh - string

strMaterialName [IN] The name for material of mesh - string

Returns

Weight of opacity - float

GetSelfIlluminationWeight

RLPy.RIMaterialComponent.GetSelfIlluminationWeight ( self, strMeshName, strMaterialName )

Get self-illumination weight. ( Experimental API )

Parameters

strMeshName [IN] The name for mesh - string

strMaterialName [IN] The name for material of mesh - string

Returns

Weight of self-illumination - float

GetSpecularColor

RLPy.RIMaterialComponent.GetSpecularColor ( self, strMeshName, strMaterialName )

Get specular color. ( Experimental API )

Parameters

strMeshName [IN] The name for mesh - string

strMaterialName [IN] The name for material of mesh - string

Returns

Specular color - RLPy.RRgb

GetSpecularWeight

RLPy.RIMaterialComponent.GetSpecularWeight ( self, strMeshName, strMaterialName )

Get specular weight. ( Experimental API )

Parameters

strMeshName [IN] The name for mesh - string

strMaterialName [IN] The name for material of mesh - string

Returns

Weight of specular - float

GetTextureWeights

RLPy.RIMaterialComponent.GetTextureWeights ( self, strMeshName, strMaterialName )

Get all channels weight of texture. ( Experimental API )

Parameters

strMeshName [IN] The name for mesh - string

strMaterialName [IN] The name for material of mesh - string

Returns

Weight of opacity - float

GetUvData

RLPy.RIMaterialComponent.GetUvData ( self, strMeshName, strMaterialName, eChannel, kUvOffset, kUvTile, fUvRotate )

Get all channels weight of texture. ( Experimental API )

Parameters

strMeshName [IN] The name for mesh - string

strMaterialName [IN] The name for material of mesh - string

eChannel [IN] The channel of texture - RLPy.EMaterialTextureChannel

  • RLPy.EMaterialTextureChannel_Metallic
  • RLPy.EMaterialTextureChannel_Diffuse
  • RLPy.EMaterialTextureChannel_Specular
  • RLPy.EMaterialTextureChannel_Shininess
  • RLPy.EMaterialTextureChannel_Glow
  • RLPy.EMaterialTextureChannel_Displacement
  • RLPy.EMaterialTextureChannel_Opacity
  • RLPy.EMaterialTextureChannel_DiffuseBlend
  • RLPy.EMaterialTextureChannel_Bump
  • RLPy.EMaterialTextureChannel_Reflection
  • RLPy.EMaterialTextureChannel_Refraction
  • RLPy.EMaterialTextureChannel_Cube
  • RLPy.EMaterialTextureChannel_AmbientOcclusion
  • RLPy.EMaterialTextureChannel_Quantity

kUvOffset [OUT] uv offset - RLPy.RVector2f

kUvTile [OUT] uv tile - RLPy.RVector2f

fUvRotate [OUT] uv rotate - float

Return Values

RLPy.RStatus.Success Success.

RLPy.RStatus.Failure Fail.


GetVideoVolume

RLPy.RIMaterialComponent.GetVideoVolume ( self, strMeshName, strMaterialName, eChannel )

Get volume of video. ( Experimental API )

Parameters

strMeshName [IN] The name for mesh - string

strMaterialName [IN] The name for material of mesh - string

eChannel [IN] The channel of texture - RLPy.EMaterialTextureChannel

  • RLPy.EMaterialTextureChannel_Metallic
  • RLPy.EMaterialTextureChannel_Diffuse
  • RLPy.EMaterialTextureChannel_Specular
  • RLPy.EMaterialTextureChannel_Shininess
  • RLPy.EMaterialTextureChannel_Glow
  • RLPy.EMaterialTextureChannel_Displacement
  • RLPy.EMaterialTextureChannel_Opacity
  • RLPy.EMaterialTextureChannel_DiffuseBlend
  • RLPy.EMaterialTextureChannel_Bump
  • RLPy.EMaterialTextureChannel_Reflection
  • RLPy.EMaterialTextureChannel_Refraction
  • RLPy.EMaterialTextureChannel_Cube
  • RLPy.EMaterialTextureChannel_AmbientOcclusion
  • RLPy.EMaterialTextureChannel_Quantity

Returns

Video volume - float

LoadImageToTexture

RLPy.RIMaterialComponent.LoadImageToTexture ( self, strMeshName, strMaterialName, eChannel, strImagePath )

Loading an image file to a texture. ( Experimental API )

Parameters

strMeshName [IN] The name for mesh - string

strMaterialName [IN] The name for material of mesh - string

eChannel [IN] The channel of texture - RLPy.EMaterialTextureChannel

  • RLPy.EMaterialTextureChannel_Metallic
  • RLPy.EMaterialTextureChannel_Diffuse
  • RLPy.EMaterialTextureChannel_Specular
  • RLPy.EMaterialTextureChannel_Shininess
  • RLPy.EMaterialTextureChannel_Glow
  • RLPy.EMaterialTextureChannel_Displacement
  • RLPy.EMaterialTextureChannel_Opacity
  • RLPy.EMaterialTextureChannel_DiffuseBlend
  • RLPy.EMaterialTextureChannel_Bump
  • RLPy.EMaterialTextureChannel_Reflection
  • RLPy.EMaterialTextureChannel_Refraction
  • RLPy.EMaterialTextureChannel_Cube
  • RLPy.EMaterialTextureChannel_AmbientOcclusion
  • RLPy.EMaterialTextureChannel_Quantity

strImagePath [IN] The file path of image - string

Return Values

RLPy.RStatus.Success Success

RLPy.RStatus.Failure Fail


LoadVideoToTexture

RLPy.RIMaterialComponent.LoadVideoToTexture ( self, kKey, strMeshName, strMaterialName, eChannel, strVideoPath )

Remove an uv key. ( Experimental API )

Parameters

kKey [IN] The key for time and transition control - RLPy.RKey

strMeshName [IN] The name for mesh - string

strMaterialName [IN] The name for material of mesh - string

eChannel [IN] The channel of texture - RLPy.EMaterialTextureChannel

  • RLPy.EMaterialTextureChannel_Metallic
  • RLPy.EMaterialTextureChannel_Diffuse
  • RLPy.EMaterialTextureChannel_Specular
  • RLPy.EMaterialTextureChannel_Shininess
  • RLPy.EMaterialTextureChannel_Glow
  • RLPy.EMaterialTextureChannel_Displacement
  • RLPy.EMaterialTextureChannel_Opacity
  • RLPy.EMaterialTextureChannel_DiffuseBlend
  • RLPy.EMaterialTextureChannel_Bump
  • RLPy.EMaterialTextureChannel_Reflection
  • RLPy.EMaterialTextureChannel_Refraction
  • RLPy.EMaterialTextureChannel_Cube
  • RLPy.EMaterialTextureChannel_AmbientOcclusion
  • RLPy.EMaterialTextureChannel_Quantity

strVideoPath [IN] The file path of video - string

Return Values

RLPy.RStatus.Success Success

RLPy.RStatus.Failure Fail


RemoveUvDataKey

RLPy.RIMaterialComponent.RemoveUvDataKey ( self, kKey, strMeshName, strMaterialName, eChannel )

Remove an uv data key. ( Experimental API )

Parameters

kKey [IN] The key for time and transition control - RLPy.RKey

strMeshName [IN] The name for mesh - string

strMaterialName [IN] The name for material of mesh - string

eChannel [IN] The channel of texture - RLPy.EMaterialTextureChannel

  • RLPy.EMaterialTextureChannel_Metallic
  • RLPy.EMaterialTextureChannel_Diffuse
  • RLPy.EMaterialTextureChannel_Specular
  • RLPy.EMaterialTextureChannel_Shininess
  • RLPy.EMaterialTextureChannel_Glow
  • RLPy.EMaterialTextureChannel_Displacement
  • RLPy.EMaterialTextureChannel_Opacity
  • RLPy.EMaterialTextureChannel_DiffuseBlend
  • RLPy.EMaterialTextureChannel_Bump
  • RLPy.EMaterialTextureChannel_Reflection
  • RLPy.EMaterialTextureChannel_Refraction
  • RLPy.EMaterialTextureChannel_Cube
  • RLPy.EMaterialTextureChannel_AmbientOcclusion
  • RLPy.EMaterialTextureChannel_Quantity

Return Values

RLPy.RStatus.Success Success

RLPy.RStatus.Failure Fail