1 // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
2 // Copyright (C) 2010 Winch Gate Property Limited
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.
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/>.
18 #include "nel/3d/water_env_map_user.h"
19 #include "nel/3d/u_scene.h"
20 #include "nel/3d/u_camera.h"
28 //////////////////////
29 // CWaterEnvMapUser //
30 //////////////////////
32 // ***********************************************************************************
33 void CWaterEnvMapUser::init(uint cubeMapSize
, uint projection2DSize
, TGlobalAnimationTime updateTime
)
35 EnvMap
.init(cubeMapSize
, projection2DSize
, updateTime
, *(EnvMap
.Driver
->getDriver()));
38 //////////////////////////////
39 // CWaterEnvMapRenderHelper //
40 //////////////////////////////
43 // ***********************************************************************************
44 void CWaterEnvMapRenderHelper::render(TFace face
, TGlobalAnimationTime time
, UDriver
&drv
)
47 using NLMISC::CVector
;
50 case IWaterEnvMapRender::positive_x
: mat
.setRot(CVector::J
, -CVector::I
, -CVector::K
); break;
51 case IWaterEnvMapRender::negative_x
: mat
.setRot(-CVector::J
, CVector::I
, -CVector::K
); break;
52 case IWaterEnvMapRender::positive_y
: mat
.setRot(CVector::I
, CVector::J
, -CVector::K
); break;
53 case IWaterEnvMapRender::negative_y
: mat
.setRot(-CVector::I
, -CVector::J
, -CVector::K
); break;
54 case IWaterEnvMapRender::positive_z
: mat
.setRot(-CVector::I
, CVector::K
, -CVector::J
); break;
55 case IWaterEnvMapRender::negative_z
: mat
.setRot(-CVector::I
, -CVector::K
, CVector::J
); break;
60 doRender(mat
, time
, drv
);
64 //////////////////////////////////
65 // CWaterEnvMapRenderFromUScene //
66 //////////////////////////////////
68 // ***********************************************************************************
69 CWaterEnvMapRenderFromUScene::CWaterEnvMapRenderFromUScene()
74 _RenderPart
= UScene::RenderAll
;
77 // ***********************************************************************************
78 void CWaterEnvMapRenderFromUScene::setScene(UScene
*scene
, UCamera cam
)
84 nlassert(!_Cam
.empty());
89 // ***********************************************************************************
90 void CWaterEnvMapRenderFromUScene::doRender(const CMatrix
&camMatrix
, TGlobalAnimationTime time
, UDriver
&drv
)
94 UCamera oldCam
= _Scene
->getCam();
95 if (_Cam
.empty()) return;
97 _Cam
.setTransformMode(UTransformable::DirectMatrix
);
98 nlassert(!_Cam
.empty());
99 _Cam
.setFrustum(-_ZNear
, _ZNear
, -_ZNear
, _ZNear
, _ZNear
, _ZFar
);
100 drv
.setCullMode(drv
.getCullMode() == UDriver::CCW
? UDriver::CW
: UDriver::CCW
);
101 CMatrix mat
= camMatrix
;
104 CViewport old
= _Scene
->getViewport();
105 _Scene
->setViewport(CViewport());
106 _Scene
->beginPartRender();
107 _Scene
->renderPart(_RenderPart
);
108 _Scene
->endPartRender();
109 _Scene
->setViewport(old
);
110 drv
.setCullMode(drv
.getCullMode() == UDriver::CCW
? UDriver::CW
: UDriver::CCW
);
111 _Scene
->setCam(oldCam
);
112 postRender(time
, drv
);
115 // ***********************************************************************************
116 void CWaterEnvMapUser::invalidate()