reference

This documentation is automatically generated from the openFrameworks source code using doxygen and refers to the most recent release, version 0.12.0.

ofLight.h
Go to the documentation of this file.
1/*
2 * ofLight.h
3 * openFrameworksLib
4 *
5 * Created by Memo Akten on 14/01/2011.
6 * Copyright 2011 MSA Visuals Ltd. All rights reserved.
7 *
8 */
9
10#pragma once
11
12#include "ofNode.h"
13#include "ofShadow.h"
14
15template<typename T>
16class ofColor_;
20
22
27 OF_LIGHT_AREA=3 // Only programmable renderer
28};
29
30void ofEnableLighting();
35void ofSetSmoothLighting(bool b);
38
39//----------------------------------------
40// Use the public API of ofNode for all transformations
41class ofLight : public ofNode {
42public:
43 ofLight();
44
45 void setup();
46 void enable();
47 void disable();
48 bool getIsEnabled() const;
49
50 void setDirectional();
51 bool getIsDirectional() const;
52
53 void setSpotlight( float spotCutOff=45.f, float exponent=0.f );
54 bool getIsSpotlight() const;
55 void setSpotlightCutOff( float spotCutOff );
56 float getSpotlightCutOff() const;
57 void setSpotConcentration( float exponent );
58 float getSpotConcentration() const;
59
60 void setPointLight();
61 bool getIsPointLight() const;
62 void setAttenuation( float constant=1.f, float linear=0.f, float quadratic=0.f );
63 float getAttenuationConstant() const;
64 float getAttenuationLinear() const;
65 float getAttenuationQuadratic() const;
66
67 void setAreaLight(float width, float height);
68 bool getIsAreaLight() const;
69
70 int getType() const;
71
72 void setAmbientColor(const ofFloatColor& c);
73 void setDiffuseColor(const ofFloatColor& c);
74 void setSpecularColor(const ofFloatColor& c);
75
79
80 int getLightID() const;
81
85 bool endShadowDepthPass();
86 bool beginShadowDepthPass( GLenum aPassIndex );
87 bool endShadowDepthPass( GLenum aPassIndex );
88
89 ofShadow& getShadow() { return shadow; }
90
91 class Data{
92 public:
93 Data();
94 ~Data();
95
99
103
105
109 float exponent;
110 glm::vec4 position;
111 glm::vec3 direction;
112
113 float width;
114 float height;
115 glm::vec3 up;
116 glm::vec3 right;
118 std::weak_ptr<ofBaseGLRenderer> rendererP;
119 };
120
121protected:
123
124private:
125 void customDraw(const ofBaseRenderer * renderer) const;
126 std::shared_ptr<Data> data;
127 // update opengl light
128 // this method overrides ofNode to catch the changes and update glLightv(GL_POSITION)
129 virtual void onPositionChanged();
130 virtual void onOrientationChanged();
131};
132
133
134std::vector<std::weak_ptr<ofLight::Data> > & ofLightsData();
Definition ofGLBaseTypes.h:95
The base renderer interface.
Definition ofGraphicsBaseTypes.h:279
ofColor represents a color in openFrameworks.
Definition ofColor.h:20
Definition ofLight.h:91
int isEnabled
Definition ofLight.h:107
float width
Definition ofLight.h:113
ofFloatColor ambientColor
Definition ofLight.h:96
glm::vec3 right
Definition ofLight.h:116
~Data()
Definition ofLight.cpp:84
glm::vec3 direction
Definition ofLight.h:111
ofFloatColor diffuseColor
Definition ofLight.h:97
Data()
Definition ofLight.cpp:71
ofFloatColor specularColor
Definition ofLight.h:98
std::weak_ptr< ofBaseGLRenderer > rendererP
weak link back to renderer for which this light was created/setup
Definition ofLight.h:118
glm::vec3 up
Definition ofLight.h:115
float height
Definition ofLight.h:114
ofLightType lightType
Definition ofLight.h:104
float attenuation_quadratic
Definition ofLight.h:102
float exponent
Definition ofLight.h:109
float spotCutOff
Definition ofLight.h:108
int glIndex
Definition ofLight.h:106
float attenuation_linear
Definition ofLight.h:101
glm::vec4 position
Definition ofLight.h:110
float attenuation_constant
Definition ofLight.h:100
Definition ofLight.h:41
bool getIsPointLight() const
Definition ofLight.cpp:254
float getAttenuationQuadratic() const
Definition ofLight.cpp:280
bool getIsDirectional() const
Definition ofLight.cpp:188
void enable()
Definition ofLight.cpp:149
ofFloatColor getAmbientColor() const
Definition ofLight.cpp:332
void setup()
Definition ofLight.cpp:108
int getType() const
Definition ofLight.cpp:302
ofFloatColor getDiffuseColor() const
Definition ofLight.cpp:337
bool getIsAreaLight() const
Definition ofLight.cpp:297
ofShadow & getShadow()
Definition ofLight.h:89
void disable()
Definition ofLight.cpp:160
void setDiffuseColor(const ofFloatColor &c)
Definition ofLight.cpp:315
ofLight()
Definition ofLight.cpp:96
void setSpecularColor(const ofFloatColor &c)
Definition ofLight.cpp:324
ofShadow shadow
Definition ofLight.h:122
void setAttenuation(float constant=1.f, float linear=0.f, float quadratic=0.f)
Definition ofLight.cpp:259
bool endShadowDepthPass()
Definition ofLight.cpp:439
ofFloatColor getSpecularColor() const
Definition ofLight.cpp:342
void setSpotlight(float spotCutOff=45.f, float exponent=0.f)
Definition ofLight.cpp:193
void setSpotConcentration(float exponent)
Definition ofLight.cpp:227
int getLightID() const
Definition ofLight.cpp:168
void setAreaLight(float width, float height)
Definition ofLight.cpp:284
float getSpotConcentration() const
Definition ofLight.cpp:235
void setDirectional()
Definition ofLight.cpp:178
void setSpotlightCutOff(float spotCutOff)
Definition ofLight.cpp:211
bool getIsSpotlight() const
Definition ofLight.cpp:206
float getAttenuationLinear() const
Definition ofLight.cpp:275
float getSpotlightCutOff() const
Definition ofLight.cpp:219
bool shouldRenderShadowDepthPass()
Definition ofLight.cpp:409
void setPointLight()
Definition ofLight.cpp:243
float getAttenuationConstant() const
Definition ofLight.cpp:270
bool getIsEnabled() const
Definition ofLight.cpp:173
void setAmbientColor(const ofFloatColor &c)
Definition ofLight.cpp:307
int getNumShadowDepthPasses()
Definition ofLight.cpp:417
bool beginShadowDepthPass()
Definition ofLight.cpp:425
A generic 3d object in space with transformation (position, rotation, scale).
Definition ofNode.h:14
virtual void customDraw()
If you extend ofNode and wish to change the way it draws, extend this.
Definition ofNode.cpp:651
Definition ofShadow.h:24
unsigned int height
Definition ofAppEGLWindow.cpp:125
unsigned int width
Definition ofAppEGLWindow.cpp:124
void ofDisableSeparateSpecularLight()
Definition ofLight.cpp:41
ofColor_< unsigned short > ofShortColor
A typedef representing a 16-bit (unsigned short) RGBA color.
Definition ofLight.h:19
const ofFloatColor & ofGetGlobalAmbientColor()
Definition ofLight.cpp:61
std::vector< std::weak_ptr< ofLight::Data > > & ofLightsData()
Definition ofLight.cpp:66
void ofDisableLighting()
Definition ofLight.cpp:31
void ofEnableLighting()
Definition ofLight.cpp:26
void ofEnableSeparateSpecularLight()
Definition ofLight.cpp:36
void ofSetSmoothLighting(bool b)
Definition ofLight.cpp:51
ofLightType
Definition ofLight.h:23
@ OF_LIGHT_AREA
Definition ofLight.h:27
@ OF_LIGHT_POINT
Definition ofLight.h:24
@ OF_LIGHT_SPOT
Definition ofLight.h:26
@ OF_LIGHT_DIRECTIONAL
Definition ofLight.h:25
void ofSetGlobalAmbientColor(const ofFloatColor &c)
Definition ofLight.cpp:56
ofColor_< float > ofFloatColor
A typedef representing a floating (float) point RGBA color.
Definition ofLight.h:18
ofColor_< unsigned char > ofColor
A typedef representing an 8-bit (unsigned char) RGBA color.
Definition ofLight.h:17
bool ofGetLightingEnabled()
Definition ofLight.cpp:46
#define c
#define b