import java.lang.*; import java.io.*; /** * Object superclass * * Each type of object must extend and implement this class. * @author Anthony Steed * @version 1.0 */ public abstract class Object { /** * Holds the material of this object */ public Material SurfaceMaterial; /** * Find the intersection of an object and a given ray. * * The return value is positive is the intersection is found and * this value gives the distance along the ray. Negative values * imply that the intersection was either not successful or the * intersection point was before the origin. This value can be used * with the pointAt method of the Ray class (@see Ray#pointAt) * * @param ray the ray to intersect with * @return a double value that gives the distance * along the ray. */ abstract public double intersect(Ray ray); /** * Find the normal of an object at the given point on its surface. * @param pt the surface point to find the normal at * @return a vector that contains the required normal */ abstract public Vector normal(Point pt); /** * Read the object from the given source * @param is the source to read from * @exception java.io.IOException * if the light can not be read * @exception java.io.NumberFormatException * if there a number format error is encountered */ abstract public void read(SceneReader is) throws IOException, NumberFormatException; /** * Write the object to the given destination * @param os the destination to write to * @exception java.io.IOException * if the write fails. */ abstract public void write(SceneWriter os) throws IOException; /** * Print a human readable version of the object definition to the * given destination * @param os the destination to write to * @exception java.io.IOException * if the write fails. */ abstract public void print(SceneWriter os) throws IOException; }