artofillusion.object
Class Object3D

java.lang.Object
  extended by artofillusion.object.Object3D
Direct Known Subclasses:
CSGObject, Cube, Curve, Cylinder, ImplicitObject, Light, NullObject, ObjectCollection, ObjectWrapper, ReferenceImage, SceneCamera, Sphere, SplineMesh, TriangleMesh

public abstract class Object3D
extends java.lang.Object

Object3D is the abstract superclass of any object which can be placed into a Scene.


Field Summary
static int APPROXIMATELY
           
static int CANT_CONVERT
           
static int EXACTLY
           
 
Constructor Summary
Object3D()
           
Object3D(java.io.DataInputStream in, Scene theScene)
           
 
Method Summary
abstract  void applyPoseKeyframe(Keyframe k)
          Modify this object based on a pose keyframe.
 boolean canConvertToActor()
          Determine whether the user should be allowed to convert this object to an Actor.
 int canConvertToTriangleMesh()
          Tells whether the object can be converted to a TriangleMesh.
 boolean canSetMaterial()
          This method tells whether materials can be assigned to the object.
 boolean canSetTexture()
          This method tells whether textures can be assigned to the object.
 void configurePoseTrack(PoseTrack track)
          This will be called whenever a new pose track is created for this object.
 TriangleMesh convertToTriangleMesh(double tol)
          Return a TriangleMesh which reproduces the shape of this object.
abstract  void copyObject(Object3D obj)
          Copy all the properties of another object, to make this one identical to it.
 void copyTextureAndMaterial(Object3D obj)
          Copy all texture and material information from another object to this one.
abstract  Object3D duplicate()
          Create a new object which is an exact duplicate of this one.
 void edit(EditingWindow parent, ObjectInfo info, java.lang.Runnable cb)
          Display a window in which the user can edit this object.
 void editGesture(EditingWindow parent, ObjectInfo info, java.lang.Runnable cb, ObjectInfo realObject)
          Edit an object which represents a gesture for an Actor object.
 void editKeyframe(EditingWindow parent, Keyframe k, ObjectInfo info)
          Allow the user to edit a keyframe returned by getPoseKeyframe().
 double[] getAverageParameterValues()
          Get the average value of each texture parameter.
abstract  BoundingBox getBounds()
          Get a BoundingBox which just encloses the object.
 Material getMaterial()
          Get this object's Material.
 MaterialMapping getMaterialMapping()
          Get this object's MaterialMapping.
 TextureParameter[] getParameters()
          Get the list of texture parameters for this object.
 ParameterValue getParameterValue(TextureParameter param)
          Get the object defining the value of a particular texture parameter.
 ParameterValue[] getParameterValues()
          Get the list of objects defining the values of texture parameters.
 Object3D getPosableObject()
          Get a version of this object to which a pose track can be attached.
abstract  Keyframe getPoseKeyframe()
          Return a Keyframe which describes the current pose of this object.
 Property[] getProperties()
          Get a list of editable properties defined by this object.
 java.lang.Object getPropertyValue(int index)
          Get the value of one of this object's editable properties.
 RenderingMesh getRenderingMesh(double tol, boolean interactive, ObjectInfo info)
          Objects which can be rendered as part of a scene should override this method to return a RenderingMesh which describes the appearance of the object.
 Skeleton getSkeleton()
          Get the skeleton for this object, or null if it does not have one.
 Texture getTexture()
          Get this object's Texture.
 TextureMapping getTextureMapping()
          Get this object's TextureMapping.
abstract  WireframeMesh getWireframeMesh()
          Every object should override this method to return a WireframeMesh.
 boolean isClosed()
          Tells whether the object is closed.
 boolean isEditable()
          If the object can be edited by the user, isEditable() should be overridden to return true.
static ParameterValue readParameterValue(java.io.DataInputStream in)
          Read in the value of a texture parameter from a stream.
 void renderObject(ObjectInfo obj, ViewerCanvas canvas, Vec3 viewDir)
          Render this object into a ViewerCanvas.
 void sceneChanged(ObjectInfo info, Scene scene)
          This will be called whenever this object is moved, or the time changes.
 void setMaterial(Material mat, MaterialMapping map)
          Set the Material and MaterialMapping for this object.
 void setParameters(TextureParameter[] param)
          Set the list of texture parameters for this object.
 void setParameterValue(TextureParameter param, ParameterValue val)
          Set the object defining the value of a particular texture parameter.
 void setParameterValues(ParameterValue[] val)
          Set the list of objects defining the values of texture parameters.
 void setPropertyValue(int index, java.lang.Object value)
          Set the value of one of this object's editable properties.
