cgv
Loading...
Searching...
No Matches
light_source.h
1#pragma once
2
3#include <cgv/math/fvec.h>
4#include <cgv/media/color.h> //@<
5
6#include "lib_begin.h" //@<
7
8namespace cgv { //@<
9 namespace media { //@<
10 namespace illum { //@<
11
13enum LightType { LT_DIRECTIONAL, LT_POINT, LT_SPOT };
14
16class CGV_API light_source
17{
18protected: //@<
20 LightType type;
41public: //@<
43 light_source(LightType _t = LT_DIRECTIONAL);
44
47 void set_type(LightType t) { type = t; }
49 LightType get_type() const { return type; }
51 LightType& ref_type() { return type; }
52
54 void set_local_to_eye(bool l) { local_to_eye_coordinates = l; }
56 bool is_local_to_eye() const { return local_to_eye_coordinates; }
58 bool& ref_local_to_eye() { return local_to_eye_coordinates; }
59
61 void set_position(const vec3& loc) { position = loc; }
63 const vec3& get_position() const { return position; }
65 vec3& ref_position() { return position; }
66
68 void set_emission(const rgb& c) { emission = c; }
70 const rgb& get_emission() const { return emission; }
72 rgb& ref_emission() { return emission; }
73
75 void set_ambient_scale(float c) { ambient_scale = c; }
77 float get_ambient_scale() const { return ambient_scale; }
79 float& ref_ambient_scale() { return ambient_scale; }
80
82 void set_constant_attenuation(float c) { constant_attenuation = c; }
84 float get_constant_attenuation() const { return constant_attenuation; }
86 float& ref_constant_attenuation() { return constant_attenuation; }
87
89 void set_linear_attenuation(float c) { linear_attenuation = c; }
91 float get_linear_attenuation() const { return linear_attenuation; }
93 float& ref_linear_attenuation() { return linear_attenuation; }
94
96 void set_quadratic_attenuation(float c) { quadratic_attenuation = c; }
98 float get_quadratic_attenuation() const { return quadratic_attenuation; }
100 float& ref_quadratic_attenuation() { return quadratic_attenuation; }
101
103 void set_spot_direction(const vec3& d) { spot_direction = d; }
105 const vec3& get_spot_direction() const { return spot_direction; }
107 vec3& ref_spot_direction() { return spot_direction; }
108
110 void set_spot_exponent(float e) { spot_exponent = e; }
112 float get_spot_exponent() const { return spot_exponent; }
114 float& ref_spot_exponent() { return spot_exponent; }
115
117 void set_spot_cutoff(float c) { spot_cutoff = c; }
119 float get_spot_cutoff() const { return spot_cutoff; }
121 float& ref_spot_cutoff() { return spot_cutoff; }
122
123}; //@<
124
125 } //@<
126 } //@<
127} //@<
128
129#include <cgv/type/info/type_name.h>
130
131namespace cgv {
132 namespace type {
133 namespace info {
134
135template <>
137{
138 static const char* get_name() { return "light_source"; }
139};
140 }
141 }
142}
143
144
145#include <cgv/config/lib_end.h>
>simple class to hold the properties of a light source
float spot_exponent
>spot exponent
vec3 spot_direction
>direction of spot light
float quadratic_attenuation
>quadratic attenuation coefficients used for positional light sources only
float constant_attenuation
>constant attenuation coefficients used for positional light sources only
void set_type(LightType t)
name getter and setters for members
float ambient_scale
> scale to use on emission to retrieve ambient illumination caused by light source
float linear_attenuation
>linear attenuation coefficients used for positional light sources only
LightType type
>type of light source
rgb emission
> radiance for directional light sources and intensity for point light sources
vec3 position
> direction to light source for directional light sources and location of light source for point or s...
bool local_to_eye_coordinates
>whether location is relative to eye coordinate system, i.e. model view is identity
float spot_cutoff
>spot cutoff in degrees
the cgv namespace
Definition print.h:11
cgv::media::color< float, cgv::media::RGB > rgb
declare rgb color type with 32 bit components
Definition color.h:853
cgv::math::fvec< float, 3 > vec3
declare type of 3d single precision floating point vectors
Definition fvec.h:669
traits class with a static function get_name() of type const char* that returns the type name of the ...
Definition type_name.h:54
static const char * get_name()
return special name for standard types or type name from RTTI cleaned from keywords for all other typ...
Definition type_name.h:56