Rings
Version 0.3

threeD.raytracer.engine
Class RayTracingEngine

java.lang.Object
  extended bythreeD.raytracer.engine.RayTracingEngine

public class RayTracingEngine
extends java.lang.Object

The RayTracingEngine class provides static methods for rendering scenes.


Field Summary
static boolean castShadows
          Controls wether or not shadow casting will be done during rendering.
static double e
          A very small value (0.00000001) that is used in '>=' and '<=' operations to account for computational errors.
 
Constructor Summary
RayTracingEngine()
           
 
Method Summary
static RGB ambientLightingCalculation(Vector point, Vector rayDirection, Surface surface, Surface[] otherSurfaces, AmbientLight light)
          Performs the lighting calculations for the specified surface at the specified point of interesection on that surface using the lighting data from the specified AmbientLight object and returns an RGB object that represents the color of the point.
static Intersection closestIntersection(Ray ray, Surface[] surfaces)
          Returns an Intersection object that represents the closest intersection (>= RayTracingEngine.e) between a surface in the specified array of Surface objects and the ray represented by the specified Ray object.
static double closestIntersectionAt(Intersection intersect)
          Returns the value (>= RayTracingEngine.e) of the closest intersection point of the specified Intersection object If there are no positive intersections, -1.0 is returned.
static RGB directionalAmbientLightingCalculation(Vector point, Vector rayDirection, Surface surface, Surface[] otherSurfaces, DirectionalAmbientLight light, Light[] otherLights)
          Performs the lighting calculations for the specified surface at the specified point of interesection on that surface using the lighting data from the specified DirectionalAmbientLight object and returns an RGB object that represents the color of the point.
static RGB lightingCalculation(Ray ray, Surface[] surfaces, Light[] lights)
          Performs intersection and lighting calculations for the specified Ray, Surfaces, and Lights.
static RGB lightingCalculation(Vector point, Vector rayDirection, Surface surface, Surface[] otherSurfaces, Light[] lights)
          Performs the lighting calculations for the specified surface at the specified point of intersection on that surface using the lighting data from the specified Light objects and returns an RGB object that represents the color of the point.
static RGB lightingCalculation(Vector point, Vector rayDirection, Surface surface, Surface[] otherSurfaces, Light light, Light[] otherLights)
          Performs the lighting calculations for the specified surface at the specified point of interesection on that surface using the lighting data from the specified Light object and returns an RGB object that represents the color of the point.
static RGB pointLightingCalculation(Vector point, Vector rayDirection, Surface surface, Surface[] otherSurfaces, PointLight light, Light[] otherLights)
          Performs the lighting calculations for the specified surface at the specified point of interesection on that surface using the lighting data from the specified PointLight object and returns an RGB object that represents the color of the point.
static Vector reflect(Vector vector, Vector normal)
          Reflects the specified Vector object across the normal vector represented by the second specified Vector object and returns the result.
static Vector refract(Vector vector, Vector normal, double ni, double nr)
          Refracts the specified Vector object based on the specified normal vector and 2 specified indices of refraction.
static RGB[][] render(Scene scene, int x, int y, int dx, int dy, int width, int height, int ssWidth, int ssHeight, ProgressMonitor monitor)
           
static RGB[][] render(Scene scene, int width, int height, int ssWidth, int ssHeight, ProgressMonitor monitor)
          Computes all intersection and lighting calculations required to produce an image of the specified width and height that is a rendering of the specified Scene object and returns the image as an array of RGB objects.
static RGB[][] render(Scene scene, RenderParameters p, ProgressMonitor monitor)
          Renders the specified scene.
static RGB[][] render(Surface[] surfaces, Camera camera, Light[] lights, int x, int y, int dx, int dy, int width, int height, int ssWidth, int ssHeight, ProgressMonitor monitor)
          Computes all intersection and lighting calculations required to produce an image of the specified width and height that is a rendering of the specified set of Surface objects using the data from the specified Camera and Light object.
