net.sf.j3d.threeD.raytracer.engine
Class SurfaceGroup

java.lang.Object
  extended by net.sf.j3d.threeD.raytracer.engine.AbstractSurface
      extended by net.sf.j3d.threeD.raytracer.engine.SurfaceGroup
All Implemented Interfaces:
Surface
Direct Known Subclasses:
SpacePartition

public class SurfaceGroup
extends AbstractSurface

A SurfaceGroup object allows Surface objects to be grouped together. The properties of the SurfaceGroup object are applied to each of its children.

Author:
Mike Murray

Constructor Summary
SurfaceGroup()
          Constructs a SurfaceGroup object with no Surface objects.
SurfaceGroup(Surface[] surfaces)
          Constructs a SurfaceGroup object using the Surface objects in the specified array.
 
Method Summary
 void addSurface(Surface surface)
          Adds the specified Surface object to this SurfaceGroup object and sets its parent to this SurfaceGroup object (if it is an instance of AbstractSurface).
 Vector getNormalAt(Vector point)
          Returns null.
 Surface getSurface(int index)
          Returns the Surface object stored by this SurfaceGroup object at the specified index.
 Surface[] getSurfaces()
          Returns the Surface objects stored by this SurfaceGroup object as a Surface array.
 boolean intersect(Ray ray)
          Returns true if the ray represented by the specified Ray object intersects any of the surfaces represented by this SurfaceGroup object.
 Intersection intersectAt(Ray ray)
          Returns an Intersection object that represents the ray-surface intersections for the AbstractSurface object which is intersected closest to the origin of the ray (>= 0).
 void removeSurface(int index)
          Removes the Surface object stored at the specified index from this SurfaceGroup object and sets the parent of the removed Surface object to null (if it is an instance of AbstractSurface).
 void setSurfaces(Surface[] surfaces)
          Replaces all of the Surface objects of this SurfaceGroup object with those represented by the specified Surface array.
 RGB shade(ShaderParameters p)
          Calculates a color value for this AbstractSurface using the sum of the values calculated by the Shader objects stored by this AbstractSurface and the parent of this AbstractSurface and returns this value as an RGB object.
 Mesh triangulate()
           
 
Methods inherited from class net.sf.j3d.threeD.raytracer.engine.AbstractSurface
addShader, addTexture, addTransform, calculateTransform, getColor, getColorAt, getColorAt, getIndexOfRefraction, getIndexOfRefraction, getLocation, getParent, getReflectedPercentage, getReflectedPercentage, getRefractedPercentage, getRefractedPercentage, getRotationCoefficients, getScaleCoefficients, getShadeBack, getShadeFront, getShaderSet, getSize, getTexture, getTextures, getTextureSet, getTransform, getTransform, getTransforms, removeTexture, removeTransform, setColor, setIndexOfRefraction, setLocation, setParent, setReflectedPercentage, setRefractedPercentage, setRotationCoefficients, setScaleCoefficients, setShadeBack, setShadeFront, setShaders, setShaders, setSize, setTexture, setTextures, setTransform, setTransforms
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SurfaceGroup

public SurfaceGroup()
Constructs a SurfaceGroup object with no Surface objects.


SurfaceGroup

public SurfaceGroup(Surface[] surfaces)
Constructs a SurfaceGroup object using the Surface objects in the specified array.

Method Detail

setSurfaces

public void setSurfaces(Surface[] surfaces)
Replaces all of the Surface objects of this SurfaceGroup object with those represented by the specified Surface array.


addSurface

public void addSurface(Surface surface)
Adds the specified Surface object to this SurfaceGroup object and sets its parent to this SurfaceGroup object (if it is an instance of AbstractSurface).


removeSurface

public void removeSurface(int index)
Removes the Surface object stored at the specified index from this SurfaceGroup object and sets the parent of the removed Surface object to null (if it is an instance of AbstractSurface).


getSurfaces

public Surface[] getSurfaces()
Returns the Surface objects stored by this SurfaceGroup object as a Surface array.


getSurface

public Surface getSurface(int index)
Returns the Surface object stored by this SurfaceGroup object at the specified index.


shade

public RGB shade(ShaderParameters p)
Description copied from class: AbstractSurface
Calculates a color value for this AbstractSurface using the sum of the values calculated by the Shader objects stored by this AbstractSurface and the parent of this AbstractSurface and returns this value as an RGB object.

Specified by:
shade in interface Surface
Overrides:
shade in class AbstractSurface
See Also:
net.sf.j3d.threeD.raytracer.engine.Surface#shade(net.sf.j3d.threeD.raytracer.engine.ShaderParameters)

getNormalAt

public Vector getNormalAt(Vector point)
Returns null.


triangulate

public Mesh triangulate()
Overrides:
triangulate in class AbstractSurface
Returns:
A Mesh object with location, size, color, scale coefficients, rotation coefficients, and transformations as this AbstractSurface.

intersect

public boolean intersect(Ray ray)
Returns true if the ray represented by the specified Ray object intersects any of the surfaces represented by this SurfaceGroup object.


intersectAt

public Intersection intersectAt(Ray ray)
Returns an Intersection object that represents the ray-surface intersections for the AbstractSurface object which is intersected closest to the origin of the ray (>= 0). If there is no intersection >= 0 along the ray, null is returned.