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

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 spot 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, "Spotlight") # use light name to find object
+
+
light_object.SetCastShadow(True)
+
print(light_object.IsCastShadow())
+
+
#set light shadow strength
+
light_object.SetDarkenShadowStrength(RLPy.RTime(0), 50.0)
+
print(light_object.GetDarkenShadowStrength())
+
+
#set light range
+
light_object.SetRange(RLPy.RTime(0), 1000.0)
+
print(light_object.GetRange())
+
+
# set light beam
+
spot_light_falloff_power = 40.0
+
spot_light_angle = 135.0
+
light_object.SetSpotLightBeam(RLPy.RTime(0), spot_light_falloff_power, spot_light_angle)
+
+
angle = 0
+
falloff = 0
+
result_list = light_object.GetSpotLightBeam(angle, falloff)
+
print(result_list[1]) # angle = 135
+
print(result_list[2]) # falloff = 40
+
  
 +
== Description ==
 +
 +
This class provides Spotlight related operations, i.e. whether or not to cast shadows, light color, light ray direction, light strength, etc.
 +
 +
=== Inheritance ===
 +
 +
*[[IC_Python_API:RLPy_RIBase|RIBase]] > [[IC_Python_API:RLPy_RIObject|RIObject]] > [[IC_Python_API:RLPy_RILight|RILight]] > '''RISpotLight'''.
 +
 +
<syntaxhighlight lang="Python">
 +
light_object = RLPy.RScene.FindObject(RLPy.EObjectType_Light, "Spotlight") # Find the spotlight by name
  
prop2 = RLPy.RScene.FindObject(RLPy.EObjectType_Prop, "Box2")
 
 
# set Parent
 
# set Parent
 +
prop2 = RLPy.RScene.FindObject(RLPy.EObjectType_Prop, "Box2")
 
result = light_object.SetParent(prop2)
 
result = light_object.SetParent(prop2)
 
result = light_object.SetParent(None) #detach from parent
 
result = light_object.SetParent(None) #detach from parent
  
# link to & unlink
+
# link to & unlink
 
result = light_object.LinkTo(prop2, RLPy.RTime(0))
 
result = light_object.LinkTo(prop2, RLPy.RTime(0))
 
result = light_object.UnLink(RLPy.RTime(0))
 
result = light_object.UnLink(RLPy.RTime(0))
 
 
# set name
 
# set name
 
light_object.SetName( "new_name" )
 
light_object.SetName( "new_name" )
 
 
#get bound
 
#get bound
 
ret_max = RLPy.RVector3()
 
ret_max = RLPy.RVector3()
Line 54: Line 30:
 
ret = light_object.GetBounds( ret_max, ret_center, ret_min )
 
ret = light_object.GetBounds( ret_max, ret_center, ret_min )
 
print(ret)
 
print(ret)
 
 
#get pivot
 
#get pivot
 
ret_pos = RLPy.RVector3()
 
ret_pos = RLPy.RVector3()
Line 60: Line 35:
 
light_object.GetPivot( ret_pos, ret_rot )
 
light_object.GetPivot( ret_pos, ret_rot )
 
print(ret)
 
print(ret)
 
 
#clone object
 
#clone object
 
clone_light_object = light_object.Clone()
 
clone_light_object = light_object.Clone()
 
print( clone_light_object )
 
print( clone_light_object )
 
 
#is selected
 
#is selected
 
RLPy.RScene.SelectObject(light_object)
 
RLPy.RScene.SelectObject(light_object)
 
print(light_object.IsSelected()) #True
 
print(light_object.IsSelected()) #True
 
</syntaxhighlight>
 
</syntaxhighlight>
==Operators==
+
 
