#include <Sphere.h>
Inherits Primitive.
Inheritance diagram for Sphere:
Public Member Functions | |
Sphere (const Vec3f ¢er, 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 |
Definition at line 15 of file Sphere.h.
Sphere::Sphere | ( | const Vec3f & | center, | |
float | radius | |||
) | [inline] |
Init constructor
center | Position of the sphere center | |
radius | Sphere radius |
Definition at line 23 of file Sphere.h.
References calcBounds().
bool Sphere::intersect | ( | Ray & | ray | ) | const [inline, virtual] |
Intersects the ray. And sets ray.hit and ray.t to the appropiate values
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().
Calculate a normal in global coordinates given barycentric coordinates of the hitpoint
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] |
gives axis of the triangle (perpenticular to the normal) this is used in bump mapping
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().
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] |