Difference between revisions of "IC Python API:RLPy RISpotLight"
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.RILight *IC...") |
Chuck (RL) (Talk | contribs) m (→SetSpotLightBeam ( self, kTime, fAngle, fFalloff, fAttenuation )) |
||
(5 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}} | ||
− | + | {{last_modified}} | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
+ | == 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]] > [[IC_Python_API:RLPy_RISpotLight|RISpotLight]] | ||
+ | |||
+ | === Examples === | ||
+ | |||
+ | <syntaxhighlight lang="python" line='line'> | ||
+ | light_object = RLPy.RScene.FindObject(RLPy.EObjectType_Light, "Spotlight") # Find the spotlight by name | ||
− | |||
# 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 32: | ||
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 37: | ||
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> | ||
− | == | + | |
− | + | == Member Functions == | |
− | + | ||
− | + | === GetDarkenShadowStrength ( self ) === | |
− | + | ||
− | + | Get the Spotlight's shadow strength at a given point in time (0 to 100). | |
− | + | ||
− | + | See Also: [[#SetDarkenShadowStrength ( self, kTime, fStrength )|SetDarkenShadowStrength]] | |
− | + | ||
− | + | ==== Returns ==== | |
− | + | :Spotlight's shadow strength - float | |
− | + | ||
− | + | <syntaxhighlight lang="python" line='line'> | |
− | + | light_object = RLPy.RScene.FindObject(RLPy.EObjectType_Light, "Spotlight") # Find the spotlight by name | |
− | | | + | |
− | == | + | #get light shadow strength |
− | = | + | print(light_object.GetDarkenShadowStrength()) |
− | <syntaxhighlight lang=" | + | |
− | RLPy. | + | |
</syntaxhighlight> | </syntaxhighlight> | ||
− | Get the | + | |
− | + | === GetRange ( self ) === | |
− | ====Returns==== | + | |
− | + | Get the Spotlight's range distance. | |
− | + | ||
− | + | See Also: [[#SetRange ( self, kTime, fRange )|SetRange]] | |
− | + | ||
− | <syntaxhighlight lang=" | + | ==== Returns ==== |
− | RLPy. | + | :Spotlight's range attribute - float |
+ | |||
+ | <syntaxhighlight lang="python" line='line'> | ||
+ | light_object = RLPy.RScene.FindObject(RLPy.EObjectType_Light, "Spotlight") # Find the spotlight by name | ||
+ | |||
+ | #get light range | ||
+ | print(light_object.GetRange()) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | === GetSpotLightBeam( self, nAngle, nFalloff, nAttenuation ) === | |
− | + | Get the Spotlight's light beam attributes, e.g. beam angle and spill light attenuation (falloff intensity). | |
− | + | ||
− | + | ||
− | + | ||
− | + | {{Notice|Current implementation is faulty, subject to change in later editions.}} | |
− | ''' | + | See Also: [[#SetSpotLightBeam ( self, kTime, fAngle, fFalloff, fAttenuation )|SetSpotLightBeam]] |
− | + | ||
− | - | + | ==== Parameters ==== |
− | === | + | :'''nAngle''' [OUT] Spotlight's angle value - int |
− | <syntaxhighlight lang=" | + | :'''nFalloff''' [OUT] Spotlight's falloff value - int |
− | RLPy. | + | :'''nAttenuation''' [OUT] Spotlight's attenuation value - int |
+ | |||
+ | ==== Returns ==== | ||
+ | :Success - RLPy.RStatus.Success | ||
+ | :Failure - RLPy.RStatus.Failure | ||
+ | |||
+ | <syntaxhighlight lang="python" line='line'> | ||
+ | light_object = RLPy.RScene.FindObject(RLPy.EObjectType_Light, "Spotlight") # Find the spotlight by name | ||
+ | |||
+ | # Set light beam | ||
+ | light_object.SetSpotLightBeam(RLPy.RTime(0), 90, 50, 2) | ||
+ | |||
+ | # Get light beam | ||
+ | angle = 0 | ||
+ | falloff = 0 | ||
+ | attenuation = 0 | ||
+ | status, angle, falloff, attenuation = light_object.GetSpotLightBeam(angle, falloff, attenuation) | ||
+ | |||
+ | print(status.IsError()) # False | ||
+ | print(angle) # 90 | ||
+ | print(falloff) # 50 | ||
+ | print(attenuation) # 2 | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | + | ||
− | + | === IsCastShadow ( self ) === | |
− | ====Returns==== | + | |
− | + | Check whether or not the Spotlight is casting shadows. | |
− | + | ||
− | + | See Also: [[#SetCastShadow ( self, bEnable )|SetCastShadow]] | |
− | + | ||
− | <syntaxhighlight lang=" | + | ==== Returns ==== |
− | RLPy. | + | :'''True''' if the spotlight is casting shadows, else '''False''' - bool |
+ | |||
+ | <syntaxhighlight lang="python" line='line'> | ||
+ | light_object = RLPy.RScene.FindObject(RLPy.EObjectType_Light, "Spotlight") # Find the spotlight by name | ||
+ | |||
+ | print(light_object.IsCastShadow()) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
− | |||
− | |||
− | |||
− | + | === SetCastShadow ( self, bEnable ) === | |
− | + | ||
− | === | + | |
− | + | ||
− | ' | + | Turn on / off the Spotlight's cast shadows. |
− | ''' | + | See Also: [[#IsCastShadow ( self )|IsCastShadow]] |
− | + | ||
− | + | ==== Parameters ==== | |
− | === | + | :'''bEnable''' [IN] Whether to cast shadows - bool |
− | <syntaxhighlight lang=" | + | |
− | RLPy. | + | ==== Returns ==== |
+ | :Success - RLPy.RStatus.Success | ||
+ | :Failure - RLPy.RStatus.Failure | ||
+ | |||
+ | <syntaxhighlight lang="python" line='line'> | ||
+ | light_object = RLPy.RScene.FindObject(RLPy.EObjectType_Light, "Spotlight") # Find the spotlight by name | ||
+ | light_object.SetCastShadow(True) | ||
+ | print(light_object.IsCastShadow()) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
− | |||
− | |||
− | |||
− | + | === SetDarkenShadowStrength ( self, kTime, fStrength ) === | |
− | + | ||
− | === | + | |
− | + | ||
− | ' | + | 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 |
− | <syntaxhighlight lang=" | + | |
− | RLPy. | + | ==== Returns ==== |
+ | :Success - RLPy.RStatus.Success | ||
+ | :Failure - RLPy.RStatus.Failure | ||
+ | |||
+ | <syntaxhighlight lang="python" line='line'> | ||
+ | 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> | ||
− | |||
− | |||
− | |||
− | |||
− | + | === SetRange ( self, kTime, fRange ) === | |
− | ' | + | Set the Spotlight's range value at a given point in time. |
− | + | ||
− | + | ||
− | + | ||
− | + | 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 | |
− | === | + | |
− | <syntaxhighlight lang=" | + | ==== Returns ==== |
− | RLPy. | + | :Success - RLPy.RStatus.Success |
+ | :Failure - RLPy.RStatus.Failure | ||
+ | |||
+ | <syntaxhighlight lang="python" line='line'> | ||
+ | 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> | ||
− | |||
− | |||
− | |||
− | |||
− | + | === SetSpotLightBeam ( self, kTime, fAngle, fFalloff, fAttenuation ) === | |
− | '' | + | 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( self, nAngle, nFalloff, nAttenuation )|GetSpotLightBeam]] | |
− | + | ||
− | + | ||
− | + | ||
− | ''' | + | ==== Parameters ==== |
+ | :'''kTime''' [IN] Time at which to set the beam - [[IC_Python_API:RLPy_RTime|RTime]] | ||
+ | :'''fAngle''' [IN] Light angle value - float | ||
+ | :'''fFalloffPower''' [IN] Light falloff power value - float | ||
+ | :'''fAttenuation''' [IN] Light attenuation - float | ||
− | + | ==== Returns ==== | |
− | </ | + | :Success - RLPy.RStatus.Success |
+ | :Failure - RLPy.RStatus.Failure | ||
+ | |||
+ | <syntaxhighlight lang="python" line='line'> | ||
+ | light_object = RLPy.RScene.FindObject(RLPy.EObjectType_Light, "Spotlight") # use light name to find object | ||
+ | |||
+ | # set light beam | ||
+ | angle = 135.0 | ||
+ | falloff_power = 40.0 | ||
+ | attenuation = 2 | ||
+ | light_object.SetSpotLightBeam(RLPy.RTime(0), angle, falloff_power, attenuation) | ||
+ | </syntaxhighlight> |
Latest revision as of 22:54, 22 June 2020
Contents
- 1 Description
- 2 Member Functions
- 2.1 GetDarkenShadowStrength ( self )
- 2.2 GetRange ( self )
- 2.3 GetSpotLightBeam( self, nAngle, nFalloff, nAttenuation )
- 2.4 IsCastShadow ( self )
- 2.5 SetCastShadow ( self, bEnable )
- 2.6 SetDarkenShadowStrength ( self, kTime, fStrength )
- 2.7 SetRange ( self, kTime, fRange )
- 2.8 SetSpotLightBeam ( self, kTime, fAngle, fFalloff, fAttenuation )
- Main article: Modules.
- Last modified: 06/22/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
RIBase > RIObject > RILight > RISpotLight
Examples
1 light_object = RLPy.RScene.FindObject(RLPy.EObjectType_Light, "Spotlight") # Find the spotlight by name
2
3 # set Parent
4 prop2 = RLPy.RScene.FindObject(RLPy.EObjectType_Prop, "Box2")
5 result = light_object.SetParent(prop2)
6 result = light_object.SetParent(None) #detach from parent
7
8 # link to & unlink
9 result = light_object.LinkTo(prop2, RLPy.RTime(0))
10 result = light_object.UnLink(RLPy.RTime(0))
11 # set name
12 light_object.SetName( "new_name" )
13 #get bound
14 ret_max = RLPy.RVector3()
15 ret_center = RLPy.RVector3()
16 ret_min = RLPy.RVector3()
17 ret = light_object.GetBounds( ret_max, ret_center, ret_min )
18 print(ret)
19 #get pivot
20 ret_pos = RLPy.RVector3()
21 ret_rot = RLPy.RVector3()
22 light_object.GetPivot( ret_pos, ret_rot )
23 print(ret)
24 #clone object
25 clone_light_object = light_object.Clone()
26 print( clone_light_object )
27 #is selected
28 RLPy.RScene.SelectObject(light_object)
29 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
1 light_object = RLPy.RScene.FindObject(RLPy.EObjectType_Light, "Spotlight") # Find the spotlight by name
2
3 #get light shadow strength
4 print(light_object.GetDarkenShadowStrength())
GetRange ( self )
Get the Spotlight's range distance.
See Also: SetRange
Returns
- Spotlight's range attribute - float
1 light_object = RLPy.RScene.FindObject(RLPy.EObjectType_Light, "Spotlight") # Find the spotlight by name
2
3 #get light range
4 print(light_object.GetRange())
GetSpotLightBeam( self, nAngle, nFalloff, nAttenuation )
Get the Spotlight's light beam attributes, e.g. beam angle and spill light attenuation (falloff intensity).
- ⚠ Current implementation is faulty, subject to change in later editions.
See Also: SetSpotLightBeam
Parameters
- nAngle [OUT] Spotlight's angle value - int
- nFalloff [OUT] Spotlight's falloff value - int
- nAttenuation [OUT] Spotlight's attenuation value - int
Returns
- Success - RLPy.RStatus.Success
- Failure - RLPy.RStatus.Failure
1 light_object = RLPy.RScene.FindObject(RLPy.EObjectType_Light, "Spotlight") # Find the spotlight by name
2
3 # Set light beam
4 light_object.SetSpotLightBeam(RLPy.RTime(0), 90, 50, 2)
5
6 # Get light beam
7 angle = 0
8 falloff = 0
9 attenuation = 0
10 status, angle, falloff, attenuation = light_object.GetSpotLightBeam(angle, falloff, attenuation)
11
12 print(status.IsError()) # False
13 print(angle) # 90
14 print(falloff) # 50
15 print(attenuation) # 2
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
1 light_object = RLPy.RScene.FindObject(RLPy.EObjectType_Light, "Spotlight") # Find the spotlight by name
2
3 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
1 light_object = RLPy.RScene.FindObject(RLPy.EObjectType_Light, "Spotlight") # Find the spotlight by name
2 light_object.SetCastShadow(True)
3 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
1 light_object = RLPy.RScene.FindObject(RLPy.EObjectType_Light, "Spotlight") # Find the spotlight by name
2
3 # Set light shadow strength
4 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
1 light_object = RLPy.RScene.FindObject(RLPy.EObjectType_Light, "Spotlight") # Find the spotlight by name
2
3 # Set light range
4 light_object.SetRange(RLPy.RTime(0), 1000.0)
5 print(light_object.GetRange())
SetSpotLightBeam ( self, kTime, fAngle, fFalloff, fAttenuation )
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
- fAngle [IN] Light angle value - float
- fFalloffPower [IN] Light falloff power value - float
- fAttenuation [IN] Light attenuation - float
Returns
- Success - RLPy.RStatus.Success
- Failure - RLPy.RStatus.Failure
1 light_object = RLPy.RScene.FindObject(RLPy.EObjectType_Light, "Spotlight") # use light name to find object
2
3 # set light beam
4 angle = 135.0
5 falloff_power = 40.0
6 attenuation = 2
7 light_object.SetSpotLightBeam(RLPy.RTime(0), angle, falloff_power, attenuation)