Package com.jme3.light
Class LightList
java.lang.Object
com.jme3.light.LightList
- All Implemented Interfaces:
Savable
,JmeCloneable
,Cloneable
,Iterable<Light>
public final class LightList
extends Object
implements Iterable<Light>, Savable, Cloneable, JmeCloneable
LightList
is used internally by Spatial
s to manage
lights that are attached to them.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a light to the list.void
clear()
Resets list size to 0.clone()
void
cloneFields
(Cloner cloner, Object original) Implemented to perform deep cloning for this object, resolving local cloned references using the specified cloner.get
(int num) iterator()
Returns an iterator that can be used to iterate over this LightList.jmeClone()
Performs a regular shallow clone of the object.void
read
(JmeImporter im) void
remove
(int index) Remove the light at the given index.void
Removes the given light from the LightList.void
Set the owner of the LightList.int
size()
void
sort
(boolean transformChanged) Sorts the elements in the list according to their Comparator.void
Updates a "world-space" light list, using the spatial's local-space light list and its parent's world-space light list.void
write
(JmeExporter ex) Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
LightList
protected LightList()constructor for serialization. Do not use -
LightList
Creates aLightList
for the givenSpatial
.- Parameters:
owner
- The spatial owner
-
-
Method Details
-
setOwner
Set the owner of the LightList. Only used for cloning.- Parameters:
owner
- the desired owner (alias created)
-
add
Adds a light to the list. List size is doubled if there is no room.- Parameters:
l
- The light to add.
-
remove
public void remove(int index) Remove the light at the given index.- Parameters:
index
- the zero-based index of the Light to be removed (≥0)
-
remove
Removes the given light from the LightList.- Parameters:
l
- the light to remove
-
size
public int size()- Returns:
- The size of the list.
-
get
- Parameters:
num
- the zero-based index of the light to be accessed (≥0)- Returns:
- the light at the given index.
- Throws:
IndexOutOfBoundsException
- If the given index is outside bounds.
-
clear
public void clear()Resets list size to 0. -
sort
public void sort(boolean transformChanged) Sorts the elements in the list according to their Comparator. There are two reasons why lights should be resorted. First, if the lights have moved, that means their distance to the spatial changed. Second, if the spatial itself moved, it means the distance from it to the individual lights might have changed.- Parameters:
transformChanged
- Whether the spatial's transform has changed
-
update
Updates a "world-space" light list, using the spatial's local-space light list and its parent's world-space light list.- Parameters:
local
- the local-space LightList (not null)parent
- the parent's world-space LightList
-
iterator
Returns an iterator that can be used to iterate over this LightList. -
clone
-
jmeClone
Description copied from interface:JmeCloneable
Performs a regular shallow clone of the object. Some fields may also be cloned but generally only if they will never be shared with other objects. (For example, local Vector3fs and so on.)This method is separate from the regular clone() method so that objects might still maintain their own regular java clone() semantics (perhaps even using Cloner for those methods). However, because Java's clone() has specific features in the sense of Object's clone() implementation, it's usually best to have some path for subclasses to bypass the public clone() method that might be cloning fields and instead get at the superclass protected clone() methods. For example, through super.jmeClone() or another protected clone method that some base class eventually calls super.clone() in.
- Specified by:
jmeClone
in interfaceJmeCloneable
- Returns:
- a new instance
-
cloneFields
Description copied from interface:JmeCloneable
Implemented 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:
cloneFields
in interfaceJmeCloneable
- 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.
-
write
- Specified by:
write
in interfaceSavable
- Throws:
IOException
-
read
- Specified by:
read
in interfaceSavable
- Throws:
IOException
-