Om  1.0.0
A universal framework for multimedia simulation
Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions | List of all members
om::graphics::shapes::Light Class Reference

A class that represents a source of light in a scene. More...

#include <omGraphicsLight.h>

Inheritance diagram for om::graphics::shapes::Light:
om::graphics::shapes::GraphicsShape om::graphics::base::Renderable om::graphics::devices::GraphicsContextObject

Public Types

enum  Type {
  NEVER = 0, DIRECTIONAL = 0, POINT = 1, SPOT = 2,
  AREA = 3
}
 An enum which represents the type of a light. More...
 

Public Member Functions

 Light (Type newType=POINT)
 Create a default white point light with an intensity of 1. More...
 
 Light (Type newType, const Color3f &newColor, Real newIntensity)
 Create a new light with the given type, color, and intensity. More...
 
Type getType () const
 Return an enum value that indicates the type of this light. More...
 
void setType (Type newType)
 Set an enum value that indicates the type of this light. More...
 
const Vector3getPosition () const
 Get the position of this spot light in world space. More...
 
void setPosition (const Vector3 &newPosition)
 Set the position of this spot light in world space. More...
 
const Vector3getDirection () const
 Return the direction that this light is facing if it is not omnidirectional. More...
 
void setDirection (const Vector3 &newDirection)
 Set the direction that this light is facing if it is not omnidirectional. More...
 
Real getPower () const
 Return the total radiant power of the light source. More...
 
void setPower (Real newPower)
 Set the total radiant power of the light source. More...
 
Real getIntensity () const
 Return the intensity of the light source radiated in any direction. More...
 
void setIntensity (Real newIntensity)
 Set the intensity of the light source radiated in any direction. More...
 
Real getAmbient () const
 Return the ambient contribution of the light source relative to its intensity. More...
 
void setAmbient (Real newAmbient)
 Set the ambient contribution of the light source relative to its intensity. More...
 
const Color3f & getColor () const
 Return the color of the light source. More...
 
void setColor (const Color3f &newColor)
 Set the color of the light source. More...
 
Color3f getColorIntensity () const
 Return the color of the light source scaled by the light source's intensity. More...
 
Real getAttenuation (Real distance) const
 Calculate and return the attenuation amount at the specified distance. More...
 
Vector3getAttenuation ()
 Return a vector indicating how this light is attenuated with distance. More...
 
const Vector3getAttenuation () const
 Return a vector indicating how this light is attenuated with distance. More...
 
void setAttenuation (const Vector3 &newAttenuation)
 Set a vector indicating how this light is attenuated with distance. More...
 
Real getSpotCutoff () const
 Get the spot cutoff angle of the light in degrees. More...
 
void setSpotCutoff (Real newSpotCutoff)
 Set the spot cutoff angle of this light in degrees. More...
 
Real getSpotExponent () const
 Return the spot exponent for this light. More...
 
void setSpotExponent (Real newSpotExponent)
 Set the spot exponent for this light. More...
 
Real getSpotFalloff () const
 Return the spot falloff size of this light. More...
 
void setSpotFalloff (Real newSpotFallOff)
 Set the spot falloff size of this light. More...
 
Sphere3 getBoundingSphere (Real cutoffIntensity) const
 Return a bounding sphere for this light's area of effect with the specified cutoff intensity. More...
 
BoundingCone getBoundingCone (Real cutoffIntensity) const
 Get a bounding cone for this light's area of effect with the specified cutoff intensity. More...
 
virtual void getRenderables (const RenderRequest &request, const Transform3 &worldTransform, RenderQueue &outputQueue) const
 Process the renderable and add all child renderable objects to the output render queue. More...
 
- Public Member Functions inherited from om::graphics::shapes::GraphicsShape
ShapeTypeID getShapeTypeID () const
 Return an integer identifying the sub type of this shape. More...
 
const ShapeTypegetShapeType () const
 Return a reference to an object representing the type of this Shape. More...
 
Sphere3 getBoundingSphere () const
 Return a bounding sphere for this transformable in its parent coordinate space. More...
 
const AABB3getBoundingBox () const
 Return an axis-aligned bounding box that encompases this entire transformable in its parent coordinate space. More...
 
virtual void updateBoundingBox ()
 Update the shape's bounding box based on its current geometric representation. More...
 
virtual void intersectRay (GraphicsRay &ray) const
 Trace a ray against this shape and compute the closest intersection. More...
 
virtual void testRay (GraphicsRay &ray) const
 Trace a ray against this shape and determine if any intersection exist along the ray. More...
 
- Public Member Functions inherited from om::graphics::base::Renderable
 Renderable ()
 Create a new renderable object with the default renderable flags. More...
 
 Renderable (const RenderableFlags &newFlags)
 Create a new renderable object with the specified renderable flags. More...
 
RenderableFlagsgetFlags ()
 Return a reference to an object that contains boolean parameters of the renderable. More...
 
const RenderableFlagsgetFlags () const
 Return an object that contains boolean parameters of the renderable. More...
 
