KrisLibrary  1.0.0
viewport.h
1 #ifndef CAMERA_VIEWPORT_H
2 #define CAMERA_VIEWPORT_H
3 
4 #include "camera.h"
5 
6 namespace Camera {
7 
11 class Viewport : public Camera
12 {
13 public:
14  Viewport();
16  void setPerspective(bool enabled);
18  inline void setLensAngle(float rads) { setFOV(rads); }
20  void setFOV(float rads);
22  float getFOV() const;
24  float getHFOV() const;
25 
27  bool clicked(int mx, int my) const;
29  void zoom(float s);
32  void scroll(float x, float y, float z=0);
33 
35  void getViewVector(Vector3&) const;
38  void getMovementVector(float dx, float dy, Vector3&) const;
42  void getMovementVectorAtDistance(float dx, float dy, float dist, Vector3&) const;
43 
46  void getClickVector(float mx, float my, Vector3&) const;
47  void getClickSource(float mx, float my, Vector3&) const;
48 
51  bool project(const Vector3& pt,float& mx,float& my,float& mz) const;
52 
53  bool perspective;
54  float scale;
55 
56  int x,y,w,h;
57  float n, f;
58 };
59 
60 std::ostream& operator << (std::ostream& out, const Viewport&);
61 std::istream& operator >> (std::istream& in, Viewport&);
62 
63 } //namespace Camera
64 
65 #endif
void getMovementVector(float dx, float dy, Vector3 &) const
Definition: viewport.cpp:62
float getFOV() const
Returns the absolute field of view in the width direction.
Definition: viewport.cpp:23
float getHFOV() const
Returns the absolute field of view in the height direction.
Definition: viewport.cpp:28
A 3D vector class.
Definition: math3d/primitives.h:136
bool clicked(int mx, int my) const
Returns true if the point (mx,my) is within the viewport.
Definition: viewport.cpp:44
void setLensAngle(float rads)
Sets the absolute field of view in the width direction (deprecated name)
Definition: viewport.h:18
void setFOV(float rads)
Sets the absolute field of view in the width direction.
Definition: viewport.cpp:18
void scroll(float x, float y, float z=0)
Definition: viewport.cpp:56
A class containing viewport / camera information. This uses OpenGL coordinate convention in which x i...
Definition: viewport.h:11
void getMovementVectorAtDistance(float dx, float dy, float dist, Vector3 &) const
Definition: viewport.cpp:70
void getClickVector(float mx, float my, Vector3 &) const
Definition: viewport.cpp:134
void getViewVector(Vector3 &) const
Returns the forward direction in world coordinates.
Definition: viewport.cpp:103
Definition: camera.cpp:7
bool project(const Vector3 &pt, float &mx, float &my, float &mz) const
Definition: viewport.cpp:155
void zoom(float s)
Multiplies the camera&#39;s zoom by the factor s.
Definition: viewport.cpp:49
void setPerspective(bool enabled)
Sets the viewport as a perspective or orthographic viewport.
Definition: viewport.cpp:33