MGCL V10  V10
MGCL V10
 全て クラス 名前空間 関数 変数 型定義 列挙型 列挙値 フレンド グループ ページ
glViewAttrib.h
1 /********************************************************************/
2 /* Copyright (c) 2015 DG Technologies Inc. and Yuzi Mizuno */
3 /* All rights reserved. */
4 /********************************************************************/
5 #ifndef _MGGLViewAttrib_HH_
6 #define _MGGLViewAttrib_HH_
7 
8 #include "mg/Position.h"
9 #include "mgGL/ConstructionPlane.h"
10 #include <iosfwd>
11 
12 class MGOfstream;
13 class MGIfstream;
14 class MGBox;
15 class MGOpenGLView;
16 
22 
27 class MG_DLL_DECLR MGglViewAttrib{
28 
29 public:
30 
32 MG_DLL_DECLR friend std::ostream& operator<< (std::ostream& out, const MGglViewAttrib& atr);
33 
35 MG_DLL_DECLR friend MGOfstream& operator<< (MGOfstream& buf, const MGglViewAttrib& atr);
36 MG_DLL_DECLR friend MGIfstream& operator>> (MGIfstream& buf, MGglViewAttrib& atr);
37 
39 MGglViewAttrib(bool is_perspective=true);
40 MGglViewAttrib(const MGBox& box, const MGColor* gridColors=0);
41 MGglViewAttrib(const MGOpenGLView& glview);
42 
44 
46 
48 void copy(const MGOpenGLView& glview);
49 
51 const MGPosition& center()const{return m_center;};
52 MGPosition& center(){return m_center;};
53 
57 void compute_viewing_environment(
58  const MGBox& box
59 );
60 
61 const MGConstructionPlane& cplane()const{return m_cplane;};
62 MGConstructionPlane& cplane(){return m_cplane;};
63 
65 double diameter()const{return m_diameter;};
66 double& diameter(){return m_diameter;};
67 
69 const MGPosition& eye_position()const{return m_eyeP;}
70 MGPosition& eye_position(){return m_eyeP;}
71 
73 bool is_perspective() const{return m_perspective;};
74 
75 void set_center(const MGPosition& pos){ m_center=pos;}
76 
78 void setEyePositionUpVector(
79  const MGPosition& eyeP,
80  const MGVector& upVector
81 );
82 
83 void set_fovy(double fovy){m_fovy=fovy;};
84 
85 void setHomeMatrix();
86 
88 void set_perspective(bool pers, double fovy=45.);
89 
91 void set_view_up_vector(const MGVector& up){m_up_vector=up;};
92 
93 MGCL::VIEWMODE viewMode()const{return m_viewMode;};
94 
96 const MGVector& view_up_vector()const{return m_up_vector;};
97 MGVector& view_up_vector(){return m_up_vector;};
98 
100 double view_volume_far()const{return m_far;}
101 
103 double view_volume_height()const{return m_diameter/m_scale;}
104 
106 double view_volume_near()const{return m_near;}
107 
108 private:
110  MGCL::VIEWMODE m_viewMode;
111  MGConstructionPlane m_cplane;
112 
113  bool m_perspective;
114  double m_fovy;
116 
118  double m_near, m_far;
119  MGPosition m_eyeP;
120  MGVector m_up_vector;
121 
124  MGPosition m_center;
125  double m_diameter;
126 
127  double m_scale;
128  double m_cx, m_cy;
129 
132 
133  glm::mat4 m_PreCenterMat;
134  glm::mat4 m_modelViewMat;
135 
136 
137 friend class MGOpenGLView;
138 
139 };
140 #define INITIAL_SCALE 6.
141  // end of DisplayHandling group
143 #endif
bool is_perspective() const
Return if this is a perspective view or not.
Definition: glViewAttrib.h:73
const MGPosition & center() const
return the center of the box of this view.
Definition: glViewAttrib.h:51
double & diameter()
Definition: glViewAttrib.h:66
MGIfstream is a class to read the serialized data generated by MGOfstream.
Definition: Ifstream.h:30
std::ostream & operator<<(std::ostream &ostrm, const MGisect &is)
Debug Function.
Definition: isect.h:95
double view_volume_far() const
compute the view volume far.
Definition: glViewAttrib.h:100
Vector of a general n space dimension.
Definition: Vector.h:26
MGPosition & eye_position()
Definition: glViewAttrib.h:70
Defines a Box of any space dimendion.
Definition: Box.h:34
MGColor defines the OpenGL color (R,G,B,A).
Definition: Color.h:26
void set_view_up_vector(const MGVector &up)
Set the view-up vector.
Definition: glViewAttrib.h:91
MGConstructionPlane & cplane()
Definition: glViewAttrib.h:62
const MGPosition & eye_position() const
Get the eye position.
Definition: glViewAttrib.h:69
double diameter() const
Obtainthe the diameter of the sphere that surround the whole model.
Definition: glViewAttrib.h:65
Represent a positional data.
Definition: Position.h:28
void set_fovy(double fovy)
Definition: glViewAttrib.h:83
void set_center(const MGPosition &pos)
Definition: glViewAttrib.h:75
Defines OpenGL display class for MGCL objects.
Definition: openglView.h:43
VIEWMODE
Definition: MGCL.h:271
MGOfstream is a class to serialize all of the subclasses of MGGel.
Definition: Ofstream.h:31
MGPosition & center()
Definition: glViewAttrib.h:52
const MGConstructionPlane & cplane() const
Definition: glViewAttrib.h:61
MGglViewAttrib is a class to serialize MGOpenGLView.
Definition: glViewAttrib.h:27
MGCL::VIEWMODE viewMode() const
Definition: glViewAttrib.h:93
double view_volume_height() const
compute the view volume height.
Definition: glViewAttrib.h:103
const MGVector & view_up_vector() const
Get the view up vector.
Definition: glViewAttrib.h:96
MGConstructionPlane defines a construction plane ton input 3D data.
Definition: ConstructionPlane.h:33
double view_volume_near() const
compute the view volume near.
Definition: glViewAttrib.h:106
MGVector & view_up_vector()
Definition: glViewAttrib.h:97