Rings
Version 0.3

threeD.raytracer.textures
Class ImageTexture

java.lang.Object
  extended bythreeD.raytracer.textures.ImageTexture
All Implemented Interfaces:
ColorProducer, Editable, Producer, Texture

public class ImageTexture
extends java.lang.Object
implements Texture, Editable

An ImageTexture object can be used to provide an image as the color data for a surface.


Nested Class Summary
 
Nested classes inherited from class threeD.raytracer.util.Editable
Editable.Selection
 
Field Summary
static int SPHERICAL_PROJECTION
           
static int XY_PLANAR_PROJECTION
           
static int XZ_PLANAR_PROJECTION
           
static int YZ_PLANAR_PROJECTION
           
 
Constructor Summary
ImageTexture()
          Constructs a new ImageTexture object.
ImageTexture(int type, java.net.URL url)
          Constructs a new ImageTexture object of unit square size.
ImageTexture(int type, java.net.URL url, double xScale, double yScale, double xOff, double yOff)
          Constrcts a new ImageTexture object with the specified scaling factors.
 
Method Summary
 RGB evaluate(java.lang.Object[] args)
          Produces a color using the specified arguments.
 RGB getColorAt(double u, double v)
          Returns the an RGB object representing the color of this ImageTexture object at the specified u, v coordinates.
 RGB getColorAt(double u, double v, double xScale, double yScale, double xOff, double yOff)
          Returns the an RGB object representing the color of this ImageTexture object at the specified u, v coordinates.
 RGB getColorAt(Vector point)
          Returns the color of the texture represented by this Texture object at the specified point as an RGB object using the arguments stored by this Texture object.
 RGB getColorAt(Vector point, java.lang.Object[] args)
          Returns the color of the texture represented by this Texture object at the specified point as an RGB object using the specified arguments.
 Producer[] getInputPropertyValues()
           
 java.lang.String[] getPropertyDescriptions()
          Returns an array of String objects with descriptions for each editable property of this Editable object.
 java.lang.String[] getPropertyNames()
          Returns an array of String objects with names for each editable property of this Editable object.
 java.lang.Class[] getPropertyTypes()
          Returns an array of Class objects representing the class types of each editable property of this Editable object.
 java.lang.Object[] getPropertyValues()
          Returns the values of the properties of this Editable object as an Object array.
 void setInputPropertyValue(int index, Producer p)
          Does nothing.
 void setPropertyValue(java.lang.Object value, int index)
          Sets the value of the property of this Editable object at the specified index to the specified value.
 void setPropertyValues(java.lang.Object[] values)
          Sets the values of properties of this Editable object to those specified.
 java.lang.String toString()
           
protected  void update()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SPHERICAL_PROJECTION

public static final int SPHERICAL_PROJECTION
See Also:
Constant Field Values

XY_PLANAR_PROJECTION

public static final int XY_PLANAR_PROJECTION
See Also:
Constant Field Values

XZ_PLANAR_PROJECTION

public static final int XZ_PLANAR_PROJECTION
See Also:
Constant Field Values

YZ_PLANAR_PROJECTION

public static final int YZ_PLANAR_PROJECTION
See Also:
Constant Field Values
Constructor Detail

ImageTexture

public ImageTexture()
Constructs a new ImageTexture object.


ImageTexture

public ImageTexture(int type,
                    java.net.URL url)
Constructs a new ImageTexture object of unit square size.

Parameters:
type - Integer code that specifies the method to use for "wrapping" the image on a surface.
url - URL object pointing to image.
Throws:
java.lang.IllegalArgumentException - If the value for type is not valid.
java.lang.RuntimeException - If image fails to load properly.

ImageTexture

public ImageTexture(int type,
                    java.net.URL url,
                    double xScale,
                    double yScale,
                    double xOff,
                    double yOff)
Constrcts a new ImageTexture object with the specified scaling factors.

Parameters:
type - Integer code that specified the method to use for "wrapping" the image on a surface.
url - URL object pointing to image.
xScale - X scale factor.
yScale - Y scale factor.
xOff - X offset.
yOff - Y offset.
Throws:
java.lang.IllegalArgumentException - If the value for type is not valid.
java.lang.RuntimeException - If image fails to load properly.
Method Detail

update

protected void update()

getColorAt

public RGB getColorAt(double u,
                      double v)
