Main Page Namespace List Class Hierarchy Alphabetical List Compound List File List Namespace Members Compound Members File Members Related Pages

# OgreBorderPanelGuiElement.cpp

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 © 2000-2002 The OGRE Team
    00008 Also see acknowledgements in Readme.html
    00009
    00010 This program is free software; you can redistribute it and/or modify it under
    00011 the terms of the GNU Lesser General Public License as published by the Free Software
    00012 Foundation; either version 2 of the License, or (at your option) any later
    00013 version.
    00014
    00015 This program is distributed in the hope that it will be useful, but WITHOUT
    00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
    00018
    00019 You should have received a copy of the GNU Lesser General Public License along with
    00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
    00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
    00022 http://www.gnu.org/copyleft/lesser.txt.
    00023 -----------------------------------------------------------------------------
    00024 */
    00025
    00026 #include "OgreBorderPanelGuiElement.h"
    00027 #include "OgreMaterialManager.h"
    00028 #include "OgreMaterial.h"
    00029 #include "OgreStringConverter.h"
    00030 #include "OgreOverlayManager.h"
    00031 #include "OgreHardwareBufferManager.h"
    00032 #include "OgreHardwareVertexBuffer.h"
    00033 #include "OgreHardwareIndexBuffer.h"
    00034 #include "OgreException.h"
    00035 #include "OgreRenderQueue.h"
    00036 #include "OgreRoot.h"
    00037 #include "OgreRenderSystem.h"
    00038
    00039 namespace Ogre {
    00040     //---------------------------------------------------------------------
    00041     String BorderPanelGuiElement::msTypeName = "BorderPanel";
    00042     BorderPanelGuiElement::CmdBorderSize BorderPanelGuiElement::msCmdBorderSize;
    00043     BorderPanelGuiElement::CmdBorderMaterial BorderPanelGuiElement::msCmdBorderMaterial;
    00044     BorderPanelGuiElement::CmdBorderLeftUV BorderPanelGuiElement::msCmdBorderLeftUV;
    00045     BorderPanelGuiElement::CmdBorderTopUV BorderPanelGuiElement::msCmdBorderTopUV;
    00046     BorderPanelGuiElement::CmdBorderBottomUV BorderPanelGuiElement::msCmdBorderBottomUV;
    00047     BorderPanelGuiElement::CmdBorderRightUV BorderPanelGuiElement::msCmdBorderRightUV;
    00048     BorderPanelGuiElement::CmdBorderTopLeftUV BorderPanelGuiElement::msCmdBorderTopLeftUV;
    00049     BorderPanelGuiElement::CmdBorderBottomLeftUV BorderPanelGuiElement::msCmdBorderBottomLeftUV;
    00050     BorderPanelGuiElement::CmdBorderTopRightUV BorderPanelGuiElement::msCmdBorderTopRightUV;
    00051     BorderPanelGuiElement::CmdBorderBottomRightUV BorderPanelGuiElement::msCmdBorderBottomRightUV;
    00052
    00053     #define BCELL_UV(x) (x * 4 * 2)
    00054     #define POSITION_BINDING 0
    00055     #define TEXCOORD_BINDING 1
    00056     //---------------------------------------------------------------------
    00057     BorderPanelGuiElement::BorderPanelGuiElement(const String& name)
    00058       : PanelGuiElement(name),
    00059         mLeftBorderSize(0),
    00060         mRightBorderSize(0),
    00061         mTopBorderSize(0),
    00062         mBottomBorderSize(0),
    00063         mPixelLeftBorderSize(0),
    00064         mPixelRightBorderSize(0),
    00065         mPixelTopBorderSize(0),
    00066         mPixelBottomBorderSize(0),
    00067         mpBorderMaterial(0),
    00068         mBorderRenderable(0)
    00069     {
    00070         if (createParamDictionary("BorderPanelGuiElement"))
    00071         {
    00072             addBaseParameters();
    00073         }
    00074     }
    00075     //---------------------------------------------------------------------
    00076     BorderPanelGuiElement::~BorderPanelGuiElement()
    00077     {
    00078         delete mRenderOp2.vertexData;
    00079         delete mRenderOp2.indexData;
    00080         delete mBorderRenderable;
    00081     }
    00082     //---------------------------------------------------------------------
    00083     void BorderPanelGuiElement::initialise(void)
    00084     {
    00085         PanelGuiElement::initialise();
    00086
    00087         // superclass will handle the interior panel area
    00088
    00089         // Setup render op in advance
    00090         mRenderOp2.vertexData = new VertexData();
    00091         mRenderOp2.vertexData->vertexCount = 4 * 8; // 8 cells, can't necessarily share vertices cos
    00092                                                     // texcoords may differ
    00093         mRenderOp2.vertexData->vertexStart = 0;
    00094
    00095         // Vertex declaration
    00096         VertexDeclaration* decl = mRenderOp2.vertexData->vertexDeclaration;
    00097         // Position and texture coords each have their own buffers to allow
    00098         // each to be edited separately with the discard flag
    00099         decl->addElement(POSITION_BINDING, 0, VET_FLOAT3, VES_POSITION);
    00100         decl->addElement(TEXCOORD_BINDING, 0, VET_FLOAT2, VES_TEXTURE_COORDINATES, 0);
    00101
    00102         // Vertex buffer #1, position
    00103         HardwareVertexBufferSharedPtr vbuf = HardwareBufferManager::getSingleton()
    00104             .createVertexBuffer(
    00105                 decl->getVertexSize(POSITION_BINDING),
    00106                 mRenderOp2.vertexData->vertexCount,
    00107                 HardwareBuffer::HBU_STATIC_WRITE_ONLY);
    00108         // bind position
    00109         VertexBufferBinding* binding = mRenderOp2.vertexData->vertexBufferBinding;
    00110         binding->setBinding(POSITION_BINDING, vbuf);
    00111
    00112         // Vertex buffer #2, texcoords
    00113         vbuf = HardwareBufferManager::getSingleton()
    00114             .createVertexBuffer(
    00115                 decl->getVertexSize(TEXCOORD_BINDING),
    00116                 mRenderOp2.vertexData->vertexCount,
    00117                 HardwareBuffer::HBU_STATIC_WRITE_ONLY, true);
    00118         // bind texcoord
    00119         binding->setBinding(TEXCOORD_BINDING, vbuf);
    00120
    00121         mRenderOp2.operationType = RenderOperation::OT_TRIANGLE_LIST;
    00122         mRenderOp2.useIndexes = true;
    00123         // Index data
    00124         mRenderOp2.indexData = new IndexData();
    00125         mRenderOp2.indexData->indexCount = 8 * 6;
    00126         mRenderOp2.indexData->indexStart = 0;
    00127
    00128         /* Each cell is
    00129             0-----2
    00130             |    /|
    00131             |  /  |
    00132             |/    |
    00133             1-----3
    00134         */
    00135         mRenderOp2.indexData->indexBuffer = HardwareBufferManager::getSingleton().
    00136             createIndexBuffer(
    00137                 HardwareIndexBuffer::IT_16BIT,
    00138                 mRenderOp2.indexData->indexCount,
    00139                 HardwareBuffer::HBU_STATIC_WRITE_ONLY);
    00140
    00141         ushort* pIdx = static_cast<ushort*>(
    00142             mRenderOp2.indexData->indexBuffer->lock(
    00143                 0,
    00144                 mRenderOp2.indexData->indexBuffer->getSizeInBytes(),
    00145                 HardwareBuffer::HBL_DISCARD) );
    00146
    00147         for (int cell = 0; cell < 8; ++cell)
    00148         {
    00149             ushort base = cell * 4;
    00150             *pIdx++ = base;
    00151             *pIdx++ = base + 1;
    00152             *pIdx++ = base + 2;
    00153
    00154             *pIdx++ = base + 2;
    00155             *pIdx++ = base + 1;
    00156             *pIdx++ = base + 3;
    00157         }
    00158
    00159         mRenderOp2.indexData->indexBuffer->unlock();
    00160
    00161         // Create sub-object for rendering border
    00162         mBorderRenderable = new BorderRenderable(this);
    00163     }
    00164     //---------------------------------------------------------------------
    00165     void BorderPanelGuiElement::addBaseParameters(void)
    00166     {
    00167         PanelGuiElement::addBaseParameters();
    00168         ParamDictionary* dict = getParamDictionary();
    00169
    00170         dict->addParameter(ParameterDef("border_size",
    00171             "The sizes of the borders relative to the screen size, in the order "
    00172             "left, right, top, bottom."
    00173             , PT_STRING),
    00174             &msCmdBorderSize);
    00175         dict->addParameter(ParameterDef("border_material",
    00176             "The material to use for the border."
    00177             , PT_STRING),
    00178             &msCmdBorderMaterial);
    00179         dict->addParameter(ParameterDef("border_topleft_uv",
    00180             "The texture coordinates for the top-left corner border texture. 2 sets of uv values, "
    00181             "one for the top-left corner, the other for the bottom-right corner."
    00182             , PT_STRING),
    00183             &msCmdBorderTopLeftUV);
    00184         dict->addParameter(ParameterDef("border_topright_uv",
    00185             "The texture coordinates for the top-right corner border texture. 2 sets of uv values, "
    00186             "one for the top-left corner, the other for the bottom-right corner."
    00187             , PT_STRING),
    00188             &msCmdBorderTopRightUV);
    00189         dict->addParameter(ParameterDef("border_bottomright_uv",
    00190             "The texture coordinates for the bottom-right corner border texture. 2 sets of uv values, "
    00191             "one for the top-left corner, the other for the bottom-right corner."
    00192             , PT_STRING),
    00193             &msCmdBorderBottomRightUV);
    00194         dict->addParameter(ParameterDef("border_bottomleft_uv",
    00195             "The texture coordinates for the bottom-left corner border texture. 2 sets of uv values, "
    00196             "one for the top-left corner, the other for the bottom-right corner."
    00197             , PT_STRING),
    00198             &msCmdBorderBottomLeftUV);
    00199         dict->addParameter(ParameterDef("border_left_uv",
    00200             "The texture coordinates for the left edge border texture. 2 sets of uv values, "
    00201             "one for the top-left corner, the other for the bottom-right corner."
    00202             , PT_STRING),
    00203             &msCmdBorderLeftUV);
    00204         dict->addParameter(ParameterDef("border_top_uv",
    00205             "The texture coordinates for the top edge border texture. 2 sets of uv values, "
    00206             "one for the top-left corner, the other for the bottom-right corner."
    00207             , PT_STRING),
    00208             &msCmdBorderTopUV);
    00209         dict->addParameter(ParameterDef("border_right_uv",
    00210             "The texture coordinates for the right edge border texture. 2 sets of uv values, "
    00211             "one for the top-left corner, the other for the bottom-right corner."
    00212             , PT_STRING),
    00213             &msCmdBorderRightUV);
    00214         dict->addParameter(ParameterDef("border_bottom_uv",
    00215             "The texture coordinates for the bottom edge border texture. 2 sets of uv values, "
    00216             "one for the top-left corner, the other for the bottom-right corner."
    00217             , PT_STRING),
    00218             &msCmdBorderBottomUV);
    00219
    00220     }
    00221     //---------------------------------------------------------------------
    00222     void BorderPanelGuiElement::setBorderSize(Real size)
    00223     {
    00224         if (mMetricsMode != GMM_RELATIVE)
    00225         {
    00226             mPixelLeftBorderSize = mPixelRightBorderSize =
    00227                 mPixelTopBorderSize = mPixelBottomBorderSize = size;
    00228         }
    00229         else
    00230         {
    00231             mLeftBorderSize = mRightBorderSize =
    00232                 mTopBorderSize = mBottomBorderSize = size;
    00233         }
    00234         mGeomPositionsOutOfDate = true;
    00235     }
    00236     //---------------------------------------------------------------------
    00237     void BorderPanelGuiElement::setBorderSize(Real sides, Real topAndBottom)
    00238     {
    00239         if (mMetricsMode != GMM_RELATIVE)
    00240         {
    00241             mPixelLeftBorderSize = mPixelRightBorderSize = sides;
    00242             mPixelTopBorderSize = mPixelBottomBorderSize = topAndBottom;
    00243         }
    00244         else
    00245         {
    00246             mLeftBorderSize = mRightBorderSize = sides;
    00247             mTopBorderSize = mBottomBorderSize = topAndBottom;
    00248         }
    00249         mGeomPositionsOutOfDate = true;
    00250
    00251
    00252     }
    00253     //---------------------------------------------------------------------
    00254     void BorderPanelGuiElement::setBorderSize(Real left, Real right, Real top, Real bottom)
    00255     {
    00256         if (mMetricsMode != GMM_RELATIVE)
    00257         {
    00258             mPixelLeftBorderSize = left;
    00259             mPixelRightBorderSize = right;
    00260             mPixelTopBorderSize = top;
    00261             mPixelBottomBorderSize = bottom;
    00262         }
    00263         else
    00264         {
    00265             mLeftBorderSize = left;
    00266             mRightBorderSize = right;
    00267             mTopBorderSize = top;
    00268             mBottomBorderSize = bottom;
    00269         }
    00270         mGeomPositionsOutOfDate = true;
    00271     }
    00272     //---------------------------------------------------------------------
    00273     Real BorderPanelGuiElement::getLeftBorderSize(void) const
    00274     {
    00275         if (mMetricsMode == GMM_PIXELS)
    00276         {
    00277             return mPixelLeftBorderSize;
    00278         }
    00279         else
    00280         {
    00281             return mLeftBorderSize;
    00282         }
    00283     }
    00284     //---------------------------------------------------------------------
    00285     Real BorderPanelGuiElement::getRightBorderSize(void) const
    00286     {
    00287         if (mMetricsMode == GMM_PIXELS)
    00288         {
    00289             return mPixelRightBorderSize;
    00290         }
    00291         else
    00292         {
    00293             return mRightBorderSize;
    00294         }
    00295     }
    00296     //---------------------------------------------------------------------
    00297     Real BorderPanelGuiElement::getTopBorderSize(void) const
    00298     {
    00299         if (mMetricsMode == GMM_PIXELS)
    00300         {
    00301             return mPixelTopBorderSize;
    00302         }
    00303         else
    00304         {
    00305             return mTopBorderSize;
    00306         }
    00307     }
    00308     //---------------------------------------------------------------------
    00309     Real BorderPanelGuiElement::getBottomBorderSize(void) const
    00310     {
    00311         if (mMetricsMode == GMM_PIXELS)
    00312         {
    00313             return mPixelBottomBorderSize;
    00314         }
    00315         else
    00316         {
    00317             return mBottomBorderSize;
    00318         }
    00319     }
    00320     //---------------------------------------------------------------------
    00321     void BorderPanelGuiElement::setCellUV(BorderCellIndex idx, Real& u1,
    00322         Real& v1, Real& u2, Real& v2)
    00323     {
    00324         /* Each cell is
    00325             0-----2
    00326             |    /|
    00327             |  /  |
    00328             |/    |
    00329             1-----3
    00330         */
    00331         // No choice but to lock / unlock each time here, but lock only small sections
    00332
    00333         HardwareVertexBufferSharedPtr vbuf =
    00334             mRenderOp2.vertexData->vertexBufferBinding->getBuffer(TEXCOORD_BINDING);
    00335         // Can't use discard since this discards whole buffer
    00336         Real* pUV = static_cast<Real*>(
    00337             vbuf->lock(
    00338                 BCELL_UV(idx) * sizeof(Real),
    00339                 sizeof(Real)*8,
    00340                 HardwareBuffer::HBL_NORMAL) );
    00341
    00342         *pUV++ = u1; *pUV++ = v1;
    00343         *pUV++ = u1; *pUV++ = v2;
    00344         *pUV++ = u2; *pUV++ = v1;
    00345         *pUV++ = u2; *pUV++ = v2;
    00346
    00347         vbuf->unlock();
    00348
    00349     }
    00350     //---------------------------------------------------------------------
    00351     String BorderPanelGuiElement::getCellUVString(BorderCellIndex idx) const
    00352     {
    00353         /* Each cell is
    00354             0-----2
    00355             |    /|
    00356             |  /  |
    00357             |/    |
    00358             1-----3
    00359         */
    00360         // No choice but to lock / unlock each time here, but lock only small sections
    00361
    00362         HardwareVertexBufferSharedPtr vbuf =
    00363             mRenderOp2.vertexData->vertexBufferBinding->getBuffer(TEXCOORD_BINDING);
    00364         // Lock just the portion we need in read-only mode
    00365         // Can't use discard since this discards whole buffer
    00366         Real* pUV = static_cast<Real*>(
    00367             vbuf->lock(
    00368                 BCELL_UV(idx) * sizeof(Real),
    00369                 sizeof(Real)*8,
    00370                 HardwareBuffer::HBL_READ_ONLY) );
    00371
    00372         String ret = StringConverter::toString(pUV[0]) + " " +
    00373                     StringConverter::toString(pUV[1]) + " " +
    00374                     StringConverter::toString(pUV[6]) + " " +
    00375                     StringConverter::toString(pUV[7]);
    00376         vbuf->unlock();
    00377         return ret;
    00378     }
    00379     //---------------------------------------------------------------------
    00380     void BorderPanelGuiElement::setLeftBorderUV(Real u1, Real v1, Real u2, Real v2)
    00381     {
    00382         setCellUV(BCELL_LEFT, u1, v1, u2, v2);
    00383     }
    00384     //---------------------------------------------------------------------
    00385     void BorderPanelGuiElement::setRightBorderUV(Real u1, Real v1, Real u2, Real v2)
    00386     {
    00387         setCellUV(BCELL_RIGHT, u1, v1, u2, v2);
    00388     }
    00389     //---------------------------------------------------------------------
    00390     void BorderPanelGuiElement::setTopBorderUV(Real u1, Real v1, Real u2, Real v2)
    00391     {
    00392         setCellUV(BCELL_TOP, u1, v1, u2, v2);
    00393     }
    00394     //---------------------------------------------------------------------
    00395     void BorderPanelGuiElement::setBottomBorderUV(Real u1, Real v1, Real u2, Real v2)
    00396     {
    00397         setCellUV(BCELL_BOTTOM, u1, v1, u2, v2);
    00398     }
    00399     //---------------------------------------------------------------------
    00400     void BorderPanelGuiElement::setTopLeftBorderUV(Real u1, Real v1, Real u2, Real v2)
    00401     {
    00402         setCellUV(BCELL_TOP_LEFT, u1, v1, u2, v2);
    00403     }
    00404     //---------------------------------------------------------------------
    00405     void BorderPanelGuiElement::setTopRightBorderUV(Real u1, Real v1, Real u2, Real v2)
    00406     {
    00407         setCellUV(BCELL_TOP_RIGHT, u1, v1, u2, v2);
    00408     }
    00409     //---------------------------------------------------------------------
    00410     void BorderPanelGuiElement::setBottomLeftBorderUV(Real u1, Real v1, Real u2, Real v2)
    00411     {
    00412         setCellUV(BCELL_BOTTOM_LEFT, u1, v1, u2, v2);
    00413     }
    00414     //---------------------------------------------------------------------
    00415     void BorderPanelGuiElement::setBottomRightBorderUV(Real u1, Real v1, Real u2, Real v2)
    00416     {
    00417         setCellUV(BCELL_BOTTOM_RIGHT, u1, v1, u2, v2);
    00418     }
    00419
    00420     //---------------------------------------------------------------------
    00421     String BorderPanelGuiElement::getLeftBorderUVString() const
    00422     {
    00423         return getCellUVString(BCELL_LEFT);
    00424     }
    00425     //---------------------------------------------------------------------
    00426     String BorderPanelGuiElement::getRightBorderUVString() const
    00427     {
    00428         return getCellUVString(BCELL_RIGHT);
    00429     }
    00430     //---------------------------------------------------------------------
    00431     String BorderPanelGuiElement::getTopBorderUVString() const
    00432     {
    00433         return getCellUVString(BCELL_TOP);
    00434     }
    00435     //---------------------------------------------------------------------
    00436     String BorderPanelGuiElement::getBottomBorderUVString() const
    00437     {
    00438         return getCellUVString(BCELL_BOTTOM);
    00439     }
    00440     //---------------------------------------------------------------------
    00441     String BorderPanelGuiElement::getTopLeftBorderUVString() const
    00442     {
    00443         return getCellUVString(BCELL_TOP_LEFT);
    00444     }
    00445     //---------------------------------------------------------------------
    00446     String BorderPanelGuiElement::getTopRightBorderUVString() const
    00447     {
    00448         return getCellUVString(BCELL_TOP_RIGHT);
    00449     }
    00450     //---------------------------------------------------------------------
    00451     String BorderPanelGuiElement::getBottomLeftBorderUVString() const
    00452     {
    00453         return getCellUVString(BCELL_BOTTOM_LEFT);
    00454     }
    00455     //---------------------------------------------------------------------
    00456     String BorderPanelGuiElement::getBottomRightBorderUVString() const
    00457     {
    00458         return getCellUVString(BCELL_BOTTOM_RIGHT);
    00459     }
    00460
    00461
    00462
    00463
    00464
    00465     //---------------------------------------------------------------------
    00466     void BorderPanelGuiElement::setBorderMaterialName(const String& name)
    00467     {
    00468         mBorderMaterialName = name;
    00469         mpBorderMaterial = (Material*)MaterialManager::getSingleton().getByName(name);
    00470         if (!mpBorderMaterial)
    00471             Except( Exception::ERR_ITEM_NOT_FOUND, "Could not find material " + name,
    00472                 "BorderPanelGuiElement::setBorderMaterialName" );
    00473         mpBorderMaterial->load();
    00474         // Set some prerequisites to be sure
    00475         mpBorderMaterial->setLightingEnabled(false);
    00476         mpBorderMaterial->setDepthCheckEnabled(false);
    00477
    00478     }
    00479     //---------------------------------------------------------------------
    00480     const String& BorderPanelGuiElement::getBorderMaterialName(void) const
    00481     {
    00482         return mBorderMaterialName;
    00483     }
    00484     //---------------------------------------------------------------------
    00485     void BorderPanelGuiElement::updatePositionGeometry(void)
    00486     {
    00487         /*
    00488         Grid is like this:
    00489         +--+---------------+--+
    00490         |0 |       1       |2 |
    00491         +--+---------------+--+
    00492         |  |               |  |
    00493         |  |               |  |
    00494         |3 |    center     |4 |
    00495         |  |               |  |
    00496         +--+---------------+--+
    00497         |5 |       6       |7 |
    00498         +--+---------------+--+
    00499         */
    00500         // Convert positions into -1, 1 coordinate space (homogenous clip space)
    00501         // Top / bottom also need inverting since y is upside down
    00502         Real left[8], right[8], top[8], bottom[8];
    00503         // Horizontal
    00504         left[0] = left[3] = left[5] = _getDerivedLeft() * 2 - 1;
    00505         left[1] = left[6] = right[0] = right[3] = right[5] = left[0] + (mLeftBorderSize * 2);
    00506         right[2] = right[4] = right[7] = left[0] + (mWidth * 2);
    00507         left[2] = left[4] = left[7] = right[1] = right[6] = right[2] - (mRightBorderSize * 2);
    00508         // Vertical
    00509         top[0] = top[1] = top[2] = -((_getDerivedTop() * 2) - 1);
    00510         top[3] = top[4] = bottom[0] = bottom[1] = bottom[2] = top[0] - (mTopBorderSize * 2);
    00511         bottom[5] = bottom[6] = bottom[7] = top[0] -  (mHeight * 2);
    00512         top[5] = top[6] = top[7] = bottom[3] = bottom[4] = bottom[5] + (mBottomBorderSize * 2);
    00513
    00514         // Lock the whole position buffer in discard mode
    00515         HardwareVertexBufferSharedPtr vbuf =
    00516             mRenderOp2.vertexData->vertexBufferBinding->getBuffer(POSITION_BINDING);
    00517         Real* pPos = static_cast<Real*>(
    00518             vbuf->lock(HardwareBuffer::HBL_DISCARD) );
    00519         // Use the furthest away depth value, since materials should have depth-check off
    00520         // This initialised the depth buffer for any 3D objects in front
    00521         Real zValue = Root::getSingleton().getRenderSystem()->getMaximumDepthInputValue();
    00522         for (ushort cell = 0; cell < 8; ++cell)
    00523         {
    00524             /*
    00525                 0-----2
    00526                 |    /|
    00527                 |  /  |
    00528                 |/    |
    00529                 1-----3
    00530             */
    00531             *pPos++ = left[cell];
    00532             *pPos++ = top[cell];
    00533             *pPos++ = zValue;
    00534
    00535             *pPos++ = left[cell];
    00536             *pPos++ = bottom[cell];
    00537             *pPos++ = zValue;
    00538
    00539             *pPos++ = right[cell];
    00540             *pPos++ = top[cell];
    00541             *pPos++ = zValue;
    00542
    00543             *pPos++ = right[cell];
    00544             *pPos++ = bottom[cell];
    00545             *pPos++ = zValue;
    00546
    00547         }
    00548         vbuf->unlock();
    00549
    00550         // Also update center geometry
    00551         // NB don't use superclass because we need to make it smaller because of border
    00552         vbuf = mRenderOp.vertexData->vertexBufferBinding->getBuffer(POSITION_BINDING);
    00553         pPos = static_cast<Real*>(
    00554             vbuf->lock(HardwareBuffer::HBL_DISCARD) );
    00555         // Use cell 1 and 3 to determine positions
    00556         *pPos++ = left[1];
    00557         *pPos++ = top[3];
    00558         *pPos++ = zValue;
    00559
    00560         *pPos++ = left[1];
    00561         *pPos++ = bottom[3];
    00562         *pPos++ = zValue;
    00563
    00564         *pPos++ = right[1];
    00565         *pPos++ = top[3];
    00566         *pPos++ = zValue;
    00567
    00568         *pPos++ = right[1];
    00569         *pPos++ = bottom[3];
    00570         *pPos++ = zValue;
    00571
    00572         vbuf->unlock();
    00573
    00574     }
    00575     //---------------------------------------------------------------------
    00576     void BorderPanelGuiElement::_updateRenderQueue(RenderQueue* queue)
    00577     {
    00578         // Add self twice to the queue
    00579         // Have to do this to allow 2 materials
    00580         if (mVisible)
    00581         {
    00582
    00583             // Add outer
    00584             queue->addRenderable(mBorderRenderable, RENDER_QUEUE_OVERLAY, mZOrder);
    00585
    00586             // do inner last so the border artifacts don't overwrite the children
    00587             // Add inner
    00588             PanelGuiElement::_updateRenderQueue(queue);
    00589         }
    00590     }
    00591     //-----------------------------------------------------------------------
    00592     void BorderPanelGuiElement::setMetricsMode(GuiMetricsMode gmm)
    00593     {
    00594         PanelGuiElement::setMetricsMode(gmm);
    00595         if (gmm != GMM_RELATIVE)
    00596         {
    00597             mPixelBottomBorderSize = mBottomBorderSize;
    00598             mPixelLeftBorderSize = mLeftBorderSize;
    00599             mPixelRightBorderSize = mRightBorderSize;
    00600             mPixelTopBorderSize = mTopBorderSize;
    00601         }
    00602     }
    00603     //-----------------------------------------------------------------------
    00604     void BorderPanelGuiElement::_update(void)
    00605     {
    00606         PanelGuiElement::_update();
    00607
    00608         if (mMetricsMode != GMM_RELATIVE &&
    00609             (OverlayManager::getSingleton().hasViewportChanged() || mGeomPositionsOutOfDate))
    00610         {
    00611             mLeftBorderSize = mPixelLeftBorderSize * mPixelScaleX;
    00612             mRightBorderSize = mPixelRightBorderSize * mPixelScaleX;
    00613             mTopBorderSize = mPixelTopBorderSize * mPixelScaleY;
    00614             mBottomBorderSize = mPixelBottomBorderSize * mPixelScaleY;
    00615             mGeomPositionsOutOfDate = true;
    00616         }
    00617     }
    00618     //-----------------------------------------------------------------------
    00619     //---------------------------------------------------------------------
    00620     //---------------------------------------------------------------------
    00621     // Command objects
    00622     //---------------------------------------------------------------------
    00623     //-----------------------------------------------------------------------
    00624     String BorderPanelGuiElement::CmdBorderSize::doGet(const void* target) const
    00625     {
    00626         const BorderPanelGuiElement* t = static_cast<const BorderPanelGuiElement*>(target);
    00627         return String(
    00628             StringConverter::toString(t->getLeftBorderSize()) + " " +
    00629             StringConverter::toString(t->getRightBorderSize()) + " " +
    00630             StringConverter::toString(t->getTopBorderSize()) + " " +
    00631             StringConverter::toString(t->getBottomBorderSize()) );
    00632     }
    00633     void BorderPanelGuiElement::CmdBorderSize::doSet(void* target, const String& val)
    00634     {
    00635         std::vector<String> vec = StringUtil::split(val);
    00636
    00637         static_cast<BorderPanelGuiElement*>(target)->setBorderSize(
    00638             StringConverter::parseReal(vec[0]),
    00639             StringConverter::parseReal(vec[1]),
    00640             StringConverter::parseReal(vec[2]),
    00641             StringConverter::parseReal(vec[3])
    00642             );
    00643     }
    00644     //-----------------------------------------------------------------------
    00645     String BorderPanelGuiElement::CmdBorderMaterial::doGet(const void* target) const
    00646     {
    00647         // No need right now..
    00648         return static_cast<const BorderPanelGuiElement*>(target)->getBorderMaterialName();
    00649     }
    00650     void BorderPanelGuiElement::CmdBorderMaterial::doSet(void* target, const String& val)
    00651     {
    00652         std::vector<String> vec = StringUtil::split(val);
    00653
    00654         static_cast<BorderPanelGuiElement*>(target)->setBorderMaterialName(val);
    00655     }
    00656     //-----------------------------------------------------------------------
    00657     String BorderPanelGuiElement::CmdBorderBottomLeftUV::doGet(const void* target) const
    00658     {
    00659         // No need right now..
    00660         return  static_cast<const BorderPanelGuiElement*>(target)->getBottomLeftBorderUVString();
    00661     }
    00662     void BorderPanelGuiElement::CmdBorderBottomLeftUV::doSet(void* target, const String& val)
    00663     {
    00664         std::vector<String> vec = StringUtil::split(val);
    00665
    00666         static_cast<BorderPanelGuiElement*>(target)->setBottomLeftBorderUV(
    00667             StringConverter::parseReal(vec[0]),
    00668             StringConverter::parseReal(vec[1]),
    00669             StringConverter::parseReal(vec[2]),
    00670             StringConverter::parseReal(vec[3])
    00671             );
    00672     }
    00673     //-----------------------------------------------------------------------
    00674     String BorderPanelGuiElement::CmdBorderBottomRightUV::doGet(const void* target) const
    00675     {
    00676         // No need right now..
    00677         return  static_cast<const BorderPanelGuiElement*>(target)->getBottomRightBorderUVString();
    00678     }
    00679     void BorderPanelGuiElement::CmdBorderBottomRightUV::doSet(void* target, const String& val)
    00680     {
    00681         std::vector<String> vec = StringUtil::split(val);
    00682
    00683         static_cast<BorderPanelGuiElement*>(target)->setBottomRightBorderUV(
    00684             StringConverter::parseReal(vec[0]),
    00685             StringConverter::parseReal(vec[1]),
    00686             StringConverter::parseReal(vec[2]),
    00687             StringConverter::parseReal(vec[3])
    00688             );
    00689     }
    00690     //-----------------------------------------------------------------------
    00691     String BorderPanelGuiElement::CmdBorderTopLeftUV::doGet(const void* target) const
    00692     {
    00693         // No need right now..
    00694         return  static_cast<const BorderPanelGuiElement*>(target)->getTopLeftBorderUVString();
    00695     }
    00696     void BorderPanelGuiElement::CmdBorderTopLeftUV::doSet(void* target, const String& val)
    00697     {
    00698         std::vector<String> vec = StringUtil::split(val);
    00699
    00700         static_cast<BorderPanelGuiElement*>(target)->setTopLeftBorderUV(
    00701             StringConverter::parseReal(vec[0]),
    00702             StringConverter::parseReal(vec[1]),
    00703             StringConverter::parseReal(vec[2]),
    00704             StringConverter::parseReal(vec[3])
    00705             );
    00706     }
    00707     //-----------------------------------------------------------------------
    00708     String BorderPanelGuiElement::CmdBorderTopRightUV::doGet(const void* target) const
    00709     {
    00710         // No need right now..
    00711         return  static_cast<const BorderPanelGuiElement*>(target)->getTopRightBorderUVString();
    00712     }
    00713     void BorderPanelGuiElement::CmdBorderTopRightUV::doSet(void* target, const String& val)
    00714     {
    00715         std::vector<String> vec = StringUtil::split(val);
    00716
    00717         static_cast<BorderPanelGuiElement*>(target)->setTopRightBorderUV(
    00718             StringConverter::parseReal(vec[0]),
    00719             StringConverter::parseReal(vec[1]),
    00720             StringConverter::parseReal(vec[2]),
    00721             StringConverter::parseReal(vec[3])
    00722             );
    00723     }
    00724     //-----------------------------------------------------------------------
    00725     String BorderPanelGuiElement::CmdBorderLeftUV::doGet(const void* target) const
    00726     {
    00727         // No need right now..
    00728         return  static_cast<const BorderPanelGuiElement*>(target)->getLeftBorderUVString();
    00729     }
    00730     void BorderPanelGuiElement::CmdBorderLeftUV::doSet(void* target, const String& val)
    00731     {
    00732         std::vector<String> vec = StringUtil::split(val);
    00733
    00734         static_cast<BorderPanelGuiElement*>(target)->setLeftBorderUV(
    00735             StringConverter::parseReal(vec[0]),
    00736             StringConverter::parseReal(vec[1]),
    00737             StringConverter::parseReal(vec[2]),
    00738             StringConverter::parseReal(vec[3])
    00739             );
    00740     }
    00741     //-----------------------------------------------------------------------
    00742     String BorderPanelGuiElement::CmdBorderRightUV::doGet(const void* target) const
    00743     {
    00744         // No need right now..
    00745         return  static_cast<const BorderPanelGuiElement*>(target)->getRightBorderUVString();
    00746     }
    00747     void BorderPanelGuiElement::CmdBorderRightUV::doSet(void* target, const String& val)
    00748     {
    00749         std::vector<String> vec = StringUtil::split(val);
    00750
    00751         static_cast<BorderPanelGuiElement*>(target)->setRightBorderUV(
    00752             StringConverter::parseReal(vec[0]),
    00753             StringConverter::parseReal(vec[1]),
    00754             StringConverter::parseReal(vec[2]),
    00755             StringConverter::parseReal(vec[3])
    00756             );
    00757     }
    00758     //-----------------------------------------------------------------------
    00759     String BorderPanelGuiElement::CmdBorderTopUV::doGet(const void* target) const
    00760     {
    00761         // No need right now..
    00762         return  static_cast<const BorderPanelGuiElement*>(target)->getTopBorderUVString();
    00763     }
    00764     void BorderPanelGuiElement::CmdBorderTopUV::doSet(void* target, const String& val)
    00765     {
    00766         std::vector<String> vec = StringUtil::split(val);
    00767
    00768         static_cast<BorderPanelGuiElement*>(target)->setTopBorderUV(
    00769             StringConverter::parseReal(vec[0]),
    00770             StringConverter::parseReal(vec[1]),
    00771             StringConverter::parseReal(vec[2]),
    00772             StringConverter::parseReal(vec[3])
    00773             );
    00774     }
    00775     //-----------------------------------------------------------------------
    00776     String BorderPanelGuiElement::CmdBorderBottomUV::doGet(const void* target) const
    00777     {
    00778         // No need right now..
    00779         return  static_cast<const BorderPanelGuiElement*>(target)->getBottomBorderUVString();
    00780     }
    00781     void BorderPanelGuiElement::CmdBorderBottomUV::doSet(void* target, const String& val)
    00782     {
    00783         std::vector<String> vec = StringUtil::split(val);
    00784
    00785         static_cast<BorderPanelGuiElement*>(target)->setBottomBorderUV(
    00786             StringConverter::parseReal(vec[0]),
    00787             StringConverter::parseReal(vec[1]),
    00788             StringConverter::parseReal(vec[2]),
    00789             StringConverter::parseReal(vec[3])
    00790             );
    00791     }
    00792     //---------------------------------------------------------------------
    00793     const String& BorderPanelGuiElement::getTypeName(void) const
    00794     {
    00795         return msTypeName;
    00796     }
    00797
    00798
    00799
    00800 }
    00801

Copyright © 2002-2003 by The OGRE Team
Last modified Sun Nov 28 19:48:15 2004