artofillusion.object
Class ImplicitObject

java.lang.Object
  extended by artofillusion.object.Object3D
      extended by artofillusion.object.ImplicitObject

public abstract class ImplicitObject
extends Object3D

This abstract class represents an object whose surface is defined as an isosurface of a 3D field function. Subclasses define the function and isosurface value used to generate a particular surface. More precisely, the interior of the object is defined to consist of all points which satisfy the following conditions:

  1. The value of the field at that point is greater than the cutoff value.
  2. The point is inside the bounding box returned by getBounds().
In general, an implicit surface can be rendered in two different ways: by triangulating the surface, or by directly evaluating the field function (e.g. raymarching). Some renderers do not have the ability to visualize implicit surfaces directly, and therefore must use triangulation. Conversely, some implicit surface implementations may not support triangulation (getRenderingMesh() returns null). In that case, they cannot be rendered by renderers that do not support direct visualization.

When both methods are available, the object can specify which is the preferred one to use. It does this by implementing getPreferDirectRendering().


Field Summary
 
Fields inherited from class artofillusion.object.Object3D
APPROXIMATELY, CANT_CONVERT, EXACTLY
 
Constructor Summary
ImplicitObject()
          The default constructor does nothing.
ImplicitObject(java.io.DataInputStream in, Scene theScene)
          Subclasses should invoke this method in their own constructors for loading from a file.
 
Method Summary
 double getCutoff()
          Get the cutoff value which defines the surface of the object.
 void getFieldGradient(double x, double y, double z, double size, double time, Vec3 grad)
          Get the gradient of the field function at a point specified in object coordinates.
abstract  double getFieldValue(double x, double y, double z, double size, double time)
          Get the value of the field function at a point specified in object coordinates.
 double getMaxGradient()
          Get the maximum value which can ever occur for the absolute value of the field gradient.
abstract  boolean getPreferDirectRendering()
          Get the preferred rendering method to use when this object is rendered by a renderer that supports direct evaluation of the field.
 void writeToFile(java.io.DataOutputStream out, Scene theScene)
          Subclasses should invoke this method in their own writeToFile() methods.
 
Methods inherited from class artofillusion.object.Object3D
applyPoseKeyframe, canConvertToActor, canConvertToTriangleMesh, canSetMaterial, canSetTexture, configurePoseTrack, convertToTriangleMesh, copyObject, copyTextureAndMaterial, duplicate, edit, editGesture, editKeyframe, getAverageParameterValues, getBounds, getMaterial, getMaterialMapping, getParameters, getParameterValue, getParameterValues, getPosableObject, getPoseKeyframe, getProperties, getPropertyValue, getRenderingMesh, getSkeleton, getTexture, getTextureMapping, getWireframeMesh, isClosed, isEditable, readParameterValue, renderObject, sceneChanged, setMaterial, setParameters, setParameterValue, setParameterValues, setPropertyValue, setSize, setTexture
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImplicitObject

public ImplicitObject()
The default constructor does nothing.


ImplicitObject

public ImplicitObject(java.io.DataInputStream in,
                      Scene theScene)
               throws java.io.IOException,
                      java.io.InvalidObjectException
Subclasses should invoke this method in their own constructors for loading from a file.

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

getFieldValue

public abstract double getFieldValue(double x,
                                     double y,
                                     double z,
                                     double size,
                                     double time)
Get the value of the field function at a point specified in object coordinates.

Parameters:
x - the x coordinate of the location at which to evaluate the function
y - the y coordinate of the location at which to evaluate the function
z - the z coordinate of the location at which to evaluate the function
size - the width of the region over which to average the function for antialiasing
time - the time at which the function is being evaluated
Returns:
the value of the field function at the specified location

getFieldGradient

public void getFieldGradient(double x,
                             double y,
                             double z,
                             double size,
                             double time,
                             Vec3 grad)
Get the gradient of the field function at a point specified in object coordinates.

The default implementation of this method estimates the gradient by evaluating the field function at several closely spaced points. In many cases, it is possible to calculate the gradient both more quickly and more accurately by analytical means. Whenever possible, this method should be overridden to calculate the gradient directly.

Parameters:
x - the x coordinate of the location at which to evaluate the function
y - the y coordinate of the location at which to evaluate the function
z - the z coordinate of the location at which to evaluate the function
size - the width of the region over which to average the function for antialiasing
time - the time at which the function is being evaluated
grad - on exit, this should be set equal to the gradient of the field function at the specified location

getMaxGradient

public double getMaxGradient()
Get the maximum value which can ever occur for the absolute value of the field gradient. The default implementation returns Double.MAX_VALUE. If you can guarantee that the gradient will never be larger than some fixed value, overriding this method to return it may allow faster rendering.


getCutoff

public double getCutoff()
Get the cutoff value which defines the surface of the object. Points for which the field value is greater than the cutoff are inside the object.

The default implementation returns 1.0. It may be overridden to return a different value.


getPreferDirectRendering

public abstract boolean getPreferDirectRendering()
Get the preferred rendering method to use when this object is rendered by a renderer that supports direct evaluation of the field.

Returns:
true if direct evaluation is preferred, false if it is preferable to triangulate the surface by calling getRenderingMesh()

writeToFile

public void writeToFile(java.io.DataOutputStream out,
                        Scene theScene)
                 throws java.io.IOException
Subclasses should invoke this method in their own writeToFile() methods.

Overrides:
writeToFile in class Object3D
Throws:
java.io.IOException


Copyright © 1999-2008 by Peter Eastman.