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

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
 
(4 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 is the base class for all light sources and provides settings for some basic properties, e.g. active states, strength, color values, etc.  It also provides a Transform Control with the ability to set translation, rotation, and scale keys.
This class is the interface to lights in the scene.
+
 
It provides methods to access various parts of a light such as
+
=== Inheritance ===
transformation, color, range etc. All methods of this class are
+
 
implemented by the system. <span style="background:#ffcccc">( Experimental Class )</span> <syntaxhighlight lang="Python">
+
[[IC_Python_API:RLPy_RIBase|RIBase]] > [[IC_Python_API:RLPy_RIObject|RIObject]] > [[IC_Python_API:RLPy_RILight|RILight]]  
light_object = RLPy.RScene.FindObject(RLPy.EObjectType_Light, "Spotlight") # use light name to find object
+
[[IC_Python_API:RLPy_RILight|RILight]] > [[#IC_Python_API:RLPy_RISpotLight|SpotLight]] | [[#IC_Python_API:RLPy_RIPointLight|PointLight]] | [[#IC_Python_API:RLPy_RIDirectionalLight|DirectionalLight]]
 +
 
 +
== Member Functions ==
 +
 
 +
=== SetActive ( self, bActive ) ===
 +
 
 +
Set the active state for the light.
 +
 
 +
See Also: [[#GetActive( self )|GetActive]]
 +
 
 +
==== Parameters ====
 +
:'''bActive''' [IN] The active state - bool
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
# Get light object
 +
light_object = RLPy.RScene.FindObject(RLPy.EObjectType_Light, "Spotlight")
 +
 
 +
# Set light object active status
 
light_object.SetActive(True)
 
light_object.SetActive(True)
print(light_object.GetActive())
+
</syntaxhighlight>
+
# set light multiplier
+
light_object.SetMultiplier(RLPy.RTime(0), 8.0)
+
print(light_object.GetMultiplier())
+
+
# set light color
+
color = RLPy.RRgb.RED
+
light_object.SetColor(RLPy.RTime(0), color)
+
light_object.GetColor().R() # is 1.0
+
light_object.GetColor().G() # is 0.0
+
light_object.GetColor().B() # is 0.0
+
+
# change light transform
+
control = light_object.GetControl("Transform")
+
transform = RLPy.RTransform.IDENTITY
+
transform.T().x = -75.0
+
transform.T().y = -150.0
+
transform.T().z = 250.0
+
time = RLPy.RTime(0)
+
control.SetValue(time, transform)
+
  
#clone object
+
=== GetActive ( self ) ===
clone_light_object = light_object.Clone()
+
print( clone_light_object )
+
  
#is selected
+
Get the active state of the light.
RLPy.RScene.SelectObject(light_object)
+
 
print(light_object.IsSelected()) #True
+
See Also: [[#SetActive( self, bActive )|SetActive]]
 +
 
 +
==== Returns ====
 +
:Whether or not the light is active - bool
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
# Get light object
 +
light_object = RLPy.RScene.FindObject(RLPy.EObjectType_Light, "Spotlight")
 +
 
 +
# Get light object active status
 +
active_status = light_object.GetActive()
 +
print(active_status)
 
</syntaxhighlight>
 
</syntaxhighlight>
==Operators==
+
 
This class supports the following operators:
+
=== SetMultiplier ( self, kTime, fMultiplier ) ===
{| class="wikitable"
+
 
!Member
+
Set the light's strength value at a given time.
!Operation
+
 
!Syntax
+
See Also: [[#GetMultiplier( self )|GetMultiplier]]
!Description
+
 
!Example
+
==== Parameters ====
|-
+
:'''kTime''' [IN] Time at which to set the light's strength value - [[IC_Python_API:RLPy_RTime|RTime]]
! scope="row"|__eq__
+
:'''fMultiplier''' [IN] The strength value - float
|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'>
===GetActive===
+
# Get light object
<syntaxhighlight lang="Python">
+
light_object = RLPy.RScene.FindObject(RLPy.EObjectType_Light, "Spotlight")
RLPy.RILight.GetActive ( self )
+
 
</syntaxhighlight>
+
# Set light object multiplier value
Get if light is active.
+
result = light_object.SetMultiplier(RLPy.RTime(0), 8.0)
<span style="background:#ffcccc">( Experimental API )</span>
+
====Returns====
+
<div style="margin-left: 2em;">True if light is active, False if light is not active - bool
+
</div>
+
-----
+
===GetColor===
+
<syntaxhighlight lang="Python">
+
RLPy.RILight.GetColor ( self )
+
 
</syntaxhighlight>
 
</syntaxhighlight>
Get the light's color.
 
<span style="background:#ffcccc">( Experimental API )</span>
 
====Returns====
 
<div style="margin-left: 2em;">The value of the "color" attribute of the light node - RLPy.RRgb
 
</div>
 
-----
 
===GetMultiplier===
 
<syntaxhighlight lang="Python">
 
RLPy.RILight.GetMultiplier ( self )
 
</syntaxhighlight>
 
Get the light's multiplier.
 
<span style="background:#ffcccc">( Experimental API )</span>
 
====Returns====
 
<div style="margin-left: 2em;">The value of the "multiplier" attribute of the light node - float
 
</div>
 
-----
 
===SetActive===
 
<syntaxhighlight lang="Python">
 
RLPy.RILight.SetActive ( self, bActive )
 
</syntaxhighlight>
 
Set if light is active.
 
<span style="background:#ffcccc">( Experimental API )</span>
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''bActive''' [in] If light is active - bool
+
=== GetMultiplier ( self ) ===
</div>
+
====Return Values====
+
<div style="margin-left: 2em;">
+
  
'''RLPy.RStatus.Success''' Success
+
Get the light's current strength.
  
'''RLPy.RStatus.Failure''' Fail
+
See Also: [[#SetMultiplier( self, kTime, fMultiplier )|SetMultiplier]]
</div>
+
 
-----
+
==== Returns ====
===SetColor===
+
:The strength of the light - float
<syntaxhighlight lang="Python">
+
 
RLPy.RILight.SetColor ( self, kTime, kColor )
+
<syntaxhighlight lang="python" line='line'>
 +
# Get light object
 +
light_object = RLPy.RScene.FindObject(RLPy.EObjectType_Light, "Spotlight")
 +
 
 +
# Get light object multiplier value
 +
multiplier_value = light_object.GetMultiplier()
 +
print(multiplier_value)
 
</syntaxhighlight>
 
</syntaxhighlight>
Set the light's color.
 
<span style="background:#ffcccc">( Experimental API )</span>
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''kTime''' [in] The time at which to set the color - RLPy.RTime
+
=== SetColor ( self, kTime, kColor ) ===
  
'''kColor''' [in] The Light RGB value - RLPy.RRgb
+
Set the light's color at a given time.
</div>
+
====Return Values====
+
<div style="margin-left: 2em;">
+
  
'''RLPy.RStatus.Success''' Success
+
See Also: [[#GetColor( self )|GetColor]]
  
'''RLPy.RStatus.Failure''' Fail
+
==== Parameters ====
</div>
+
:'''kTime''' [IN] Time at which to set the light's color - [[IC_Python_API:RLPy_RTime|RTime]]
-----
+
:'''kColor''' [IN] The target color for the light - [[IC_Python_API:RLPy_RRgb|RRgb]]
===SetMultiplier===
+
 
<syntaxhighlight lang="Python">
+
==== Returns ====
RLPy.RILight.SetMultiplier ( self, kTime, fMultiplier )
+
:Success - RLPy.RStatus.Success
 +
:Failure - RLPy.RStatus.Failure
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
# Get light object
 +
light_object = RLPy.RScene.FindObject(RLPy.EObjectType_Light, "Spotlight")
 +
 
 +
# Set light object color value
 +
result = light_object.SetColor(RLPy.RTime(0), RLPy.RRgb.RED)
 
</syntaxhighlight>
 
</syntaxhighlight>
Set the light's multiplier.
 
<span style="background:#ffcccc">( Experimental API )</span>
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''kTime''' [in] The time at which to set the multiplier - RLPy.RTime
+
=== GetColor ( self ) ===
  
'''fMultiplier''' [in] The Light multiplier value - float
+
Get the light's color at a given time.
</div>
+
====Return Values====
+
<div style="margin-left: 2em;">
+
  
'''RLPy.RStatus.Success''' Success
+
See Also: [[#SetColor( self, kTime, kColor )|SetColor]]
  
'''RLPy.RStatus.Failure''' Fail
+
==== Returns ====
</div>
+
:The light's color in '''RRgb''' - [[IC_Python_API:RLPy_RRgb|RRgb]]
==Inherited By==
+
 
This class is inherited by the following classes:
+
<syntaxhighlight lang="python" line='line'>
{| class="wikitable"
+
# Get light object
!Class
+
light_object = RLPy.RScene.FindObject(RLPy.EObjectType_Light, "Spotlight")
!Description
+
 
|-
+
# Set light object color value
| [[ IC_Python_API:RLPy_RIDirectionalLight | DirectionalLight ]] || The interface to directional light in the scene.
+
light_color = light_object.GetColor()
|-
+
print(light_color)
| [[ IC_Python_API:RLPy_RIPointLight | PointLight ]] || The interface to point light in the scene.
+
</syntaxhighlight>
|-
+
| [[ IC_Python_API:RLPy_RISpotLight | SpotLight ]] || The interface to spot light in the scene.
+
|}
+

Latest revision as of 00:00, 15 April 2020

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

Description

This is the base class for all light sources and provides settings for some basic properties, e.g. active states, strength, color values, etc. It also provides a Transform Control with the ability to set translation, rotation, and scale keys.

Inheritance

RIBase > RIObject > RILight 
RILight > SpotLight | PointLight | DirectionalLight

Member Functions

SetActive ( self, bActive )

Set the active state for the light.

See Also: GetActive

Parameters

bActive [IN] The active state - bool
1 # Get light object
2 light_object = RLPy.RScene.FindObject(RLPy.EObjectType_Light, "Spotlight")
3 
4 # Set light object active status
5 light_object.SetActive(True)

GetActive ( self )

Get the active state of the light.

See Also: SetActive

Returns

Whether or not the light is active - bool
1 # Get light object
2 light_object = RLPy.RScene.FindObject(RLPy.EObjectType_Light, "Spotlight")
3 
4 # Get light object active status
5 active_status = light_object.GetActive()
6 print(active_status)

SetMultiplier ( self, kTime, fMultiplier )

Set the light's strength value at a given time.

See Also: GetMultiplier

Parameters

kTime [IN] Time at which to set the light's strength value - RTime
fMultiplier [IN] The strength value - float

Returns

Success - RLPy.RStatus.Success
Failure - RLPy.RStatus.Failure
1 # Get light object
2 light_object = RLPy.RScene.FindObject(RLPy.EObjectType_Light, "Spotlight")
3 
4 # Set light object multiplier value
5 result = light_object.SetMultiplier(RLPy.RTime(0), 8.0)

GetMultiplier ( self )

Get the light's current strength.

See Also: SetMultiplier

Returns

The strength of the light - float
1 # Get light object
2 light_object = RLPy.RScene.FindObject(RLPy.EObjectType_Light, "Spotlight")
3 
4 # Get light object multiplier value
5 multiplier_value = light_object.GetMultiplier()
6 print(multiplier_value)

SetColor ( self, kTime, kColor )

Set the light's color at a given time.

See Also: GetColor

Parameters

kTime [IN] Time at which to set the light's color - RTime
kColor [IN] The target color for the light - RRgb

Returns

Success - RLPy.RStatus.Success
Failure - RLPy.RStatus.Failure
1 # Get light object
2 light_object = RLPy.RScene.FindObject(RLPy.EObjectType_Light, "Spotlight")
3 
4 # Set light object color value
5 result = light_object.SetColor(RLPy.RTime(0), RLPy.RRgb.RED)

GetColor ( self )

Get the light's color at a given time.

See Also: SetColor

Returns

The light's color in RRgb - RRgb
1 # Get light object
2 light_object = RLPy.RScene.FindObject(RLPy.EObjectType_Light, "Spotlight")
3 
4 # Set light object color value
5 light_color = light_object.GetColor()
6 print(light_color)