mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-17 13:01:42 +00:00
Separate some camera related functions, ref #43
This commit is contained in:
parent
f84f5807c1
commit
3a4204e091
5 changed files with 116 additions and 60 deletions
85
code/ryzom/client/src/camera.cpp
Normal file
85
code/ryzom/client/src/camera.cpp
Normal file
|
@ -0,0 +1,85 @@
|
|||
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include <nel/misc/types_nl.h>
|
||||
#include "camera.h"
|
||||
|
||||
#include <nel/3d/stereo_ovr.h>
|
||||
|
||||
#include "global.h"
|
||||
#include "misc.h"
|
||||
|
||||
using namespace NLMISC;
|
||||
using namespace NL3D;
|
||||
|
||||
//---------------------------------------------------
|
||||
// update the camera perspective setup
|
||||
//---------------------------------------------------
|
||||
void updateCameraPerspective()
|
||||
{
|
||||
float fov, aspectRatio;
|
||||
computeCurrentFovAspectRatio(fov, aspectRatio);
|
||||
|
||||
// change the perspective of the scene
|
||||
if(!MainCam.empty())
|
||||
MainCam.setPerspective(fov, aspectRatio, CameraSetupZNear, ClientCfg.Vision);
|
||||
// change the perspective of the root scene
|
||||
if(SceneRoot)
|
||||
{
|
||||
UCamera cam= SceneRoot->getCam();
|
||||
cam.setPerspective(fov, aspectRatio, SceneRootCameraZNear, SceneRootCameraZFar);
|
||||
}
|
||||
}
|
||||
|
||||
void buildCameraClippingPyramid(std::vector<CPlane> &planes)
|
||||
{
|
||||
if (StereoDisplay) StereoDisplay->getClippingFrustum(0, &MainCam);
|
||||
|
||||
// Compute pyramid in view basis.
|
||||
CVector pfoc(0,0,0);
|
||||
const CFrustum &frustum = MainCam.getFrustum();
|
||||
InvMainSceneViewMatrix = MainCam.getMatrix();
|
||||
MainSceneViewMatrix = InvMainSceneViewMatrix;
|
||||
MainSceneViewMatrix.invert();
|
||||
|
||||
CVector lb(frustum.Left, frustum.Near, frustum.Bottom );
|
||||
CVector lt(frustum.Left, frustum.Near, frustum.Top );
|
||||
CVector rb(frustum.Right, frustum.Near, frustum.Bottom );
|
||||
CVector rt(frustum.Right, frustum.Near, frustum.Top );
|
||||
|
||||
CVector lbFar(frustum.Left, ClientCfg.CharacterFarClip, frustum.Bottom);
|
||||
CVector ltFar(frustum.Left, ClientCfg.CharacterFarClip, frustum.Top );
|
||||
CVector rtFar(frustum.Right, ClientCfg.CharacterFarClip, frustum.Top );
|
||||
|
||||
planes.resize (4);
|
||||
// planes[0].make(lbFar, ltFar, rtFar);
|
||||
planes[0].make(pfoc, lt, lb);
|
||||
planes[1].make(pfoc, rt, lt);
|
||||
planes[2].make(pfoc, rb, rt);
|
||||
planes[3].make(pfoc, lb, rb);
|
||||
|
||||
// Compute pyramid in World basis.
|
||||
// The vector transformation M of a plane p is computed as p*M-1.
|
||||
// Here, ViewMatrix== CamMatrix-1. Hence the following formula.
|
||||
uint i;
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
planes[i] = planes[i]*MainSceneViewMatrix;
|
||||
}
|
||||
}
|
||||
|
||||
/* end of file */
|
29
code/ryzom/client/src/camera.h
Normal file
29
code/ryzom/client/src/camera.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef CL_CAMERA_H
|
||||
#define CL_CAMERA_H
|
||||
|
||||
#include <nel/misc/types_nl.h>
|
||||
|
||||
#include <nel/misc/plane.h>
|
||||
|
||||
void updateCameraPerspective();
|
||||
void buildCameraClippingPyramid(std::vector<NLMISC::CPlane> &planes);
|
||||
|
||||
#endif // CL_CAMERA_H
|
||||
|
||||
/* end of file */
|
|
@ -142,6 +142,7 @@
|
|||
// pulled from main_loop.cpp
|
||||
#include "ping.h"
|
||||
#include "profiling.h"
|
||||
#include "camera.h"
|
||||
#include "main_loop_debug.h"
|
||||
#include "main_loop_temp.h"
|
||||
#include "main_loop_utilities.h"
|
||||
|
@ -351,44 +352,6 @@ void displaySceneProfiles();
|
|||
// validate current dialogs (end them if the player is too far from its interlocutor)
|
||||
void validateDialogs(const CGameContextMenu &gcm);
|
||||
|
||||
void buildCameraClippingPyramid (vector<CPlane> &planes)
|
||||
{
|
||||
if (StereoDisplay) StereoDisplay->getClippingFrustum(0, &MainCam);
|
||||
|
||||
// Compute pyramid in view basis.
|
||||
CVector pfoc(0,0,0);
|
||||
const CFrustum &frustum = MainCam.getFrustum();
|
||||
InvMainSceneViewMatrix = MainCam.getMatrix();
|
||||
MainSceneViewMatrix = InvMainSceneViewMatrix;
|
||||
MainSceneViewMatrix.invert();
|
||||
|
||||
CVector lb(frustum.Left, frustum.Near, frustum.Bottom );
|
||||
CVector lt(frustum.Left, frustum.Near, frustum.Top );
|
||||
CVector rb(frustum.Right, frustum.Near, frustum.Bottom );
|
||||
CVector rt(frustum.Right, frustum.Near, frustum.Top );
|
||||
|
||||
CVector lbFar(frustum.Left, ClientCfg.CharacterFarClip, frustum.Bottom);
|
||||
CVector ltFar(frustum.Left, ClientCfg.CharacterFarClip, frustum.Top );
|
||||
CVector rtFar(frustum.Right, ClientCfg.CharacterFarClip, frustum.Top );
|
||||
|
||||
planes.resize (4);
|
||||
// planes[0].make(lbFar, ltFar, rtFar);
|
||||
planes[0].make(pfoc, lt, lb);
|
||||
planes[1].make(pfoc, rt, lt);
|
||||
planes[2].make(pfoc, rb, rt);
|
||||
planes[3].make(pfoc, lb, rb);
|
||||
|
||||
// Compute pyramid in World basis.
|
||||
// The vector transformation M of a plane p is computed as p*M-1.
|
||||
// Here, ViewMatrix== CamMatrix-1. Hence the following formula.
|
||||
uint i;
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
planes[i] = planes[i]*MainSceneViewMatrix;
|
||||
}
|
||||
}
|
||||
|
||||
void preRenderNewSky ()
|
||||
{
|
||||
CSky &sky = ContinentMngr.cur()->CurrentSky;
|
||||
|
|
|
@ -33,29 +33,11 @@
|
|||
#include "entities.h"
|
||||
#include "input.h"
|
||||
#include "sound_manager.h"
|
||||
#include "camera.h"
|
||||
|
||||
using namespace NLMISC;
|
||||
using namespace NL3D;
|
||||
|
||||
//---------------------------------------------------
|
||||
// update the camera perspective setup
|
||||
//---------------------------------------------------
|
||||
void updateCameraPerspective()
|
||||
{
|
||||
float fov, aspectRatio;
|
||||
computeCurrentFovAspectRatio(fov, aspectRatio);
|
||||
|
||||
// change the perspective of the scene
|
||||
if(!MainCam.empty())
|
||||
MainCam.setPerspective(fov, aspectRatio, CameraSetupZNear, ClientCfg.Vision);
|
||||
// change the perspective of the root scene
|
||||
if(SceneRoot)
|
||||
{
|
||||
UCamera cam= SceneRoot->getCam();
|
||||
cam.setPerspective(fov, aspectRatio, SceneRootCameraZNear, SceneRootCameraZFar);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------
|
||||
// Compare ClientCfg and LastClientCfg to know what we must update
|
||||
//---------------------------------------------------
|
||||
|
|
|
@ -24,9 +24,6 @@
|
|||
// This is mainly for system configuration related functions
|
||||
// such as config file changes.
|
||||
|
||||
/// does not belong here
|
||||
void updateCameraPerspective();
|
||||
|
||||
/// Compare ClientCfg and LastClientCfg to know what we must update
|
||||
void updateFromClientCfg();
|
||||
|
||||
|
|
Loading…
Reference in a new issue