artofillusion
Class Scene

java.lang.Object
  extended by artofillusion.Scene

public class Scene
extends java.lang.Object

The Scene class describes a collection of objects, arranged relative to each other to form a scene, as well as the available textures and materials, environment options, etc.


Field Summary
static int ENVIRON_DIFFUSE
           
static int ENVIRON_EMISSIVE
           
static int ENVIRON_SOLID
           
static int HANDLE_SIZE
           
 
Constructor Summary
Scene()
           
Scene(java.io.DataInputStream in, boolean fullScene)
          The following constructor is used for reading from arbitrary input streams.
Scene(java.io.File f, boolean fullScene)
          The following constructor is used for reading files.
 
Method Summary
 void addImage(ImageMap im)
          Add an image map to the scene.
 void addMaterial(Material mat)
          Add a new Material to the scene.
 void addMaterial(Material mat, int index)
          Add a new Material to the scene.
 void addMaterialListener(ListChangeListener ls)
          Add an object which wants to be notified when the list of Materials in the Scene changes.
 void addObject(Object3D obj, CoordinateSystem coords, java.lang.String name, UndoRecord undo)
          Add a new object to the scene.
 void addObject(ObjectInfo info, int index, UndoRecord undo)
          Add a new object to the scene in the specified position.
 void addObject(ObjectInfo info, UndoRecord undo)
          Add a new object to the scene.
 void addTexture(Texture tex)
          Add a new Texture to the scene.
 void addTexture(Texture tex, int index)
          Add a new Texture to the scene.
 void addTextureListener(ListChangeListener ls)
          Add an object which wants to be notified when the list of Textures in the Scene changes.
 void addToSelection(int which)
          Deprecated. Call addToSelection() on the LayoutWindow instead.
 void applyTracksAfterModification(java.util.Collection<ObjectInfo> changedObjects)
          This should be called after one or more objects have been modified by the user.
 void applyTracksToObject(ObjectInfo info)
          Modify an object (and any objects that depend on it) based on its tracks at the current time.
 void changeMaterial(int which)
          This method should be called after a Material has been edited.
 void changeTexture(int which)
          This method should be called after a Texture has been edited.
 void clearSelection()
          Deprecated. Call clearSelection() on the LayoutWindow instead.
 boolean errorsOccurredInLoading()
          Return true if any errors occurred while loading the scene.
 java.util.Set<java.lang.String> getAllMetadataNames()
          Get the names of all metadata objects stored in this scene.
 java.util.List<ObjectInfo> getAllObjects()
          Get all objects in the Scene in the form of a List.
 RGBColor getAmbientColor()
          Get the scene's ambient light color.
 Texture getDefaultTexture()
          Get the default Texture for newly created objects.
 java.lang.String getDirectory()
          Get the directory on disk in which this scene is saved.
 RGBColor getEnvironmentColor()
          Get the environment color.
 TextureMapping getEnvironmentMapping()
          Get the TextureMapping being used to map the environment map texture to the environment sphere.
 int getEnvironmentMode()
          Get the Scene's environment mapping mode.
 ParameterValue[] getEnvironmentParameterValues()
          Get the parameter values used for the environment map.
 Texture getEnvironmentTexture()
          Get the texture being used as an environment mapping.
 RGBColor getFogColor()
          Get the fog color.
 double getFogDistance()
          Get the length constant for exponential fog.
 boolean getFogState()
          Determine whether fog is enabled.
 int getFramesPerSecond()
          Get the number of frames per second.
 double getGridSpacing()
          Get the grid spacing.
 int getGridSubdivisions()
          Get the number of grid snap-to subdivisions.
 ImageMap getImage(int i)
          Get the i'th image map.
 java.lang.String getLoadingErrors()
          Get a description of any errors which occurred while loading the scene.
 Material getMaterial(int i)
          Get the i'th material.
 Material getMaterial(java.lang.String name)
          Get the material with the specified name, or null if there is none.
 java.lang.Object getMetadata(java.lang.String name)
          Get a piece of metadata stored in this scene.
 java.lang.String getName()
          Get the name of this scene.
 int getNumImages()
          Get the number of image maps in this scene.
 int getNumMaterials()
          Get the number of materials in this scene.
 int getNumObjects()
          Get the number of objects in this scene.
 int getNumTextures()
          Get the number of textures in this scene.
 ObjectInfo getObject(int i)
          Get the i'th object.
 ObjectInfo getObject(java.lang.String name)
          Get the object with the specified name, or null if there is none.
 ObjectInfo getObjectById(int id)
          Get the object with the specified ID, or null if there is none.
 int[] getSelection()
          Deprecated. Call getSelectedIndices() or getSelectedObjects() on the LayoutWindow instead.
 int[] getSelectionWithChildren()
          Deprecated. Call getSelectionWithChildren() on the LayoutWindow instead.
 boolean getShowGrid()
          Get whether the grid is displayed.
 boolean getSnapToGrid()
          Get whether snap-to-grid is enabled.
 Texture getTexture(int i)
          Get the i'th texture.
 Texture getTexture(java.lang.String name)
          Get the texture with the specified name, or null if there is none.
 double getTime()
          Get the current time.
 int indexOf(ImageMap im)
          Get the index of the specified image map.
 int indexOf(Material mat)
          Get the index of the specified material.
 int indexOf(ObjectInfo info)
          Get the index of the specified object.
 int indexOf(Texture tex)
          Get the index of the specified texture.
 void objectModified(Object3D obj)
          This should be called whenever an object changes.
 void removeFromSelection(int which)
          Deprecated. Call removeFromSelection() on the LayoutWindow instead.
 boolean removeImage(int which)
          Remove an image map from the scene.
 void removeMaterial(int which)
          Remove a Material from the scene.
 void removeMaterialListener(ListChangeListener ls)
          Remove an object from the set to be notified when the list of Materials changes.
 void removeObject(int which, UndoRecord undo)
          Delete an object from the scene.
 void removeTexture(int which)
          Remove a Texture from the scene.
 void removeTextureListener(ListChangeListener ls)
          Remove an object from the set to be notified when the list of Textures changes.
 void reorderMaterial(int oldIndex, int newIndex)
          Reorder the list of Materials by moving a Material to a new position in the list.
 void reorderTexture(int oldIndex, int newIndex)
          Reorder the list of Textures by moving a Texture to a new position in the list.
 void replaceObject(Object3D original, Object3D replaceWith, UndoRecord undo)
          Replace every instance of one object in the scene with another one.
 void setAmbientColor(RGBColor color)
          Set the scene's ambient light color.
 void setDirectory(java.lang.String newDir)
          Set the directory on disk in which this scene is saved.
 void setEnvironmentColor(RGBColor color)
          Set the environment color.
 void setEnvironmentMapping(TextureMapping map)
          Set the TextureMapping to use for mapping the environment map texture to the environment sphere.
 void setEnvironmentMode(int mode)
          Set the Scene's environment mapping mode.
 void setEnvironmentParameterValues(ParameterValue[] value)
          Set the parameter values used for the environment map.
 void setEnvironmentTexture(Texture tex)
          Set the texture being used as an environment mapping.
 void setFog(boolean state, double dist)
          Set the state of fog in the scene.
 void setFogColor(RGBColor color)
          Set the fog color.
 void setFramesPerSecond(int n)
          Set the number of frames per second.
 void setGridSpacing(double spacing)
          Set the grid spacing.
 void setGridSubdivisions(int subdivisions)
          Set the number of grid snap-to subdivisions.
 void setMetadata(java.lang.String name, java.lang.Object value)
          Store a piece of metadata in this scene.
 void setName(java.lang.String newName)
          Set the name of this scene.
 void setSelection(int which)
          Deprecated. Call setSelection() on the LayoutWindow instead.
 void setSelection(int[] which)
          Deprecated. Call setSelection() on the LayoutWindow instead.
 void setShowGrid(boolean show)
          Set whether the grid is displayed.
 void setSnapToGrid(boolean snap)
          Set whether snap-to-grid is enabled.
 void setTime(double t)
          Set the current time.
 void showTexturesDialog(EditingWindow parent)
          Show the dialog for editing textures and materials.
 void writeToFile(java.io.File f)
          Save the Scene to a file.
 void writeToStream(java.io.DataOutputStream out)
          Write the Scene's representation to an output stream.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HANDLE_SIZE