void setFlags (const RenderableFlags &newFlags)
 Set an object that contains boolean parameters of the renderable. More...
 
Bool flagIsSet (RenderableFlags::Flag flag) const
 Return whether or not the specified boolan flag is set for this renderable. More...
 
Bool flagsAreSet (const RenderableFlags &otherFlags) const
 Return whether or not all of the specified boolan flags are set for this renderable. More...
 
void setFlag (RenderableFlags::Flag flag, Bool newIsSet=true)
 Set whether or not the specified boolan flag is set for this renderable. More...
 
Bool getIsVisible () const
 Get whether or not the renderable and its children are visible in the scene. More...
 
void setIsVisible (Bool newIsVisible)
 Set whether or not the renderable and its children are visible in the scene. More...
 
Bool getShadowsEnabled () const
 Return whether or not this renderable can cast shadows. More...
 
void setShadowsEnabled (Bool newCanCastShadows)
 Set whether or not this renderable can cast shadows. More...
 
- Public Member Functions inherited from om::graphics::devices::GraphicsContextObject
virtual ~GraphicsContextObject ()
 Destory this graphics context object. More...
 
GraphicsContextgetContext () const
 Return a pointer to the graphics context this context object is using to do rendering. More...
 
virtual void setContext (GraphicsContext *newContext)
 Set a pointer to the graphics context this context object should use to do rendering. More...
 
void clearContext ()
 Clear the previous context from this object. More...
 
void upload ()
 Upload this resource's CPU representation to the GPU device. More...
 
virtual void upload (UploadRequest &request)
 Upload this resource's CPU representation to the GPU device. More...
 
void download ()
 Upload this resource's CPU representation to the GPU device. More...
 
virtual void download (DownloadRequest &request)
 Download the resource's GPU representation to CPU memory. More...
 
virtual Bool isUploaded () const
 Return whether or not this graphics resource has been successfully created and uploaded to the device. More...
 
virtual Bool isDownloaded () const
 Return whether or not this graphics resource has a copy of its data stored in CPU-side memory. More...
 
virtual Bool isValid () const
 Return whether or not the state of this graphics resource is valid (either on CPU or GPU) and able to be used for rendering. More...
 

Static Public Attributes

static const ShapeType TYPE
 A shape type object that represents the shape type to use for a light. More...
 
- Static Public Attributes inherited from om::graphics::shapes::GraphicsShape
static const ResourceType RESOURCE_TYPE
 The resource type for a graphics shape. More...
 

Protected Member Functions

 Light (const ShapeType *newShapeType)
 Create a light as a subclass that has the given shape type. More...
 
- Protected Member Functions inherited from om::graphics::shapes::GraphicsShape
 GraphicsShape (const ShapeType *newType)
 Create a new shape with the specified type. More...
 
void setBoundingBox (const AABB3 &newBoundingBox)
 Set the local axis-aligned bounding box for this shape. More...
 
- Protected Member Functions inherited from om::graphics::devices::GraphicsContextObject
 GraphicsContextObject ()
 Create a new graphics context object that doesn't have an associated graphics context. More...
 
 GraphicsContextObject (GraphicsContext *newContext)
 Create a new graphics context object that uses the specified context for rendering. More...
 

Additional Inherited Members

- Protected Attributes inherited from om::graphics::base::Renderable
RenderableFlags flags
 An object containing boolean configuration flags for this renderable. More...
 
- Protected Attributes inherited from om::graphics::devices::GraphicsContextObject
GraphicsContextcontext
 A pointer to the graphics context this object is using. More...
 

Detailed Description

A class that represents a source of light in a scene.

Member Enumeration Documentation

An enum which represents the type of a light.

Enumerator
NEVER 

A depth test where the test never succeeds (no fragments ever pass or update the depth buffer).

DIRECTIONAL 

A light that is infinitely far away (e.g. Sun), such that all rays from it can be assumed to be parallel.

POINT 

A light that radiates light in all directions from a point source.

SPOT 

A point light whose radiation is constrained to a conic volume.

AREA 

A light that emits light from the surface of a 3D shape.

Constructor & Destructor Documentation

om::graphics::shapes::Light::Light ( Type  newType = POINT)

Create a default white point light with an intensity of 1.

om::graphics::shapes::Light::Light ( Type  newType,
const Color3f &  newColor,
Real  newIntensity 
)

Create a new light with the given type, color, and intensity.

om::graphics::shapes::Light::Light ( const ShapeType newShapeType)
protected

Create a light as a subclass that has the given shape type.

Member Function Documentation

Type om::graphics::shapes::Light::getType ( ) const
inline

Return an enum value that indicates the type of this light.

void om::graphics::shapes::Light::setType ( Type  newType)
inline

Set an enum value that indicates the type of this light.

const Vector3& om::graphics::shapes::Light::getPosition ( ) const
inline

Get the position of this spot light in world space.

void om::graphics::shapes::Light::setPosition ( const Vector3 newPosition)
inline

