4
* 2000-December-20 Jason Rohrer
9
#ifndef DIRECTION_LIGHTING_GL_INCLUDED
10
#define DIRECTION_LIGHTING_GL_INCLUDED
14
#include "LightingGL.h"
17
* A LightingGL implementation with a single point light source
18
* at distance infinity.
20
* @author Jason Rohrer
22
class DirectionLightingGL : public LightingGL {
27
* Constructs a DirectionLighting.
29
* @param inColor color of lighting for a surface
30
* that is facing directly into the light source.
31
* Is not copied, so cannot be accessed again by caller.
32
* @param inDirection incoming direction of light source.
33
* Is not copied, so cannot be accessed again by caller.
35
DirectionLightingGL( Color *inColor, Vector3D *inDirection );
38
~DirectionLightingGL();
41
// implements LightingGL interface
42
void getLighting( Vector3D *inPoint, Vector3D *inNormal,
48
// direction pointing *towards* light source
55
inline DirectionLightingGL::DirectionLightingGL( Color *inColor,
56
Vector3D *inDirection )
57
: mColor( inColor ), mDirection( inDirection ) {
59
// reverse the passed-in direction
60
mDirection->scale( -1 );
65
inline DirectionLightingGL::~DirectionLightingGL() {
73
inline void DirectionLightingGL::getLighting( Vector3D *inPoint,
74
Vector3D *inNormal, Color *outColor ) {
76
double dot = inNormal->dot( mDirection );
79
outColor->r = mColor->r * dot;
80
outColor->g = mColor->g * dot;
81
outColor->b = mColor->b * dot;