KrisLibrary  1.0.0
GLView.h
1 #ifndef GL_VIEW_H
2 #define GL_VIEW_H
3 
5 #include <KrisLibrary/camera/viewport.h>
6 
7 namespace GLDraw {
8 
9 using namespace Math3D;
10 
11 //pscreen = V*homogeneous(P*M*pworld)
12 //pcamera=M*pworld
13 //pobject=P*M*pworld
14 class GLView
15 {
16 public:
17  GLView();
18  void setCurrentGL();
19  void getCurrentGL();
20  void updateInverses(); //must call this after each change of modelview/projection matrices to update the inverse transforms
21 
22  void setViewport(const Camera::Viewport& v);
23  bool getViewport(Camera::Viewport& v) const;
24 
25  static bool getFrustumMatrix(Real l,Real r,Real b,Real t,Real n,Real f,Matrix4& m);
26  static bool getOrthoMatrix(Real l,Real r,Real b,Real t,Real n,Real f,Matrix4& m);
27 
28  void worldToScreen(const Vector4& p, Vector3& out);
29  void worldToObject(const Vector4& p, Vector4& out);
30  void worldToCamera(const Vector4& p, Vector4& out);
31  void screenToWorld(const Vector3& p, Vector4& out);
32  void objectToWorld(const Vector4& p, Vector4& out);
33  void cameraToWorld(const Vector4& p, Vector4& out);
34 
35  void pointWorldToObject(const Vector3& p, Vector3& out);
36  void pointWorldToCamera(const Vector3& p, Vector3& out);
37  void pointObjectToWorld(const Vector3& p, Vector3& out);
38  void pointCameraToWorld(const Vector3& p, Vector3& out);
39  void vectorWorldToObject(const Vector3& v, Vector3& out);
40  void vectorWorldToCamera(const Vector3& p, Vector3& out);
41  void vectorObjectToWorld(const Vector3& v, Vector3& out);
42  void vectorCameraToWorld(const Vector3& p, Vector3& out);
43  void normalWorldToObject(const Vector3& v, Vector3& out);
44  void normalWorldToCamera(const Vector3& p, Vector3& out);
45  void normalObjectToWorld(const Vector3& v, Vector3& out);
46  void normalCameraToWorld(const Vector3& p, Vector3& out);
47 
48  Real x,y,w,h; //viewport
49  Matrix4 modelview;
50  Matrix4 projection;
51 
52  Matrix4 modelviewInverse;
53  Matrix4 projectionInverse;
54 };
55 
56 } //namespace GLDraw
57 
58 #endif
Definition: GLView.h:14
A 3D vector class.
Definition: math3d/primitives.h:136
Class declarations for useful 3D math types.
A 4D vector class.
Definition: math3d/primitives.h:228
A 4x4 matrix class.
Definition: math3d/primitives.h:626
Contains all the definitions in the Math3D package.
Definition: AnyGeometry.h:12
A class containing viewport / camera information. This uses OpenGL coordinate convention in which x i...
Definition: viewport.h:11
Contains all definitions in the GLDraw package.
Definition: AnyGeometry.h:13