mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-11 09:49:04 +00:00
Put stereo render loop inside ryzom client main loop, see #43
This commit is contained in:
parent
fbb9ec7379
commit
fc663f210f
2 changed files with 536 additions and 462 deletions
|
@ -438,8 +438,17 @@ void CStereoOVR::getCurrentMatrix(uint cid, NL3D::UCamera *camera) const
|
||||||
CMatrix translate;
|
CMatrix translate;
|
||||||
if (m_Stage % 2) translate.translate(CVector((m_DevicePtr->HMDInfo.InterpupillaryDistance * m_Scale) * -0.5f, 0.f, 0.f));
|
if (m_Stage % 2) translate.translate(CVector((m_DevicePtr->HMDInfo.InterpupillaryDistance * m_Scale) * -0.5f, 0.f, 0.f));
|
||||||
else translate.translate(CVector((m_DevicePtr->HMDInfo.InterpupillaryDistance * m_Scale) * 0.5f, 0.f, 0.f));
|
else translate.translate(CVector((m_DevicePtr->HMDInfo.InterpupillaryDistance * m_Scale) * 0.5f, 0.f, 0.f));
|
||||||
camera->setTransformMode(NL3D::UTransformable::DirectMatrix);
|
CMatrix mat = m_CameraMatrix[cid] * translate;
|
||||||
camera->setMatrix(m_CameraMatrix[cid] * translate);
|
if (camera->getTransformMode() == NL3D::UTransformable::RotQuat)
|
||||||
|
{
|
||||||
|
camera->setPos(mat.getPos());
|
||||||
|
camera->setRotQuat(mat.getRot());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// camera->setTransformMode(NL3D::UTransformable::DirectMatrix);
|
||||||
|
camera->setMatrix(mat);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CStereoOVR::wantClear()
|
bool CStereoOVR::wantClear()
|
||||||
|
|
|
@ -398,8 +398,8 @@ void commitCamera()
|
||||||
// Update Camera Position/Rotation.
|
// Update Camera Position/Rotation.
|
||||||
//camRoot.setPos(View.currentViewPos());
|
//camRoot.setPos(View.currentViewPos());
|
||||||
//camRoot.setRotQuat(View.currentViewQuat());
|
//camRoot.setRotQuat(View.currentViewQuat());
|
||||||
camRoot.setTransformMode(UTransformable::DirectMatrix); // FIXME
|
camRoot.setPos(MainCam.getPos());
|
||||||
camRoot.setMatrix(MainCam.getMatrix());
|
camRoot.setRotQuat(MainCam.getRotQuat());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -533,6 +533,30 @@ private:
|
||||||
};
|
};
|
||||||
static CForceFullDetail s_ForceFullDetail;
|
static CForceFullDetail s_ForceFullDetail;
|
||||||
|
|
||||||
|
void clearBuffers()
|
||||||
|
{
|
||||||
|
if (Render)
|
||||||
|
{
|
||||||
|
if (Driver->getPolygonMode() == UDriver::Filled)
|
||||||
|
{
|
||||||
|
Driver->clearZBuffer();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sky is used to clear the frame buffer now, but if in line or point polygon mode, we should draw it
|
||||||
|
if (Driver->getPolygonMode() != UDriver::Filled)
|
||||||
|
{
|
||||||
|
if (!Driver->isLost())
|
||||||
|
{
|
||||||
|
Driver->clearBuffers (CRGBA(127, 127, 127));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Driver->clearBuffers(ClientCfg.BGColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void renderScene(bool forceFullDetail, bool bloom)
|
void renderScene(bool forceFullDetail, bool bloom)
|
||||||
{
|
{
|
||||||
if (bloom)
|
if (bloom)
|
||||||
|
@ -548,6 +572,7 @@ void renderScene(bool forceFullDetail, bool bloom)
|
||||||
s_ForceFullDetail.backup();
|
s_ForceFullDetail.backup();
|
||||||
s_ForceFullDetail.set();
|
s_ForceFullDetail.set();
|
||||||
}
|
}
|
||||||
|
clearBuffers();
|
||||||
renderScene();
|
renderScene();
|
||||||
if (forceFullDetail)
|
if (forceFullDetail)
|
||||||
{
|
{
|
||||||
|
@ -688,20 +713,6 @@ void updateWeather()
|
||||||
// Render all scenes
|
// Render all scenes
|
||||||
void renderScene()
|
void renderScene()
|
||||||
{
|
{
|
||||||
if (Driver->getPolygonMode() == UDriver::Filled)
|
|
||||||
{
|
|
||||||
Driver->clearZBuffer();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sky is used to clear the frame buffer now, but if in line or point polygon mode, we should draw it
|
|
||||||
if (Driver->getPolygonMode() != UDriver::Filled)
|
|
||||||
{
|
|
||||||
if (!Driver->isLost())
|
|
||||||
{
|
|
||||||
Driver->clearBuffers (CRGBA(127, 127, 127));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update Filter Flags
|
// Update Filter Flags
|
||||||
Scene->enableElementRender(UScene::FilterAllMeshNoVP, Filter3D[FilterMeshNoVP]);
|
Scene->enableElementRender(UScene::FilterAllMeshNoVP, Filter3D[FilterMeshNoVP]);
|
||||||
Scene->enableElementRender(UScene::FilterAllMeshVP, Filter3D[FilterMeshVP]);
|
Scene->enableElementRender(UScene::FilterAllMeshVP, Filter3D[FilterMeshVP]);
|
||||||
|
@ -1371,6 +1382,10 @@ bool mainLoop()
|
||||||
MainCam.setTransformMode(UTransformable::RotQuat);
|
MainCam.setTransformMode(UTransformable::RotQuat);
|
||||||
MainCam.setPos(currViewPos);
|
MainCam.setPos(currViewPos);
|
||||||
MainCam.setRotQuat(View.currentViewQuat());
|
MainCam.setRotQuat(View.currentViewQuat());
|
||||||
|
if (StereoHMD)
|
||||||
|
{
|
||||||
|
// ...
|
||||||
|
}
|
||||||
if (StereoDisplay)
|
if (StereoDisplay)
|
||||||
{
|
{
|
||||||
StereoDisplay->updateCamera(0, &MainCam);
|
StereoDisplay->updateCamera(0, &MainCam);
|
||||||
|
@ -1575,6 +1590,11 @@ bool mainLoop()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint i = 0;
|
||||||
|
uint bloomStage = 0;
|
||||||
|
while ((!StereoDisplay && i == 0) || (StereoDisplay && StereoDisplay->nextPass()))
|
||||||
|
{
|
||||||
|
++i;
|
||||||
///////////////////
|
///////////////////
|
||||||
// SETUP CAMERAS //
|
// SETUP CAMERAS //
|
||||||
///////////////////
|
///////////////////
|
||||||
|
@ -1590,7 +1610,7 @@ bool mainLoop()
|
||||||
{
|
{
|
||||||
SceneRoot->setViewport(vp);
|
SceneRoot->setViewport(vp);
|
||||||
}
|
}
|
||||||
MainCam.setTransformMode(UTransformable::DirectMatrix);
|
//MainCam.setTransformMode(UTransformable::DirectMatrix);
|
||||||
StereoDisplay->getCurrentMatrix(0, &MainCam);
|
StereoDisplay->getCurrentMatrix(0, &MainCam);
|
||||||
StereoDisplay->getCurrentFrustum(0, &MainCam);
|
StereoDisplay->getCurrentFrustum(0, &MainCam);
|
||||||
if (SceneRoot)
|
if (SceneRoot)
|
||||||
|
@ -1607,19 +1627,38 @@ bool mainLoop()
|
||||||
// RENDER THE FRAME 3D //
|
// RENDER THE FRAME 3D //
|
||||||
//////////////////////////
|
//////////////////////////
|
||||||
|
|
||||||
|
if (StereoDisplay)
|
||||||
|
{
|
||||||
|
StereoDisplay->beginRenderTarget();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!StereoDisplay || StereoDisplay->wantClear())
|
||||||
|
{
|
||||||
|
if(Render)
|
||||||
|
{
|
||||||
|
if (ClientCfg.Bloom)
|
||||||
|
{
|
||||||
|
nlassert(bloomStage == 0);
|
||||||
|
// set bloom parameters before applying bloom effect
|
||||||
|
CBloomEffect::getInstance().setSquareBloom(ClientCfg.SquareBloom);
|
||||||
|
CBloomEffect::getInstance().setDensityBloom((uint8)ClientCfg.DensityBloom);
|
||||||
|
// start bloom effect (just before the first scene element render)
|
||||||
|
CBloomEffect::instance().initBloom();
|
||||||
|
bloomStage = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clear buffers
|
||||||
|
clearBuffers();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!StereoDisplay || StereoDisplay->wantScene())
|
||||||
|
{
|
||||||
if (!ClientCfg.Light)
|
if (!ClientCfg.Light)
|
||||||
{
|
{
|
||||||
// Render
|
// Render
|
||||||
if(Render)
|
if(Render)
|
||||||
{
|
{
|
||||||
if (ClientCfg.Bloom)
|
|
||||||
{
|
|
||||||
// set bloom parameters before applying bloom effect
|
|
||||||
CBloomEffect::getInstance().setSquareBloom(ClientCfg.SquareBloom);
|
|
||||||
CBloomEffect::getInstance().setDensityBloom((uint8)ClientCfg.DensityBloom);
|
|
||||||
// init bloom
|
|
||||||
CBloomEffect::getInstance().initBloom();
|
|
||||||
}
|
|
||||||
// nb : force full detail if a screenshot is asked
|
// nb : force full detail if a screenshot is asked
|
||||||
// todo : move outside render code
|
// todo : move outside render code
|
||||||
bool fullDetail = ScreenshotRequest != ScreenshotRequestNone && ClientCfg.ScreenShotFullDetail;
|
bool fullDetail = ScreenshotRequest != ScreenshotRequestNone && ClientCfg.ScreenShotFullDetail;
|
||||||
|
@ -1636,10 +1675,24 @@ bool mainLoop()
|
||||||
{
|
{
|
||||||
s_ForceFullDetail.restore();
|
s_ForceFullDetail.restore();
|
||||||
}
|
}
|
||||||
if (ClientCfg.Bloom)
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!StereoDisplay || StereoDisplay->wantInterface3D())
|
||||||
{
|
{
|
||||||
// apply bloom effect
|
if (!ClientCfg.Light)
|
||||||
CBloomEffect::getInstance().endBloom();
|
{
|
||||||
|
// Render
|
||||||
|
if (Render)
|
||||||
|
{
|
||||||
|
if (ClientCfg.Bloom && bloomStage == 1)
|
||||||
|
{
|
||||||
|
// End the actual bloom effect visible in the scene.
|
||||||
|
if (StereoDisplay) Driver->setViewport(NL3D::CViewport());
|
||||||
|
CBloomEffect::instance().endBloom();
|
||||||
|
if (StereoDisplay) Driver->setViewport(StereoDisplay->getCurrentViewport());
|
||||||
|
bloomStage = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// for that frame and
|
// for that frame and
|
||||||
|
@ -1660,11 +1713,7 @@ bool mainLoop()
|
||||||
H_AUTO_USE ( RZ_Client_Main_Loop_Debug )
|
H_AUTO_USE ( RZ_Client_Main_Loop_Debug )
|
||||||
PrimFiles.display (*Driver);
|
PrimFiles.display (*Driver);
|
||||||
}
|
}
|
||||||
}
|
} /* if (Render) */
|
||||||
else
|
|
||||||
{
|
|
||||||
Driver->clearBuffers(ClientCfg.BGColor);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw Extra 3D Objects
|
// Draw Extra 3D Objects
|
||||||
Driver->setMatrixMode3D(MainCam);
|
Driver->setMatrixMode3D(MainCam);
|
||||||
|
@ -1691,8 +1740,7 @@ bool mainLoop()
|
||||||
H_AUTO_USE ( RZ_Client_Main_Loop_Debug )
|
H_AUTO_USE ( RZ_Client_Main_Loop_Debug )
|
||||||
displayDebugClusters();
|
displayDebugClusters();
|
||||||
}
|
}
|
||||||
|
} /* if (!ClientCfg.Light) */
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// static UTextureFile *backgroundBitmap = NULL;
|
// static UTextureFile *backgroundBitmap = NULL;
|
||||||
|
@ -1721,6 +1769,10 @@ bool mainLoop()
|
||||||
CGraph::render (ShowInfos);
|
CGraph::render (ShowInfos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} /* if (!StereoDisplay || StereoDisplay->wantInterface3D()) */
|
||||||
|
|
||||||
|
if (!StereoDisplay || StereoDisplay->wantInterface2D())
|
||||||
|
{
|
||||||
// Render in 2D Mode to display 2D Interfaces and 2D texts.
|
// Render in 2D Mode to display 2D Interfaces and 2D texts.
|
||||||
Driver->setMatrixMode2D11();
|
Driver->setMatrixMode2D11();
|
||||||
|
|
||||||
|
@ -1761,8 +1813,14 @@ bool mainLoop()
|
||||||
|
|
||||||
// special case in OpenGL : all scene has been display in render target,
|
// special case in OpenGL : all scene has been display in render target,
|
||||||
// now, final texture is display with a quad
|
// now, final texture is display with a quad
|
||||||
if(!ClientCfg.Light && ClientCfg.Bloom)
|
if (!ClientCfg.Light && ClientCfg.Bloom && Render && bloomStage == 2)
|
||||||
CBloomEffect::getInstance().endInterfacesDisplayBloom();
|
{
|
||||||
|
// End bloom effect system after drawing the 3d interface (z buffer related).
|
||||||
|
if (StereoDisplay) Driver->setViewport(NL3D::CViewport());
|
||||||
|
CBloomEffect::instance().endInterfacesDisplayBloom();
|
||||||
|
if (StereoDisplay) Driver->setViewport(StereoDisplay->getCurrentViewport());
|
||||||
|
bloomStage = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -2067,6 +2125,13 @@ bool mainLoop()
|
||||||
SoundMngr->drawSounds(camHeigh);
|
SoundMngr->drawSounds(camHeigh);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} /* if (!StereoDisplay || StereoDisplay->wantInterface2D()) */
|
||||||
|
|
||||||
|
if (StereoDisplay)
|
||||||
|
{
|
||||||
|
StereoDisplay->endRenderTarget();
|
||||||
|
}
|
||||||
|
} /* stereo pass */
|
||||||
|
|
||||||
// Draw to screen.
|
// Draw to screen.
|
||||||
static CQuat MainCamOri;
|
static CQuat MainCamOri;
|
||||||
|
|
Loading…
Reference in a new issue