artofillusion.object
Class ImplicitSphere

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

public class ImplicitSphere
extends ImplicitObject

This is a spherical implicit object (i.e. a metaball). It is characterized by two numbers: a radius, which is the radius of the sphere it creates in isolation, and an "influence radius", which is the distance it extends outward before the implicit function becomes zero. The influence radius must by larger than the radius, or the behavior becomes undefined. This class is generally not useful on its own, but collections of ImplicitSpheres are useful for many sorts of effects where balls should smoothly merge together when they come close.


Nested Class Summary
static class ImplicitSphere.ImplicitSphereKeyframe
          Inner class representing a pose for an ImplicitSphere.
 
Field Summary
 
Fields inherited from class artofillusion.object.Object3D
APPROXIMATELY, CANT_CONVERT, EXACTLY
 
Constructor Summary
ImplicitSphere(java.io.DataInputStream in, Scene theScene)
          The following two methods are used for reading and writing files.
ImplicitSphere(double radius, double influenceRadius)
           
 
Method Summary
 void applyPoseKeyframe(Keyframe k)
          Modify this object based on a pose keyframe.
 void configurePoseTrack(PoseTrack track)
          This will be called whenever a new pose track is created for this object.
 void copyObject(Object3D obj)
          Copy all the properties of another object, to make this one identical to it.
 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 editKeyframe(EditingWindow parent, Keyframe k, ObjectInfo info)
          Allow the user to edit a keyframe returned by getPoseKeyframe().
 BoundingBox getBounds()
          Get a BoundingBox which just encloses the object.
 double getCutoff()
          Get the cutoff value which defines the surface of the object.
 double[] getDefaultPoseValues()
          Get the default list of graphable values for a keyframe returned by getPoseKeyframe().
 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.
 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 getInfluenceRadius()
           
 Keyframe getPoseKeyframe()
          Return a Keyframe which describes the current pose of this object.
 java.lang.String[] getPoseValueNames()
          Return an array containing the names of the graphable values for the keyframes returned by getPoseKeyframe().
 boolean getPreferDirectRendering()
          Get the preferred rendering method to use when this object is rendered by a renderer that supports direct evaluation of the field.
 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.
 double getRadius()
           
 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.
 WireframeMesh getWireframeMesh()
          Every object should override this method to return a WireframeMesh.
 boolean isEditable()
          If the object can be edited by the user, isEditable() should be overridden to return true.
 void setInfluenceRadius(double influenceRadius)
           
 void setMaterial(Material mat, MaterialMapping map)
          Set the Material and MaterialMapping for this object.
 void setPropertyValue(int index, java.lang.Object value)
          Set the value of one of this object's editable properties.
 void setRadius(double radius)
           
 void setSize(double xsize, double ysize, double zsize)
          Resize the object.
 void setTexture(Texture tex, TextureMapping mapping)
          Set the Texture and TextureMapping for this object.
 void writeToFile(java.io.DataOutputStream out, Scene theScene)
          Subclasses should invoke this method in their own writeToFile() methods.
 
Methods inherited from class artofillusion.object.ImplicitObject
canConvertToTriangleMesh, convertToTriangleMesh, generateMesh, getMaxGradient, sceneChanged
 
Methods inherited from class artofillusion.object.Object3D
canConvertToActor, canSetMaterial, canSetTexture, copyTextureAndMaterial, editGesture, getAverageParameterValues, getMaterial, getMaterialMapping, getParameters, getParameterValue, getParameterValues, getPosableObject, getSkeleton, getTexture, getTextureMapping, isClosed, readParameterValue, renderObject, setParameters, setParameterValue, setParameterValues
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImplicitSphere

public ImplicitSphere(double radius,
                      double influenceRadius)

ImplicitSphere

public ImplicitSphere(java.io.DataInputStream in,
                      Scene theScene)
               throws java.io.IOException,
                      java.io.InvalidObjectException
The following two methods are used for reading and writing files. The first is a constructor which reads the necessary data from an input stream. The other writes the object's representation to an output stream.

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