Set the position of this spot light in world space.

const Vector3& om::graphics::shapes::Light::getDirection ( ) const
inline

Return the direction that this light is facing if it is not omnidirectional.

void om::graphics::shapes::Light::setDirection ( const Vector3 newDirection)
inline

Set the direction that this light is facing if it is not omnidirectional.

Real om::graphics::shapes::Light::getPower ( ) const
inline

Return the total radiant power of the light source.

An omnidirectional light source is assumed. In that case, the power is equal to the intensity multiplied by 4 pi.

void om::graphics::shapes::Light::setPower ( Real  newPower)
inline

Set the total radiant power of the light source.

An omnidirectional light source is assumed. In that case, the power is equal to the intensity multiplied by 4 pi.

Real om::graphics::shapes::Light::getIntensity ( ) const
inline

Return the intensity of the light source radiated in any direction.

An omnidirectional light source is assumed. In that case, the intensity radiated in all directions is equal to the power divided by 4 pi.

void om::graphics::shapes::Light::setIntensity ( Real  newIntensity)
inline

Set the intensity of the light source radiated in any direction.

An omnidirectional light source is assumed. In that case, the intensity radiated in all directions is equal to the power divided by 4 pi.

Real om::graphics::shapes::Light::getAmbient ( ) const
inline

Return the ambient contribution of the light source relative to its intensity.

void om::graphics::shapes::Light::setAmbient ( Real  newAmbient)
inline

Set the ambient contribution of the light source relative to its intensity.

const Color3f& om::graphics::shapes::Light::getColor ( ) const
inline

Return the color of the light source.

void om::graphics::shapes::Light::setColor ( const Color3f &  newColor)
inline

Set the color of the light source.

Color3f om::graphics::shapes::Light::getColorIntensity ( ) const
inline

Return the color of the light source scaled by the light source's intensity.

Real om::graphics::shapes::Light::getAttenuation ( Real  distance) const
inline

Calculate and return the attenuation amount at the specified distance.

Vector3& om::graphics::shapes::Light::getAttenuation ( )
inline

Return a vector indicating how this light is attenuated with distance.

The XYZ components refer to constant, linear, and quadratic attenuation respectively.

const Vector3& om::graphics::shapes::Light::getAttenuation ( ) const
inline

Return a vector indicating how this light is attenuated with distance.

The XYZ components refer to constant, linear, and quadratic attenuation respectively.

void om::graphics::shapes::Light::setAttenuation ( const Vector3 newAttenuation)
inline

Set a vector indicating how this light is attenuated with distance.

The XYZ components refer to constant, linear, and quadratic attenuation respectively.

Real om::graphics::shapes::Light::getSpotCutoff ( ) const
inline

Get the spot cutoff angle of the light in degrees.

This is the maximum angle from the light's direction where light will be produced.

void om::graphics::shapes::Light::setSpotCutoff ( Real  newSpotCutoff)
inline

Set the spot cutoff angle of this light in degrees.

This is the maximum angle from the light's direction where light will be produced. The input value is clamped to the valid range of [0,90].

Real om::graphics::shapes::Light::getSpotExponent ( ) const
inline

Return the spot exponent for this light.

If this value is 0, it will result in a spot light with uniform light distribution across the spot area. A value greater than 0 will cause the light to be more focused toward the center of the light spot.

void om::graphics::shapes::Light::setSpotExponent ( Real  newSpotExponent)
inline

Set the spot exponent for this light.

If this value is 0, it will result in a spot light with uniform light distribution across the spot area. A value greater than 0 will cause the light to be more focused toward the center of the light spot.

Real om::graphics::shapes::Light::getSpotFalloff ( ) const
inline

Return the spot falloff size of this light.

This value is used to create a smooth transition from 100% illuination to 0% illumination outside of the spot light's cutoff angle. This value is multiplied by the cutoff angle to determine how many degrees that falloff spans.

void om::graphics::shapes::Light::setSpotFalloff ( Real  newSpotFallOff)
inline

Set the spot falloff size of this light.

This value is used to create a smooth transition from 100% illuination to 0% illumination outside of the spot light's cutoff angle. This value is multiplied by the cutoff angle to determine how many degrees that falloff spans.

The new falloff value is clamped to the range [0,1].

Sphere3 om::graphics::shapes::Light::getBoundingSphere ( Real  cutoffIntensity) const

Return a bounding sphere for this light's area of effect with the specified cutoff intensity.

BoundingCone om::graphics::shapes::Light::getBoundingCone ( Real  cutoffIntensity) const

Get a bounding cone for this light's area of effect with the specified cutoff intensity.

virtual void om::graphics::shapes::Light::getRenderables ( const RenderRequest request,
const Transform3 worldTransform,
RenderQueue outputQueue 
) const
virtual

Process the renderable and add all child renderable objects to the output render queue.

Implements om::graphics::base::Renderable.

Member Data Documentation

const ShapeType om::graphics::shapes::Light::TYPE
static

A shape type object that represents the shape type to use for a light.


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