public static final int HANDLE_SIZE
See Also:
Constant Field Values

ENVIRON_SOLID

public static final int ENVIRON_SOLID
See Also:
Constant Field Values

ENVIRON_DIFFUSE

public static final int ENVIRON_DIFFUSE
See Also:
Constant Field Values

ENVIRON_EMISSIVE

public static final int ENVIRON_EMISSIVE
See Also:
Constant Field Values
Constructor Detail

Scene

public Scene()

Scene

public Scene(java.io.File f,
             boolean fullScene)
      throws java.io.IOException,
             java.io.InvalidObjectException
The following constructor is used for reading files. If fullScene is false, only the Textures and Materials are read.

Throws:
java.io.IOException
java.io.InvalidObjectException

Scene

public Scene(java.io.DataInputStream in,
             boolean fullScene)
      throws java.io.IOException,
             java.io.InvalidObjectException
The following constructor is used for reading from arbitrary input streams. If fullScene is false, only the Textures and Materials are read.

Throws:
java.io.IOException
java.io.InvalidObjectException
Method Detail

getName

public java.lang.String getName()
Get the name of this scene.


setName

public void setName(java.lang.String newName)
Set the name of this scene.


getDirectory

public java.lang.String getDirectory()
Get the directory on disk in which this scene is saved.


