SO3Engine
SO3ViewPort.h
Go to the documentation of this file.
1/*
2-----------------------------------------------------------------------------
3This source file is part of OpenSpace3D
4For the latest info, see http://www.openspace3d.com
5
6Copyright (c) 2012 I-maginer
7
8This program is free software; you can redistribute it and/or modify it under
9the terms of the GNU Lesser General Public License as published by the Free Software
10Foundation; either version 2 of the License, or (at your option) any later
11version.
12
13This program is distributed in the hope that it will be useful, but WITHOUT
14ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
16
17You should have received a copy of the GNU Lesser General Public License along with
18this program; if not, write to the Free Software Foundation, Inc., 59 Temple
19Place - Suite 330, Boston, MA 02111-1307, USA, or go to
20http://www.gnu.org/copyleft/lesser.txt
21
22-----------------------------------------------------------------------------
23*/
24
31#ifndef __SO3VIEWPORT_H__
32#define __SO3VIEWPORT_H__
33
35#include "SO3HdrHandler.h"
36
37#ifdef SO3_BUILD_DEFERRED
39#endif
40
41namespace SO3
42{
43class SSsaoHandler;
44
45#define SO3_VISIBILITY_MASK_DEFAULT 0xFFFFFFFF
46#define SO3_VISIBILITY_MASK_INVISIBLE_ENVIRONMENT 0xFFFFFFFE
47#define SO3_VISIBILITY_MASK_VISIBLE_WATER_RTT 0x00000002
48
49#define SO3_VISIBILITY_FLAGS_DEFAULT 0xFFFFFFFF
50#define SO3_VISIBILITY_FLAG_INVISIBLE_ENVIRONMENT 0x00000001
51#define SO3_VISIBILITY_FLAG_INTERNAL_MAXIMUM 0x00000002
52
55class SViewPort : public Ogre::Viewport::Listener, Ogre::MaterialManager::Listener
56{
57public:
58protected:
59private:
60 bool bClearDepth; //$BB
61 bool bClearColor; //$BB
62 SWindow* scolWindow;
63 SCamera* scolCamera;
64 Ogre::Viewport* O3ViewPort;
65 SCompositorMap compList;
66
67#ifdef SO3_BUILD_DEFERRED
68 bool bDeferredEnable;
69#endif
70
71 bool bSSAOEnable;
72
73#ifdef SO3_BUILD_DEFERRED
75#endif
76
77 SSsaoHandler* ssaoHandler;
78 SHdrHandler* hdrHandler;
79public:
83 SViewPort(SWindow* parent, SCamera* targetCamera, int priority, const float& x, const float& y, const float& w, const float& h);
84
88 ~SViewPort();
89
92 Ogre::Viewport* GetOgreViewPortPointer();
93
96 SWindow* GetParentWindow() const;
97
100 std::string GetMaterialScheme();
101
104 void SetMaterialScheme(const std::string& existingScheme);
105
108 void SetPositionAndSize(const float& x, const float& y, const float& w, const float& h);
109
112 void ResizeToWindow(const float& w, const float& h);
113
116 float GetLeft();
117
120 float GetTop();
121
124 float GetWidth();
125
128 float GetHeight();
129
132 int GetLeftPixels();
133
136 int GetTopPixels();
137
140 int GetWidthPixels();
141
144 int GetHeightPixels();
145
148 int GetPriority();
149
152 bool GetShadowsEnabled();
153
156 void SetShadowsEnabled(const bool& enableShadows);
157
160 void SetBackgroundColour(const int& backgroundColor);
161
164 int GetBackgroundColor();
165
169
172 void SetCamera(SCamera* camera);
173
176 bool UpdateStereoCompositorState(const Ogre::String compname, bool state);
177
180 void UpdateStereoCamera(Ogre::Camera* camera);
181
184 void RestoreStereoCamera();
185
188 void UpdateStereoCameraMatrix(Ogre::Camera* camera);
189
193
197
201
204 bool GetClearDepth();
205
208 void SetClearDepth(const bool& state);
209
212 bool GetClearColor();
213
216 void SetClearColor(const bool& value);
217
220 void SetSkyEnable(const bool& value);
221
224 bool GetSkyEnable();
225
228 void SetOverlayEnable(const bool& value);
229
232 bool GetOverlayEnable();
233
234#ifdef SO3_BUILD_DEFERRED
237 void SetDeferredEnable(const bool& value);
238
241 bool GetDeferredEnable();
242#endif
243
246 void SetSSAOEnable(const bool& value);
247
250 bool GetSSAOEnable();
251
255
258 void SetHDREnable(const bool& value);
259
262 bool GetHDREnable();
263
267
270 void SetHDRBlurAmount(const float& value);
271
274 void SetHDREffectAmount(const float& value);
275
278 void SetHDRGamma(const float& value);
279
280#ifdef SO3_BUILD_DEFERRED
284
288
289
292 void SetDeferredDebugMode(const int& value);
293
297#endif
298
301 void SetVisibilityMask(const Ogre::uint32& mask);
302
305 Ogre::uint32 GetVisibilityMask();
306
309 void SetVisibilityMaskIndexEnable(const Ogre::uint32 flagIndex, const bool enable);
310
313 bool GetVisibilityMaskIndexEnable(const Ogre::uint32 flagIndex);
314
317 void Update();
318
322 SCompositor* CreateCompositor(const std::string& newCompositorName, const std::string& newSchemeName);
323
327 void DeleteCompositor(SCompositor* existingCompositor);
328
331 void DeleteCompositor(const std::string& existingCompositorName);
332
336 SCompositor* GetCompositor(const std::string& compositorName);
337
341 const SCompositorMap& GetCompositorList() const;
342
346 void ClearCompositors();
347
351 bool GetScreenPosFromWorldPos(Ogre::Vector3 worldPosition, Ogre::Vector2 &screenPos);
352
357 SRaycastResult RayCast(const int& pixelsX, const int& pixelsY, SSubEntitySelectorBuffer* subEntitySelector);
358
363 SRaycastResult RayCast(const int& pixelsX, const int& pixelsY);
364
365 Ogre::Vector3 RayCastCamera(const int& pixelsX, const int& pixelsY, const float distance, Ogre::Vector3 &outDirection);
366
367 unsigned int GetNumRenderedFaces();
368
369 unsigned int GetNumRenderedBatches();
370
375 void ToPixelPos(int& px, int& py);
376 void ToPixelPos(float& px, float& py);
377
382 void ToWindowPos(int& px, int& py);
383 void ToWindowPos(float& px, float& py);
384
385protected:
389 void AddCompositor(SCompositor* existingCompositor);
390
394 void RemoveCompositor(SCompositor* existingCompositor);
395
399 void RemoveCompositor(const std::string& compositorName);
400
401 virtual void viewportDimensionsChanged(Ogre::Viewport* viewport);
402
407 virtual Ogre::Technique* handleSchemeNotFound(unsigned short schemeIndex, const Ogre::String& schemeName, Ogre::Material* originalMaterial, unsigned short lodIndex, const Ogre::Renderable* rend);
408
409private:
413 SViewPort();
414};
415
416}
417
418#endif
librairies include
SCOL_EXPORT int cbmachine w
Definition SO3SCOL.cpp:5150
void SetVisibilityMaskIndexEnable(const Ogre::uint32 flagIndex, const bool enable)
SHdrHandler * GetHDRhandler()
void SetSkyEnable(const bool &value)
void SetVisibilityMask(const Ogre::uint32 &mask)
bool GetShadowsEnabled()
void AddCompositor(SCompositor *existingCompositor)
void ToWindowPos(int &px, int &py)
void SetDeferredEnable(const bool &value)
bool GetVisibilityMaskIndexEnable(const Ogre::uint32 flagIndex)
void SetHDREnable(const bool &value)
void RegisterStereoViewport()
SCompositor * GetCompositor(const std::string &compositorName)
SCamera * GetCamera()
void SetPositionAndSize(const float &x, const float &y, const float &w, const float &h)
void ToPixelPos(int &px, int &py)
void UnregisterStereoViewport()
Ogre::Vector3 RayCastCamera(const int &pixelsX, const int &pixelsY, const float distance, Ogre::Vector3 &outDirection)
void SetShadowsEnabled(const bool &enableShadows)
void SetMaterialScheme(const std::string &existingScheme)
void ClearCompositors()
void SetOverlayEnable(const bool &value)
void SetDeferredDebugMode(const int &value)
SDeferredShading::DeferredShadingAntiAliasingMode GetDeferredAntiAliasingMode()
Ogre::uint32 GetVisibilityMask()
void SetSSAOEnable(const bool &value)
void SetHDREffectAmount(const float &value)
void RestoreStereoCamera()
bool IsStereoViewportRegistered()
void ResizeToWindow(const float &w, const float &h)
unsigned int GetNumRenderedBatches()
SRaycastResult RayCast(const int &pixelsX, const int &pixelsY, SSubEntitySelectorBuffer *subEntitySelector)
unsigned int GetNumRenderedFaces()
bool GetDeferredEnable()
int GetDeferredDebugMode()
void SetBackgroundColour(const int &backgroundColor)
SWindow * GetParentWindow() const
void UpdateStereoCamera(Ogre::Camera *camera)
const SCompositorMap & GetCompositorList() const
void RemoveCompositor(SCompositor *existingCompositor)
Ogre::Viewport * GetOgreViewPortPointer()
SCompositor * CreateCompositor(const std::string &newCompositorName, const std::string &newSchemeName)
void SetClearDepth(const bool &state)
void SetDeferredAntiAliasingMode(const SDeferredShading::DeferredShadingAntiAliasingMode &value)
void UpdateStereoCameraMatrix(Ogre::Camera *camera)
void SetHDRBlurAmount(const float &value)
bool GetOverlayEnable()
std::string GetMaterialScheme()
SSsaoHandler * GetSSAOhandler()
void SetCamera(SCamera *camera)
virtual Ogre::Technique * handleSchemeNotFound(unsigned short schemeIndex, const Ogre::String &schemeName, Ogre::Material *originalMaterial, unsigned short lodIndex, const Ogre::Renderable *rend)
bool GetScreenPosFromWorldPos(Ogre::Vector3 worldPosition, Ogre::Vector2 &screenPos)
void SetHDRGamma(const float &value)
bool UpdateStereoCompositorState(const Ogre::String compname, bool state)
void SetClearColor(const bool &value)
virtual void viewportDimensionsChanged(Ogre::Viewport *viewport)
void DeleteCompositor(SCompositor *existingCompositor)
std::unordered_map< std::string, SCompositor * > SCompositorMap