#include <Ray.h>
Collaboration diagram for Ray:
Public Member Functions | |
Ray () | |
void | init (const Vec3f &origin, const Vec3f &direction, float t=INFINITY) |
const Vec3f & | org () const |
const Vec3f & | dir () const |
float | t () const |
Vec3f | hitPoint (float eps) const |
const Primitive * | hit () const |
void | setHit (const Primitive *hit, float t) |
const Object * | obj () const |
void | setObj (const Object *object) |
float | u () const |
float | v () const |
void | setUV (float u, float v) |
float | influence () const |
int | recDeep () const |
void | setInfluence (float infl, int recursionDeep) |
void | updateInfluence (const Ray &ray, float infl=1.0f) |
Private Attributes | |
Vec3f | mOrg |
Origin. | |
Vec3f | mDir |
Direction. | |
float | mT |
Current / maximum hit distance. | |
const Primitive * | mHit |
Currently closest primitive. | |
const Object * | mHitObj |
Currently closest object. | |
float | mU |
Barycentric u coordinate of the hit point. | |
float | mV |
Barycentric v coordinate of the hit point. | |
float | mInfluence |
Influence on the resulting color (used in adaptive recursion termination). | |
int | mRecursionDeep |
Recursion deep of this ray. |
Definition at line 22 of file Ray.h.
Initialize the ray. Should be called before starting tracing
origin | New ray origin | |
direction | New ray direction, normalized if needed | |
t | New current hit distance |
Definition at line 46 of file Ray.h.
References EPSILON, mDir, mHit, mHitObj, mInfluence, mOrg, mRecursionDeep, mT, mU, mV, Vec3f::normal(), and t().
Referenced by QuadAreaLight::illuminate(), PointLight::illuminate(), PerspectiveCamera::initRay(), DepthOfFieldCamera::initRay(), operator *(), TransparentShader::shade(), RefractiveShader::shade(), and MirrorShader::shade().
const Vec3f& Ray::org | ( | ) | const [inline] |
Get ray origin
Definition at line 64 of file Ray.h.
References mOrg.
Referenced by Node::distanceToSplitPlane(), Triangle::intersect(), Sphere::intersect(), InfinitePlane::intersect(), Box::intersect(), Node::nearFar(), operator *(), operator<<(), and CookTorranceShader::shade().
const Vec3f& Ray::dir | ( | ) | const [inline] |
Get ray direction
Definition at line 71 of file Ray.h.
References mDir.
Referenced by Node::distanceToSplitPlane(), Triangle::intersect(), Sphere::intersect(), InfinitePlane::intersect(), Box::intersect(), operator *(), operator<<(), TransparentShader::shade(), RefractiveShader::shade(), PhongShader::shade(), MirrorShader::shade(), and CookTorranceShader::shade().
float Ray::t | ( | ) | const [inline] |
Get current hit distance
Definition at line 78 of file Ray.h.
References mT.
Referenced by QuadAreaLight::illuminate(), PointLight::illuminate(), init(), Triangle::intersect(), Sphere::intersect(), InfinitePlane::intersect(), Node::leafIntersect(), operator *(), RefractiveShader::shade(), and CookTorranceShader::shade().
Vec3f Ray::hitPoint | ( | float | eps | ) | const [inline] |
Get current hit point
eps | Offset to add to t |
Definition at line 87 of file Ray.h.
References mDir, mOrg, and mT.
Referenced by DepthOfFieldCamera::initRay(), Sphere::intersect(), WoodShader::shade(), TransparentShader::shade(), RefractiveShader::shade(), PhongShader::shade(), and MirrorShader::shade().
const Primitive* Ray::hit | ( | ) | const [inline] |
Get currently closest primitive
Definition at line 94 of file Ray.h.
References mHit.
Referenced by Sphere::axes(), QuadAreaLight::illuminate(), PointLight::illuminate(), Triangle::normal(), TexturedSmoothTriangle::normal(), Sphere::normal(), Shader::normal(), operator *(), Scene::rayTrace(), setHit(), WoodShader::shade(), RefractiveShader::shade(), PhongShader::shade(), MirrorShader::shade(), DebugShader::shade(), CookTorranceShader::shade(), CombineShader::shade(), CloudShader::shade(), and TexturedSmoothTriangle::texCoord().
void Ray::setHit | ( | const Primitive * | hit, | |
float | t | |||
) | [inline] |
Set current hit distance and closest primitive
Definition at line 101 of file Ray.h.
References hit(), mHit, and mT.
Referenced by Triangle::intersect(), Sphere::intersect(), InfinitePlane::intersect(), Node::leafIntersect(), and operator *().
const Object* Ray::obj | ( | ) | const [inline] |
Get currently closest object
Definition at line 109 of file Ray.h.
References mHitObj.
Referenced by Sphere::axes(), Triangle::normal(), TexturedSmoothTriangle::normal(), Sphere::normal(), operator *(), RefractiveShader::shade(), PhongShader::shade(), and MirrorShader::shade().
void Ray::setObj | ( | const Object * | object | ) | [inline] |
Set closest object. Object must be NULL if hit() is NULL
Definition at line 116 of file Ray.h.
Referenced by Object::intersect(), and operator *().
float Ray::u | ( | ) | const [inline] |
Get barycentric U coordinate
Definition at line 124 of file Ray.h.
References mU.
Referenced by TexturedSmoothTriangle::normal(), Sphere::normal(), operator *(), TexturedSmoothTriangle::texCoord(), and Sphere::texCoord().
float Ray::v | ( | ) | const [inline] |
Get barycentric V coordinate
Definition at line 131 of file Ray.h.
References mV.
Referenced by TexturedSmoothTriangle::normal(), Sphere::normal(), operator *(), TexturedSmoothTriangle::texCoord(), and Sphere::texCoord().
void Ray::setUV | ( | float | u, | |
float | v | |||
) | [inline] |
Set barycentric coordinates
Definition at line 138 of file Ray.h.
Referenced by Triangle::intersect(), Sphere::intersect(), and operator *().
float Ray::influence | ( | ) | const [inline] |
Get ray influence on resulting color
Definition at line 146 of file Ray.h.
References mInfluence.
Referenced by operator *(), RefractiveShader::shade(), MirrorShader::shade(), and updateInfluence().
int Ray::recDeep | ( | ) | const [inline] |
Get current recursion deep
Definition at line 153 of file Ray.h.
References mRecursionDeep.
Referenced by operator *(), Scene::rayTrace(), RefractiveShader::shade(), MirrorShader::shade(), and updateInfluence().
void Ray::setInfluence | ( | float | infl, | |
int | recursionDeep | |||
) | [inline] |
Set ray influence
infl | How large influence of this ray is on resulting color | |
recursionDeep | Current recursion deep |
Definition at line 163 of file Ray.h.
References mInfluence, and mRecursionDeep.
Referenced by operator *().
void Ray::updateInfluence | ( | const Ray & | ray, | |
float | infl = 1.0f | |||
) | [inline] |
Update ray influence of given ray with new values, multiply influence to old influence and increment recursion deep
ray | Ray with initial values | |
infl | Value to multiply to the influence of another ray |
Definition at line 177 of file Ray.h.
References influence(), mInfluence, mRecursionDeep, and recDeep().
Referenced by TransparentShader::shade(), RefractiveShader::shade(), MirrorShader::shade(), and CombineShader::shade().
float Ray::mT [private] |
const Object* Ray::mHitObj [private] |
float Ray::mU [private] |
float Ray::mV [private] |
float Ray::mInfluence [private] |
Influence on the resulting color (used in adaptive recursion termination).
Definition at line 207 of file Ray.h.
Referenced by influence(), init(), setInfluence(), and updateInfluence().
int Ray::mRecursionDeep [private] |
Recursion deep of this ray.
Definition at line 210 of file Ray.h.
Referenced by init(), recDeep(), setInfluence(), and updateInfluence().