Sphere Class Reference

#include <Sphere.h>

Inherits Primitive.

Inheritance diagram for Sphere:

Inheritance graph
[legend]
Collaboration diagram for Sphere:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Sphere (const Vec3f &center, float radius)
virtual ~Sphere ()
bool intersect (Ray &ray) const
Vec3f normal (const Ray &ray) const
virtual TexCoordinate texCoord (const Ray &ray) const
void axes (const Ray &ray, Vec3f &x, Vec3f &y) const

Protected Member Functions

void calcBounds ()

Protected Attributes

Vec3f mCenter
 Position of sphere center.
float mRadius

Detailed Description

Represents a sphere

Author:
Alex Busenius

Christian Engels

Definition at line 15 of file Sphere.h.


Constructor & Destructor Documentation

Sphere::Sphere ( const Vec3f center,
float  radius 
) [inline]

Init constructor

Parameters:
center Position of the sphere center
radius Sphere radius

Definition at line 23 of file Sphere.h.

References calcBounds().

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

Definition at line 31 of file Sphere.h.


Member Function Documentation

bool Sphere::intersect ( Ray ray  )  const [inline, virtual]

Intersects the ray. And sets ray.hit and ray.t to the appropiate values

Returns:
true if something hit, false if not

Implements Primitive.

Definition at line 38 of file Sphere.h.

References Ray::dir(), Vec3f::dot(), EPSILON, Ray::hitPoint(), mCenter, mRadius, Ray::org(), Ray::setHit(), Ray::setUV(), Ray::t(), Vec3f::x(), Vec3f::y(), and Vec3f::z().

Referenced by SphereObject::doIntersect().

Vec3f Sphere::normal ( const Ray ray  )  const [inline, virtual]

Calculate a normal in global coordinates given barycentric coordinates of the hitpoint

Returns:
the normal of the ray with the apropiate position

Implements Primitive.

Definition at line 84 of file Sphere.h.

References Ray::hit(), Vec3f::normal(), Ray::obj(), PhysicalObject::toGlobalCoordinates(), Ray::u(), and Ray::v().

Referenced by axes().

virtual TexCoordinate Sphere::texCoord ( const Ray ray  )  const [inline, virtual]

Returns:
the Texture Coordinate

Reimplemented from Primitive.

Definition at line 99 of file Sphere.h.

References Ray::u(), and Ray::v().

void Sphere::axes ( const Ray ray,
Vec3f x,
Vec3f y 
) const [inline, virtual]

gives axis of the triangle (perpenticular to the normal) this is used in bump mapping

See also:
Shader::normal()

Implements Primitive.

Definition at line 107 of file Sphere.h.

References Vec3f::cross(), EPSILON, Ray::hit(), Vec3f::normal(), normal(), Ray::obj(), Vec3f::setX(), Vec3f::x(), Vec3f::y(), and Vec3f::z().

void Sphere::calcBounds (  )  [inline, protected, virtual]

Calculate sphere bounds

Implements Primitive.

Definition at line 141 of file Sphere.h.

References Box::extend(), Primitive::mBounds, mCenter, and mRadius.

Referenced by Sphere().


Member Data Documentation

Vec3f Sphere::mCenter [protected]

Position of sphere center.

Definition at line 133 of file Sphere.h.

Referenced by calcBounds(), and intersect().

float Sphere::mRadius [protected]

Definition at line 136 of file Sphere.h.

Referenced by calcBounds(), and intersect().


The documentation for this class was generated from the following file:
Generated on Fri Feb 1 00:02:30 2008 for Grayfall by  doxygen 1.5.1