setDirectory

public void setDirectory(java.lang.String newDir)
Set the directory on disk in which this scene is saved.


getTime

public double getTime()
Get the current time.


setTime

public void setTime(double t)
Set the current time.


applyTracksToObject

public void applyTracksToObject(ObjectInfo info)
Modify an object (and any objects that depend on it) based on its tracks at the current time.


applyTracksAfterModification

public void applyTracksAfterModification(java.util.Collection<ObjectInfo> changedObjects)
This should be called after one or more objects have been modified by the user. It applies the animation tracks of all other objects which depend on the modified ones. It also applies a subset of the animation tracks on the modified objects themselves to reflect their dependencies on other parts of the scene.


getFramesPerSecond

public int getFramesPerSecond()
Get the number of frames per second.


setFramesPerSecond

public void setFramesPerSecond(int n)
Set the number of frames per second.


getAmbientColor

public RGBColor getAmbientColor()
Get the scene's ambient light color.


setAmbientColor

public void setAmbientColor(RGBColor color)
Set the scene's ambient light color.


getEnvironmentMode

public int getEnvironmentMode()
Get the Scene's environment mapping mode. This will be either ENVIRON_SOLID, ENVIRON_DIFFUSE, or ENVIRON_EMISSIVE.


setEnvironmentMode

public void setEnvironmentMode(int mode)
Set the Scene's environment mapping mode. This should be either ENVIRON_SOLID, ENVIRON_DIFFUSE, or ENVIRON_EMISSIVE.


getEnvironmentTexture

public Texture getEnvironmentTexture()
Get the texture being used as an environment mapping.


setEnvironmentTexture

public void setEnvironmentTexture(Texture tex)
Set the texture being used as an environment mapping.


getEnvironmentMapping

public TextureMapping getEnvironmentMapping()
Get the TextureMapping being used to map the environment map texture to the environment sphere.


setEnvironmentMapping

public void setEnvironmentMapping(TextureMapping map)
Set the TextureMapping to use for mapping the environment map texture to the environment sphere.


getEnvironmentParameterValues

public ParameterValue[] getEnvironmentParameterValues()
Get the parameter values used for the environment map.


setEnvironmentParameterValues

public void setEnvironmentParameterValues(ParameterValue[] value)
Set the parameter values used for the environment map.


getEnvironmentColor

public RGBColor getEnvironmentColor()
Get the environment color.


setEnvironmentColor

public void setEnvironmentColor(RGBColor color)
Set the environment color.


getFogColor

public RGBColor getFogColor()
Get the fog color.


setFogColor

public void setFogColor(RGBColor color)
Set the fog color.


getFogState

public boolean getFogState()
Determine whether fog is enabled.


getFogDistance

public double getFogDistance()
Get the length constant for exponential fog.


setFog

public void setFog(boolean state,
                   double dist)
Set the state of fog in the scene.

