Some necessary changes to camera setting, re #43

This commit is contained in:
kaetemi 2013-07-05 00:17:09 +02:00
parent 32e3da752f
commit 5e5cfba035
3 changed files with 60 additions and 25 deletions

View file

@ -541,12 +541,12 @@ void renderSceneScreenShot (uint left, uint right, uint top, uint bottom, uint s
{
CCameraBackup cbScene = setupCameraForScreenshot(*Scene, left, right, top, bottom, screenShotWidth, screenShotHeight);
CCameraBackup cbCanopy = setupCameraForScreenshot(*SceneRoot, left, right, top, bottom, screenShotWidth, screenShotHeight);
commitCamera();
// sky setup are copied from main scene before rendering so no setup done here
commitCameraSky();
renderScene(ClientCfg.ScreenShotFullDetail, ClientCfg.Bloom);
restoreCamera(*Scene, cbScene);
restoreCamera(*SceneRoot, cbCanopy);
commitCameraSky();
commitCamera();
}
// ***************************************************************************

View file

@ -370,8 +370,9 @@ void preRenderNewSky ()
sky.setup(cd, SmoothedClientDate, WeatherManager.getWeatherValue(), MainFogState.FogColor, Scene->getSunDirection(), false);
}
void commitCameraSky()
void commitCamera()
{
// Set the sky camera
if (s_SkyMode == NewSky)
{
CSky &sky = ContinentMngr.cur()->CurrentSky;
@ -389,6 +390,17 @@ void commitCameraSky()
skyCameraMatrix.setPos(CVector::Null);
camSky.setMatrix(skyCameraMatrix);
}
// Set The Root Camera
UCamera camRoot = SceneRoot->getCam();
if(!camRoot.empty())
{
// Update Camera Position/Rotation.
//camRoot.setPos(View.currentViewPos());
//camRoot.setRotQuat(View.currentViewQuat());
camRoot.setTransformMode(UTransformable::DirectMatrix); // FIXME
camRoot.setMatrix(MainCam.getMatrix());
}
}
// ***************************************************************************
@ -439,14 +451,6 @@ static void renderCanopyPart(UScene::TRenderPart renderPart)
ContinentMngr.getFogState(CanopyFog, LightCycleManager.getLightLevel(), LightCycleManager.getLightDesc().DuskRatio, LightCycleManager.getState(), View.viewPos(), RootFogState);
RootFogState.setupInDriver(*Driver);
// Set The Root Camera
UCamera camRoot = SceneRoot->getCam();
if(!camRoot.empty())
{
// Update Camera Position/Rotation.
camRoot.setPos(View.currentViewPos());
camRoot.setRotQuat(View.currentViewQuat());
}
// Render the root scene
SceneRoot->renderPart(renderPart);
}
@ -1364,9 +1368,17 @@ bool mainLoop()
// Update Camera Position/Orientation.
CVector currViewPos = View.currentViewPos();
MainCam.setTransformMode(UTransformable::RotQuat);
MainCam.setPos(currViewPos);
MainCam.setRotQuat(View.currentViewQuat());
if (StereoDisplay) StereoDisplay->updateCamera(0, &MainCam);
if (StereoDisplay)
{
StereoDisplay->updateCamera(0, &MainCam);
if (SceneRoot)
{
StereoDisplay->updateCamera(1, &SceneRoot->getCam());
}
}
// see if camera is below water (useful for sort order)
if (ContinentMngr.cur())
@ -1457,9 +1469,6 @@ bool mainLoop()
}
//////////////////////////
// RENDER THE FRAME 3D //
//////////////////////////
if (!ClientCfg.Light)
{
CClientDate newDate(RT.getRyzomDay(), DayNightCycleHour);
@ -1546,9 +1555,6 @@ bool mainLoop()
}
}
// Set the matrix in 3D Mode.
Driver->setMatrixMode3D(MainCam);
// R2ED pre render update
if (ClientCfg.R2EDEnabled)
@ -1556,11 +1562,8 @@ bool mainLoop()
R2::getEditor().updateBeforeRender();
}
// Position the camera to prepare the render
if (!ClientCfg.Light)
{
// Render
if(Render)
{
@ -1569,7 +1572,42 @@ bool mainLoop()
// Update weather
updateWeather();
}
}
//////////////////////////
// RENDER THE FRAME 3D //
//////////////////////////
if (StereoDisplay)
{
// modify cameras for stereo display
const CViewport &vp = StereoDisplay->getCurrentViewport();
Driver->setViewport(vp);
nlassert(Scene);
Scene->setViewport(vp);
if (SceneRoot)
{
SceneRoot->setViewport(vp);
}
MainCam.setTransformMode(UTransformable::DirectMatrix);
StereoDisplay->getCurrentMatrix(0, &MainCam);
StereoDisplay->getCurrentFrustum(0, &MainCam);
if (SceneRoot)
{
// matrix updated during commitCamera from maincam
StereoDisplay->getCurrentFrustum(1, &SceneRoot->getCam());
}
}
// Commit camera changes
commitCamera();
if (!ClientCfg.Light)
{
// Render
if(Render)
{
if (ClientCfg.Bloom)
{
// set bloom parameters before applying bloom effect
@ -1587,9 +1625,6 @@ bool mainLoop()
s_ForceFullDetail.set();
}
// Commit camera changes to the sky camera
commitCameraSky();
// Render scene
renderScene();

View file

@ -34,7 +34,7 @@ void renderScene(bool forceFullDetail, bool bloom);
void setDefaultChatWindow(CChatWindow *defaultChatWindow);
// Commit sky scene camera for rendering
void commitCameraSky();
void commitCamera();
void updateDayNightCycleHour();