pl.webnet.JaTrac
Class Sphere

java.lang.Object
  |
  +--pl.webnet.JaTrac.TreeNode
        |
        +--pl.webnet.JaTrac.Primitive
              |
              +--pl.webnet.JaTrac.Sphere
All Implemented Interfaces:
XmlSettable

class Sphere
extends Primitive
implements XmlSettable

Sphere implements spherical primitive.


Field Summary
(package private)  boolean castShadows
           
(package private)  pl.webnet.JaTrac.Point center
           
(package private) static int count
           
(package private)  pl.webnet.JaTrac.Point lastHitPoint
           
(package private)  pl.webnet.JaTrac.Intersection lastIntersection
           
(package private)  long mailbox
           
(package private)  pl.webnet.JaTrac.Mapping mapping
           
(package private)  java.lang.String name
           
(package private)  pl.webnet.JaTrac.Level parent
           
(package private)  double radius
           
(package private)  double radiusSquared
           
(package private)  boolean reflected
           
(package private) static pl.webnet.JaTrac.Level root
           
(package private)  boolean shadows
           
(package private)  pl.webnet.JaTrac.Spectrum spectrum
           
(package private) static pl.webnet.JaTrac.Vec unit
           
(package private)  boolean unshaded
           
 
Constructor Summary
Sphere()
           
Sphere(pl.webnet.JaTrac.Point center, double radius)
          Construct a sphere.
 
Method Summary
 java.lang.String[] getAttachArray()
          Get object's attach array.
 pl.webnet.JaTrac.BoundingBox getBoundingBox(pl.webnet.JaTrac.BoundingBox bx)
           
 pl.webnet.JaTrac.Mapping getMapping()
           
 pl.webnet.JaTrac.Vec getNormal(pl.webnet.JaTrac.Point p)
          Return unit normal in given point.
 java.lang.String[] getParamArray()
          Get object's parameter array.
 pl.webnet.JaTrac.Spectrum getSpectrum()
           
 pl.webnet.JaTrac.Surface getSurface()
           
 pl.webnet.JaTrac.Vec getTangent(pl.webnet.JaTrac.Point p, pl.webnet.JaTrac.Vec n)
          Compute tangent vector at given point on object's surface.
 java.lang.Object initialize()
          Initialize object's internal state after setting all params from XML file.
 int intersect(pl.webnet.JaTrac.Ray ray)
          Check if given ray intersects the sphere.
 void setName(java.lang.String name)
           
 void setParent(pl.webnet.JaTrac.Level parent)
           
 void setRadius(java.lang.String rad)
           
static void setRoot(pl.webnet.JaTrac.Level root)
           
 void setSpectrum(pl.webnet.JaTrac.Spectrum s)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

center

pl.webnet.JaTrac.Point center

radius

double radius

radiusSquared

double radiusSquared

unit

static pl.webnet.JaTrac.Vec unit

count

static int count

spectrum

pl.webnet.JaTrac.Spectrum spectrum

mapping

pl.webnet.JaTrac.Mapping mapping

shadows

boolean shadows

castShadows

boolean castShadows

reflected

boolean reflected

unshaded

boolean unshaded

lastIntersection

pl.webnet.JaTrac.Intersection lastIntersection

lastHitPoint

pl.webnet.JaTrac.Point lastHitPoint

mailbox

long mailbox

name

java.lang.String name

parent

pl.webnet.JaTrac.Level parent

root

static pl.webnet.JaTrac.Level root
Constructor Detail

Sphere

public Sphere(pl.webnet.JaTrac.Point center,
              double radius)
Construct a sphere.

Parameters:
center - sphere's center in world coordinates
radius - sphere's radius

Sphere

public Sphere()
Method Detail

getParamArray

public java.lang.String[] getParamArray()
Description copied from interface: XmlSettable
Get object's parameter array. The array maps XML element names to variable names and, if setting one variable is not enough, lists names of functions to call.

Specified by:
getParamArray in interface XmlSettable
Overrides:
getParamArray in class Primitive
Returns:
object's parameter array.

getAttachArray

public java.lang.String[] getAttachArray()
Description copied from interface: XmlSettable
Get object's attach array. The array specifies what functions to call to attach children nodes to this object.

Specified by:
getAttachArray in interface XmlSettable
Overrides:
getAttachArray in class Primitive
Returns:
object's attach array.

initialize

public java.lang.Object initialize()
Description copied from interface: XmlSettable
Initialize object's internal state after setting all params from XML file. Called after element's end tag is encountered in XML file.

Specified by:
initialize in interface XmlSettable
Overrides:
initialize in class Primitive

setRadius

public void setRadius(java.lang.String rad)

intersect

public int intersect(pl.webnet.JaTrac.Ray ray)
Check if given ray intersects the sphere. Uses geometric solution from An Introduction to Raytracing by A. S. Glassner et all.

Specified by:
intersect in class Primitive
Parameters:
ray - the ray to test against
Returns:
the number of intersections

getTangent

public pl.webnet.JaTrac.Vec getTangent(pl.webnet.JaTrac.Point p,
                                       pl.webnet.JaTrac.Vec n)
Description copied from class: Primitive
Compute tangent vector at given point on object's surface. Used for bump mapping.

Specified by:
getTangent in class Primitive
Parameters:
p - point (in world coordinates) on object's surface
Returns:
normal vector

getNormal

public pl.webnet.JaTrac.Vec getNormal(pl.webnet.JaTrac.Point p)
Return unit normal in given point.

Specified by:
getNormal in class Primitive
Parameters:
p - point to calculate normal at
Returns:
unit normal vector.

getBoundingBox

public pl.webnet.JaTrac.BoundingBox getBoundingBox(pl.webnet.JaTrac.BoundingBox bx)
Specified by:
getBoundingBox in class Primitive

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getSurface

public pl.webnet.JaTrac.Surface getSurface()

getMapping

public pl.webnet.JaTrac.Mapping getMapping()

getSpectrum

public pl.webnet.JaTrac.Spectrum getSpectrum()

setSpectrum

public void setSpectrum(pl.webnet.JaTrac.Spectrum s)

setName

public void setName(java.lang.String name)

setRoot

public static void setRoot(pl.webnet.JaTrac.Level root)

setParent

public void setParent(pl.webnet.JaTrac.Level parent)