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

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.RILight *IC...")
 
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_RILight|RLPy.RILight]]
+
*[[IC_Python_API:RLPy_RIObject|RLPy.RIObject]]
+
*[[IC_Python_API:RLPy_RIBase|RLPy.RIBase]]
+
==Detailed Description==
+
This class is the interface to directional light in the scene.
+
It provides methods to access various parts of a light such as
+
transformation, color, range etc. All methods of this class are
+
implemented by the system. <span style="background:#ffcccc">( Experimental Class )</span> <syntaxhighlight lang="Python">
+
light_object = RLPy.RScene.FindObject(RLPy.EObjectType_Light, "Dir. Light") # use light name to find object
+
  
light_object.SetCastShadow(True)
+
== Description ==
print(light_object.IsCastShadow())
+
+
#set light shadow strength
+
light_object.SetDarkenShadowStrength(RLPy.RTime(0), 50.0)
+
print(light_object.GetDarkenShadowStrength())
+
  
prop2 = RLPy.RScene.FindObject(RLPy.EObjectType_Prop, "Box2")
+
This class provides operations for Directional Lights, e.g. whether or not to cast shadows, the light's color, light strength, etc. You must first retrieve a directional light from the scene in order to use these operations.
# set Parent
+
result = light_object.SetParent(prop2)
+
result = light_object.SetParent(None) #detach from parent
+
  
# set name
+
=== Inheritance ===
light_object.SetName( "new_name" )
+
  
#get bound
+
*[[IC_Python_API:RLPy_RIBase|RIBase]] > [[IC_Python_API:RLPy_RIObject|RIObject]] > [[IC_Python_API:RLPy_RILight|RILight]] > '''RIDirectionalLight'''.
ret_max = RLPy.RVector3()
+
ret_center = RLPy.RVector3()
+
ret_min = RLPy.RVector3()
+
ret = light_object.GetBounds( ret_max, ret_center, ret_min )
+
print(ret)
+
  
#get pivot
+
== Member Functions ==
ret_pos = RLPy.RVector3()
+
ret_rot = RLPy.RVector3()
+
light_object.GetPivot( ret_pos, ret_rot )
+
print(ret)
+
  
#clone object
+
=== SetCastShadow ( self, bEnable ) ===
clone_light_object = light_object.Clone()
+
 
print( clone_light_object )
+
Turn on or off the directional light's cast shadow.
  
#is selected
 
RLPy.RScene.SelectObject(light_object)
 
print(light_object.IsSelected()) #True
 
</syntaxhighlight>
 
==Operators==
 
This class supports the following operators:
 
{| class="wikitable"
 
!Member
 
!Operation
 
!Syntax
 
!Description
 
!Example
 
|-
 
! scope="row"|__eq__
 
|Equality
 
|a == b
 
|If the values of two operands are equal, then the condition becomes true.
 
|(a == b) is not true.
 
|}
 
==Member Functions==
 
===GetDarkenShadowStrength===
 
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RIDirectionalLight.GetDarkenShadowStrength ( self )
+
light_object = RLPy.RScene.FindObject(RLPy.EObjectType_Light, "Dir. Light")
 +
 
 +
if light_object:
 +
    light_object.SetCastShadow(True)
 +
    light_object.SetCastShadow(False)
 
</syntaxhighlight>
 
</syntaxhighlight>
Get the light darken shadow strength.
+
 
<span style="background:#ffcccc">( Experimental API )</span>
+
==== Parameters ====
====Returns====
+
:bEnable [in] Enable or disable cast shadows for the light  - bool
<div style="margin-left: 2em;">The value of the "shadow strength" attribute of the light node - float
+
 
</div>
+
==== Returns ====
-----
+
:Success - RLPy.RStatus.Success
===IsCastShadow===
+
:Failure - RLPy.RStatus.Failure
 +
 
 +
=== IsCastShadow ( self ) ===
 +
 
 +
Check whether or not the light is casting shadows.
 +
 
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RIDirectionalLight.IsCastShadow ( self )
+
light_object = RLPy.RScene.FindObject(RLPy.EObjectType_Light, "Dir. Light")
 +
 
 +
if light_object:
 +
    light_object.SetCastShadow(True)
 +
    print(light_object.IsCastShadow())
 +
 
 +
    light_object.SetCastShadow(False)
 +
    print(light_object.IsCastShadow())
 
</syntaxhighlight>
 
</syntaxhighlight>
Get the light if cast shadow enable.
 
<span style="background:#ffcccc">( Experimental API )</span>
 
====Returns====
 
<div style="margin-left: 2em;">True if light is cast shadow enable, False if not - bool
 
