Project

General

Profile

SO3Engine
SO3SubEntitySelectorBuffer.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
32#ifndef __SO3_NODE_SELECTOR_BUFFER_H__
33#define __SO3_NODE_SELECTOR_BUFFER_H__
34
38#include <OgreOverlay.h>
39#include <OgreOverlaySystem.h>
40#include <OgreOverlayElement.h>
41#include <OgreOverlayManager.h>
42#include <OgrePanelOverlayElement.h>
43#include <OgreRectangle2D.h>
44namespace SO3
45{
46
56class SSubEntitySelectorBuffer : public Ogre::RenderTargetListener
57{
58public:
59protected:
60private:
61 SSubEntitySelectorMaterialSwitcher* nodeSelectorMaterialSwitcher;
62 std::string mBaseResourceName;
63 SWindow* mWindow;
64 Ogre::TexturePtr mOgreTexture;
65 Ogre::TexturePtr mOgreDepthTexture;
66 Ogre::RenderTexture* mOgreRenderTexture;
67 Ogre::RenderTexture* mOgreRenderDepthTexture;
68 Ogre::RenderTarget* mOgreRenderWindow;
69 Ogre::MultiRenderTarget* mMrtTexture;
70 Ogre::Overlay* mOgreDebugOverlay;
71 Ogre::OverlayContainer* mOgreDebugOverlayPanel;
72 Ogre::MaterialPtr mOgreOverlayMaterial;
73 typedef std::map<Ogre::Camera*, Ogre::PolygonMode> WireCameraList;
74 typedef std::map<SViewPort*, Ogre::Viewport*> SelectorViewportList;
75 SelectorViewportList mSelectorViewportList;
76 WireCameraList mWireCameraList;
77
78 unsigned int mTextureWidth;
79 unsigned int mTextureHeight;
80 unsigned int mRealWidth;
81 unsigned int mRealHeight;
82
83 Ogre::MaterialPtr mPickerMat;
84 Ogre::TexturePtr mOgrePickerTexture;
85 Ogre::RenderTexture* mOgrePickerRenderTexture;
86 Ogre::SceneManager* mOgrePickerScene;
87 Ogre::Camera* mOgrePickerCamera;
88 Ogre::Rectangle2D* mOgrePickerRect;
89 Ogre::PixelBox* mOgrePixelBox;
90 Ogre::uint8* mRenderPickerBuffer;
91
92 bool mCompensateNPOT;
93 bool mUseDepth;
94public:
97 SSubEntitySelectorBuffer(SWindow* targetWindow, bool useDepth = true);
98
102
105 void DestroyBuffers();
106
109 void CreateBuffers();
110
113 void AddViewport(SViewPort* newViewport);
114
117 void RemoveViewport(SViewPort* existingViewport);
118
122 Ogre::SubEntity* GetSelectedSubEntity(int posX, int posY);
123
127 float GetSelectedZdepth(int posX, int posY);
128
131 virtual void preRenderTargetUpdate(const Ogre::RenderTargetEvent& evt);
132
135 virtual void postRenderTargetUpdate(const Ogre::RenderTargetEvent& evt);
136
139 void Update();
140
143 void UpdateBufferSize(const bool& forceRefresh);
144
147 void CreatePicker();
148
151 void DeletePicker();
152
155 bool UseDepthBuffer();
156protected:
157private:
162
165 void CreateTexture(const unsigned int& width, const unsigned int& height);
166
169 void DeleteTexture();
170
173 void CreateDebugOverlay();
174
177 void DeleteDebugOverlay();
178};
179
180}
181
182#endif
librairies include
void UpdateBufferSize(const bool &forceRefresh)
void RemoveViewport(SViewPort *existingViewport)
virtual void preRenderTargetUpdate(const Ogre::RenderTargetEvent &evt)
void AddViewport(SViewPort *newViewport)
virtual void postRenderTargetUpdate(const Ogre::RenderTargetEvent &evt)
Ogre::SubEntity * GetSelectedSubEntity(int posX, int posY)