Returns the an RGB object representing the color of this ImageTexture object at the specified u, v coordinates.

Parameters:
u - u coordinate between 0.0 and 1.0
v - v coordinate between 0.0 and 1.0
Returns:
The color at the specified location (black if the pixel data is not loaded).

getColorAt

public RGB getColorAt(double u,
                      double v,
                      double xScale,
                      double yScale,
                      double xOff,
                      double yOff)
Returns the an RGB object representing the color of this ImageTexture object at the specified u, v coordinates.

Parameters:
u - u coordinate between 0.0 and 1.0
v - v coordinate between 0.0 and 1.0
xScale - X scale factor
yScale - Y scale factor
xOff - X offset
yOff - Y offset
Returns:
The color at the specified location
Throws:
java.lang.NullPointerException - If pixel data is not loaded.

getColorAt

public RGB getColorAt(Vector point)
Description copied from interface: Texture
Returns the color of the texture represented by this Texture object at the specified point as an RGB object using the arguments stored by this Texture object.

Specified by:
getColorAt in interface Texture
Throws:
java.lang.NullPointerException - If pixel data is not loaded.
See Also:
Texture.getColorAt(threeD.raytracer.util.Vector)

getColorAt

public RGB getColorAt(Vector point,
                      java.lang.Object[] args)
Description copied from interface: Texture
Returns the color of the texture represented by this Texture object at the specified point as an RGB object using the specified arguments.

Specified by:
getColorAt in interface Texture
Throws:
java.lang.IllegalArgumentException - If args does not contain the correct object types.
java.lang.NullPointerException - If pixel data is not loaded.
See Also:
Texture.getColorAt(threeD.raytracer.util.Vector, java.lang.Object[])

evaluate

public RGB evaluate(java.lang.Object[] args)
Description copied from interface: ColorProducer
Produces a color using the specified arguments.

Specified by:
evaluate in interface ColorProducer
Parameters:
args - Arguments.
Returns:
The RGB color produced.
Throws:
java.lang.IllegalArgumentException - If args does not contain the correct object types.
See Also:
ColorProducer.evaluate(java.lang.Object[])

getPropertyNames

public java.lang.String[] getPropertyNames()
Description copied from interface: Editable
Returns an array of String objects with names for each editable property of this Editable object.

Specified by:
getPropertyNames in interface Editable
See Also:
Editable.getPropertyNames()

getPropertyDescriptions

public java.lang.String[] getPropertyDescriptions()
Description copied from interface: Editable
Returns an array of String objects with descriptions for each editable property of this Editable object.

Specified by:
getPropertyDescriptions in interface Editable
See Also:
Editable.getPropertyDescriptions()

getPropertyTypes

public java.lang.Class[] getPropertyTypes()
Description copied from interface: Editable
Returns an array of Class objects representing the class types of each editable property of this Editable object.

Specified by:
getPropertyTypes in interface Editable
See Also:
Editable.getPropertyTypes()

getPropertyValues

public java.lang.Object[] getPropertyValues()
Description copied from interface: Editable
Returns the values of the properties of this Editable object as an Object array.

Specified by:
getPropertyValues in interface Editable
See Also:
Editable.getPropertyValues()

setPropertyValue

public void setPropertyValue(java.lang.Object value,
                             int index)
Description copied from interface: Editable
Sets the value of the property of this Editable object at the specified index to the specified value.

Specified by:
setPropertyValue in interface Editable
See Also:
Editable.setPropertyValue(java.lang.Object, int)

setPropertyValues

public void setPropertyValues(java.lang.Object[] values)
Description copied from interface: Editable
Sets the values of properties of this Editable object to those specified.

Specified by:
setPropertyValues in interface Editable
See Also:
Editable.setPropertyValues(java.lang.Object[])

getInputPropertyValues

public Producer[] getInputPropertyValues()
Specified by:
getInputPropertyValues in interface Editable
Returns:
An empty array.

setInputPropertyValue

public void setInputPropertyValue(int index,
                                  Producer p)
Does nothing.

Specified by:
setInputPropertyValue in interface Editable
Parameters:
index - Index of input property (array index from this.getInputPropertyValue).
p - Producer object to use for input property.

toString

public java.lang.String toString()
Returns:
"Image Texture".

Rings
Version 0.3

Copyright 2003-05 Mike Murray