Parameters:
state - sets whether fog is enabled
dist - the length constant for exponential fog.

getShowGrid

public boolean getShowGrid()
Get whether the grid is displayed.


setShowGrid

public void setShowGrid(boolean show)
Set whether the grid is displayed.


getSnapToGrid

public boolean getSnapToGrid()
Get whether snap-to-grid is enabled.


setSnapToGrid

public void setSnapToGrid(boolean snap)
Set whether snap-to-grid is enabled.


getGridSpacing

public double getGridSpacing()
Get the grid spacing.


setGridSpacing

public void setGridSpacing(double spacing)
Set the grid spacing.


getGridSubdivisions

public int getGridSubdivisions()
Get the number of grid snap-to subdivisions.


setGridSubdivisions

public void setGridSubdivisions(int subdivisions)
Set the number of grid snap-to subdivisions.


addObject

public void addObject(Object3D obj,
                      CoordinateSystem coords,
                      java.lang.String name,
                      UndoRecord undo)
Add a new object to the scene. If undo is not null, appropriate commands will be added to it to undo this operation.


addObject

public void addObject(ObjectInfo info,
                      UndoRecord undo)
Add a new object to the scene. If undo is not null, appropriate commands will be added to it to undo this operation.


addObject

public void addObject(ObjectInfo info,
                      int index,
                      UndoRecord undo)
Add a new object to the scene in the specified position. If undo is not null, appropriate commands will be added to it to undo this operation.


removeObject

public void removeObject(int which,
                         UndoRecord undo)
Delete an object from the scene. If undo is not null, appropriate commands will be added to it to undo this operation.


addMaterial

public void addMaterial(Material mat)
Add a new Material to the scene.


addMaterial

public void addMaterial(Material mat,
                        int index)
Add a new Material to the scene.

Parameters:
mat - the Material to add
index - the position in the list to add it at

removeMaterial

public void removeMaterial(int which)
Remove a Material from the scene.


reorderMaterial

public void reorderMaterial(int oldIndex,
                            int newIndex)
Reorder the list of Materials by moving a Material to a new position in the list.

Parameters:
oldIndex - the index of the Material to move
newIndex - the new position to move it to

addTexture

public void addTexture(Texture tex)
Add a new Texture to the scene.


addTexture

public void addTexture(Texture tex,
                       int index)
Add a new Texture to the scene.

Parameters:
tex - the Texture to add
index - the position in the list to add it at

removeTexture

public void removeTexture(int which)
Remove a Texture from the scene.


reorderTexture

public void reorderTexture(int oldIndex,
                           int newIndex)
Reorder the list of Textures by moving a Texture to a new position in the list.

Parameters:
oldIndex - the index of the Texture to move
newIndex - the new position to move it to

changeMaterial

public void changeMaterial(int which)
This method should be called after a Material has been edited. It notifies any objects using the Material that it has changed.


changeTexture

public void changeTexture(int which)
This method should be called after a Texture has been edited. It notifies any objects using the Texture that it has changed.


addMaterialListener

public void addMaterialListener(ListChangeListener ls)
Add an object which wants to be notified when the list of Materials in the Scene changes.


removeMaterialListener

public void removeMaterialListener(ListChangeListener ls)
Remove an object from the set to be notified when the list of Materials changes.


addTextureListener

public void addTextureListener(ListChangeListener ls)
Add an object which wants to be notified when the list of Textures in the Scene changes.


removeTextureListener

public void removeTextureListener(ListChangeListener ls)
Remove an object from the set to be notified when the list of Textures changes.


getMetadata

public java.lang.Object getMetadata(java.lang.String name)
Get a piece of metadata stored in this scene.

Parameters:
name - the name of the piece of metadata to get
Returns:
the value associated with that name, or null if there is none

setMetadata

public void setMetadata(java.lang.String name,
                        java.lang.Object value)
Store a piece of metadata in this scene. This may be an arbitrary object which you want to store as part of the scene. When the scene is saved to disk, metadata objects are stored using the java.beans.XMLEncoder class. This means that if the object is not a bean, you must register a PersistenceDelegate for it before calling this method. Otherwise, it will fail to be saved.

Parameters:
name - the name of the piece of metadata to set
value - the value to store

getAllMetadataNames

