Robotran C Documentation
MbsViewPoint.hh
Go to the documentation of this file.
1 
6 #ifdef OPEN_GL
7 
8 #ifndef _MBS_VIEW_POINT_HH_
9 #define _MBS_VIEW_POINT_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 
22 namespace OpenGLMbs{
23 
24 // forward declaration
25 class MbsWorld3D;
26 
29 class MbsViewPoint
30 {
31  public:
32  MbsViewPoint(glm::vec3 const&rel_pos, glm::vec3 const&rel_look_at, glm::vec3 const&z_up, MbsWorld3D *world_3d,
33  bool pers_flag=true, float FoV_scale=0.785f, float camera_near=0.1f, float camera_far=100.0f,
34  glm::mat4 const& parent_mat = glm::mat4(1.0f));
35  virtual ~MbsViewPoint();
36 
38  glm::mat4 GetViewMatrix() const { return view_mat; }
39 
41  glm::mat4 GetProjectionMatrix() const { return proj_mat; }
42 
44  glm::vec3 GetPosition() const { return position; }
45 
47  glm::vec3 GetParentPosition() const { return glm::vec3(parent_mat[3][0], parent_mat[3][1], parent_mat[3][2]); }
48 
50  void UpdateParentPos(glm::mat4 const& parent_mat) { this->parent_mat = parent_mat; }
51 
53  glm::mat4 const& GetPosMat() { return posMat; }
54 
56  void UpdatePosMat(glm::mat4 const& posMat) { this->posMat = posMat; }
57 
59  glm::mat4 const& GetRotMat() { return rotMat; }
60 
62  void UpdateRotMat(glm::mat4 const& rotMat) { this->rotMat = rotMat; }
63 
65  void SetWinSize(int x_width, int y_width);
66 
68  bool GetPerspectiveMode(){return this->pers_flag;}
69 
71  void SetPerspectiveMode(bool flag){this->pers_flag=flag;}
72 
73 
74  void UpdateMatrices();
75  void ScaleFactor(float factor);
76 
77  virtual void UpdateView();
78 
79 
80  protected:
81  MbsWorld3D *world_3d;
82 
83  glm::mat4 view_mat;
84  glm::mat4 proj_mat;
85 
86  glm::vec3 position;
87  glm::vec3 look_at;
88  glm::vec3 z_up;
89 
90  glm::mat4 rotMat;
91  glm::mat4 posMat;
92 
93  bool pers_flag;
94 
95  // window size
96  int x_width;
97  int y_width;
98 
99  float x_width_f;
100  float y_width_f;
101  float semi_x_width_f;
102  float semi_y_width_f;
103 
104  float par_fact;
105 
106  float camera_near;
107  float camera_far;
108  float FoV_rad;
109  float FoV_deg;
110  float scale;
111 
112  glm::mat4 parent_mat;
113 
114  // function prototype
115  void UpdateProjection();
116  void UpdateScale(float scale);
117 
118  private:
119  glm::vec3 look_vec;
120 
121  float look_len;
122 
123  // function prototypes
124  glm::mat4 ParentApply(glm::mat4 const& child_look_at, glm::mat4 const& parent_joint);
125 
126 };
127 
128 }
129 #endif
130 #endif
OpenGLMbs
Definition: MpegFrameCaptureOptions.hh:6
MbsWorld3D.hh
MbsWorld3D class.
MbsViewPoint.hh
MbsViewPoint class.