AnyLogic
Expand
Font size
All Implemented Interfaces:
com.anylogic.engine.internal.Child, AggregatableAnimationElement, HasLevel, LevelElement, SVGElement, Serializable, Cloneable
Direct Known Subclasses:
Light3DAmbient, Light3DDirectional, Light3DPoint, Light3DSpot

public abstract class Light3D
extends Object
implements SVGElement
Base class for all 3D lights, may be added to 3D groups for scene lighting

The light consists of a number of different components: Ambient, Diffuse and Specular.
  • Ambient light is a light that had scattered for many times, so that it does not have any certain direction. Ambient light does not die out and is uniformly distributed all over the space.
  • Diffuse light shines in a particular direction but is reflected homogenously from each point of the surface (for example, fluorescent lights).
  • Specular light is a light that reflects off a smooth shiny surface.
The intensity and color of each component is defined in terms of general Color object. For example, Black means "No light", White - white light with maximum intensity, Red - red light with maximum intensity (e.g. green shape will be invisible under this light), Dark Red - red light with low intensity.
Each component is applied to the corresponding color part of shape's texture (if shape has texture) or the general shape's color (if shape has only Color).
Author:
AnyLogic North America, LLC https://anylogic.com
See Also:
ShapeGroup.add(Light3D)Serialized Form

Nested Class Summary

Modifier and TypeClassDescription
static class Light3D.CarHeadlight 
static class Light3D.Daylight 
static class Light3D.Moonlight 
static class Light3D.StreetLight 

Method Summary

