[692] | 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-2005 The OGRE Team
|
---|
| 8 | Also see acknowledgements in Readme.html
|
---|
| 9 |
|
---|
| 10 | This program is free software; you can redistribute it and/or modify it under
|
---|
| 11 | the terms of the GNU Lesser General Public License as published by the Free Software
|
---|
| 12 | Foundation; either version 2 of the License, or (at your option) any later
|
---|
| 13 | version.
|
---|
| 14 |
|
---|
| 15 | This program is distributed in the hope that it will be useful, but WITHOUT
|
---|
| 16 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
---|
| 17 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
---|
| 18 |
|
---|
| 19 | You should have received a copy of the GNU Lesser General Public License along with
|
---|
| 20 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
---|
| 21 | Place - Suite 330, Boston, MA 02111-1307, USA, or go to
|
---|
| 22 | http://www.gnu.org/copyleft/lesser.txt.
|
---|
| 23 | -----------------------------------------------------------------------------
|
---|
| 24 | */
|
---|
| 25 |
|
---|
| 26 | #ifndef __PanelOverlayElement_H__
|
---|
| 27 | #define __PanelOverlayElement_H__
|
---|
| 28 |
|
---|
| 29 | #include "OgreOverlayContainer.h"
|
---|
| 30 |
|
---|
| 31 | namespace Ogre {
|
---|
| 32 |
|
---|
| 33 |
|
---|
| 34 | /** OverlayElement representing a flat, single-material (or transparent) panel which can contain other elements.
|
---|
| 35 | @remarks
|
---|
| 36 | This class subclasses OverlayContainer because it can contain other elements. Like other
|
---|
| 37 | containers, if hidden it's contents are also hidden, if moved it's contents also move etc.
|
---|
| 38 | The panel itself is a 2D rectangle which is either completely transparent, or is rendered
|
---|
| 39 | with a single material. The texture(s) on the panel can be tiled depending on your requirements.
|
---|
| 40 | @par
|
---|
| 41 | This component is suitable for backgrounds and grouping other elements. Note that because
|
---|
| 42 | it has a single repeating material it cannot have a discrete border (unless the texture has one and
|
---|
| 43 | the texture is tiled only once). For a bordered panel, see it's subclass BorderPanelOverlayElement.
|
---|
| 44 | @par
|
---|
| 45 | Note that the material can have all the usual effects applied to it like multiple texture
|
---|
| 46 | layers, scrolling / animated textures etc. For multiple texture layers, you have to set
|
---|
| 47 | the tiling level for each layer.
|
---|
| 48 | */
|
---|
| 49 | class _OgreExport PanelOverlayElement : public OverlayContainer
|
---|
| 50 | {
|
---|
| 51 | public:
|
---|
| 52 | /** Constructor. */
|
---|
| 53 | PanelOverlayElement(const String& name);
|
---|
| 54 | virtual ~PanelOverlayElement();
|
---|
| 55 |
|
---|
| 56 | /** Initialise */
|
---|
| 57 | virtual void initialise(void);
|
---|
| 58 |
|
---|
| 59 | /** Sets the number of times textures should repeat.
|
---|
| 60 | @param x The number of times the texture should repeat horizontally
|
---|
| 61 | @param y The number of times the texture should repeat vertically
|
---|
| 62 | @param layer The texture layer to specify (only needs to be altered if
|
---|
| 63 | you're using a multi-texture layer material)
|
---|
| 64 | */
|
---|
| 65 | void setTiling(Real x, Real y, ushort layer = 0);
|
---|
| 66 |
|
---|
| 67 | Real getTileX(ushort layer = 0) const;
|
---|
| 68 | /** Gets the number of times the texture should repeat vertically.
|
---|
| 69 | @param layer The texture layer to specify (only needs to be altered if
|
---|
| 70 | you're using a multi-texture layer material)
|
---|
| 71 | */
|
---|
| 72 | Real getTileY(ushort layer = 0) const;
|
---|
| 73 |
|
---|
| 74 | /** Sets the texture coordinates for the panel. */
|
---|
| 75 | void setUV(Real u1, Real v1, Real u2, Real v2);
|
---|
| 76 |
|
---|
| 77 | /** Get the uv coordinates for the panel*/
|
---|
| 78 | void getUV(Real& u1, Real& v1, Real& u2, Real& v2) const;
|
---|
| 79 |
|
---|
| 80 | /** Sets whether this panel is transparent (used only as a grouping level), or
|
---|
| 81 | if it is actually renderred.
|
---|
| 82 | */
|
---|
| 83 | void setTransparent(bool isTransparent);
|
---|
| 84 |
|
---|
| 85 | /** Returns whether this panel is transparent. */
|
---|
| 86 | bool isTransparent(void) const;
|
---|
| 87 |
|
---|
| 88 | /** See OverlayElement. */
|
---|
| 89 | virtual const String& getTypeName(void) const;
|
---|
| 90 | /** See Renderable. */
|
---|
| 91 | void getRenderOperation(RenderOperation& op);
|
---|
| 92 | /** Overridden from OverlayElement */
|
---|
| 93 | void setMaterialName(const String& matName);
|
---|
| 94 | /** Overridden from OverlayContainer */
|
---|
| 95 | void _updateRenderQueue(RenderQueue* queue);
|
---|
| 96 |
|
---|
| 97 |
|
---|
| 98 | /** Command object for specifying tiling (see ParamCommand).*/
|
---|
| 99 | class _OgrePrivate CmdTiling : public ParamCommand
|
---|
| 100 | {
|
---|
| 101 | public:
|
---|
| 102 | String doGet(const void* target) const;
|
---|
| 103 | void doSet(void* target, const String& val);
|
---|
| 104 | };
|
---|
| 105 | /** Command object for specifying transparency (see ParamCommand).*/
|
---|
| 106 | class _OgrePrivate CmdTransparent : public ParamCommand
|
---|
| 107 | {
|
---|
| 108 | public:
|
---|
| 109 | String doGet(const void* target) const;
|
---|
| 110 | void doSet(void* target, const String& val);
|
---|
| 111 | };
|
---|
| 112 | /** Command object for specifying UV coordinates (see ParamCommand).*/
|
---|
| 113 | class _OgrePrivate CmdUVCoords : public ParamCommand
|
---|
| 114 | {
|
---|
| 115 | public:
|
---|
| 116 | String doGet(const void* target) const;
|
---|
| 117 | void doSet(void* target, const String& val);
|
---|
| 118 | };
|
---|
| 119 | protected:
|
---|
| 120 | // Flag indicating if this panel should be visual or just group things
|
---|
| 121 | bool mTransparent;
|
---|
| 122 | // Texture tiling
|
---|
| 123 | Real mTileX[OGRE_MAX_TEXTURE_LAYERS];
|
---|
| 124 | Real mTileY[OGRE_MAX_TEXTURE_LAYERS];
|
---|
| 125 | size_t mNumTexCoordsInBuffer;
|
---|
| 126 | Real mU1, mV1, mU2, mV2;
|
---|
| 127 |
|
---|
| 128 | RenderOperation mRenderOp;
|
---|
| 129 |
|
---|
| 130 | /// internal method for setting up geometry, called by OverlayElement::update
|
---|
| 131 | virtual void updatePositionGeometry(void);
|
---|
| 132 |
|
---|
| 133 | /// Called to update the texture coords when layers change
|
---|
| 134 | virtual void updateTextureGeometry(void);
|
---|
| 135 |
|
---|
| 136 | /// Method for setting up base parameters for this class
|
---|
| 137 | void addBaseParameters(void);
|
---|
| 138 |
|
---|
| 139 | static String msTypeName;
|
---|
| 140 |
|
---|
| 141 | // Command objects
|
---|
| 142 | static CmdTiling msCmdTiling;
|
---|
| 143 | static CmdTransparent msCmdTransparent;
|
---|
| 144 | static CmdUVCoords msCmdUVCoords;
|
---|
| 145 |
|
---|
| 146 | };
|
---|
| 147 |
|
---|
| 148 | }
|
---|
| 149 |
|
---|
| 150 | #endif
|
---|