1 /* 2 ----------------------------------------------------------------------------- 3 This source file is part of OGRE 4 (Object-oriented Graphics Rendering Engine) 5 For the latest info, see http://www.ogre3d.org/ 6 7 Copyright (c) 2000-2014 Torus Knot Software Ltd 8 9 Permission is hereby granted, free of charge, to any person obtaining a copy 10 of this software and associated documentation files (the "Software"), to deal 11 in the Software without restriction, including without limitation the rights 12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 copies of the Software, and to permit persons to whom the Software is 14 furnished to do so, subject to the following conditions: 15 16 The above copyright notice and this permission notice shall be included in 17 all copies or substantial portions of the Software. 18 19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 THE SOFTWARE. 26 ----------------------------------------------------------------------------- 27 */ 28 29 #ifndef __PanelOverlayElement_H__ 30 #define __PanelOverlayElement_H__ 31 32 #include "OgreOverlayContainer.h" 33 #include "OgreRenderOperation.h" 34 35 namespace Ogre { 36 37 /** \addtogroup Optional 38 * @{ 39 */ 40 /** \addtogroup Overlays 41 * @{ 42 */ 43 /** OverlayElement representing a flat, single-material (or transparent) panel which can contain other elements. 44 @remarks 45 This class subclasses OverlayContainer because it can contain other elements. Like other 46 containers, if hidden it's contents are also hidden, if moved it's contents also move etc. 47 The panel itself is a 2D rectangle which is either completely transparent, or is rendered 48 with a single material. The texture(s) on the panel can be tiled depending on your requirements. 49 @par 50 This component is suitable for backgrounds and grouping other elements. Note that because 51 it has a single repeating material it cannot have a discrete border (unless the texture has one and 52 the texture is tiled only once). For a bordered panel, see it's subclass BorderPanelOverlayElement. 53 @par 54 Note that the material can have all the usual effects applied to it like multiple texture 55 layers, scrolling / animated textures etc. For multiple texture layers, you have to set 56 the tiling level for each layer. 57 */ 58 class _OgreOverlayExport PanelOverlayElement : public OverlayContainer 59 { 60 public: 61 /** Constructor. */ 62 PanelOverlayElement(const String& name); 63 virtual ~PanelOverlayElement(); 64 65 /** Initialise */ 66 virtual void initialise(void); 67 68 /** @copydoc OverlayElement::_releaseManualHardwareResources */ 69 virtual void _releaseManualHardwareResources(); 70 /** @copydoc OverlayElement::_restoreManualHardwareResources */ 71 virtual void _restoreManualHardwareResources(); 72 73 /** Sets the number of times textures should repeat. 74 @param x The number of times the texture should repeat horizontally 75 @param y The number of times the texture should repeat vertically 76 @param layer The texture layer to specify (only needs to be altered if 77 you're using a multi-texture layer material) 78 */ 79 void setTiling(Real x, Real y, ushort layer = 0); 80 81 Real getTileX(ushort layer = 0) const; 82 /** Gets the number of times the texture should repeat vertically. 83 @param layer The texture layer to specify (only needs to be altered if 84 you're using a multi-texture layer material) 85 */ 86 Real getTileY(ushort layer = 0) const; 87 88 /** Sets the texture coordinates for the panel. */ 89 void setUV(Real u1, Real v1, Real u2, Real v2); 90 91 /** Get the uv coordinates for the panel*/ 92 void getUV(Real& u1, Real& v1, Real& u2, Real& v2) const; 93 94 /** Sets whether this panel is transparent (used only as a grouping level), or 95 if it is actually rendered. 96 */ 97 void setTransparent(bool isTransparent); 98 99 /** Returns whether this panel is transparent. */ 100 bool isTransparent(void) const; 101 102 /** See OverlayElement. */ 103 virtual const String& getTypeName(void) const; 104 /** See Renderable. */ 105 void getRenderOperation(RenderOperation& op); 106 /** Overridden from OverlayContainer */ 107 void _updateRenderQueue(RenderQueue* queue); 108 109 110 /** Command object for specifying tiling (see ParamCommand).*/ 111 class _OgrePrivate CmdTiling : public ParamCommand 112 { 113 public: 114 String doGet(const void* target) const; 115 void doSet(void* target, const String& val); 116 }; 117 /** Command object for specifying transparency (see ParamCommand).*/ 118 class _OgrePrivate CmdTransparent : public ParamCommand 119 { 120 public: 121 String doGet(const void* target) const; 122 void doSet(void* target, const String& val); 123 }; 124 /** Command object for specifying UV coordinates (see ParamCommand).*/ 125 class _OgrePrivate CmdUVCoords : public ParamCommand 126 { 127 public: 128 String doGet(const void* target) const; 129 void doSet(void* target, const String& val); 130 }; 131 protected: 132 /// Flag indicating if this panel should be visual or just group things 133 bool mTransparent; 134 // Texture tiling 135 Real mTileX[OGRE_MAX_TEXTURE_LAYERS]; 136 Real mTileY[OGRE_MAX_TEXTURE_LAYERS]; 137 size_t mNumTexCoordsInBuffer; 138 Real mU1, mV1, mU2, mV2; 139 140 RenderOperation mRenderOp; 141 142 /// Internal method for setting up geometry, called by OverlayElement::update 143 virtual void updatePositionGeometry(void); 144 145 /// Called to update the texture coords when layers change 146 virtual void updateTextureGeometry(void); 147 148 /// Method for setting up base parameters for this class 149 void addBaseParameters(void); 150 151 static String msTypeName; 152 153 // Command objects 154 static CmdTiling msCmdTiling; 155 static CmdTransparent msCmdTransparent; 156 static CmdUVCoords msCmdUVCoords; 157 158 }; 159 /** @} */ 160 /** @} */ 161 162 } 163 164 #endif 165