Package com.jme3.scene.control
Class LightControl
java.lang.Object
com.jme3.scene.control.AbstractControl
com.jme3.scene.control.LightControl
- All Implemented Interfaces:
Savable,Control,JmeCloneable,Cloneable
`LightControl` synchronizes the world transformation (position and/or
direction) of a `Light` with its attached `Spatial`. This control allows
a light to follow a spatial or vice-versa, depending on the chosen
LightControl.ControlDirection.
This is particularly useful for attaching lights to animated characters, moving vehicles, or dynamically controlled objects.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumRepresents the local axis of the spatial (X, Y, or Z) to be used for determining the light's direction when `ControlDirection` is `SpatialToLight`.static enumDefines the direction of synchronization between the light and the spatial. -
Field Summary
Fields inherited from class com.jme3.scene.control.AbstractControl
enabled, spatial -
Constructor Summary
ConstructorsConstructorDescriptionFor serialization only.LightControl(Light light) Creates a new `LightControl` that synchronizes the light's transform to the spatial.LightControl(Light light, LightControl.ControlDirection controlDir) Creates a new `LightControl` with a specified synchronization direction. -
Method Summary
Modifier and TypeMethodDescriptionvoidcloneFields(Cloner cloner, Object original) Implemented to perform deep cloning for this object, resolving local cloned references using the specified cloner.protected voidcontrolRender(RenderManager rm, ViewPort vp) To be implemented in subclass.protected voidcontrolUpdate(float tpf) To be implemented in subclass.getLight()booleanvoidread(JmeImporter im) voidsetAxisRotation(LightControl.Axis axisRotation) voidsetControlDir(LightControl.ControlDirection controlDir) voidsetInvertAxisDirection(boolean invertAxisDirection) voidtoString()voidwrite(JmeExporter ex) Methods inherited from class com.jme3.scene.control.AbstractControl
cloneForSpatial, getSpatial, isEnabled, jmeClone, render, setEnabled, setSpatial, update
-
Constructor Details
-
LightControl
public LightControl()For serialization only. Do not use. -
LightControl
Creates a new `LightControl` that synchronizes the light's transform to the spatial.- Parameters:
light- The light to be synced.- Throws:
IllegalArgumentException- if the light type is not supported (only Point, Directional, and Spot lights are supported).
-
LightControl
Creates a new `LightControl` with a specified synchronization direction.- Parameters:
light- The light to be synced.controlDir- The direction of synchronization (SpatialToLight or LightToSpatial).- Throws:
IllegalArgumentException- if the light type is not supported (only Point, Directional, and Spot lights are supported).
-
-
Method Details
-
getLight
-
setLight
-
getControlDir
-
setControlDir
-
getAxisRotation
-
setAxisRotation
-
isInvertAxisDirection
public boolean isInvertAxisDirection() -
setInvertAxisDirection
public void setInvertAxisDirection(boolean invertAxisDirection) -
controlUpdate
protected void controlUpdate(float tpf) Description copied from class:AbstractControlTo be implemented in subclass.- Specified by:
controlUpdatein classAbstractControl- Parameters:
tpf- time per frame (in seconds)
-
controlRender
Description copied from class:AbstractControlTo be implemented in subclass.- Specified by:
controlRenderin classAbstractControl- Parameters:
rm- the RenderManager rendering the controlled Spatial (not null)vp- the ViewPort being rendered (not null)
-
cloneFields
Description copied from interface:JmeCloneableImplemented to perform deep cloning for this object, resolving local cloned references using the specified cloner. The object can call cloner.clone(fieldValue) to deep clone any of its fields.Note: during normal clone operations the original object will not be needed as the clone has already had all of the fields shallow copied.
- Specified by:
cloneFieldsin interfaceJmeCloneable- Overrides:
cloneFieldsin classAbstractControl- Parameters:
cloner- The cloner that is performing the cloning operation. The cloneFields method can call back into the cloner to make clones of its subordinate fields.original- The original object from which this object was cloned. This is provided for the very rare case that this object needs to refer to its original for some reason. In general, all of the relevant values should have been transferred during the shallow clone, and this object need only clone what it wants.
-
read
- Specified by:
readin interfaceSavable- Overrides:
readin classAbstractControl- Throws:
IOException
-
write
- Specified by:
writein interfaceSavable- Overrides:
writein classAbstractControl- Throws:
IOException
-
toString
-