cgv
light_source.hh
1 #pragma once
2 
3 #include <cgv/math/fvec.h>
4 #include <cgv/media/color.h> //@<
5 
6 #include "lib_begin.h" //@<
7 
8 namespace cgv { //@<
9  namespace media { //@<
10  namespace illum { //@<
11 
13 enum LightType { LT_DIRECTIONAL, LT_POINT, LT_SPOT };
14 
16 class CGV_API light_source
17 {
18 public: //@<
23 protected: //@<
25  LightType type;
45  float spot_cutoff;
46 public: //@<
48  light_source(LightType _t = LT_DIRECTIONAL);
49 
51  void set_type(LightType t) { type = t; }
54  LightType get_type() const { return type; }
56  LightType& ref_type() { return type; }
57 
59  void set_local_to_eye(bool l) { local_to_eye_coordinates = l; }
61  bool is_local_to_eye() const { return local_to_eye_coordinates; }
63  bool& ref_local_to_eye() { return local_to_eye_coordinates; }
64 
66  void set_position(const vec3& loc) { position = loc; }
68  const vec3& get_position() const { return position; }
70  vec3& ref_position() { return position; }
71 
73  void set_emission(const rgb& c) { emission = c; }
75  const rgb& get_emission() const { return emission; }
77  rgb& ref_emission() { return emission; }
78 
80  void set_ambient_scale(float c) { ambient_scale = c; }
82  float get_ambient_scale() const { return ambient_scale; }
84  float& ref_ambient_scale() { return ambient_scale; }
85 
87  void set_constant_attenuation(float c) { constant_attenuation = c; }
89  float get_constant_attenuation() const { return constant_attenuation; }
91  float& ref_constant_attenuation() { return constant_attenuation; }
92 
94  void set_linear_attenuation(float c) { linear_attenuation = c; }
96  float get_linear_attenuation() const { return linear_attenuation; }
98  float& ref_linear_attenuation() { return linear_attenuation; }
99 
101  void set_quadratic_attenuation(float c) { quadratic_attenuation = c; }
103  float get_quadratic_attenuation() const { return quadratic_attenuation; }
105  float& ref_quadratic_attenuation() { return quadratic_attenuation; }
106 
108  void set_spot_direction(const vec3& d) { spot_direction = d; }
110  const vec3& get_spot_direction() const { return spot_direction; }
112  vec3& ref_spot_direction() { return spot_direction; }
113 
115  void set_spot_exponent(float e) { spot_exponent = e; }
117  float get_spot_exponent() const { return spot_exponent; }
119  float& ref_spot_exponent() { return spot_exponent; }
120 
122  void set_spot_cutoff(float c) { spot_cutoff = c; }
124  float get_spot_cutoff() const { return spot_cutoff; }
126  float& ref_spot_cutoff() { return spot_cutoff; }
127 
128 }; //@<
129 
130  } //@<
131  } //@<
132 } //@<
133 
134 #include <cgv/type/info/type_name.h>
135 
136 namespace cgv {
137  namespace type {
138  namespace info {
139 
140 template <>
141 struct type_name<cgv::media::illum::light_source>
142 {
143  static const char* get_name() { return "light_source"; }
144 };
145  }
146  }
147 }
148 
149 
150 #include <cgv/config/lib_end.h>
cgv::media::illum::light_source
>simple class to hold the properties of a light source
Definition: light_source.hh:17
cgv::media::illum::light_source::emission
rgb emission
> radiance for directional light sources and intensity for point light sources
Definition: light_source.hh:31
cgv::media::illum::light_source::local_to_eye_coordinates
bool local_to_eye_coordinates
>whether location is relative to eye coordinate system, i.e. model view is identity
Definition: light_source.hh:27
cgv::media::illum::light_source::spot_cutoff
float spot_cutoff
>spot cutoff in degrees
Definition: light_source.hh:45
cgv::math::fvec< float, 3 >
cgv::media::illum::light_source::type
LightType type
>type of light source
Definition: light_source.hh:25
cgv::type::info::type_name::get_name
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
cgv::media::illum::light_source::vec3
cgv::math::fvec< float, 3 > vec3
>type of vector used for directions
Definition: light_source.hh:22
cgv::media::color< float, RGB >
cgv::media::illum::light_source::ambient_scale
float ambient_scale
> scale to use on emission to retrieve ambient illumination caused by light source
Definition: light_source.hh:33
cgv::media::illum::light_source::linear_attenuation
float linear_attenuation
>linear attenuation coefficients used for positional light sources only
Definition: light_source.hh:37
cgv::media::illum::light_source::spot_exponent
float spot_exponent
>spot exponent
Definition: light_source.hh:43
cgv::media::illum::light_source::position
vec3 position
> direction to light source for directional light sources and location of light source for point or s...
Definition: light_source.hh:29
cgv::media::illum::light_source::rgb
color< float, RGB > rgb
>used color type
Definition: light_source.hh:20
cgv::media::illum::light_source::constant_attenuation
float constant_attenuation
>constant attenuation coefficients used for positional light sources only
Definition: light_source.hh:35
cgv::media::illum::light_source::quadratic_attenuation
float quadratic_attenuation
>quadratic attenuation coefficients used for positional light sources only
Definition: light_source.hh:39
cgv::media::illum::light_source::spot_direction
vec3 spot_direction
>direction of spot light
Definition: light_source.hh:41
cgv
the cgv namespace
Definition: vr_calib.cxx:9