static Light[] separateLights(int index, Light[] allLights)
          Removes the Light object at the specified index from the specified Light object array and returns the new array.
static Surface[] separateSurfaces(int index, Surface[] allSurfaces)
          Removes the Surface object at the specified index from the specified Surface object array and returns the new array.
static Surface[] separateSurfaces(Surface surface, Surface[] allSurfaces)
          Removes the specified Surface object from the specified Surface object array and returns the new array.
static boolean shadowCalculation(Vector point, Surface[] surfaces, Light light)
          Performs the shadow calculations for the specified surfaces at the specified point using the data from the specified Light object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

castShadows

public static boolean castShadows
Controls wether or not shadow casting will be done during rendering. By default set to true.


e

public static final double e
A very small value (0.00000001) that is used in '>=' and '<=' operations to account for computational errors.

See Also:
Constant Field Values
Constructor Detail

RayTracingEngine

public RayTracingEngine()
Method Detail

render

public static RGB[][] render(Scene scene,
                             int width,
                             int height,
                             int ssWidth,
                             int ssHeight,
                             ProgressMonitor monitor)
Computes all intersection and lighting calculations required to produce an image of the specified width and height that is a rendering of the specified Scene object and returns the image as an array of RGB objects. The image is anti-aliased using the specified supersampling width (ssWidth) and height (ssHeight). and progress is reported to the specified ProgressMonitor object.


render

public static RGB[][] render(Scene scene,
                             int x,
                             int y,
                             int dx,
                             int dy,
                             int width,
                             int height,
                             int ssWidth,
                             int ssHeight,
                             ProgressMonitor monitor)

render

public static RGB[][] render(Scene scene,
                             RenderParameters p,
                             ProgressMonitor monitor)
Renders the specified scene.

Parameters:
scene - Scene object to render.
p - RenderParamters object to use.
monitor - ProgressMonitor to use.
Returns:
Rendered image data.

render

public static RGB[][] render(Surface[] surfaces,
                             Camera camera,
                             Light[] lights,
                             int x,
                             int y,
                             int dx,
                             int dy,
                             int width,
                             int height,
                             int ssWidth,
                             int ssHeight,
                             ProgressMonitor monitor)
Computes all intersection and lighting calculations required to produce an image of the specified width and height that is a rendering of the specified set of Surface objects using the data from the specified Camera and Light object. The image is anti-aliased using the specified supersampling width (ssWidth) and height (ssHeight) and progress is reported to the specified ProgressMonitor object. The image is returned as an array of RGB objects.

Parameters:
surfaces - Surface objects in scene.
camera - Camera object for scene.
lights - Light objects in scene.
x - X coordinate of upper left corner of image.
y - Y coordinate of upper left corner of image.
dx - Width of image.
dy - Height of image.
width - Width of total image.
height - Height of total image.
ssWidth - Supersample width.
ssHeight - Supersample height.
monitor - ProgressMonitor instance to use.
Returns:
Image data.

lightingCalculation

public static RGB lightingCalculation(Ray ray,
                                      Surface[] surfaces,
                                      Light[] lights)
Performs intersection and lighting calculations for the specified Ray, Surfaces, and Lights.


lightingCalculation

public static RGB lightingCalculation(Vector point,
                                      Vector rayDirection,
                                      Surface surface,
                                      Surface[] otherSurfaces,
                                      Light[] lights)
Performs the lighting calculations for the specified surface at the specified point of intersection on that surface using the lighting data from the specified Light objects and returns an RGB object that represents the color of the point. A list of all other surfaces in the scene must be specified for reflection/shadowing. This list does not include the specified surface for which the lighting calculations are to be done.


lightingCalculation

public static RGB lightingCalculation(Vector point,
                                      Vector rayDirection,
                                      Surface surface,
                                      Surface[] otherSurfaces,
                                      Light light,
                                      Light[] otherLights)
