Robotran C Documentation
MbsLight.hh
Go to the documentation of this file.
1 
6 #ifdef OPEN_GL
7 
8 #ifndef _MBS_LIGHT_HH_
9 #define _MBS_LIGHT_HH_
10 
11 #ifndef degreesToRadians
12  #define degreesToRadians(x) x*(3.141592f/180.0f)
13 #endif
14 
15 #ifndef GLM_FORCE_RADIANS
16  #define GLM_FORCE_RADIANS
17 #endif
18 
19 #include <glm.hpp>
20 
21 namespace OpenGLMbs{
22 
23 // types of lights
24 enum {POINT_LIGHT, SPOT_LIGHT, DIR_LIGHT, NB_LIGHT_TYPES};
25 
28 class MbsLight
29 {
30  public:
31  MbsLight(glm::mat4 const& parent_mat = glm::mat4(1.0f), glm::vec3 const& color = glm::vec3(1.0f),
32  float ambient = 0.05f, bool active = true,
33  int depth_x_width = 1024, int depth_y_width = 1024, float shadow_bias = 0.0f,
34  float depth_near = -10.0f, float depth_far = 20.0f,
35  glm::vec3 const& rel_shadow_z_up = glm::vec3(0.0, 0.0, 1.0),
36  float depth_scale = 0.0015f, float depth_FoV_rad = 1.0f,
37  glm::vec3 const& shadow_point = glm::vec3(0.0f),
38  glm::vec3 const& shadow_dir = glm::vec3(1.0f));
39  virtual ~MbsLight();
40 
41  virtual void Update();
42 
44  virtual void UpdateParentPos(glm::mat4 const& parent_mat) { this->parent_mat = parent_mat; }
45 
47  bool IsActive() const { return active; }
48 
50  int GetType() const { return type; }
51 
53  glm::vec3 GetColor() const { return color; }
54 
55  // get ambient coefficient
56  float GetAmbient() const { return ambient; }
57 
59  int GetDepthXWidth() const { return depth_x_width; }
60 
62  int GetDepthYWidth() const { return depth_y_width; }
63 
65  float GetShadowBias() const { return shadow_bias; }
66 
68  float GetDepthNear() const { return depth_near; }
69 
71  float GetDepthFar() const { return depth_far; }
72 
74  glm::vec3 GetShadowZUp() const { return shadow_z_up; }
75 
77  float GetDepthScale() const { return depth_scale; }
78 
80  float GetDepthFoVRad() const { return depth_FoV_rad; }
81 
83  glm::vec3 GetShadowDir() const { return shadow_dir; }
84 
86  glm::vec3 GetShadowPoint() const { return shadow_point; }
87 
88  protected:
89  glm::mat4 parent_mat;
90 
91  glm::vec3 color;
92 
93  float ambient;
94 
95  int type;
96 
97  bool active;
98 
99  // shadow mapping
100  glm::vec4 rel_z_up_4;
101 
102  int depth_x_width;
103  int depth_y_width;
104 
105  float shadow_bias;
106 
107  float depth_near;
108  float depth_far;
109 
110  glm::vec3 shadow_z_up;
111 
112  // directional light
113  float depth_scale;
114  glm::vec3 shadow_point;
115 
116  // point (or spot) light
117  float depth_FoV_rad;
118 
119  // point light
120  glm::vec3 shadow_dir;
121 };
122 
123 }
124 #endif
125 #endif
OpenGLMbs
Definition: MpegFrameCaptureOptions.hh:6
MbsLight.hh
MbsLight class.