artofillusion.object
Class Curve

java.lang.Object
  extended by artofillusion.object.Object3D
      extended by artofillusion.object.Curve
All Implemented Interfaces:
Mesh
Direct Known Subclasses:
Tube

public class Curve
extends Object3D
implements Mesh

The Curve class represents a continuous curve defined by a series of control vertices. It may be either open or closed, and may either interpolate or approximate the control vertices. There is also a smoothness parameter associated with each vertex.


Nested Class Summary
static class Curve.CurveKeyframe
          This class represents a pose of a Curve.
 
Field Summary
 
Fields inherited from class artofillusion.object.Object3D
APPROXIMATELY, CANT_CONVERT, EXACTLY
 
Fields inherited from interface artofillusion.object.Mesh
APPROXIMATING, INTERPOLATING, NO_SMOOTHING, SMOOTH_SHADING
 
Constructor Summary
Curve(java.io.DataInputStream in, Scene theScene)
          The following two methods are used for reading and writing files.
Curve(Vec3[] v, float[] smoothness, int smoothingMethod, boolean isClosed)
           
 
Method Summary
 void applyPoseKeyframe(Keyframe k)
          Modify this object based on a pose keyframe.
static Vec3 calcApproxPoint(Vec3[] v, float[] s, int i, int j, int k)
           
static Vec3 calcInterpPoint(Vec3[] v, float[] s, int i, int j, int k, int m)
          The following two routines are used by subdivideCurve to calculate new point positions for interpolating and approximating subdivision.
 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 canSetTexture()
          This method tells whether textures can be assigned to the object.
 TriangleMesh convertToTriangleMesh(double tol)
          Return a TriangleMesh which reproduces the shape of this object.
 void copyObject(Object3D obj)
          Copy all the properties of another object, to make this one identical to it.
 MeshViewer createMeshViewer(MeshEditController controller, RowContainer options)
          Get a MeshViewer which can be used for viewing this mesh.
 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.
 BoundingBox getBounds()
          Get a BoundingBox which just encloses the object.
 Vec3[] getNormals()
          Normal vectors do not make sense for a curve, since it does not define a surface.
 Object3D getPosableObject()
          Curves cannot be keyframed directly, since any change to mesh topology would cause all keyframes to become invalid.
 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.
 Skeleton getSkeleton()
          Get the skeleton.
 int getSmoothingMethod()
          Get the smoothing method being used for this mesh.
 float[] getSmoothness()
           
 Vec3[] getVertexPositions()
          Get a list of the positions of all vertices which define the mesh.
 MeshVertex[] getVertices()
          Get the list of vertices which define the mesh.
 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.
 void movePoint(int which, Vec3 pos)
          Move a single control vertex.
 void setClosed(boolean isClosed)
           
 void setPropertyValue(int index, java.lang.Object value)
          Set the value of one of this object's editable properties.
 void setShape(Vec3[] v, float[] smoothness)
          Set both the positions and smoothness values for all points.
 void setSize(double xsize, double ysize, double zsize)
          Resize the object.
 void setSkeleton(Skeleton s)
          Set the skeleton.
 void setSmoothingMethod(int method)
          Set the smoothing method.
 void setSmoothness(float[] s)
          Set the smoothness values for all vertices.
 void setVertexPositions(Vec3[] v)
          Set new positions for all vertices.
 Curve subdivideCurve()
          Return a new Curve object which has been subdivided once to give a finer approximation of the curve shape.
 Curve subdivideCurve(int times)
          Return a new Curve object which has been subdivided the specified number of times to give a finer approximation of the curve shape.
 void writeToFile(java.io.DataOutputStream out, Scene theScene)
          The following method writes the object's data to an output stream.
 
Methods inherited from class artofillusion.object.Object3D
canSetMaterial, configurePoseTrack, copyTextureAndMaterial, editKeyframe, getAverageParameterValues, getMaterial, getMaterialMapping, getParameters, getParameterValue, getParameterValues, getRenderingMesh, getTexture, getTextureMapping, readParameterValue, renderObject, sceneChanged, setMaterial, setParameters, setParameterValue, setParameterValues, setTexture
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface artofillusion.object.Mesh
getParameters, getParameterValues
 

Constructor Detail

Curve

public Curve(Vec3[] v,
             float[] smoothness,
             int smoothingMethod,
             boolean isClosed)

