Use configured resolution for login/outgame/ingame
[ryzomcore.git] / ryzom / client / src / water_env_map_rdr.cpp
bloba1d87ae23d9be2cdc7bd76a17c9e4c3cf113c4d8
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #include "stdpch.h"
18 #include "water_env_map_rdr.h"
19 #include "sky.h"
20 #include "global.h"
21 #include "view.h"
22 #include "continent_manager.h"
23 #include "light_cycle_manager.h"
24 #include "weather.h"
25 #include "nel/3d/viewport.h"
26 #include "nel/3d/u_driver.h"
27 #include "nel/misc/matrix.h"
28 #include "nel/misc/vectord.h"
30 #ifdef DEBUG_NEW
31 #define new DEBUG_NEW
32 #endif
34 using namespace NL3D;
35 using namespace NLMISC;
38 extern CContinentManager ContinentMngr;
39 extern CFogState RootFogState;
41 H_AUTO_DECL(RZ_WaterEnvMapRDR)
43 static void renderEnvMapScene(UScene *scene, UCamera &cam, const CMatrix &camMatrix, float znear, float zfar)
45 H_AUTO_USE(RZ_WaterEnvMapRDR)
46 if (!scene) return;
47 if (!cam.empty())
49 UCamera oldCam = scene->getCam();
50 scene->setCam(cam);
51 cam.setTransformMode(UTransformable::DirectMatrix);
52 cam.setFrustum(-znear, znear, -znear, znear, znear, zfar);
53 cam.setMatrix(camMatrix);
54 CViewport old = scene->getViewport();
55 scene->setViewport(CViewport());
56 scene->beginPartRender();
57 scene->renderPart((UScene::TRenderPart) (UScene::RenderOpaque | UScene::RenderTransparent));
58 scene->endPartRender();
59 scene->setViewport(old);
60 scene->setCam(oldCam);
64 void CWaterEnvMapRdr::doRender(const CMatrix &camMatrix, TGlobalAnimationTime time, UDriver &drv)
66 H_AUTO_USE(RZ_WaterEnvMapRDR)
67 drv.clearZBuffer();
68 if (time != _LastRenderStartTime) // begin a new rendering of the cube
70 _DateForRender = CurrDate;
71 _AnimationDateForRender = AnimationDate;
72 _WeatherForRender = CurrWeather;
73 _FogColorForRender = CurrFogColor;
74 _LastRenderStartTime = time;
75 _CurrCanopyCamPos = View.currentViewPos();
77 if (Sky)
79 Sky->setup(_DateForRender, _AnimationDateForRender, _WeatherForRender, _FogColorForRender, CVector(0.5f, 0.f, -0.85f).normed(), true);
80 if (CurrTime != -1)
82 if (Sky->getScene()) Sky->getScene()->animate(CurrTime); // this will force the elapsed time to be set to so that fx won't be animated twice
85 drv.setCullMode(drv.getCullMode() == UDriver::CCW ? UDriver::CW : UDriver::CCW);
86 // render canopy
87 ContinentMngr.getFogState(CanopyFog, LightCycleManager.getLightLevel(), LightCycleManager.getLightDesc().DuskRatio, LightCycleManager.getState(), CVectorD(View.viewPos()), RootFogState);
88 RootFogState.setupInDriver(drv);
89 CMatrix mat = camMatrix;
90 drv.setDepthRange(0.f, 0.5f);
91 mat.setPos(_CurrCanopyCamPos);
92 renderEnvMapScene(SceneRoot, WaterEnvMapCanopyCam, mat, SceneRootCameraZNear, SceneRootCameraZFar);
93 Driver->enableFog(false);
94 // render sky
95 if (Sky)
97 drv.setDepthRange(0.5f, 1.f); // force sky scene to appear behind canopy scene
98 mat.setPos(CVector(0.f, 0.f, Sky->getWaterEnvMapCameraHeight()));
99 renderEnvMapScene(Sky->getScene(), WaterEnvMapSkyCam, mat, 0.1f, 1000.f);
101 drv.setCullMode(drv.getCullMode() == UDriver::CCW ? UDriver::CW : UDriver::CCW);
102 drv.setDepthRange(0.f, 1.f);