Camera.h
1 //##################################################################################################
2 //
3 // Ceetron Desktop Components
4 // Component: Visualization
5 //
6 // --------------------------------------------------------------------------------------------
7 // Copyright (C) 2011, Ceetron AS
8 // This is UNPUBLISHED PROPRIETARY SOURCE CODE of Ceetron AS. The contents of this file may
9 // not be disclosed to third parties, copied or duplicated in any form, in whole or in part,
10 // without the prior written permission of Ceetron AS.
11 //##################################################################################################
12 
13 #pragma once
14 
15 #include "CeeVisualization/Base.h"
16 #include "CeeCore/RefCountedObject.h"
17 #include "CeeCore/Ray.h"
18 #include "CeeCore/Plane.h"
19 
20 namespace cee {
21 class Vec3d;
22 class BoundingBox;
23 
24 namespace vis {
25 class View;
26 class CameraInputHandler;
27 
28 //==================================================================================================
29 //
30 //
31 //
32 //==================================================================================================
33 class CEE_VIS_EXPORT Camera : public RefCountedObject
34 {
35 public:
38  {
40  ORTHO
41  };
44  {
47  SCREEN_Z_AXIS
48  };
49 
50 public:
51  virtual ~Camera();
52 
53  void setFromLookAt(const Vec3d& eye, const Vec3d& vrp, const Vec3d& up);
54  void toLookAt(Vec3d* eye, Vec3d* vrp, Vec3d* up) const;
55  void fitView(const BoundingBox& boundingBox, const Vec3d& dir, const Vec3d& up, double adjustmentFactor = 0.9);
56  void fitViewOrtho(const BoundingBox& boundingBox, double eyeDist, const Vec3d& dir, const Vec3d& up, double adjustmentFactor = 0.9);
57  void rotateGlobalAxis(double radians, const Vec3d& axis);
58  void rotateScreenAxis(double radians, ScreenAxis dir);
59  void rubberbandZoom(int x, int y, unsigned int width, unsigned int height);
60 
61  void setProjectionAsPerspective(double fieldOfViewYDeg, double nearPlane, double farPlane);
62  void setProjectionAsOrtho(double height, double nearPlane, double farPlane);
63 
64  void enableAutoClipMinimumNearDistance(double minNearDistance);
65  void enableAutoClipFixedNearDistance(double fixedNearDistance);
66  void disableAutoClip();
67 
68  ProjectionType projection() const;
69  double fieldOfViewYDegrees() const;
70  double nearPlane() const;
71  double farPlane() const;
72  double frontPlaneFrustumHeight() const;
73  Vec3d computeFitViewEyePosition(const BoundingBox& boundingBox, const Vec3d& dir, const Vec3d& up, double adjustmentFactor = 0.9, double fieldOfViewYDeg = 40.0) const;
74 
75  unsigned int viewportWidth() const;
76  unsigned int viewportHeight() const;
77  int viewportPositionX() const;
78  int viewportPositionY() const;
79  void setViewport(int x, int y, unsigned int width, unsigned int height);
80 
81  Ray rayFromWindowCoordinates(int x, int y) const;
82  Plane planeFromWindowCoordinates(int x1, int y1, int x2, int y2) const;
83  bool unproject(const Vec3d& coord, Vec3d* out) const;
84  bool project(const Vec3d& point, Vec3d* out) const;
85 
86  Mat4d viewMatrix() const;
87  void setViewMatrix(Mat4d mat);
88 
89  CameraInputHandler* inputHandler();
90  const CameraInputHandler* inputHandler() const;
91  void setInputHandler(CameraInputHandler* handler);
92 
93 private:
94  Camera(View* view);
95 
96  CEE_PRIVATE_F(View);
97  CEE_PRIVATE_F(OverlayAxisCross);
98  CEE_PRIVATE_F(OverlayNavigationCube);
99  CEE_PRIVATE_IMPL(Camera);
100  CEE_DISALLOW_COPY_AND_ASSIGN(Camera);
101 };
102 
103 } // namespace vis
104 } // namespace cee
Horizontal axis to the right.
Definition: Camera.h:45
Namespace cee contains all functionality and structures under the Core component. ...
Definition: AppComponent.cpp:26
The camera configuration of a view.
Definition: Camera.h:33
Overlay navigation cube used for navigation and orientation in a View.
Definition: OverlayNavigationCube.h:34
ProjectionType
Projection type.
Definition: Camera.h:37
Vertical axis to the up.
Definition: Camera.h:46
A view overlay item showing an axis cross synchronized with current camera settings.
Definition: OverlayAxisCross.h:31
Class for manipulating a camera from input events (typically mouse interaction).
Definition: CameraInputHandler.h:31
ScreenAxis
Rotation screen axis.
Definition: Camera.h:43
A ray that can be used for intersection testing.
Definition: Ray.h:27
Class defining a plane in space.
Definition: Plane.h:27
Base class for all reference counted objects with built-in support for intrusive reference counting...
Definition: RefCountedObject.h:34
Axis-aligned bounding box.
Definition: BoundingBox.h:27
Provides a render area in the user control/widget to enable visualization of the current model data a...
Definition: View.h:40
Vector class for a 3D double vector.
Definition: Vec3d.h:26
Perspective projection.
Definition: Camera.h:39
4 dimensional matrix.
Definition: Mat4d.h:26