[148] | 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-2013 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 | |
---|
| 34 | namespace Ogre { |
---|
| 35 | |
---|
| 36 | |
---|
| 37 | /** \addtogroup Core |
---|
| 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 | /** Sets the number of times textures should repeat. |
---|
| 69 | @param x The number of times the texture should repeat horizontally |
---|
| 70 | @param y The number of times the texture should repeat vertically |
---|
| 71 | @param layer The texture layer to specify (only needs to be altered if |
---|
| 72 | you're using a multi-texture layer material) |
---|
| 73 | */ |
---|
| 74 | void setTiling(Real x, Real y, ushort layer = 0); |
---|
| 75 | |
---|
| 76 | Real getTileX(ushort layer = 0) const; |
---|
| 77 | /** Gets the number of times the texture should repeat vertically. |
---|
| 78 | @param layer The texture layer to specify (only needs to be altered if |
---|
| 79 | you're using a multi-texture layer material) |
---|
| 80 | */ |
---|
| 81 | Real getTileY(ushort layer = 0) const; |
---|
| 82 | |
---|
| 83 | /** Sets the texture coordinates for the panel. */ |
---|
| 84 | void setUV(Real u1, Real v1, Real u2, Real v2); |
---|
| 85 | |
---|
| 86 | /** Get the uv coordinates for the panel*/ |
---|
| 87 | void getUV(Real& u1, Real& v1, Real& u2, Real& v2) const; |
---|
| 88 | |
---|
| 89 | /** Sets whether this panel is transparent (used only as a grouping level), or |
---|
| 90 | if it is actually rendered. |
---|
| 91 | */ |
---|
| 92 | void setTransparent(bool isTransparent); |
---|
| 93 | |
---|
| 94 | /** Returns whether this panel is transparent. */ |
---|
| 95 | bool isTransparent(void) const; |
---|
| 96 | |
---|
| 97 | /** See OverlayElement. */ |
---|
| 98 | virtual const String& getTypeName(void) const; |
---|
| 99 | /** See Renderable. */ |
---|
| 100 | void getRenderOperation(RenderOperation& op); |
---|
| 101 | /** Overridden from OverlayElement */ |
---|
| 102 | void setMaterialName(const String& matName); |
---|
| 103 | /** Overridden from OverlayContainer */ |
---|
| 104 | void _updateRenderQueue(RenderQueue* queue); |
---|
| 105 | |
---|
| 106 | |
---|
| 107 | /** Command object for specifying tiling (see ParamCommand).*/ |
---|
| 108 | class _OgrePrivate CmdTiling : public ParamCommand |
---|
| 109 | { |
---|
| 110 | public: |
---|
| 111 | String doGet(const void* target) const; |
---|
| 112 | void doSet(void* target, const String& val); |
---|
| 113 | }; |
---|
| 114 | /** Command object for specifying transparency (see ParamCommand).*/ |
---|
| 115 | class _OgrePrivate CmdTransparent : public ParamCommand |
---|
| 116 | { |
---|
| 117 | public: |
---|
| 118 | String doGet(const void* target) const; |
---|
| 119 | void doSet(void* target, const String& val); |
---|
| 120 | }; |
---|
| 121 | /** Command object for specifying UV coordinates (see ParamCommand).*/ |
---|
| 122 | class _OgrePrivate CmdUVCoords : public ParamCommand |
---|
| 123 | { |
---|
| 124 | public: |
---|
| 125 | String doGet(const void* target) const; |
---|
| 126 | void doSet(void* target, const String& val); |
---|
| 127 | }; |
---|
| 128 | protected: |
---|
| 129 | /// Flag indicating if this panel should be visual or just group things |
---|
| 130 | bool mTransparent; |
---|
| 131 | // Texture tiling |
---|
| 132 | Real mTileX[OGRE_MAX_TEXTURE_LAYERS]; |
---|
| 133 | Real mTileY[OGRE_MAX_TEXTURE_LAYERS]; |
---|
| 134 | size_t mNumTexCoordsInBuffer; |
---|
| 135 | Real mU1, mV1, mU2, mV2; |
---|
| 136 | |
---|
| 137 | RenderOperation mRenderOp; |
---|
| 138 | |
---|
| 139 | /// Internal method for setting up geometry, called by OverlayElement::update |
---|
| 140 | virtual void updatePositionGeometry(void); |
---|
| 141 | |
---|
| 142 | /// Called to update the texture coords when layers change |
---|
| 143 | virtual void updateTextureGeometry(void); |
---|
| 144 | |
---|
| 145 | /// Method for setting up base parameters for this class |
---|
| 146 | void addBaseParameters(void); |
---|
| 147 | |
---|
| 148 | static String msTypeName; |
---|
| 149 | |
---|
| 150 | // Command objects |
---|
| 151 | static CmdTiling msCmdTiling; |
---|
| 152 | static CmdTransparent msCmdTransparent; |
---|
| 153 | static CmdUVCoords msCmdUVCoords; |
---|
| 154 | |
---|
| 155 | }; |
---|
| 156 | /** @} */ |
---|
| 157 | /** @} */ |
---|
| 158 | |
---|
| 159 | } |
---|
| 160 | |
---|
| 161 | #endif |
---|