Linux multi-monitor fullscreen support
[ryzomcore.git] / ryzom / client / src / camera.cpp
blob5ca126c35d6d73de186542adca2c5e53e28b1739
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-2014 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/>.
20 #include "stdpch.h"
21 #include "camera.h"
23 #include <nel/3d/stereo_display.h>
25 #include "global.h"
26 #include "misc.h"
28 #ifdef DEBUG_NEW
29 #define new DEBUG_NEW
30 #endif
32 using namespace NLMISC;
33 using namespace NL3D;
35 //---------------------------------------------------
36 // update the camera perspective setup
37 //---------------------------------------------------
38 void updateCameraPerspective()
40 float fov, aspectRatio;
41 computeCurrentFovAspectRatio(fov, aspectRatio);
43 // change the perspective of the scene
44 if(!MainCam.empty())
45 MainCam.setPerspective(fov, aspectRatio, CameraSetupZNear, ClientCfg.Vision);
46 // change the perspective of the root scene
47 if(SceneRoot)
49 UCamera cam= SceneRoot->getCam();
50 cam.setPerspective(fov, aspectRatio, SceneRootCameraZNear, SceneRootCameraZFar);
54 void buildCameraClippingPyramid(std::vector<CPlane> &planes)
56 if (StereoDisplay) StereoDisplay->getClippingFrustum(0, &MainCam);
58 // Compute pyramid in view basis.
59 CVector pfoc(0,0,0);
60 const CFrustum &frustum = MainCam.getFrustum();
61 InvMainSceneViewMatrix = MainCam.getMatrix();
62 MainSceneViewMatrix = InvMainSceneViewMatrix;
63 MainSceneViewMatrix.invert();
65 CVector lb(frustum.Left, frustum.Near, frustum.Bottom );
66 CVector lt(frustum.Left, frustum.Near, frustum.Top );
67 CVector rb(frustum.Right, frustum.Near, frustum.Bottom );
68 CVector rt(frustum.Right, frustum.Near, frustum.Top );
70 CVector lbFar(frustum.Left, ClientCfg.CharacterFarClip, frustum.Bottom);
71 CVector ltFar(frustum.Left, ClientCfg.CharacterFarClip, frustum.Top );
72 CVector rtFar(frustum.Right, ClientCfg.CharacterFarClip, frustum.Top );
74 planes.resize (4);
75 // planes[0].make(lbFar, ltFar, rtFar);
76 planes[0].make(pfoc, lt, lb);
77 planes[1].make(pfoc, rt, lt);
78 planes[2].make(pfoc, rb, rt);
79 planes[3].make(pfoc, lb, rb);
81 // Compute pyramid in World basis.
82 // The vector transformation M of a plane p is computed as p*M-1.
83 // Here, ViewMatrix== CamMatrix-1. Hence the following formula.
84 uint i;
86 for (i = 0; i < 4; i++)
88 planes[i] = planes[i]*MainSceneViewMatrix;
92 /* end of file */