From 6d28f88601dfb7139b2e11843fcfae9979dba0c6 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Wed, 26 Jun 2013 21:36:21 +0200 Subject: [PATCH] Return view as CQuat, see #43 --HG-- branch : multipass-stereo --- code/ryzom/client/src/global.cpp | 2 ++ code/ryzom/client/src/global.h | 3 +++ code/ryzom/client/src/main_loop.cpp | 12 ++++++++---- code/ryzom/client/src/view.cpp | 9 ++++++++- code/ryzom/client/src/view.h | 2 ++ 5 files changed, 23 insertions(+), 5 deletions(-) diff --git a/code/ryzom/client/src/global.cpp b/code/ryzom/client/src/global.cpp index 8bd6f10fa..bb60f5c04 100644 --- a/code/ryzom/client/src/global.cpp +++ b/code/ryzom/client/src/global.cpp @@ -26,6 +26,8 @@ using namespace NLMISC; // *************************************************************************** // Main System NL3D::UDriver *Driver = 0; // The main 3D Driver +NL3D::CStereoOVR *StereoDisplay = NULL; // Stereo display +NL3D::CStereoOVR *StereoHMD = NULL; // Head mount display CSoundManager *SoundMngr = 0; // the sound manager NL3D::UMaterial GenericMat; // Generic Material NL3D::UTextContext *TextContext = 0; // Context for all the text in the client. diff --git a/code/ryzom/client/src/global.h b/code/ryzom/client/src/global.h index a6b7a03c6..6ec3db7ec 100644 --- a/code/ryzom/client/src/global.h +++ b/code/ryzom/client/src/global.h @@ -40,6 +40,7 @@ namespace NL3D class UMaterial; class UTextContext; class UWaterEnvMap; + class CStereoOVR; } class CEntityAnimationManager; @@ -77,6 +78,8 @@ const float ExtraZoneLoadingVision = 100.f; // *************************************************************************** // Main System extern NL3D::UDriver *Driver; // The main 3D Driver +extern NL3D::CStereoOVR *StereoDisplay; // Stereo display +extern NL3D::CStereoOVR *StereoHMD; extern CSoundManager *SoundMngr; // the sound manager extern NL3D::UMaterial GenericMat; // Generic Material extern NL3D::UTextContext *TextContext; // Context for all the text in the client. diff --git a/code/ryzom/client/src/main_loop.cpp b/code/ryzom/client/src/main_loop.cpp index 2c362aceb..c034eaa83 100644 --- a/code/ryzom/client/src/main_loop.cpp +++ b/code/ryzom/client/src/main_loop.cpp @@ -42,6 +42,7 @@ #include "nel/3d/u_material.h" #include "nel/3d/u_instance_material.h" #include "nel/3d/u_cloud_scape.h" +#include "nel/3d/stereo_ovr.h" // game share #include "game_share/brick_types.h" #include "game_share/light_cycle.h" @@ -136,6 +137,7 @@ #include "nel/3d/driver_user.h" + #ifdef USE_WATER_ENV_MAP #include "water_env_map_rdr.h" #endif @@ -452,6 +454,8 @@ void validateDialogs(const CGameContextMenu &gcm); void buildCameraClippingPyramid (vector &planes) { + if (StereoDisplay) StereoDisplay->getClippingFrustum(0, &MainCam); + // Compute pyramid in view basis. CVector pfoc(0,0,0); const CFrustum &frustum = MainCam.getFrustum(); @@ -1006,7 +1010,7 @@ static void renderCanopyPart(UScene::TRenderPart renderPart) { // Update Camera Position/Rotation. camRoot.setPos(View.currentViewPos()); - camRoot.setRotQuat(View.currentView()); + camRoot.setRotQuat(View.currentViewQuat()); } // Render the root scene SceneRoot->renderPart(renderPart); @@ -1859,9 +1863,9 @@ bool mainLoop() // Update Camera Position/Orientation. CVector currViewPos = View.currentViewPos(); - MainCam.setPos(currViewPos);; - MainCam.setRotQuat(View.currentView()); - + MainCam.setPos(currViewPos); + MainCam.setRotQuat(View.currentViewQuat()); + if (StereoDisplay) StereoDisplay->updateCamera(0, &MainCam); // see if camera is below water (useful for sort order) if (ContinentMngr.cur()) diff --git a/code/ryzom/client/src/view.cpp b/code/ryzom/client/src/view.cpp index ded81013d..4bc52af08 100644 --- a/code/ryzom/client/src/view.cpp +++ b/code/ryzom/client/src/view.cpp @@ -183,7 +183,6 @@ CVector CView::currentViewPos() const //----------------------------------------------- // currentView : -// Set the user position. //----------------------------------------------- CVector CView::currentView() const { @@ -200,6 +199,14 @@ CVector CView::currentView() const return _View; }// currentView // +NLMISC::CQuat CView::currentViewQuat() const +{ + CMatrix mat; + mat.setRot(CVector::I, currentView(), CVector::K); + mat.normalize(CMatrix::YZX); + return mat.getRot(); +} + //----------------------------------------------- // currentCameraTarget : //----------------------------------------------- diff --git a/code/ryzom/client/src/view.h b/code/ryzom/client/src/view.h index 69fcea994..e1c57d4ca 100644 --- a/code/ryzom/client/src/view.h +++ b/code/ryzom/client/src/view.h @@ -115,6 +115,8 @@ public: CVector currentViewPos() const; // Return the current view (rear or normal) CVector currentView() const; + // Return the current view as a quaternion + NLMISC::CQuat currentViewQuat() const; // Return the current Camera Target (for 3rd person only. 1st person: return currentViewPos()) CVector currentCameraTarget() const;