Sphere Class Reference

Representation of a 3D sphere with radius .5, enclosed in the unit box (-.5,-.5,-.5) to (.5,.5,.5). More...

#include <Sphere.h>

Inheritance diagram for Sphere:

Implicit Transformable Shape Intersectable SSEAligned

List of all members.

Public Member Functions

 Sphere (Material *material=NULL)
virtual ~Sphere ()
Intersection routines
virtual real_t getIntersection (const Ray &ray, SurfacePoint &pt)
 Tests the given ray with this object for intersection. If a valid intersection exists, its "t" value will be returned and the given SurfacePoint will be initialized with enough data for this object to later fill in all relevant information lazily (world space normal at intersection point, uv coordinates, etc.).
virtual bool intersects (const Ray &ray, real_t tMax=INFINITY)
 Used for occlusion/visibility testing where you don't necessarily care about anything other than whether or not an intersection exists. (generally faster than getIntersection).
Core functionality
virtual void preview ()
Sampling functionality
virtual void getRandomPoint (SurfacePoint &pt)
virtual Point3 getPosition (const UV &uv)

Protected Member Functions

virtual void _getUV (SurfacePoint &pt) const
virtual void _getGeometricNormal (SurfacePoint &pt) const
virtual real_t _getSurfaceArea ()

Protected Attributes

GLUquadric * m_quadric
UniformOnSphereSamplerm_surfaceSampler


Detailed Description

Representation of a 3D sphere with radius .5, enclosed in the unit box (-.5,-.5,-.5) to (.5,.5,.5).

Author:
Travis Fischer (fisch0920@gmail.com)

Matthew Jacobs (jacobs.mh@gmail.com)

Date:
Fall 2008

Definition at line 18 of file Sphere.h.


Constructor & Destructor Documentation

Sphere::Sphere ( Material material = NULL  )  [inline]

Definition at line 20 of file Sphere.h.

virtual Sphere::~Sphere (  )  [inline, virtual]

Definition at line 25 of file Sphere.h.


Member Function Documentation

real_t Sphere::getIntersection ( const Ray ray,
SurfacePoint pt 
) [virtual]

Tests the given ray with this object for intersection. If a valid intersection exists, its "t" value will be returned and the given SurfacePoint will be initialized with enough data for this object to later fill in all relevant information lazily (world space normal at intersection point, uv coordinates, etc.).

Note:
if you only care about whether or not an intersection exists and don't actually need to know the exact intersection point, see the intersects method instead.
Returns:
the smallest positive "t" value of any intersections found, or INFINITY if no valid intersection exists

Implements Intersectable.

Definition at line 15 of file Sphere.cpp.

bool Sphere::intersects ( const Ray ray,
real_t  tMax = INFINITY 
) [virtual]

Used for occlusion/visibility testing where you don't necessarily care about anything other than whether or not an intersection exists. (generally faster than getIntersection).

Note:
default implementation defers to getIntersection
Returns:
whether or not the given ray intersects this object with a positive "t" value greater than EPSILON and less than the given tMax

Reimplemented from Intersectable.

Definition at line 46 of file Sphere.cpp.

void Sphere::preview (  )  [virtual]

Display a crude OpenGL preview of this shape

Note:
Default implementation sets the ModelView matrix appropriately with respect to this Transformable's transformation

Reimplemented from Transformable.

Definition at line 95 of file Sphere.cpp.

void Sphere::getRandomPoint ( SurfacePoint pt  )  [virtual]

Returns:
a point chosen uniformly random over the surface of this shape
Note:
the probability density of selecting this point is assumed to be (1.0 / getSurfaceArea())

Reimplemented from Shape.

Definition at line 106 of file Sphere.cpp.

Point3 Sphere::getPosition ( const UV uv  )  [virtual]

Returns:
the point on the surface of this shape corresponding to the given UV coordinates

Reimplemented from Transformable.

Definition at line 116 of file Sphere.cpp.

void Sphere::_getUV ( SurfacePoint pt  )  const [protected, virtual]

Implements Shape.

Definition at line 78 of file Sphere.cpp.

void Sphere::_getGeometricNormal ( SurfacePoint pt  )  const [protected, virtual]

Implements Shape.

Definition at line 87 of file Sphere.cpp.

real_t Sphere::_getSurfaceArea (  )  [protected, virtual]

Returns:
the total surface area of this shape
return surface area in world-space!!!

Reimplemented from Shape.

Definition at line 137 of file Sphere.cpp.


Member Data Documentation

GLUquadric* Sphere::m_quadric [protected]

Definition at line 84 of file Sphere.h.

Definition at line 85 of file Sphere.h.


The documentation for this class was generated from the following files:

Generated on 28 Feb 2009 for Milton by doxygen 1.5.6