getRadius

public double getRadius()

setRadius

public void setRadius(double radius)

getInfluenceRadius

public double getInfluenceRadius()

setInfluenceRadius

public void setInfluenceRadius(double influenceRadius)

getCutoff

public double getCutoff()
Description copied from class: ImplicitObject
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.

Overrides:
getCutoff in class ImplicitObject

getPreferDirectRendering

public boolean getPreferDirectRendering()
Description copied from class: ImplicitObject
Get the preferred rendering method to use when this object is rendered by a renderer that supports direct evaluation of the field.

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

getFieldValue

public double getFieldValue(double x,
                            double y,
                            double z,
                            double size,
                            double time)
Description copied from class: ImplicitObject
Get the value of the field function at a point specified in object coordinates.

Specified by:
getFieldValue in class ImplicitObject
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)
Description copied from class: ImplicitObject
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.

Overrides:
getFieldGradient in class ImplicitObject
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

applyPoseKeyframe

public void applyPoseKeyframe(Keyframe k)
Description copied from class: Object3D
Modify this object based on a pose keyframe.

Specified by:
applyPoseKeyframe in class Object3D

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.

Overrides:
configurePoseTrack in class Object3D

getPoseValueNames

public java.lang.String[] getPoseValueNames()
Return an array containing the names of the graphable values for the keyframes returned by getPoseKeyframe().


getDefaultPoseValues

public double[] getDefaultPoseValues()
Get the default list of graphable values for a keyframe returned by getPoseKeyframe().


duplicate

public Object3D duplicate()
Description copied from class: Object3D
Create a new object which is an exact duplicate of this one.

Specified by:
duplicate in class Object3D

copyObject

public void copyObject(Object3D obj)
Description copied from class: Object3D
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.

Specified by:
copyObject in class Object3D

getBounds

public BoundingBox getBounds()
Description copied from class: Object3D
Get a BoundingBox which just encloses the object.

Specified by:
getBounds in class Object3D

setSize

public void setSize(double xsize,
                    double ysize,
                    double zsize)
Description copied from class: Object3D
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().

Specified by:
setSize in class Object3D

getWireframeMesh

public WireframeMesh getWireframeMesh()
Description copied from class: Object3D
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.

Overrides:
getWireframeMesh in class ImplicitObject

getRenderingMesh

public RenderingMesh getRenderingMesh(double tol,
                                      boolean interactive,
                                      ObjectInfo info)
Description copied from class: Object3D
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.

Overrides:
getRenderingMesh in class ImplicitObject

getPoseKeyframe

public Keyframe getPoseKeyframe()
Description copied from class: Object3D
Return a Keyframe which describes the current pose of this object.

Specified by:
getPoseKeyframe in class Object3D

getProperties

public Property[] getProperties()
Description copied from class: Object3D
Get a list of editable properties defined by this object.

Overrides:
getProperties in class Object3D

getPropertyValue

public java.lang.Object getPropertyValue(int index)
Description copied from class: Object3D
Get the value of one of this object's editable properties.

Overrides:
getPropertyValue in class Object3D
Parameters:
index - the index of the property to get

setPropertyValue

public void setPropertyValue(int index,
                             java.lang.Object value)
Description copied from class: Object3D
Set the value of one of this object's editable properties.

Overrides:
setPropertyValue in class Object3D
Parameters:
index - the index of the property to set
value - the value to set for the property

setTexture

public void setTexture(Texture tex,
                       TextureMapping mapping)
Description copied from class: Object3D
Set the Texture and TextureMapping for this object.

Overrides:
setTexture in class Object3D

setMaterial

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

Overrides:
setMaterial in class Object3D

isEditable

public boolean isEditable()
Description copied from class: Object3D
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.

Overrides:
isEditable in class Object3D

edit

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

Overrides:
edit in class Object3D
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.

writeToFile

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

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

editKeyframe

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

Overrides:
editKeyframe in class Object3D


Copyright © 1999-2011 by Peter Eastman.