abstract  void setSize(double xsize, double ysize, double zsize)
          Resize the object.
 void setTexture(Texture tex, TextureMapping map)
          Set the Texture and TextureMapping for this object.
 void writeToFile(java.io.DataOutputStream out, Scene theScene)
          The following method writes the object's data to an output stream.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CANT_CONVERT

public static final int CANT_CONVERT
See Also:
Constant Field Values

EXACTLY

public static final int EXACTLY
See Also:
Constant Field Values

APPROXIMATELY

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

Object3D

public Object3D()

Object3D

public Object3D(java.io.DataInputStream in,
                Scene theScene)
         throws java.io.IOException,
                java.io.InvalidObjectException
Throws:
java.io.IOException
java.io.InvalidObjectException
Method Detail

duplicate

public abstract Object3D duplicate()
Create a new object which is an exact duplicate of this one.


copyObject

public abstract void copyObject(Object3D obj)
Copy all the properties of another object, to make this one identical to it. If the two objects are of different classes, this will throw a ClassCastException.


getBounds

public abstract BoundingBox getBounds()
Get a BoundingBox which just encloses the object.


setSize

public abstract void setSize(double xsize,
                             double ysize,
                             double zsize)
Resize the object. This should be interpreted such that, if setSize() is followed by a call to getBounds(), the dimensions of the BoundingBox will exactly match the dimensions specified in setSize().


isClosed

public boolean isClosed()
Tells whether the object is closed. For curves, this means it has no endpoints. For surface, it means the surface has no boundary.


canConvertToTriangleMesh

public int canConvertToTriangleMesh()
Tells whether the object can be converted to a TriangleMesh. It should return one of the following values: CANT_CONVERT: The object cannot be converted to a TriangleMesh. EXACTLY: The object can be represented exactly by a TriangleMesh. APPROXIMATELY: The object can be converted to a TriangleMesh. However, the resulting mesh will not be exactly the same shape as the original object. If a class overrides this method, it must also override convertToTriangleMesh().


convertToTriangleMesh

public TriangleMesh convertToTriangleMesh(double tol)
Return a TriangleMesh which reproduces the shape of this object. If canConvertToTriangleMesh() returned APPROXIMATELY, this method should return a TriangleMesh which reproduces the object to within the specified tolerance. That is, no point on the mesh should be further than tol from the corresponding point on the original surface. If canConvertToTriangleMesh() returned EXACTLY, then tol should be ignored. If canConvertToTriangleMesh() return CANT_CONVERT, this method returns null.


sceneChanged

public void sceneChanged(ObjectInfo info,
                         Scene scene)
This will be called whenever this object is moved, or the time changes. Most objects will do nothing here, and do not need to override this. It is available for those cases where an object's internal properties depend explicitly on time or on the object's position within the scene.


isEditable

public boolean isEditable()
If the object can be edited by the user, isEditable() should be overridden to return true. edit() should then create a window and allow the user to edit the object.


edit

public void edit(EditingWindow parent,
                 ObjectInfo info,
                 java.lang.Runnable cb)
Display a window in which the user can edit this object.

Parameters:
parent - the window from which this command is being invoked
info - the ObjectInfo corresponding to this object
cb - a callback which will be executed when editing is complete. If the user cancels the operation, it will not be called.

editGesture

public void editGesture(EditingWindow parent,
                        ObjectInfo info,
                        java.lang.Runnable cb,
                        ObjectInfo realObject)
Edit an object which represents a gesture for an Actor object. realObject specifies the object in the scene which this is a gesture for.


canSetTexture

public boolean canSetTexture()
This method tells whether textures can be assigned to the object. Objects for which it makes no sense to assign a texture (curves, lights, etc.) should override this method to return false.


canSetMaterial

public boolean canSetMaterial()
This method tells whether materials can be assigned to the object. The default implementation will give the correct result for most objects, but subclasses can override this if necessary.


setTexture

public void setTexture(Texture tex,
                       TextureMapping map)
Set the Texture and TextureMapping for this object.


getTexture

public Texture getTexture()
Get this object's Texture.


getTextureMapping

public TextureMapping getTextureMapping()
Get this object's TextureMapping.


setMaterial

public void setMaterial(Material mat,
                        MaterialMapping map)
Set the Material and MaterialMapping for this object. Pass null for both arguments to specify that the object does not have a Material.


getMaterial

public Material getMaterial()
Get this object's Material.


getMaterialMapping

public MaterialMapping getMaterialMapping()
Get this object's MaterialMapping.


getParameters