Performs the lighting calculations for the specified surface at the specified point of interesection on that surface using the lighting data from the specified Light object and returns an RGB object that represents the color of the point. A list of all other surfaces in the scene must be specified for reflection/shadowing. This list does not include the specified surface for which the lighting calculations are to be done.


ambientLightingCalculation

public static RGB ambientLightingCalculation(Vector point,
                                             Vector rayDirection,
                                             Surface surface,
                                             Surface[] otherSurfaces,
                                             AmbientLight light)
Performs the lighting calculations for the specified surface at the specified point of interesection on that surface using the lighting data from the specified AmbientLight object and returns an RGB object that represents the color of the point. A list of all other surfaces in the scene must be specified for reflection/shadowing. This list does not include the specified surface for which the lighting calculations are to be done.


directionalAmbientLightingCalculation

public static RGB directionalAmbientLightingCalculation(Vector point,
                                                        Vector rayDirection,
                                                        Surface surface,
                                                        Surface[] otherSurfaces,
                                                        DirectionalAmbientLight light,
                                                        Light[] otherLights)
Performs the lighting calculations for the specified surface at the specified point of interesection on that surface using the lighting data from the specified DirectionalAmbientLight object and returns an RGB object that represents the color of the point. A list of all other surfaces in the scene must be specified for reflection/shadowing. This list does not include the specified surface for which the lighting calculations are to be done.


pointLightingCalculation

public static RGB pointLightingCalculation(Vector point,
                                           Vector rayDirection,
                                           Surface surface,
                                           Surface[] otherSurfaces,
                                           PointLight light,
                                           Light[] otherLights)
Performs the lighting calculations for the specified surface at the specified point of interesection on that surface using the lighting data from the specified PointLight object and returns an RGB object that represents the color of the point. A list of all other surfaces in the scene must be specified for reflection/shadowing. This list does not include the specified surface for which the lighting calculations are to be done.


shadowCalculation

public static boolean shadowCalculation(Vector point,
                                        Surface[] surfaces,
                                        Light light)
Performs the shadow calculations for the specified surfaces at the specified point using the data from the specified Light object. Returns true if the point has a shadow cast on it.


reflect

public static Vector reflect(Vector vector,
                             Vector normal)
Reflects the specified Vector object across the normal vector represented by the second specified Vector object and returns the result.


refract

public static Vector refract(Vector vector,
                             Vector normal,
                             double ni,
                             double nr)
Refracts the specified Vector object based on the specified normal vector and 2 specified indices of refraction.

Parameters:
vector - A Vector object representing a unit vector in the direction of the incident ray normal A Vector object respresenting a unit vector that is normal to the surface refracting the ray ni A double value representing the index of refraction of the incident medium nr A double value representing the index of refraction of the refracting medium

closestIntersection

public static Intersection closestIntersection(Ray ray,
                                               Surface[] surfaces)
Returns an Intersection object that represents the closest intersection (>= RayTracingEngine.e) between a surface in the specified array of Surface objects and the ray represented by the specified Ray object. If there are no intersections >= RayTracingEngine.e then null is returned.


closestIntersectionAt

public static double closestIntersectionAt(Intersection intersect)
Returns the value (>= RayTracingEngine.e) of the closest intersection point of the specified Intersection object If there are no positive intersections, -1.0 is returned.


separateLights

public static Light[] separateLights(int index,
                                     Light[] allLights)
Removes the Light object at the specified index from the specified Light object array and returns the new array.


separateSurfaces

public static Surface[] separateSurfaces(int index,
                                         Surface[] allSurfaces)
Removes the Surface object at the specified index from the specified Surface object array and returns the new array.


separateSurfaces

public static Surface[] separateSurfaces(Surface surface,
                                         Surface[] allSurfaces)
Removes the specified Surface object from the specified Surface object array and returns the new array. If the specified Surface object is not matched, the whole array is returned.


Rings
Version 0.3

Copyright 2003-05 Mike Murray