Modifier and TypeMethodDescription
Light3Dclone()
Creates and returns a copy of this light (i.e.
voidexecuteUserAction(String value)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
SVGElementfindSVGElement(long svgId)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
ColorgetAmbientColor()
ColorgetDiffuseColor()
ShapeGroupgetGroup()
Returns the group containing this light.
LevelgetLevel()
Returns the level containing this shape.
StringgetName()
If the light is declared as field in a presentable object class (Agent), e.g.
PresentablegetPresentable()
Returns the Presentable object (Agent or Experiment) where this light belongs to, or null.
ColorgetSpecularColor()
longgetSVGId()
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
booleanisEnabled()
Returns true if this light is turned on.
booleanisGlobal()
Returns true if this light affects shapes outside the parent group of this light
voidonAggregatorVisibilityChanged()
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
voidremoveSVGFromOwner(Shape oldOwner)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
voidresetSVGState()
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
final voidrestoreOwner(Object owner)
Deprecated.
voidsetAmbientColor(Color ambientColor)
voidsetContextReference_xjal(Presentable contextReference)
Deprecated.
voidsetDiffuseColor(Color diffuseColor)
voidsetEnabled(boolean enabled)
Enables or disables this light
voidsetGlobal(boolean global)
Sets whether this light should affect shapes outside the parent group of this light
voidsetLevel(Level level)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
voidsetSpecularColor(Color specularColor)
voidupdate()
User extension point for dynamic properties update code
booleanupdateDynamicPropertiesStructural(boolean publicOnly) 
SVGElementupdateSVGProperties(List<SVGCommand> commands, ShapeDrawMode drawMode, boolean publicOnly, SVGElement owner, SVGElement elbehind)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
Updates SVG properties of the element that are then sent to the rendering client.

Methods inherited from class java.lang.Object

equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Methods inherited from interface com.anylogic.engine.markup.AggregatableAnimationElement

initializeInternal, postInitialize

Method Details

getDiffuseColor

public Color getDiffuseColor()
Returns:
the diffuse color component

setDiffuseColor

public void setDiffuseColor(Color diffuseColor)
Parameters:
diffuseColor - the diffuse color component

getSpecularColor

public Color getSpecularColor()
Returns:
the specular color component

setSpecularColor

public void setSpecularColor(Color specularColor)
Parameters:
specularColor - the specular color component

getAmbientColor

public Color getAmbientColor()
Returns:
the ambient color component

setAmbientColor

public void setAmbientColor(Color ambientColor)
Parameters:
ambientColor - the ambient color component

isGlobal

public boolean isGlobal()
Returns true if this light affects shapes outside the parent group of this light
Returns:
true if this light affects shapes outside the parent group of this light

setGlobal

public void setGlobal(boolean global)
Sets whether this light should affect shapes outside the parent group of this light
Parameters:
global - true if this light should affect shapes outside the parent group of this light

onAggregatorVisibilityChanged

public void onAggregatorVisibilityChanged()
Description copied from interface: AggregatableAnimationElement
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
Specified by:
onAggregatorVisibilityChanged in interface AggregatableAnimationElement

setEnabled

public void setEnabled(boolean enabled)
Enables or disables this light
Parameters:
enabled - true to turn on the light

isEnabled

public boolean isEnabled()
Returns true if this light is turned on. Note that Level containing the element may be invisible, and this method only returns the own state of the element.
Returns:
true if this light is enabled

getGroup

public ShapeGroup getGroup()
Returns the group containing this light.
Returns:
the group containing this light

getPresentable

public Presentable getPresentable()
Returns the Presentable object (Agent or Experiment) where this light belongs to, or null.
Returns:
the Presentable that owns this light, or null

getName

public String getName()
If the light is declared as field in a presentable object class (Agent), e.g. if it was drawn in the graphical editor, returns the name of the field, otherwise returns the string Shape.UNKNOWN_NAME.
This method is designed to be used for debug/development purposes only. It has a very inefficient implementation
Returns:
the name of the corresponding field or Shape.UNKNOWN_NAME

update

public void update()
User extension point for dynamic properties update code

clone

public Light3D clone()
Creates and returns a copy of this light (i.e. new light instance).
The returned light has the same type and parameters
The returned copy isn't automatically added to the group this light belongs to.
The clone is created in the context of the same agent

getSVGId

@AnyLogicInternalAPI
public long getSVGId()
Description copied from interface: SVGElement
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
Specified by:
getSVGId in interface SVGElement

updateSVGProperties

@AnyLogicInternalAPI
public SVGElement updateSVGProperties(List<SVGCommand> commands,
 ShapeDrawMode drawMode,
 boolean publicOnly,
 SVGElement owner,
 SVGElement elbehind)
Description copied from interface: SVGElement
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
Updates SVG properties of the element that are then sent to the rendering client. If the element is not yet in the SVG scene, generates "C" command, if it is there, but some properties are out of date, generates "U" command. If SVG drawing of this element is not needed because of public only settings, or permanently not needed, or not supported yet, returns false and does nothing.
Specified by:
updateSVGProperties in interface SVGElement
Parameters:
commands - the list of commands to add to
drawMode - TODO
publicOnly - drawing context: if true, only shapes that are marked as public only are updated
owner - the SVG element that serves as a container for this element
elbehind - the SVG element behind this one, or null if none or if order is irrelevant
Returns:
the actual owner this element has been added to or null if element is not drawn (e.g. drawing of this element is not needed because of public only settings, permanently not needed or not supported - hence SVG id is not set). The actual owner may differ from the given owner when the svg element is added to a different place (e.g. GIS map).

resetSVGState

@AnyLogicInternalAPI
public void resetSVGState()
Description copied from interface: SVGElement
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
Specified by:
resetSVGState in interface SVGElement

findSVGElement

@AnyLogicInternalAPI
public SVGElement findSVGElement(long svgId)
Description copied from interface: SVGElement
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
Specified by:
findSVGElement in interface SVGElement

executeUserAction

@AnyLogicInternalAPI
public void executeUserAction(String value)
Description copied from interface: SVGElement
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
Specified by:
executeUserAction in interface SVGElement

removeSVGFromOwner

@AnyLogicInternalAPI
public void removeSVGFromOwner(Shape oldOwner)
Description copied from interface: SVGElement
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
Specified by:
removeSVGFromOwner in interface SVGElement

updateDynamicPropertiesStructural

@AnyLogicInternalAPI
public boolean updateDynamicPropertiesStructural(boolean publicOnly)
Returns:
true if update was done (usually for visible elements, respecting public flag etc.)

getLevel

public Level getLevel()
Returns the level containing this shape. The returned value is null for shapes in the experiments.
Specified by:
getLevel in interface HasLevel
Returns:
the level containing this shape

setLevel

@AnyLogicInternalAPI
public void setLevel(Level level)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future. Please use Level.add(Shape) instead.
Specified by:
setLevel in interface LevelElement

restoreOwner

@AnyLogicInternalCodegenAPI
@Deprecated
public final void restoreOwner(Object owner)
Deprecated.
This method normally should not be called by user
This method restores owner of this object
The method is used in snapshot saving/loading
Specified by:
restoreOwner in interface com.anylogic.engine.internal.Child
Parameters:
owner - owner of this object, usually Agent, Experiment or ShapeGroup

setContextReference_xjal

@AnyLogicInternalAPI
@Deprecated
public void setContextReference_xjal(Presentable contextReference)
Deprecated.