/usr/include/OGRE/OgreBorderPanelOverlayElement.h is in libogre-dev 1.7.4+dfsg1-7.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 | /*
-----------------------------------------------------------------------------
This source file is part of OGRE
(Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org/
Copyright (c) 2000-2011 Torus Knot Software Ltd
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-----------------------------------------------------------------------------
*/
#ifndef __BorderPanelOverlayElement_H__
#define __BorderPanelOverlayElement_H__
#include "OgrePanelOverlayElement.h"
namespace Ogre {
/** \addtogroup Core
* @{
*/
/** \addtogroup Overlays
* @{
*/
class BorderRenderable;
/** A specialisation of the PanelOverlayElement to provide a panel with a border.
@remarks
Whilst the standard panel can use a single tiled material, this class allows
panels with a tileable backdrop plus a border texture. This is handy for large
panels that are too big to use a single large texture with a border, or
for multiple different size panels where you want the border a constant width
but the center to repeat.
@par
In addition to the usual PanelOverlayElement properties, this class has a 'border
material', which specifies the material used for the edges of the panel,
a border width (which can either be constant all the way around, or specified
per edge), and the texture coordinates for each of the border sections.
*/
class _OgreExport BorderPanelOverlayElement : public PanelOverlayElement
{
friend class BorderRenderable;
public:
/** Constructor */
BorderPanelOverlayElement(const String& name);
virtual ~BorderPanelOverlayElement();
virtual void initialise(void);
const String& getTypeName(void) const;
/** Sets the size of the border.
@remarks
This method sets a constant size for all borders. There are also alternative
methods which allow you to set border widths for individual edges separately.
Remember that the dimensions specified here are in relation to the size of
the screen, so 0.1 is 1/10th of the screen width or height. Also note that because
most screen resolutions are 1.333:1 width:height ratio that using the same
border size will look slightly bigger across than up.
@param size The size of the border as a factor of the screen dimensions ie 0.2 is one-fifth
of the screen size.
*/
void setBorderSize(Real size);
/** Sets the size of the border, with different sizes for vertical and horizontal borders.
@remarks
This method sets a size for the side and top / bottom borders separately.
Remember that the dimensions specified here are in relation to the size of
the screen, so 0.1 is 1/10th of the screen width or height. Also note that because
most screen resolutions are 1.333:1 width:height ratio that using the same
border size will look slightly bigger across than up.
@param sides The size of the side borders as a factor of the screen dimensions ie 0.2 is one-fifth
of the screen size.
@param topAndBottom The size of the top and bottom borders as a factor of the screen dimensions.
*/
void setBorderSize(Real sides, Real topAndBottom);
/** Sets the size of the border separately for all borders.
@remarks
This method sets a size all borders separately.
Remember that the dimensions specified here are in relation to the size of
the screen, so 0.1 is 1/10th of the screen width or height. Also note that because
most screen resolutions are 1.333:1 width:height ratio that using the same
border size will look slightly bigger across than up.
@param left The size of the left border as a factor of the screen dimensions ie 0.2 is one-fifth
of the screen size.
@param right The size of the left border as a factor of the screen dimensions.
@param top The size of the top border as a factor of the screen dimensions.
@param bottom The size of the bottom border as a factor of the screen dimensions.
*/
void setBorderSize(Real left, Real right, Real top, Real bottom);
/** Gets the size of the left border. */
Real getLeftBorderSize(void) const;
/** Gets the size of the right border. */
Real getRightBorderSize(void) const;
/** Gets the size of the top border. */
Real getTopBorderSize(void) const;
/** Gets the size of the bottom border. */
Real getBottomBorderSize(void) const;
/** Sets the texture coordinates for the left edge of the border.
@remarks
The border panel uses 8 panels for the border (9 including the center).
Imagine a table with 3 rows and 3 columns. The corners are always the same size,
but the edges stretch depending on how big the panel is. Those who have done
resizable HTML tables will be familiar with this approach.
@par
We only require 2 sets of uv coordinates, one for the top-left and one for the
bottom-right of the panel, since it is assumed the sections are aligned on the texture.
*/
void setLeftBorderUV(Real u1, Real v1, Real u2, Real v2);
/** Sets the texture coordinates for the right edge of the border.
@remarks See setLeftBorderUV.
*/
void setRightBorderUV(Real u1, Real v1, Real u2, Real v2);
/** Sets the texture coordinates for the top edge of the border.
@remarks See setLeftBorderUV.
*/
void setTopBorderUV(Real u1, Real v1, Real u2, Real v2);
/** Sets the texture coordinates for the bottom edge of the border.
@remarks See setLeftBorderUV.
*/
void setBottomBorderUV(Real u1, Real v1, Real u2, Real v2);
/** Sets the texture coordinates for the top-left corner of the border.
@remarks See setLeftBorderUV.
*/
void setTopLeftBorderUV(Real u1, Real v1, Real u2, Real v2);
/** Sets the texture coordinates for the top-right corner of the border.
@remarks See setLeftBorderUV.
*/
void setTopRightBorderUV(Real u1, Real v1, Real u2, Real v2);
/** Sets the texture coordinates for the bottom-left corner of the border.
@remarks See setLeftBorderUV.
*/
void setBottomLeftBorderUV(Real u1, Real v1, Real u2, Real v2);
/** Sets the texture coordinates for the bottom-right corner of the border.
@remarks See setLeftBorderUV.
*/
void setBottomRightBorderUV(Real u1, Real v1, Real u2, Real v2);
String getLeftBorderUVString() const;
String getRightBorderUVString() const;
String getTopBorderUVString() const;
String getBottomBorderUVString() const;
String getTopLeftBorderUVString() const;
String getTopRightBorderUVString() const;
String getBottomLeftBorderUVString() const;
String getBottomRightBorderUVString() const;
/** Sets the name of the material to use for the borders. */
void setBorderMaterialName(const String& name);
/** Gets the name of the material to use for the borders. */
const String& getBorderMaterialName(void) const;
/** Overridden from OverlayContainer */
void _updateRenderQueue(RenderQueue* queue);
/// @copydoc OvelayElement::visitRenderables
void visitRenderables(Renderable::Visitor* visitor,
bool debugRenderables = false);
/** Overridden from OverlayElement */
void setMetricsMode(GuiMetricsMode gmm);
/** Overridden from OverlayElement */
void _update(void);
/** Command object for specifying border sizes (see ParamCommand).*/
class _OgrePrivate CmdBorderSize : public ParamCommand
{
public:
String doGet(const void* target) const;
void doSet(void* target, const String& val);
};
/** Command object for specifying the Material for the border (see ParamCommand).*/
class _OgrePrivate CmdBorderMaterial : public ParamCommand
{
public:
String doGet(const void* target) const;
void doSet(void* target, const String& val);
};
/** Command object for specifying texture coordinates for the border (see ParamCommand).*/
class _OgrePrivate CmdBorderLeftUV : public ParamCommand
{
public:
String doGet(const void* target) const;
void doSet(void* target, const String& val);
};
/** Command object for specifying texture coordinates for the border (see ParamCommand).*/
class _OgrePrivate CmdBorderTopUV : public ParamCommand
{
public:
String doGet(const void* target) const;
void doSet(void* target, const String& val);
};
/** Command object for specifying texture coordinates for the border (see ParamCommand).*/
class _OgrePrivate CmdBorderRightUV : public ParamCommand
{
public:
String doGet(const void* target) const;
void doSet(void* target, const String& val);
};
/** Command object for specifying texture coordinates for the border (see ParamCommand).*/
class _OgrePrivate CmdBorderBottomUV : public ParamCommand
{
public:
String doGet(const void* target) const;
void doSet(void* target, const String& val);
};
/** Command object for specifying texture coordinates for the border (see ParamCommand).*/
class _OgrePrivate CmdBorderTopLeftUV : public ParamCommand
{
public:
String doGet(const void* target) const;
void doSet(void* target, const String& val);
};
/** Command object for specifying texture coordinates for the border (see ParamCommand).*/
class _OgrePrivate CmdBorderBottomLeftUV : public ParamCommand
{
public:
String doGet(const void* target) const;
void doSet(void* target, const String& val);
};
/** Command object for specifying texture coordinates for the border (see ParamCommand).*/
class _OgrePrivate CmdBorderBottomRightUV : public ParamCommand
{
public:
String doGet(const void* target) const;
void doSet(void* target, const String& val);
};
/** Command object for specifying texture coordinates for the border (see ParamCommand).*/
class _OgrePrivate CmdBorderTopRightUV : public ParamCommand
{
public:
String doGet(const void* target) const;
void doSet(void* target, const String& val);
};
protected:
Real mLeftBorderSize;
Real mRightBorderSize;
Real mTopBorderSize;
Real mBottomBorderSize;
struct CellUV {
Real u1, v1, u2, v2;
};
CellUV mBorderUV[8];
ushort mPixelLeftBorderSize;
ushort mPixelRightBorderSize;
ushort mPixelTopBorderSize;
ushort mPixelBottomBorderSize;
String mBorderMaterialName;
MaterialPtr mpBorderMaterial;
// Render operation for the border area
RenderOperation mRenderOp2;
static String msTypeName;
/// internal method for setting up geometry, called by OverlayElement::update
void updatePositionGeometry(void);
/// internal method for setting up geometry, called by OverlayElement::update
void updateTextureGeometry(void);
/// Internal method for setting up parameters
void addBaseParameters(void);
enum BorderCellIndex {
BCELL_TOP_LEFT = 0,
BCELL_TOP = 1,
BCELL_TOP_RIGHT = 2,
BCELL_LEFT = 3,
BCELL_RIGHT = 4,
BCELL_BOTTOM_LEFT = 5,
BCELL_BOTTOM = 6,
BCELL_BOTTOM_RIGHT = 7
};
String getCellUVString(BorderCellIndex idx) const;
// Command objects
static CmdBorderSize msCmdBorderSize;
static CmdBorderMaterial msCmdBorderMaterial;
static CmdBorderLeftUV msCmdBorderLeftUV;
static CmdBorderTopUV msCmdBorderTopUV;
static CmdBorderBottomUV msCmdBorderBottomUV;
static CmdBorderRightUV msCmdBorderRightUV;
static CmdBorderTopLeftUV msCmdBorderTopLeftUV;
static CmdBorderBottomLeftUV msCmdBorderBottomLeftUV;
static CmdBorderTopRightUV msCmdBorderTopRightUV;
static CmdBorderBottomRightUV msCmdBorderBottomRightUV;
BorderRenderable* mBorderRenderable;
};
/** Class for rendering the border of a BorderPanelOverlayElement.
@remarks
We need this because we have to render twice, once with the inner panel's repeating
material (handled by superclass) and once for the border's separate material.
*/
class _OgreExport BorderRenderable : public Renderable, public OverlayAlloc
{
protected:
BorderPanelOverlayElement* mParent;
public:
/** Constructed with pointers to parent. */
BorderRenderable(BorderPanelOverlayElement* parent) : mParent(parent)
{
mUseIdentityProjection = true;
mUseIdentityView = true;
}
const MaterialPtr& getMaterial(void) const { return mParent->mpBorderMaterial; }
void getRenderOperation(RenderOperation& op) { op = mParent->mRenderOp2; }
void getWorldTransforms(Matrix4* xform) const { mParent->getWorldTransforms(xform); }
unsigned short getNumWorldTransforms(void) const { return 1; }
Real getSquaredViewDepth(const Camera* cam) const { return mParent->getSquaredViewDepth(cam); }
const LightList& getLights(void) const
{
// N/A, panels are not lit
static LightList ll;
return ll;
}
bool getPolygonModeOverrideable(void) const
{
return mParent->getPolygonModeOverrideable();
}
};
/** @} */
/** @} */
}
#endif
|