Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/OgreMain/include/OgrePanelOverlayElement.h @ 3

Last change on this file since 3 was 3, checked in by anonymous, 17 years ago

=update

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