public TextureParameter[] getParameters()
Get the list of texture parameters for this object.


setParameters

public void setParameters(TextureParameter[] param)
Set the list of texture parameters for this object.


getParameterValues

public ParameterValue[] getParameterValues()
Get the list of objects defining the values of texture parameters.


getAverageParameterValues

public double[] getAverageParameterValues()
Get the average value of each texture parameter.


setParameterValues

public void setParameterValues(ParameterValue[] val)
Set the list of objects defining the values of texture parameters.


getParameterValue

public ParameterValue getParameterValue(TextureParameter param)
Get the object defining the value of a particular texture parameter. If the parameter is not defined for this object, this returns null.


setParameterValue

public void setParameterValue(TextureParameter param,
                              ParameterValue val)
Set the object defining the value of a particular texture parameter.


copyTextureAndMaterial

public void copyTextureAndMaterial(Object3D obj)
Copy all texture and material information from another object to this one. This method is intended to be called by subclasses' implementations of duplicate() and copyObject().


getSkeleton

public Skeleton getSkeleton()
Get the skeleton for this object, or null if it does not have one.


getRenderingMesh

public RenderingMesh getRenderingMesh(double tol,
                                      boolean interactive,
                                      ObjectInfo info)
Objects which can be rendered as part of a scene should override this method to return a RenderingMesh which describes the appearance of the object. All points on the RenderingMesh should be within a distance tol of the true surface. The interactive flag tells whether the resulting Mesh will be rendered in interactive mode. When interactive is set to true, the RenderingMesh should be cached for future use, so that it may be rendered repeatedly without needing to be regenerated.

The ObjectInfo contains additional information which may affect how the object is rendered, such as it location in the scene, texture parameters, etc.

Objects which cannot be rendered directly (lights, cameras, curves, etc.) do not need to override this method.


getWireframeMesh

public abstract WireframeMesh getWireframeMesh()
Every object should override this method to return a WireframeMesh. This will be used for drawing the object in wireframe mode, and also for drawing "nonrenderable" objects in other rendering modes.


renderObject

public void renderObject(ObjectInfo obj,
                         ViewerCanvas canvas,
                         Vec3 viewDir)
Render this object into a ViewerCanvas. The default implementation is sufficient for most objects, but subclasses may override this to customize how they are displayed.

Parameters:
obj - the ObjectInfo for this object
canvas - the canvas in which to render this object
viewDir - the direction from which this object is being viewed

writeToFile

public void writeToFile(java.io.DataOutputStream out,
                        Scene theScene)
                 throws java.io.IOException
The following method writes the object's data to an output stream. Subclasses should override this method, but also call super.writeToFile() to save information about materials, etc. In addition to this method, every Object3D must include a constructor with the signature public Classname(DataInputStream in, Scene theScene) throws IOException, InvalidObjectException which reconstructs the object by reading its data from an input stream. This constructor, similarly, should call the overridden constructor to read information about materials, etc.

Throws:
java.io.IOException

readParameterValue

public static ParameterValue readParameterValue(java.io.DataInputStream in)
                                         throws java.io.IOException
Read in the value of a texture parameter from a stream.

Throws:
java.io.IOException

getProperties

public Property[] getProperties()
Get a list of editable properties defined by this object.


getPropertyValue

public java.lang.Object getPropertyValue(int index)
Get the value of one of this object's editable properties.

Parameters:
index - the index of the property to get

setPropertyValue

public void setPropertyValue(int index,
                             java.lang.Object value)
Set the value of one of this object's editable properties.

Parameters:
index - the index of the property to set
value - the value to set for the property

getPoseKeyframe

public abstract Keyframe getPoseKeyframe()
Return a Keyframe which describes the current pose of this object.


applyPoseKeyframe

public abstract void applyPoseKeyframe(Keyframe k)
Modify this object based on a pose keyframe.


configurePoseTrack

public void configurePoseTrack(PoseTrack track)
This will be called whenever a new pose track is created for this object. It allows the object to configure the track by setting its graphable values, subtracks, etc.


editKeyframe

public void editKeyframe(EditingWindow parent,
                         Keyframe k,
                         ObjectInfo info)
Allow the user to edit a keyframe returned by getPoseKeyframe().


canConvertToActor

public boolean canConvertToActor()
Determine whether the user should be allowed to convert this object to an Actor.


getPosableObject

public Object3D getPosableObject()
Get a version of this object to which a pose track can be attached. For most objects, this simply returns itself. Some objects, however, need to be converted to Actors to have pose tracks. If this method returns null, no pose track will be attached.



Copyright © 1999-2011 by Peter Eastman.