source: GTP/trunk/App/Demos/Geom/OgreStuff/include/OgrePanelOverlayElement.h @ 1030

Revision 1030, 5.4 KB checked in by gumbau, 18 years ago (diff)

Ogre Stuff initial import

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-2005 The OGRE Team
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-----------------------------------------------------------------------------
24*/
25
26#ifndef __PanelOverlayElement_H__
27#define __PanelOverlayElement_H__
28
29#include "OgreOverlayContainer.h"
30
31namespace 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 whether this panel is transparent (used only as a grouping level), or
75            if it is actually renderred.
76        */
77        void setTransparent(bool isTransparent);
78
79        /** Returns whether this panel is transparent. */
80        bool isTransparent(void) const;
81
82        /** See OverlayElement. */
83        virtual const String& getTypeName(void) const;
84        /** See Renderable. */
85        void getRenderOperation(RenderOperation& op);
86        /** Overridden from OverlayElement */
87        void setMaterialName(const String& matName);
88        /** Overridden from OverlayContainer */
89        void _updateRenderQueue(RenderQueue* queue);
90
91
92        /** Command object for specifying tiling (see ParamCommand).*/
93        class _OgrePrivate CmdTiling : public ParamCommand
94        {
95        public:
96            String doGet(const void* target) const;
97            void doSet(void* target, const String& val);
98        };
99        /** Command object for specifying transparency (see ParamCommand).*/
100        class _OgrePrivate CmdTransparent : public ParamCommand
101        {
102        public:
103            String doGet(const void* target) const;
104            void doSet(void* target, const String& val);
105        };
106    protected:
107        // Flag indicating if this panel should be visual or just group things
108        bool mTransparent;
109        // Texture tiling
110        Real mTileX[OGRE_MAX_TEXTURE_LAYERS];
111        Real mTileY[OGRE_MAX_TEXTURE_LAYERS];
112        size_t mNumTexCoordsInBuffer;
113
114        RenderOperation mRenderOp;
115
116        /// internal method for setting up geometry, called by OverlayElement::update
117        virtual void updatePositionGeometry(void);
118
119        /// Called to update the texture coords when layers change
120        virtual void updateTextureGeometry(void);
121
122        /// Method for setting up base parameters for this class
123        void addBaseParameters(void);
124
125
126        static String msTypeName;
127
128
129        // Command objects
130        static CmdTiling msCmdTiling;
131        static CmdTransparent msCmdTransparent;
132
133       
134
135    };
136
137
138}
139
140#endif
Note: See TracBrowser for help on using the repository browser.