mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-14 03:09:08 +00:00
Restore camera and scene viewport after disabling VR
This commit is contained in:
parent
ce2de7ec8e
commit
f6483d45ef
6 changed files with 31 additions and 0 deletions
|
@ -78,6 +78,8 @@ public:
|
||||||
virtual void updateCamera(uint cid, const NL3D::UCamera *camera);
|
virtual void updateCamera(uint cid, const NL3D::UCamera *camera);
|
||||||
/// Get the frustum to use for clipping
|
/// Get the frustum to use for clipping
|
||||||
virtual void getClippingFrustum(uint cid, NL3D::UCamera *camera) const;
|
virtual void getClippingFrustum(uint cid, NL3D::UCamera *camera) const;
|
||||||
|
/// Get the original frustum of the camera
|
||||||
|
virtual void getOriginalFrustum(uint cid, NL3D::UCamera *camera) const;
|
||||||
|
|
||||||
/// Is there a next pass
|
/// Is there a next pass
|
||||||
virtual bool nextPass();
|
virtual bool nextPass();
|
||||||
|
|
|
@ -101,6 +101,8 @@ public:
|
||||||
virtual void updateCamera(uint cid, const NL3D::UCamera *camera) = 0;
|
virtual void updateCamera(uint cid, const NL3D::UCamera *camera) = 0;
|
||||||
/// Get the frustum to use for clipping
|
/// Get the frustum to use for clipping
|
||||||
virtual void getClippingFrustum(uint cid, NL3D::UCamera *camera) const = 0;
|
virtual void getClippingFrustum(uint cid, NL3D::UCamera *camera) const = 0;
|
||||||
|
/// Get the original frustum of the camera
|
||||||
|
virtual void getOriginalFrustum(uint cid, NL3D::UCamera *camera) const = 0;
|
||||||
|
|
||||||
/// Is there a next pass
|
/// Is there a next pass
|
||||||
virtual bool nextPass() = 0;
|
virtual bool nextPass() = 0;
|
||||||
|
|
|
@ -91,6 +91,8 @@ public:
|
||||||
virtual void updateCamera(uint cid, const NL3D::UCamera *camera);
|
virtual void updateCamera(uint cid, const NL3D::UCamera *camera);
|
||||||
/// Get the frustum to use for clipping
|
/// Get the frustum to use for clipping
|
||||||
virtual void getClippingFrustum(uint cid, NL3D::UCamera *camera) const;
|
virtual void getClippingFrustum(uint cid, NL3D::UCamera *camera) const;
|
||||||
|
/// Get the original frustum of the camera
|
||||||
|
virtual void getOriginalFrustum(uint cid, NL3D::UCamera *camera) const;
|
||||||
|
|
||||||
/// Is there a next pass
|
/// Is there a next pass
|
||||||
virtual bool nextPass();
|
virtual bool nextPass();
|
||||||
|
@ -152,6 +154,7 @@ private:
|
||||||
CFrustum m_ClippingFrustum[NL_STEREO_MAX_USER_CAMERAS];
|
CFrustum m_ClippingFrustum[NL_STEREO_MAX_USER_CAMERAS];
|
||||||
CFrustum m_LeftFrustum[NL_STEREO_MAX_USER_CAMERAS];
|
CFrustum m_LeftFrustum[NL_STEREO_MAX_USER_CAMERAS];
|
||||||
CFrustum m_RightFrustum[NL_STEREO_MAX_USER_CAMERAS];
|
CFrustum m_RightFrustum[NL_STEREO_MAX_USER_CAMERAS];
|
||||||
|
CFrustum m_OriginalFrustum[NL_STEREO_MAX_USER_CAMERAS];
|
||||||
CMatrix m_CameraMatrix[NL_STEREO_MAX_USER_CAMERAS];
|
CMatrix m_CameraMatrix[NL_STEREO_MAX_USER_CAMERAS];
|
||||||
mutable bool m_OrientationCached;
|
mutable bool m_OrientationCached;
|
||||||
mutable NLMISC::CQuat m_OrientationCache;
|
mutable NLMISC::CQuat m_OrientationCache;
|
||||||
|
|
|
@ -328,6 +328,12 @@ void CStereoDebugger::getClippingFrustum(uint cid, NL3D::UCamera *camera) const
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get the original frustum of the camera
|
||||||
|
void CStereoDebugger::getOriginalFrustum(uint cid, NL3D::UCamera *camera) const
|
||||||
|
{
|
||||||
|
// do nothing, as we never modified it
|
||||||
|
}
|
||||||
|
|
||||||
/// Is there a next pass
|
/// Is there a next pass
|
||||||
bool CStereoDebugger::nextPass()
|
bool CStereoDebugger::nextPass()
|
||||||
{
|
{
|
||||||
|
|
|
@ -400,6 +400,8 @@ bool CStereoOVR::getScreenResolution(uint &width, uint &height)
|
||||||
|
|
||||||
void CStereoOVR::initCamera(uint cid, const NL3D::UCamera *camera)
|
void CStereoOVR::initCamera(uint cid, const NL3D::UCamera *camera)
|
||||||
{
|
{
|
||||||
|
m_OriginalFrustum[cid] = camera->getFrustum();
|
||||||
|
|
||||||
float ar = (float)m_DevicePtr->HMDInfo.HResolution / ((float)m_DevicePtr->HMDInfo.VResolution * 2.0f);
|
float ar = (float)m_DevicePtr->HMDInfo.HResolution / ((float)m_DevicePtr->HMDInfo.VResolution * 2.0f);
|
||||||
float fov = 2.0f * atanf((m_DevicePtr->HMDInfo.HScreenSize * 0.5f * 0.5f) / (m_DevicePtr->HMDInfo.EyeToScreenDistance)); //(float)NLMISC::Pi/2.f; // 2.0f * atanf(m_DevicePtr->HMDInfo.VScreenSize / 2.0f * m_DevicePtr->HMDInfo.EyeToScreenDistance);
|
float fov = 2.0f * atanf((m_DevicePtr->HMDInfo.HScreenSize * 0.5f * 0.5f) / (m_DevicePtr->HMDInfo.EyeToScreenDistance)); //(float)NLMISC::Pi/2.f; // 2.0f * atanf(m_DevicePtr->HMDInfo.VScreenSize / 2.0f * m_DevicePtr->HMDInfo.EyeToScreenDistance);
|
||||||
m_LeftFrustum[cid].initPerspective(fov, ar, camera->getFrustum().Near, camera->getFrustum().Far);
|
m_LeftFrustum[cid].initPerspective(fov, ar, camera->getFrustum().Near, camera->getFrustum().Far);
|
||||||
|
@ -427,6 +429,12 @@ void CStereoOVR::getClippingFrustum(uint cid, NL3D::UCamera *camera) const
|
||||||
camera->setFrustum(m_ClippingFrustum[cid]);
|
camera->setFrustum(m_ClippingFrustum[cid]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get the original frustum of the camera
|
||||||
|
void CStereoOVR::getOriginalFrustum(uint cid, NL3D::UCamera *camera) const
|
||||||
|
{
|
||||||
|
camera->setFrustum(m_OriginalFrustum[cid]);
|
||||||
|
}
|
||||||
|
|
||||||
void CStereoOVR::updateCamera(uint cid, const NL3D::UCamera *camera)
|
void CStereoOVR::updateCamera(uint cid, const NL3D::UCamera *camera)
|
||||||
{
|
{
|
||||||
if (camera->getFrustum().Near != m_LeftFrustum[cid].Near
|
if (camera->getFrustum().Near != m_LeftFrustum[cid].Near
|
||||||
|
|
|
@ -516,6 +516,16 @@ void releaseStereoDisplayDevice()
|
||||||
{
|
{
|
||||||
if (StereoDisplay)
|
if (StereoDisplay)
|
||||||
{
|
{
|
||||||
|
StereoDisplay->getOriginalFrustum(0, &MainCam);
|
||||||
|
if (SceneRoot)
|
||||||
|
{
|
||||||
|
UCamera cam = SceneRoot->getCam();
|
||||||
|
StereoDisplay->getOriginalFrustum(1, &cam);
|
||||||
|
}
|
||||||
|
nlassert(Driver);
|
||||||
|
Driver->setViewport(NL3D::CViewport());
|
||||||
|
nlassert(Scene);
|
||||||
|
Scene->setViewport(NL3D::CViewport());
|
||||||
delete StereoDisplay;
|
delete StereoDisplay;
|
||||||
StereoDisplay = NULL;
|
StereoDisplay = NULL;
|
||||||
StereoHMD = NULL;
|
StereoHMD = NULL;
|
||||||
|
|
Loading…
Reference in a new issue