net.sf.j3d.threeD.raytracer.textures
Class ImageTexture

java.lang.Object
  extended by net.sf.j3d.threeD.raytracer.textures.ImageTexture
All Implemented Interfaces:
Texture, ColorProducer, Editable, Producer

public class ImageTexture
extends Object
implements Texture, Editable

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

Author:
Mike Murray

Nested Class Summary
 
Nested classes/interfaces inherited from interface net.sf.j3d.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, URL url)
          Constructs a new ImageTexture object of unit square size.
ImageTexture(int type, URL url, double xScale, double yScale, double xOff, double yOff)
          Constrcts a new ImageTexture object with the specified scaling factors.
 
Method Summary
 RGB evaluate(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, 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()
           
 String[] getPropertyDescriptions()
          Returns an array of String objects with descriptions for each editable property of this Editable object.
 String[] getPropertyNames()
          Returns an array of String objects with names for each editable property of this Editable object.
 Class[] getPropertyTypes()
          Returns an array of Class objects representing the class types of each editable property of this Editable object.
 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(Object value, int index)
          Sets the value of the property of this Editable object at the specified index to the specified value.
 void setPropertyValues(Object[] values)
          Sets the values of properties of this Editable object to those specified.
 String toString()
           
 
Methods inherited from class java.lang.Object
equals, 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,
                    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:
IllegalArgumentException - If the value for type is not valid.
RuntimeException - If image fails to load properly.

ImageTexture

public ImageTexture(int type,
                    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:
IllegalArgumentException - If the value for type is not valid.
RuntimeException - If image fails to load properly.
Method Detail

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:
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:
NullPointerException - If pixel data is not loaded.
See Also:
Texture.getColorAt(net.sf.j3d.util.Vector)

getColorAt

public RGB getColorAt(Vector point,
                      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
Parameters:
args[] - {Double, Double, Double, Double} X scale factor, Y scale factor, X offset, Y offset.
Throws:
IllegalArgumentException - If args does not contain the correct object types.
NullPointerException - If pixel data is not loaded.
See Also:
Texture.getColorAt(net.sf.j3d.util.Vector, java.lang.Object[])

evaluate

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

Specified by:
evaluate in interface ColorProducer
Parameters:
args[] - {Vector, Double, Double, Double, Double} Point, X scale factor, Y scale factor, X offset, Y offset.
Returns:
The RGB color produced.
Throws:
IllegalArgumentException - If args does not contain the correct object types.
See Also:
ColorProducer.evaluate(java.lang.Object[])

getPropertyNames

public 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 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 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 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(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(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 String toString()
Overrides:
toString in class Object
Returns:
"Image Texture".