Linux multi-monitor fullscreen support
[ryzomcore.git] / ryzom / client / src / view.h
blob002edbf8b462e4d8cb0eadd5c79c77127e1ea01d
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2013 Jan BOON (Kaetemi) <jan.boon@kaetemi.be>
6 //
7 // This program is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Affero General Public License as
9 // published by the Free Software Foundation, either version 3 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU Affero General Public License for more details.
17 // You should have received a copy of the GNU Affero General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #ifndef NL_VIEW_H
23 #define NL_VIEW_H
26 /////////////
27 // INCLUDE //
28 /////////////
29 #include "nel/misc/types_nl.h"
30 #include "nel/misc/vector.h"
33 ///////////
34 // USING //
35 ///////////
36 using NLMISC::CVector;
39 ////////////
40 // GLOBAL //
41 ////////////
42 extern class CView View;
45 ///////////
46 // CLASS //
47 ///////////
48 /**
49 * Class to manage the vision.
50 * \author Guillaume PUZIN
51 * \author Nevrax France
52 * \date 2001
54 class CView
56 public:
57 float _CurrentCameraSpeed;
58 float _CurrentCameraDist;
59 float _CurrentCameraHeight;
60 float _MaxCameraHeight;
61 float _MinCameraHeight;
62 float _CurrentCameraDistanceMax; //equal ClientCfg.CameraDistMax in Ryzom or ring(play/test)mode or equal ClientCfg.DMCameraDistMax in ring dm mode
64 protected:
65 /// Vector for the view position.
66 CVector _ViewPos;
67 /// Vector for the view heading.
68 CVector _View;
69 /// Rear View
70 bool _RearView;
71 /// Vector for the refine.
72 CVector _RefinePos;
73 /// The cameraDist due to collision
74 float _CollisionCameraDist;
75 /// The Third person cluster system
76 NL3D::UInstanceGroup *_ThirPersonClusterSystem;
77 /// Force Temporary FirstPersonView if too near a wall
78 bool _ForceFirstPersonView;
80 /// const. move back camera target to avoid problem of camera target too near a wall
81 float _CameraCollisionDecal;
82 // const the threshold is to avoid problem because of imprecision and camera near clip
83 float _CameraCollisionThreshold;
85 public:
87 /// Constructor
88 CView();
90 void update();
92 /// Get the user position.
93 const CVector &viewPos() const {return _ViewPos;}
94 /// Set the user position.
95 void viewPos(const CVector &vect) {_ViewPos = vect;}
97 /// Get the view (like a camera).
98 const CVector &view() const {return _View;}
99 /// Set the view (like a camera).
100 void view(const CVector &vect) {_View = vect;}
102 /// Change the height of the camera
103 void changeCameraHeight(bool up, bool down);
104 /// Change the distance of the camera
105 void changeCameraDist(bool forward, bool backward);
106 // Change the distance from the user to the camera.
107 void cameraDistance(float dist);
109 /// rotate the view on the left or right.
110 void rotate(float ang);
112 /// rotate the view vertically.
113 void rotVertically(float ang);
114 /// rotate the view horizontally.
115 void rotHorizontally(float ang);
117 // Return the current view position (rear or normal)
118 CVector currentViewPos() const;
119 // Return the current view (rear or normal)
120 CVector currentView() const;
121 // Return the current view as a quaternion
122 NLMISC::CQuat currentViewQuat() const;
124 // Return the current Camera Target (for 3rd person only. 1st person: return currentViewPos())
125 CVector currentCameraTarget() const;
127 // For debug only
128 void getCamera3rdPersonSetup(CVector &cameraStart, CVector &cameraEnd, CVector &cameraTestStart) const;
131 void rearView(bool r) {_RearView = r;}
132 bool rearView() const {return _RearView;}
134 /** Special for optimisation, set the "refinePos".
135 * The refine Pos is used for Async Loading, Landscape refining, etc...
136 * For optimisation, it should be the UserEntity pos, and not the view pos (else 3rd person=> slower)
138 void refinePos(const CVector &pos) {_RefinePos= pos;}
139 const CVector &refinePos() const {return _RefinePos;}
141 // update the camera collision, must be called once per frame, after changing viewPos() and/or view()
142 void updateCameraCollision();
144 NL3D::UInstanceGroup *getThirdPersonClusterSystem() const {return _ThirPersonClusterSystem;}
146 // true if the camera collision want to force the first person view
147 bool forceFirstPersonView() const {return _ForceFirstPersonView;}
149 // update the max distance of the camera for player that want to play as dm (camera can be far)
150 void setCameraDistanceMaxForDm();
151 // update the max distance of the camera for player that want to play as player (camera must be near)
152 void setCameraDistanceMaxForPlayer();
154 protected:
155 // Move Forward or Backward
156 void increaseCameraDist();
157 void decreaseCameraDist();
159 // get the input data for camera 3d person collision test
160 void getCamera3rdPersonSetupInternal(CVector &cameraStart, CVector &cameraEnd, CVector &cameraTestStart, float &testStartDecal) const;
165 #endif // NL_VIEW_H
167 /* End of view.h */