Class Light
java.lang.Object
net.risingworld.api.worldelements.GameObject
net.risingworld.api.worldelements.Light
Represents a light source.
Example: Spawn bright yellow light above player head
-
Nested Class Summary
Nested classes/interfaces inherited from class net.risingworld.api.worldelements.GameObject
GameObject.AttachTarget
-
Constructor Summary
ConstructorDescriptionLight
(Light.Type type) Light
(Light.Type type, float intensity, float range, int color) -
Method Summary
Modifier and TypeMethodDescriptionint
getColor()
Gets the light color (as rgba int).void
setColor
(float r, float g, float b, float a) Updates the light color.void
setColor
(int color) Updates the light color (as rgba int).void
setIntensity
(float intensity) Sets the light intensity.void
setRadius
(float radius) Sets the radius of the light source.void
setRange
(float range) Sets the max range for the light source, i.e how far the light is emitted from the light source position.void
setShadowIntensity
(float intensity) Sets the intensity for the shadows (0-1).void
setShadowsEnabled
(boolean set) Enables/disables shadows for this light.void
setShadowsMapResolution
(int resolution) Sets the resolution for the shadow map.void
setSpotAngle
(float angle) Only works for spot lights!
Sets the outer angle of the spot light in degree (1-179).void
setSpotInnerAngle
(float angle) Only works for spot lights!
Sets the inner angle of the spot light in degree (1-179).void
setVisibleDistance
(float distance) Determines how far the light is visible.void
setVolumetrics
(boolean set) Enables/disables volumetrics for this light.void
setVolumetricsIntensity
(float intensity) If volumetrics are enabled for this light, this determines the intensity.Methods inherited from class net.risingworld.api.worldelements.GameObject
addChild, addComponent, attachTo, attachTo, deleteAttribute, getAttribute, getAttributes, getChildCount, getChilds, getCollider, getID, getLayer, getLocalPosition, getLocalRotation, getLocalScale, getParent, getPluginID, hasAttribute, hasAttribute, invokeComponentMethod, isActive, isAttached, isColliderVisible, isDisposed, moveToLocalPosition, moveToLocalPosition, moveToLocalPosition, moveToLocalPosition, moveToLocalTransform, readWorldPosition, readWorldRotation, removeAllChilds, removeChild, removeComponent, removeFromParent, rotateToLocalRotation, setActive, setAttribute, setCollider, setColliderVisible, setComponentEnabled, setComponentProperty, setLayer, setLocalPosition, setLocalPosition, setLocalRotation, setLocalRotation, setLocalScale, setLocalScale
-
Constructor Details
-
Light
-
Light
-
-
Method Details
-
getLightType
-
getColor
public int getColor()Gets the light color (as rgba int).- Returns:
- the light color.
-
setColor
public void setColor(float r, float g, float b, float a) Updates the light color.- Parameters:
r
- the red color component (0-1).g
- the green color component (0-1).b
- the blue color component (0-1).a
- the alpha color component (0-1). Affects the light intensity.
-
setColor
public void setColor(int color) Updates the light color (as rgba int).- Parameters:
color
- the new rgba color.- Example: Set red color
-
setIntensity
public void setIntensity(float intensity) Sets the light intensity.- Parameters:
intensity
- the new light intensity.
-
setRange
public void setRange(float range) Sets the max range for the light source, i.e how far the light is emitted from the light source position.- Parameters:
range
- the new light range.
-
setRadius
public void setRadius(float radius) Sets the radius of the light source. Not to be confused with the light range!
Higher values result in less punctual light. You can compare this with the radius of a light bulb.- Parameters:
radius
- the radius of the light source.
-
setVisibleDistance
public void setVisibleDistance(float distance) Determines how far the light is visible. Set lower values to improve performance.- Parameters:
distance
- the max visible distance for the light.
-
setSpotAngle
public void setSpotAngle(float angle) Only works for spot lights!
Sets the outer angle of the spot light in degree (1-179).- Parameters:
angle
- the spot light angle (degree).
-
setSpotInnerAngle
public void setSpotInnerAngle(float angle) Only works for spot lights!
Sets the inner angle of the spot light in degree (1-179). Must be less than the outer angle!- Parameters:
angle
- the inner spot light angle (degree).
-
setVolumetrics
public void setVolumetrics(boolean set) Enables/disables volumetrics for this light. Use with caution due to high performance impact!- Parameters:
set
- true to enable volumetrics, false to disable it.
-
setVolumetricsIntensity
public void setVolumetricsIntensity(float intensity) If volumetrics are enabled for this light, this determines the intensity.- Parameters:
intensity
- the volumetric light intensity (0-16).
-
setShadowsEnabled
public void setShadowsEnabled(boolean set) Enables/disables shadows for this light. Warning: Shadows have a big impact on performance!- Parameters:
set
- true to enable shadows, false to disable them.
-
setShadowsMapResolution
public void setShadowsMapResolution(int resolution) Sets the resolution for the shadow map. The higher the resolution, the sharper the shadows, but also the higher the impact on performance. Please bear in mind that point lights use 6 shadow maps, while spot lights only use 1 shadow map. Recommended values for point lights are usually 64, 128 or 256, while for spot lights, 512 or 1024 can be used.- Parameters:
resolution
- resolution for the shadow map.
-
setShadowIntensity
public void setShadowIntensity(float intensity) Sets the intensity for the shadows (0-1). 1 is the default value (opaque shadows), 0 results in shadows being invisible. This setting has no impact on performance.- Parameters:
intensity
- intensity for the shadows from this light source.
-