Project

General

Profile

SO3Engine
SO3SubEntityCameraSelectorBuffer.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_VIEWPORT_SELECTOR_BUFFER_H__
33#define __SO3_NODE_VIEWPORT_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>
44
45namespace SO3
46{
47class SSubEntityCameraSelectorBuffer : public Ogre::RenderTargetListener
48{
49public:
50protected:
51private:
52 SSubEntitySelectorMaterialSwitcher* nodeSelectorMaterialSwitcher;
53 std::string mBaseResourceName;
54
55 Ogre::Camera* mCamera;
56 Ogre::TexturePtr mOgreTexture;
57 Ogre::TexturePtr mOgreDepthTexture;
58 Ogre::RenderTexture* mOgreRenderTexture;
59 Ogre::RenderTexture* mOgreRenderDepthTexture;
60 Ogre::MultiRenderTarget* mMrtTexture;
61 Ogre::Overlay* mOgreDebugOverlay;
62 Ogre::OverlayContainer* mOgreDebugOverlayPanel;
63 Ogre::MaterialPtr mOgreOverlayMaterial;
64
65 unsigned int mTextureWidth;
66 unsigned int mTextureHeight;
67 unsigned int mRealWidth;
68 unsigned int mRealHeight;
69
70 Ogre::MaterialPtr mPickerMat;
71 Ogre::TexturePtr mOgrePickerTexture;
72 Ogre::RenderTexture* mOgrePickerRenderTexture;
73 Ogre::SceneManager* mOgrePickerScene;
74 Ogre::Camera* mOgrePickerCamera;
75 Ogre::Rectangle2D* mOgrePickerRect;
76 Ogre::PixelBox* mOgrePixelBox;
77 Ogre::uint8* mRenderPickerBuffer;
78
79 bool mCompensateNPOT;
80 bool mUseDepth;
81public:
84 SSubEntityCameraSelectorBuffer(Ogre::Camera* camera, const std::string& name, unsigned int texwidth = 128, unsigned int texheight = 128, bool useDepth = true);
85
89
92 void DestroyBuffers();
93
96 void CreateBuffers();
97
101 Ogre::SubEntity* GetSelectedSubEntity(int posX, int posY);
102
106 float GetSelectedZdepth(int posX, int posY);
107
110 virtual void preRenderTargetUpdate(const Ogre::RenderTargetEvent& evt);
111
114 virtual void postRenderTargetUpdate(const Ogre::RenderTargetEvent& evt);
115
118 void Update();
119
122 void UpdateBufferSize(unsigned int texwidth, unsigned int texheight, const bool& forceRefresh = false);
123
126 void CreatePicker();
127
130 void DeletePicker();
131
134 bool UseDepthBuffer();
135protected:
136private:
141
144 void CreateTexture(const unsigned int& width, const unsigned int& height);
145
148 void DeleteTexture();
149};
150
151}
152
153#endif
librairies include
virtual void preRenderTargetUpdate(const Ogre::RenderTargetEvent &evt)
void UpdateBufferSize(unsigned int texwidth, unsigned int texheight, const bool &forceRefresh=false)
Ogre::SubEntity * GetSelectedSubEntity(int posX, int posY)
virtual void postRenderTargetUpdate(const Ogre::RenderTargetEvent &evt)