</div>
 
-----
 
===SetCastShadow===
 
<syntaxhighlight lang="Python">
 
RLPy.RIDirectionalLight.SetCastShadow ( self, bEnable )
 
</syntaxhighlight>
 
Set the light's cast shadow is enable.
 
<span style="background:#ffcccc">( Experimental API )</span>
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''bEnable''' [in] If light's cast shadow is enable - bool
+
==== Returns ====
</div>
+
:'''True''' if the light is casting shadows, else '''False''' - bool
====Return Values====
+
<div style="margin-left: 2em;">
+
  
'''RLPy.RStatus.Success''' Success
+
=== SetDarkenShadowStrength ( self, kTime, fStrength ) ===
 +
 
 +
Set the directional light's shadow strength at a given point in time (0 to 100).
  
'''RLPy.RStatus.Failure''' Fail
 
</div>
 
-----
 
===SetDarkenShadowStrength===
 
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RIDirectionalLight.SetDarkenShadowStrength ( self, kTime, fStrength )
+
light_object = RLPy.RScene.FindObject(RLPy.EObjectType_Light, "Dir. Light")
 +
 
 +
if light_object:
 +
  result = light_object.SetDarkenShadowStrength(RLPy.RGlobal.GetTime(), 50)
 +
  print(result)
 
</syntaxhighlight>
 
</syntaxhighlight>
Set the light's shadow strength.
 
<span style="background:#ffcccc">( Experimental API )</span>
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''fStrength''' [in] The Light shadow strength value - float
+
==== Parameters ====
</div>
+
:fStrength [in] The Light shadow strength value - float
====Return Values====
+
<div style="margin-left: 2em;">
+
  
'''RLPy.RStatus.Success''' Success
+
==== Returns ====
 +
:RLPy.RStatus.Success Success
 +
:RLPy.RStatus.Failure Fail
  
'''RLPy.RStatus.Failure''' Fail
+
=== GetDarkenShadowStrength ( self ) ===
</div>
+
 
 +
Get the directional light's shadow strength at a given point in time (0 to 100).
 +
 
 +
==== Returns ====
 +
:The light's shadow strength value - float
 +
 
 +
<syntaxhighlight lang="Python">
 +
light_object = RLPy.RScene.FindObject(RLPy.EObjectType_Light, "Dir. Light")
 +
 
 +
if light_object:
 +
  result = light_object.SetDarkenShadowStrength(RLPy.RGlobal.GetTime(), 50)
 +
  print(light_object.GetDarkenShadowStrength())
 +
</syntaxhighlight>

Revision as of 01:09, 6 April 2020

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

Description

This class provides operations for Directional Lights, e.g. whether or not to cast shadows, the light's color, light strength, etc. You must first retrieve a directional light from the scene in order to use these operations.

Inheritance

Member Functions

SetCastShadow ( self, bEnable )

Turn on or off the directional light's cast shadow.

light_object = RLPy.RScene.FindObject(RLPy.EObjectType_Light, "Dir. Light")

if light_object:
    light_object.SetCastShadow(True)
    light_object.SetCastShadow(False)

Parameters

bEnable [in] Enable or disable cast shadows for the light - bool

Returns

Success - RLPy.RStatus.Success
Failure - RLPy.RStatus.Failure

IsCastShadow ( self )

Check whether or not the light is casting shadows.

light_object = RLPy.RScene.FindObject(RLPy.EObjectType_Light, "Dir. Light")

if light_object:
    light_object.SetCastShadow(True)
    print(light_object.IsCastShadow())

    light_object.SetCastShadow(False)
    print(light_object.IsCastShadow())

Returns

True if the light is casting shadows, else False - bool

SetDarkenShadowStrength ( self, kTime, fStrength )

Set the directional light's shadow strength at a given point in time (0 to 100).

light_object = RLPy.RScene.FindObject(RLPy.EObjectType_Light, "Dir. Light")

if light_object:
  result = light_object.SetDarkenShadowStrength(RLPy.RGlobal.GetTime(), 50)
  print(result)

Parameters

fStrength [in] The Light shadow strength value - float

Returns

RLPy.RStatus.Success Success
RLPy.RStatus.Failure Fail

GetDarkenShadowStrength ( self )

Get the directional light's shadow strength at a given point in time (0 to 100).

Returns

The light's shadow strength value - float
light_object = RLPy.RScene.FindObject(RLPy.EObjectType_Light, "Dir. Light")

if light_object:
  result = light_object.SetDarkenShadowStrength(RLPy.RGlobal.GetTime(), 50)
  print(light_object.GetDarkenShadowStrength())