import java.io.*; import java.lang.*; /** * PointLight represents a light sources that illuminates from a * fixed origin * * @author Anthony Steed * @version 1.0 */ public class PointLight extends Light { /** * Stores the origin of the point light. */ public Point Origin; /** * Create a default light. */ public PointLight() { Intensity = new Colour(1.0,1.0,1.0); Origin = new Point(); } /** * Create a new point light that at the given point. * @param p The position of the light. */ public PointLight(Point p) { Intensity = new Colour(1.0,1.0,1.0); Origin = p; } /** * Read the light 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 */ public void read(SceneReader is) throws IOException, NumberFormatException { Intensity.read(is); Origin.read(is); } /** * Write the light to the given destination * @param os The destination to write to * @exception java.io.IOException * if the write fails. */ public void write(SceneWriter os) throws IOException { Intensity.write(os); os.writeChar(' '); Origin.write(os); } /** * Print a human readable version of the light definition to the * given destination * @param os The destination to write to * @exception java.io.IOException * if the write fails. */ public void print(SceneWriter os) throws IOException { os.writeString("Point light with colour: "); Intensity.print(os); os.writeString(" and origin: "); Origin.print(os); os.writeString("\n"); } }