OgreBorderPanelOverlayElement.h
Go to the documentation of this file.

    00001 /*
    00002 -----------------------------------------------------------------------------
    00003 This source file is part of OGRE
    00004     (Object-oriented Graphics Rendering Engine)
    00005 For the latest info, see http://www.ogre3d.org/
    00006
    00007 Copyright (c) 2000-2012 Torus Knot Software Ltd
    00008
    00009 Permission is hereby granted, free of charge, to any person obtaining a copy
    00010 of this software and associated documentation files (the "Software"), to deal
    00011 in the Software without restriction, including without limitation the rights
    00012 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    00013 copies of the Software, and to permit persons to whom the Software is
    00014 furnished to do so, subject to the following conditions:
    00015
    00016 The above copyright notice and this permission notice shall be included in
    00017 all copies or substantial portions of the Software.
    00018
    00019 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    00020 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    00021 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    00022 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    00023 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    00024 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    00025 THE SOFTWARE.
    00026 -----------------------------------------------------------------------------
    00027 */
    00028
    00029 #ifndef __BorderPanelOverlayElement_H__
    00030 #define __BorderPanelOverlayElement_H__
    00031
    00032 #include "OgrePanelOverlayElement.h"
    00033
    00034 namespace Ogre {
    00042     class BorderRenderable;
    00043
    00057     class _OgreExport BorderPanelOverlayElement : public PanelOverlayElement
    00058     {
    00059         friend class BorderRenderable;
    00060     public:
    00062         BorderPanelOverlayElement(const String& name);
    00063         virtual ~BorderPanelOverlayElement();
    00064
    00065         virtual void initialise(void);
    00066
    00067         const String& getTypeName(void) const;
    00079         void setBorderSize(Real size);
    00080
    00092         void setBorderSize(Real sides, Real topAndBottom);
    00093
    00107         void setBorderSize(Real left, Real right, Real top, Real bottom);
    00108
    00110         Real getLeftBorderSize(void) const;
    00112         Real getRightBorderSize(void) const;
    00114         Real getTopBorderSize(void) const;
    00116         Real getBottomBorderSize(void) const;
    00117
    00128         void setLeftBorderUV(Real u1, Real v1, Real u2, Real v2);
    00132         void setRightBorderUV(Real u1, Real v1, Real u2, Real v2);
    00136         void setTopBorderUV(Real u1, Real v1, Real u2, Real v2);
    00140         void setBottomBorderUV(Real u1, Real v1, Real u2, Real v2);
    00144         void setTopLeftBorderUV(Real u1, Real v1, Real u2, Real v2);
    00148         void setTopRightBorderUV(Real u1, Real v1, Real u2, Real v2);
    00152         void setBottomLeftBorderUV(Real u1, Real v1, Real u2, Real v2);
    00156         void setBottomRightBorderUV(Real u1, Real v1, Real u2, Real v2);
    00157
    00158         String getLeftBorderUVString() const;
    00159         String getRightBorderUVString() const;
    00160         String getTopBorderUVString() const;
    00161         String getBottomBorderUVString() const;
    00162         String getTopLeftBorderUVString() const;
    00163         String getTopRightBorderUVString() const;
    00164         String getBottomLeftBorderUVString() const;
    00165         String getBottomRightBorderUVString() const;
    00166
    00167
    00168
    00169
    00171         void setBorderMaterialName(const String& name);
    00173         const String& getBorderMaterialName(void) const;
    00174
    00176         void _updateRenderQueue(RenderQueue* queue);
    00178         void visitRenderables(Renderable::Visitor* visitor,
    00179             bool debugRenderables = false);
    00180
    00182         void setMetricsMode(GuiMetricsMode gmm);
    00183
    00185         void _update(void);
    00186
    00187
    00189         class _OgrePrivate CmdBorderSize : public ParamCommand
    00190         {
    00191         public:
    00192             String doGet(const void* target) const;
    00193             void doSet(void* target, const String& val);
    00194         };
    00196         class _OgrePrivate CmdBorderMaterial : public ParamCommand
    00197         {
    00198         public:
    00199             String doGet(const void* target) const;
    00200             void doSet(void* target, const String& val);
    00201         };
    00203         class _OgrePrivate CmdBorderLeftUV : public ParamCommand
    00204         {
    00205         public:
    00206             String doGet(const void* target) const;
    00207             void doSet(void* target, const String& val);
    00208         };
    00210         class _OgrePrivate CmdBorderTopUV : public ParamCommand
    00211         {
    00212         public:
    00213             String doGet(const void* target) const;
    00214             void doSet(void* target, const String& val);
    00215         };
    00217         class _OgrePrivate CmdBorderRightUV : public ParamCommand
    00218         {
    00219         public:
    00220             String doGet(const void* target) const;
    00221             void doSet(void* target, const String& val);
    00222         };
    00224         class _OgrePrivate CmdBorderBottomUV : public ParamCommand
    00225         {
    00226         public:
    00227             String doGet(const void* target) const;
    00228             void doSet(void* target, const String& val);
    00229         };
    00231         class _OgrePrivate CmdBorderTopLeftUV : public ParamCommand
    00232         {
    00233         public:
    00234             String doGet(const void* target) const;
    00235             void doSet(void* target, const String& val);
    00236         };
    00238         class _OgrePrivate CmdBorderBottomLeftUV : public ParamCommand
    00239         {
    00240         public:
    00241             String doGet(const void* target) const;
    00242             void doSet(void* target, const String& val);
    00243         };
    00245         class _OgrePrivate CmdBorderBottomRightUV : public ParamCommand
    00246         {
    00247         public:
    00248             String doGet(const void* target) const;
    00249             void doSet(void* target, const String& val);
    00250         };
    00252         class _OgrePrivate CmdBorderTopRightUV : public ParamCommand
    00253         {
    00254         public:
    00255             String doGet(const void* target) const;
    00256             void doSet(void* target, const String& val);
    00257         };
    00258     protected:
    00259         Real mLeftBorderSize;
    00260         Real mRightBorderSize;
    00261         Real mTopBorderSize;
    00262         Real mBottomBorderSize;
    00263         struct CellUV {
    00264             Real u1, v1, u2, v2;
    00265         };
    00266         CellUV mBorderUV[8];
    00267
    00268         ushort mPixelLeftBorderSize;
    00269         ushort mPixelRightBorderSize;
    00270         ushort mPixelTopBorderSize;
    00271         ushort mPixelBottomBorderSize;
    00272
    00273         String mBorderMaterialName;
    00274         MaterialPtr mBorderMaterial;
    00275
    00276         // Render operation for the border area
    00277         RenderOperation mRenderOp2;
    00278
    00279         static String msTypeName;
    00280
    00282         void updatePositionGeometry(void);
    00284         void updateTextureGeometry(void);
    00286         void addBaseParameters(void);
    00287
    00288         enum BorderCellIndex {
    00289             BCELL_TOP_LEFT = 0,
    00290             BCELL_TOP = 1,
    00291             BCELL_TOP_RIGHT = 2,
    00292             BCELL_LEFT = 3,
    00293             BCELL_RIGHT = 4,
    00294             BCELL_BOTTOM_LEFT = 5,
    00295             BCELL_BOTTOM = 6,
    00296             BCELL_BOTTOM_RIGHT = 7
    00297         };
    00298         String getCellUVString(BorderCellIndex idx) const;
    00299
    00300         // Command objects
    00301         static CmdBorderSize msCmdBorderSize;
    00302         static CmdBorderMaterial msCmdBorderMaterial;
    00303         static CmdBorderLeftUV msCmdBorderLeftUV;
    00304         static CmdBorderTopUV msCmdBorderTopUV;
    00305         static CmdBorderBottomUV msCmdBorderBottomUV;
    00306         static CmdBorderRightUV msCmdBorderRightUV;
    00307         static CmdBorderTopLeftUV msCmdBorderTopLeftUV;
    00308         static CmdBorderBottomLeftUV msCmdBorderBottomLeftUV;
    00309         static CmdBorderTopRightUV msCmdBorderTopRightUV;
    00310         static CmdBorderBottomRightUV msCmdBorderBottomRightUV;
    00311
    00312         BorderRenderable* mBorderRenderable;
    00313     };
    00314
    00320     class _OgreExport BorderRenderable : public Renderable, public OverlayAlloc
    00321     {
    00322     protected:
    00323         BorderPanelOverlayElement* mParent;
    00324     public:
    00326         BorderRenderable(BorderPanelOverlayElement* parent) : mParent(parent)
    00327         {
    00328             mUseIdentityProjection = true;
    00329             mUseIdentityView = true;
    00330         }
    00331         const MaterialPtr& getMaterial(void) const { return mParent->mBorderMaterial; }
    00332         void getRenderOperation(RenderOperation& op) { op = mParent->mRenderOp2; }
    00333         void getWorldTransforms(Matrix4* xform) const { mParent->getWorldTransforms(xform); }
    00334         unsigned short getNumWorldTransforms(void) const { return 1; }
    00335         Real getSquaredViewDepth(const Camera* cam) const { return mParent->getSquaredViewDepth(cam); }
    00336         const LightList& getLights(void) const
    00337         {
    00338             // N/A, panels are not lit
    00339             static LightList ll;
    00340             return ll;
    00341         }
    00342         bool getPolygonModeOverrideable(void) const
    00343         {
    00344             return mParent->getPolygonModeOverrideable();
    00345         }
    00346     };
    00350 }
    00351
    00352 #endif

Copyright © 2012 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Sun Sep 2 2012 07:27:20