mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-23 07:16:15 +00:00
Put stereo render loop inside ryzom client main loop, see #43
This commit is contained in:
parent
541f75920b
commit
c3f6f5b8ff
2 changed files with 536 additions and 462 deletions
|
@ -438,8 +438,17 @@ void CStereoOVR::getCurrentMatrix(uint cid, NL3D::UCamera *camera) const
|
|||
CMatrix translate;
|
||||
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));
|
||||
camera->setTransformMode(NL3D::UTransformable::DirectMatrix);
|
||||
camera->setMatrix(m_CameraMatrix[cid] * translate);
|
||||
CMatrix mat = 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()
|
||||
|
|
|
@ -398,8 +398,8 @@ void commitCamera()
|
|||
// Update Camera Position/Rotation.
|
||||
//camRoot.setPos(View.currentViewPos());
|
||||
//camRoot.setRotQuat(View.currentViewQuat());
|
||||
camRoot.setTransformMode(UTransformable::DirectMatrix); // FIXME
|
||||
camRoot.setMatrix(MainCam.getMatrix());
|
||||
camRoot.setPos(MainCam.getPos());
|
||||
camRoot.setRotQuat(MainCam.getRotQuat());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -533,6 +533,30 @@ private:
|
|||
};
|
||||
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)
|
||||
{
|
||||
if (bloom)
|
||||
|
@ -548,6 +572,7 @@ void renderScene(bool forceFullDetail, bool bloom)
|
|||
s_ForceFullDetail.backup();
|
||||
s_ForceFullDetail.set();
|
||||
}
|
||||
clearBuffers();
|
||||
renderScene();
|
||||
if (forceFullDetail)
|
||||
{
|
||||
|
@ -688,20 +713,6 @@ void updateWeather()
|
|||
// Render all scenes
|
||||
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
|
||||
Scene->enableElementRender(UScene::FilterAllMeshNoVP, Filter3D[FilterMeshNoVP]);
|
||||
Scene->enableElementRender(UScene::FilterAllMeshVP, Filter3D[FilterMeshVP]);
|
||||
|
@ -1371,6 +1382,10 @@ bool mainLoop()
|
|||
MainCam.setTransformMode(UTransformable::RotQuat);
|
||||
MainCam.setPos(currViewPos);
|
||||
MainCam.setRotQuat(View.currentViewQuat());
|
||||
if (StereoHMD)
|
||||
{
|
||||
// ...
|
||||
}
|
||||
if (StereoDisplay)
|
||||
{
|
||||
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 //
|
||||
///////////////////
|
||||
|
@ -1590,7 +1610,7 @@ bool mainLoop()
|
|||
{
|
||||
SceneRoot->setViewport(vp);
|
||||
}
|
||||
MainCam.setTransformMode(UTransformable::DirectMatrix);
|
||||
//MainCam.setTransformMode(UTransformable::DirectMatrix);
|
||||
StereoDisplay->getCurrentMatrix(0, &MainCam);
|
||||
StereoDisplay->getCurrentFrustum(0, &MainCam);
|
||||
if (SceneRoot)
|
||||
|
@ -1607,19 +1627,38 @@ bool mainLoop()
|
|||
// 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)
|
||||
{
|
||||
// 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
|
||||
// todo : move outside render code
|
||||
bool fullDetail = ScreenshotRequest != ScreenshotRequestNone && ClientCfg.ScreenShotFullDetail;
|
||||
|
@ -1636,10 +1675,24 @@ bool mainLoop()
|
|||
{
|
||||
s_ForceFullDetail.restore();
|
||||
}
|
||||
if (ClientCfg.Bloom)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!StereoDisplay || StereoDisplay->wantInterface3D())
|
||||
{
|
||||
// apply bloom effect
|
||||
CBloomEffect::getInstance().endBloom();
|
||||
if (!ClientCfg.Light)
|
||||
{
|
||||
// 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
|
||||
|
@ -1660,11 +1713,7 @@ bool mainLoop()
|
|||
H_AUTO_USE ( RZ_Client_Main_Loop_Debug )
|
||||
PrimFiles.display (*Driver);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Driver->clearBuffers(ClientCfg.BGColor);
|
||||
}
|
||||
} /* if (Render) */
|
||||
|
||||
// Draw Extra 3D Objects
|
||||
Driver->setMatrixMode3D(MainCam);
|
||||
|
@ -1691,16 +1740,15 @@ bool mainLoop()
|
|||
H_AUTO_USE ( RZ_Client_Main_Loop_Debug )
|
||||
displayDebugClusters();
|
||||
}
|
||||
|
||||
}
|
||||
} /* if (!ClientCfg.Light) */
|
||||
else
|
||||
{
|
||||
// static UTextureFile *backgroundBitmap = NULL;
|
||||
// if (backgroundBitmap == NULL)
|
||||
// backgroundBitmap = Driver->createTextureFile("temp_background.tga");
|
||||
// Driver->setMatrixMode2D11();
|
||||
// Driver->drawBitmap (0.f, 0.f, 1024.f/1024.f, 1024.f/768.f, (UTexture&)*backgroundBitmap);
|
||||
// Driver->setMatrixMode3D(MainCam);
|
||||
// static UTextureFile *backgroundBitmap = NULL;
|
||||
// if (backgroundBitmap == NULL)
|
||||
// backgroundBitmap = Driver->createTextureFile("temp_background.tga");
|
||||
// Driver->setMatrixMode2D11();
|
||||
// Driver->drawBitmap (0.f, 0.f, 1024.f/1024.f, 1024.f/768.f, (UTexture&)*backgroundBitmap);
|
||||
// Driver->setMatrixMode3D(MainCam);
|
||||
|
||||
Driver->clearBuffers(CRGBA (0,0,0,0));
|
||||
displayPACSBorders();
|
||||
|
@ -1721,6 +1769,10 @@ bool mainLoop()
|
|||
CGraph::render (ShowInfos);
|
||||
}
|
||||
|
||||
} /* if (!StereoDisplay || StereoDisplay->wantInterface3D()) */
|
||||
|
||||
if (!StereoDisplay || StereoDisplay->wantInterface2D())
|
||||
{
|
||||
// Render in 2D Mode to display 2D Interfaces and 2D texts.
|
||||
Driver->setMatrixMode2D11();
|
||||
|
||||
|
@ -1761,8 +1813,14 @@ bool mainLoop()
|
|||
|
||||
// special case in OpenGL : all scene has been display in render target,
|
||||
// now, final texture is display with a quad
|
||||
if(!ClientCfg.Light && ClientCfg.Bloom)
|
||||
CBloomEffect::getInstance().endInterfacesDisplayBloom();
|
||||
if (!ClientCfg.Light && ClientCfg.Bloom && Render && bloomStage == 2)
|
||||
{
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -2013,7 +2071,7 @@ bool mainLoop()
|
|||
}
|
||||
}
|
||||
|
||||
#if !FINAL_VERSION
|
||||
#if !FINAL_VERSION
|
||||
CVector2f camPos(Scene->getCam().getPos().x, Scene->getCam().getPos().y);
|
||||
if (!ClientCfg.Light)
|
||||
{
|
||||
|
@ -2052,9 +2110,9 @@ bool mainLoop()
|
|||
static bool drawSound = false;
|
||||
static float camHeigh = 150.0f;
|
||||
|
||||
#if FINAL_VERSION
|
||||
#if FINAL_VERSION
|
||||
if (ClientCfg.ExtendedCommands)
|
||||
#endif
|
||||
#endif
|
||||
if (Actions.valide ("draw_sound"))
|
||||
drawSound = !drawSound;
|
||||
|
||||
|
@ -2067,6 +2125,13 @@ bool mainLoop()
|
|||
SoundMngr->drawSounds(camHeigh);
|
||||
}
|
||||
}
|
||||
} /* if (!StereoDisplay || StereoDisplay->wantInterface2D()) */
|
||||
|
||||
if (StereoDisplay)
|
||||
{
|
||||
StereoDisplay->endRenderTarget();
|
||||
}
|
||||
} /* stereo pass */
|
||||
|
||||
// Draw to screen.
|
||||
static CQuat MainCamOri;
|
||||
|
|
Loading…
Reference in a new issue