Curve

public Curve(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

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 interface Mesh
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 interface Mesh
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 interface Mesh
Specified by:
getBounds in class Object3D

getVertices

public MeshVertex[] getVertices()
Description copied from interface: Mesh
Get the list of vertices which define the mesh.

Specified by:
getVertices in interface Mesh

getSmoothness

public float[] getSmoothness()

getSmoothingMethod

public int getSmoothingMethod()
Get the smoothing method being used for this mesh.


movePoint

public void movePoint(int which,
                      Vec3 pos)
Move a single control vertex.


getVertexPositions

public Vec3[] getVertexPositions()
Get a list of the positions of all vertices which define the mesh.

Specified by:
getVertexPositions in interface Mesh

setVertexPositions

public void setVertexPositions(Vec3[] v)
Set new positions for all vertices.

Specified by:
setVertexPositions in interface Mesh

setSmoothingMethod

public void setSmoothingMethod(int method)
Set the smoothing method.


setSmoothness

public void setSmoothness(float[] s)
Set the smoothness values for all vertices.


setShape

public void setShape(Vec3[] v,
                     float[] smoothness)
Set both the positions and smoothness values for all points.


setClosed

public void setClosed(boolean isClosed)

isClosed

public boolean isClosed()
Description copied from class: Object3D
Tells whether the object is closed. For curves, this means it has no endpoints. For surface, it means the surface has no boundary.

Overrides:
isClosed 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.

Specified by:
getWireframeMesh in class Object3D

subdivideCurve

public Curve subdivideCurve()
Return a new Curve object which has been subdivided once to give a finer approximation of the curve shape.


subdivideCurve

public Curve subdivideCurve(int times)
Return a new Curve object which has been subdivided the specified number of times to give a finer approximation of the curve shape.


calcInterpPoint

public static Vec3 calcInterpPoint(Vec3[] v,
                                   float[] s,
                                   int i,
                                   int j,
                                   int k,
                                   int m)
The following two routines are used by subdivideCurve to calculate new point positions for interpolating and approximating subdivision. v is the array of current points, s is the array of smoothness values for them, and i, j, k, and m are the indices of the points from which the new point will be calculated.


calcApproxPoint

public static Vec3 calcApproxPoint(Vec3[] v,
                                   float[] s,
                                   int i,
                                   int j,
                                   int k)

canSetTexture

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

Overrides:
canSetTexture in class Object3D

canConvertToTriangleMesh

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

Overrides:
canConvertToTriangleMesh in class Object3D

convertToTriangleMesh

public TriangleMesh convertToTriangleMesh(double tol)
Description copied from class: Object3D
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.

Overrides:
convertToTriangleMesh in class Object3D

getNormals

public Vec3[] getNormals()
Normal vectors do not make sense for a curve, since it does not define a surface.

Specified by:
getNormals in interface Mesh

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

getSkeleton

public Skeleton getSkeleton()
Get the skeleton. This returns null, since Curves cannot have skeletons.

Specified by:
getSkeleton in interface Mesh
Overrides:
getSkeleton in class Object3D

setSkeleton

public void setSkeleton(Skeleton s)
Set the skeleton. This does nothing, since Curves cannot have skeletons.

Specified by:
setSkeleton in interface Mesh

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.

editGesture

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

Overrides:
editGesture in class Object3D

createMeshViewer

public MeshViewer createMeshViewer(MeshEditController controller,
                                   RowContainer options)
Get a MeshViewer which can be used for viewing this mesh.

Specified by:
createMeshViewer in interface Mesh

writeToFile

public void writeToFile(java.io.DataOutputStream out,
                        Scene theScene)
                 throws java.io.IOException
Description copied from class: Object3D
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.

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

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

getPoseKeyframe

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

Specified by:
getPoseKeyframe in class Object3D

applyPoseKeyframe

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

Specified by:
applyPoseKeyframe in class Object3D

canConvertToActor

public boolean canConvertToActor()
Description copied from class: Object3D
Determine whether the user should be allowed to convert this object to an Actor.

Overrides:
canConvertToActor in class Object3D

getPosableObject

public Object3D getPosableObject()
Curves cannot be keyframed directly, since any change to mesh topology would cause all keyframes to become invalid. Return an actor for this mesh.

Overrides:
getPosableObject in class Object3D


Copyright © 1999-2011 by Peter Eastman.