public java.util.Set<java.lang.String> getAllMetadataNames()
Get the names of all metadata objects stored in this scene.


showTexturesDialog

public void showTexturesDialog(EditingWindow parent)
Show the dialog for editing textures and materials.


addImage

public void addImage(ImageMap im)
Add an image map to the scene.


removeImage

public boolean removeImage(int which)
Remove an image map from the scene.


replaceObject

public void replaceObject(Object3D original,
                          Object3D replaceWith,
                          UndoRecord undo)
Replace every instance of one object in the scene with another one. If undo is not null, commands will be added to it to undo this operation.


objectModified

public void objectModified(Object3D obj)
This should be called whenever an object changes. It clears any cached meshes for any instances of the object.


setSelection

public void setSelection(int which)
Deprecated. Call setSelection() on the LayoutWindow instead.

Set one object to be selected, deselecting all other objects.


setSelection

public void setSelection(int[] which)
Deprecated. Call setSelection() on the LayoutWindow instead.

Set a list of objects to be selected, deselecting all other objects.


addToSelection

public void addToSelection(int which)
Deprecated. Call addToSelection() on the LayoutWindow instead.

Add an object to the list of selected objects.


clearSelection

public void clearSelection()
Deprecated. Call clearSelection() on the LayoutWindow instead.

Deselect all objects.


removeFromSelection

public void removeFromSelection(int which)
Deprecated. Call removeFromSelection() on the LayoutWindow instead.

Deselect a particular object.


getNumObjects

public int getNumObjects()
Get the number of objects in this scene.


getObject

public ObjectInfo getObject(int i)
Get the i'th object.


getObject

public ObjectInfo getObject(java.lang.String name)
Get the object with the specified name, or null if there is none. If more than one object has the same name, this will return the first one.


getObjectById

public ObjectInfo getObjectById(int id)
Get the object with the specified ID, or null if there is none.


getAllObjects

public java.util.List<ObjectInfo> getAllObjects()
Get all objects in the Scene in the form of a List.


indexOf

public int indexOf(ObjectInfo info)
Get the index of the specified object.


getNumTextures

public int getNumTextures()
Get the number of textures in this scene.


indexOf

public int indexOf(Texture tex)
Get the index of the specified texture.


getTexture

public Texture getTexture(int i)
Get the i'th texture.


getTexture

public Texture getTexture(java.lang.String name)
Get the texture with the specified name, or null if there is none. If more than one texture has the same name, this will return the first one.


getNumMaterials

public int getNumMaterials()
Get the number of materials in this scene.


getMaterial

public Material getMaterial(int i)
Get the i'th material.


getMaterial

public Material getMaterial(java.lang.String name)
Get the material with the specified name, or null if there is none. If more than one material has the same name, this will return the first one.


indexOf

public int indexOf(Material mat)
Get the index of the specified material.


getNumImages

public int getNumImages()
Get the number of image maps in this scene.


getImage

public ImageMap getImage(int i)
Get the i'th image map.


indexOf

public int indexOf(ImageMap im)
Get the index of the specified image map.


getDefaultTexture

public Texture getDefaultTexture()
Get the default Texture for newly created objects.


getSelection

public int[] getSelection()
Deprecated. Call getSelectedIndices() or getSelectedObjects() on the LayoutWindow instead.

Get a list of the indices of all selected objects.


getSelectionWithChildren

public int[] getSelectionWithChildren()
Deprecated. Call getSelectionWithChildren() on the LayoutWindow instead.

Get the indices of all objects which are either selected, or are children of selected objects.


errorsOccurredInLoading

public boolean errorsOccurredInLoading()
Return true if any errors occurred while loading the scene. The scene is still valid and usable, but some objects in it were not loaded correctly.


getLoadingErrors

public java.lang.String getLoadingErrors()
Get a description of any errors which occurred while loading the scene.


writeToFile

public void writeToFile(java.io.File f)
                 throws java.io.IOException
Save the Scene to a file.

Throws:
java.io.IOException

writeToStream

public void writeToStream(java.io.DataOutputStream out)
                   throws java.io.IOException
Write the Scene's representation to an output stream.

Throws:
java.io.IOException


Copyright © 1999-2011 by Peter Eastman.