This class supports the following operators:
+
== Member Functions ==
{| class="wikitable"
+
 
!Member
+
=== GetDarkenShadowStrength ( self ) ===
!Operation
+
 
!Syntax
+
Get the Spotlight's shadow strength at a given point in time (0 to 100).
!Description
+
 
!Example
+
See Also: [[#SetDarkenShadowStrength ( self, kTime, fStrength )|SetDarkenShadowStrength]]
|-
+
 
! scope="row"|__eq__
+
==== Returns ====
|Equality
+
:Spotlight's shadow strength - float
|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.RISpotLight.GetDarkenShadowStrength ( self )
+
light_object = RLPy.RScene.FindObject(RLPy.EObjectType_Light, "Spotlight") # Find the spotlight by name
 +
 +
#get light shadow strength
 +
print(light_object.GetDarkenShadowStrength())
 
</syntaxhighlight>
 
</syntaxhighlight>
Get the light darken shadow strength.
+
 
<span style="background:#ffcccc">( Experimental API )</span>
+
=== GetRange ( self ) ===
====Returns====
+
 
<div style="margin-left: 2em;">The value of the "shadow strength" attribute of the light node - float
+
Get the Spotlight's range distance.
</div>
+
 
-----
+
See Also: [[#SetRange ( self, kTime, fRange  )|SetRange]]
===GetRange===
+
 
 +
==== Returns ====
 +
:Spotlight's range attribute - float
 +
 
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RISpotLight.GetRange ( self )
+
light_object = RLPy.RScene.FindObject(RLPy.EObjectType_Light, "Spotlight") # Find the spotlight by name
 +
 +
#get light range
 +
print(light_object.GetRange())
 
</syntaxhighlight>
 
</syntaxhighlight>
Get the light range.
+
 
<span style="background:#ffcccc">( Experimental API )</span>
+
=== GetSpotLightBeam ( self, nAngle, nFalloff ) ===
====Returns====
+
 
<div style="margin-left: 2em;">The value of the "range" attribute of the light node - float
+
Get the Spotlight's light beam attributes, e.g. beam angle and spill light attenuation (falloff intensity).
</div>
+
 
-----
+
See Also: [[#SetSpotLightBeam ( self, kTime, fFalloffPower, fAngle )|SetSpotLightBeam]]
===GetSpotLightBeam===
+
 
 +
==== Parameters ====
 +
:'''nAngle''' [OUT] Spotlight's angle value - int
 +
:'''nFalloff''' [OUT] Spotlight's falloff value - int
 +
 
 +
==== Returns ====
 +
:Success - RLPy.RStatus.Success
 +
:Failure - RLPy.RStatus.Failure
 +
 
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RISpotLight.GetSpotLightBeam ( self, nAngle, nFalloff )
+
light_object = RLPy.RScene.FindObject(RLPy.EObjectType_Light, "Spotlight") # Find the spotlight by name
 +
 +
# set light beam
 +
spot_light_falloff_power = 40.0
 +
spot_light_angle = 135.0
 +
light_object.SetSpotLightBeam(RLPy.RTime(0), spot_light_falloff_power, spot_light_angle)
 +
# get light beam
 +
angle = 0
 +
falloff = 0
 +
light_object.GetSpotLightBeam(angle, falloff)
 +
print(angle) # angle = 135
 +
print(falloff) # falloff = 40
 
</syntaxhighlight>
 
</syntaxhighlight>
Get the spot light beam value.
 
<span style="background:#ffcccc">( Experimental API )</span>
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''nAngle''' [out] Get the Light angle value - int
+
=== IsCastShadow ( self ) ===
  
'''nFalloff''' [out] Get the Light falloff value - int
+
Check whether or not the Spotlight is casting shadows.
</div>
+
====Return Values====
+
<div style="margin-left: 2em;">
+
  
'''RLPy.RStatus.Success''' Success
+
See Also: [[#SetCastShadow ( self, bEnable )|SetCastShadow]]
 +
 
 +
==== Returns ====
 +
:'''True''' if the spotlight is casting shadows, else '''False''' - bool
  
'''RLPy.RStatus.Failure''' Fail
 
</div>
 
-----
 
===IsCastShadow===
 
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RISpotLight.IsCastShadow ( self )
+
light_object = RLPy.RScene.FindObject(RLPy.EObjectType_Light, "Spotlight") # Find the spotlight by name
</syntaxhighlight>
+
Get the light if cast shadow enable.
+
print(light_object.IsCastShadow())
<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.RISpotLight.SetCastShadow ( self, bEnable )
+
 
</syntaxhighlight>
 
</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
+
=== SetCastShadow ( self, bEnable ) ===
</div>
+
====Return Values====
+
<div style="margin-left: 2em;">
+
  
'''RLPy.RStatus.Success''' Success
+
Turn on / off the Spotlight's cast shadows.
 +
 
 +
See Also: [[#IsCastShadow ( self )|IsCastShadow]]
 +
 
 +
==== Parameters ====
 +
:'''bEnable''' [IN] Whether to cast shadows - bool
 +
 
 +
==== Returns ====
 +
:Success - RLPy.RStatus.Success
 +
:Failure - RLPy.RStatus.Failure
  
'''RLPy.RStatus.Failure''' Fail
 
</div>
 
-----
 
===SetDarkenShadowStrength===
 
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RISpotLight.SetDarkenShadowStrength ( self, kTime, fStrength )
+
light_object = RLPy.RScene.FindObject(RLPy.EObjectType_Light, "Spotlight") # Find the spotlight by name
 +
light_object.SetCastShadow(True)
 +
print(light_object.IsCastShadow())
 
</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
+
=== SetDarkenShadowStrength ( self, kTime, fStrength ) ===
</div>
+
====Return Values====
+
<div style="margin-left: 2em;">
+
  
'''RLPy.RStatus.Success''' Success
+
Set the Spotlight's shadow strength at a given point in time (0 to 100).
 +
 
 +
See Also: [[#GetDarkenShadowStrength ( self )|GetDarkenShadowStrength]]
 +
 
 +
==== Parameters ====
 +
:'''fStrength''' [IN] Spotlight shadow strength value - float
 +
 
 +
==== Returns ====
 +
:Success - RLPy.RStatus.Success
 +
:Failure - RLPy.RStatus.Failure
  
'''RLPy.RStatus.Failure''' Fail
 
</div>
 
-----
 
===SetRange===
 
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RISpotLight.SetRange ( self, kTime, fRange )
+
light_object = RLPy.RScene.FindObject(RLPy.EObjectType_Light, "Spotlight") # Find the spotlight by name
 +
 +
# Set light shadow strength
 +
light_object.SetDarkenShadowStrength(RLPy.RTime(0), 50.0)
 
</syntaxhighlight>
 
</syntaxhighlight>
Set the light range.
 
<span style="background:#ffcccc">( Experimental API )</span>
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''kTime''' [in] The time at which to set the beam - RLPy.RTime
+
=== SetRange ( self, kTime, fRange  ) ===
  
'''fRange''' [in] The Light range value - float
+
Set the Spotlight's range value at a given point in time.
</div>
+
====Return Values====
+
<div style="margin-left: 2em;">
+
  
'''RLPy.RStatus.Success''' Success
+
See Also: [[#GetRange ( self )|GetRange]]
 +
 
 +
==== Parameters ====
 +
:'''kTime''' [IN] Time at which to set the beam - [[IC_Python_API:RLPy_RTime|RTime]]
 +
:'''fRange''' [IN] Spotlight range value - float
 +
 
 +
==== Returns ====
 +
:Success - RLPy.RStatus.Success
 +
:Failure - RLPy.RStatus.Failure
  
'''RLPy.RStatus.Failure''' Fail
 
</div>
 
-----
 
===SetSpotLightBeam===
 
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RISpotLight.SetSpotLightBeam ( self, kTime, fFalloffPower, fAngle )
+
light_object = RLPy.RScene.FindObject(RLPy.EObjectType_Light, "Spotlight") # Find the spotlight by name
 +
 +
# Set light range
 +
light_object.SetRange(RLPy.RTime(0), 1000.0)
 +
print(light_object.GetRange())
 
</syntaxhighlight>
 
</syntaxhighlight>
Set the spot light beam.
 
<span style="background:#ffcccc">( Experimental API )</span>
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''kTime''' [in] The time at which to set the beam - RLPy.RTime
+
=== SetSpotLightBeam ( self, kTime, fFalloffPower, fAngle ) ===
  
'''fFalloffPower''' [in] The Light falloff power value - float
+
Set the Spotlight's light beam attributes at a given point in time.  These attributes include the light beam's angle and spill light attenuation (falloff intensity).
  
'''fAngle''' [in] The Light angle value - float
+
See Also: [[#GetSpotLightBeam ( self, nAngle, nFalloff )|GetSpotLightBeam]]
</div>
+
====Return Values====
+
<div style="margin-left: 2em;">
+
  
'''RLPy.RStatus.Success''' Success
+
==== Parameters ====
 +
:'''kTime''' [IN] Time at which to set the beam - [[IC_Python_API:RLPy_RTime|RTime]]
 +
:'''fFalloffPower''' [IN] Light falloff power value - float
 +
:'''fAngle''' [IN] Light angle value - float
  
'''RLPy.RStatus.Failure''' Fail
+
==== Returns ====
</div>
+
:Success - RLPy.RStatus.Success
 +
:Failure - RLPy.RStatus.Failure
 +
 
 +
<syntaxhighlight lang="Python">
 +
light_object = RLPy.RScene.FindObject(RLPy.EObjectType_Light, "Spotlight") # Find the spotlight by name
 +
 +
# Set light beam attributes
 +
spot_light_falloff_power = 40.0
 +
spot_light_angle = 135.0
 +
light_object.SetSpotLightBeam(RLPy.RTime(0), spot_light_falloff_power, spot_light_angle)
 +
</syntaxhighlight>

Revision as of 20:05, 6 April 2020

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

Description

This class provides Spotlight related operations, i.e. whether or not to cast shadows, light color, light ray direction, light strength, etc.

Inheritance

light_object = RLPy.RScene.FindObject(RLPy.EObjectType_Light, "Spotlight") # Find the spotlight by name

# set Parent
prop2 = RLPy.RScene.FindObject(RLPy.EObjectType_Prop, "Box2")
result = light_object.SetParent(prop2)
result = light_object.SetParent(None) #detach from parent

# link to &  unlink
result = light_object.LinkTo(prop2, RLPy.RTime(0))
result = light_object.UnLink(RLPy.RTime(0))
# set name
light_object.SetName( "new_name" )
#get bound
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
ret_pos = RLPy.RVector3()
ret_rot = RLPy.RVector3()
light_object.GetPivot( ret_pos, ret_rot )
print(ret)
#clone object
clone_light_object = light_object.Clone()
print( clone_light_object )
#is selected
RLPy.RScene.SelectObject(light_object)
print(light_object.IsSelected()) #True

Member Functions

GetDarkenShadowStrength ( self )

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

See Also: SetDarkenShadowStrength

Returns

Spotlight's shadow strength - float
light_object = RLPy.RScene.FindObject(RLPy.EObjectType_Light, "Spotlight") # Find the spotlight by name
 
#get light shadow strength
print(light_object.GetDarkenShadowStrength())

GetRange ( self )

Get the Spotlight's range distance.

See Also: SetRange

Returns

Spotlight's range attribute - float
light_object = RLPy.RScene.FindObject(RLPy.EObjectType_Light, "Spotlight") # Find the spotlight by name
 
#get light range
print(light_object.GetRange())

GetSpotLightBeam ( self, nAngle, nFalloff )

Get the Spotlight's light beam attributes, e.g. beam angle and spill light attenuation (falloff intensity).

See Also: SetSpotLightBeam

Parameters

nAngle [OUT] Spotlight's angle value - int
nFalloff [OUT] Spotlight's falloff value - int

Returns

Success - RLPy.RStatus.Success
Failure - RLPy.RStatus.Failure
light_object = RLPy.RScene.FindObject(RLPy.EObjectType_Light, "Spotlight") # Find the spotlight by name
 
# set light beam
spot_light_falloff_power = 40.0
spot_light_angle = 135.0
light_object.SetSpotLightBeam(RLPy.RTime(0), spot_light_falloff_power, spot_light_angle)
# get light beam
angle = 0
falloff = 0
light_object.GetSpotLightBeam(angle, falloff)
print(angle) # angle = 135
print(falloff) # falloff = 40

IsCastShadow ( self )

Check whether or not the Spotlight is casting shadows.

See Also: SetCastShadow

Returns

True if the spotlight is casting shadows, else False - bool
light_object = RLPy.RScene.FindObject(RLPy.EObjectType_Light, "Spotlight") # Find the spotlight by name
 
print(light_object.IsCastShadow())

SetCastShadow ( self, bEnable )

Turn on / off the Spotlight's cast shadows.

See Also: IsCastShadow

Parameters

bEnable [IN] Whether to cast shadows - bool

Returns

Success - RLPy.RStatus.Success
Failure - RLPy.RStatus.Failure
light_object = RLPy.RScene.FindObject(RLPy.EObjectType_Light, "Spotlight") # Find the spotlight by name
light_object.SetCastShadow(True)
print(light_object.IsCastShadow())

SetDarkenShadowStrength ( self, kTime, fStrength )

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

See Also: GetDarkenShadowStrength

Parameters

fStrength [IN] Spotlight shadow strength value - float

Returns

Success - RLPy.RStatus.Success
Failure - RLPy.RStatus.Failure
light_object = RLPy.RScene.FindObject(RLPy.EObjectType_Light, "Spotlight") # Find the spotlight by name
 
# Set light shadow strength
light_object.SetDarkenShadowStrength(RLPy.RTime(0), 50.0)

SetRange ( self, kTime, fRange )

Set the Spotlight's range value at a given point in time.

See Also: GetRange

Parameters

kTime [IN] Time at which to set the beam - RTime
fRange [IN] Spotlight range value - float

Returns

Success - RLPy.RStatus.Success
Failure - RLPy.RStatus.Failure
light_object = RLPy.RScene.FindObject(RLPy.EObjectType_Light, "Spotlight") # Find the spotlight by name
 
# Set light range
light_object.SetRange(RLPy.RTime(0), 1000.0)
print(light_object.GetRange())

SetSpotLightBeam ( self, kTime, fFalloffPower, fAngle )

Set the Spotlight's light beam attributes at a given point in time. These attributes include the light beam's angle and spill light attenuation (falloff intensity).

See Also: GetSpotLightBeam

Parameters

kTime [IN] Time at which to set the beam - RTime
fFalloffPower [IN] Light falloff power value - float
fAngle [IN] Light angle value - float

Returns

Success - RLPy.RStatus.Success
Failure - RLPy.RStatus.Failure
light_object = RLPy.RScene.FindObject(RLPy.EObjectType_Light, "Spotlight") # Find the spotlight by name
 
# Set light beam attributes
spot_light_falloff_power = 40.0
spot_light_angle = 135.0
light_object.SetSpotLightBeam(RLPy.RTime(0), spot_light_falloff_power, spot_light_angle)