[692] | 1 | /*
|
---|
| 2 | -----------------------------------------------------------------------------
|
---|
| 3 | This source file is part of OGRE
|
---|
| 4 | (Object-oriented Graphics Rendering Engine)
|
---|
| 5 | For the latest info, see http://www.ogre3d.org/
|
---|
| 6 |
|
---|
| 7 | Copyright (c) 2000-2005 The OGRE Team
|
---|
| 8 | Also see acknowledgements in Readme.html
|
---|
| 9 |
|
---|
| 10 | This program is free software; you can redistribute it and/or modify it under
|
---|
| 11 | the terms of the GNU Lesser General Public License as published by the Free Software
|
---|
| 12 | Foundation; either version 2 of the License, or (at your option) any later
|
---|
| 13 | version.
|
---|
| 14 |
|
---|
| 15 | This program is distributed in the hope that it will be useful, but WITHOUT
|
---|
| 16 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
---|
| 17 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
---|
| 18 |
|
---|
| 19 | You should have received a copy of the GNU Lesser General Public License along with
|
---|
| 20 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
---|
| 21 | Place - Suite 330, Boston, MA 02111-1307, USA, or go to
|
---|
| 22 | http://www.gnu.org/copyleft/lesser.txt.
|
---|
| 23 | -----------------------------------------------------------------------------
|
---|
| 24 | */
|
---|
| 25 | #ifndef __Common_H__
|
---|
| 26 | #define __Common_H__
|
---|
| 27 | // Common stuff
|
---|
| 28 |
|
---|
| 29 | #include <utility>
|
---|
| 30 |
|
---|
| 31 | namespace Ogre {
|
---|
| 32 |
|
---|
| 33 |
|
---|
| 34 | /** Comparison functions used for the depth/stencil buffer operations and
|
---|
| 35 | others. */
|
---|
| 36 | enum CompareFunction
|
---|
| 37 | {
|
---|
| 38 | CMPF_ALWAYS_FAIL,
|
---|
| 39 | CMPF_ALWAYS_PASS,
|
---|
| 40 | CMPF_LESS,
|
---|
| 41 | CMPF_LESS_EQUAL,
|
---|
| 42 | CMPF_EQUAL,
|
---|
| 43 | CMPF_NOT_EQUAL,
|
---|
| 44 | CMPF_GREATER_EQUAL,
|
---|
| 45 | CMPF_GREATER
|
---|
| 46 | };
|
---|
| 47 |
|
---|
| 48 | /** High-level filtering options providing shortcuts to settings the
|
---|
| 49 | minification, magnification and mip filters. */
|
---|
| 50 | enum TextureFilterOptions
|
---|
| 51 | {
|
---|
| 52 | /// Equal to: min=FO_POINT, mag=FO_POINT, mip=FO_NONE
|
---|
| 53 | TFO_NONE,
|
---|
| 54 | /// Equal to: min=FO_LINEAR, mag=FO_LINEAR, mip=FO_POINT
|
---|
| 55 | TFO_BILINEAR,
|
---|
| 56 | /// Equal to: min=FO_LINEAR, mag=FO_LINEAR, mip=FO_LINEAR
|
---|
| 57 | TFO_TRILINEAR,
|
---|
| 58 | /// Equal to: min=FO_ANISOTROPIC, max=FO_ANISOTROPIC, mip=FO_LINEAR
|
---|
| 59 | TFO_ANISOTROPIC
|
---|
| 60 | };
|
---|
| 61 |
|
---|
| 62 | enum FilterType
|
---|
| 63 | {
|
---|
| 64 | /// The filter used when shrinking a texture
|
---|
| 65 | FT_MIN,
|
---|
| 66 | /// The filter used when magnifiying a texture
|
---|
| 67 | FT_MAG,
|
---|
| 68 | /// The filter used when determining the mipmap
|
---|
| 69 | FT_MIP
|
---|
| 70 | };
|
---|
| 71 | /** Filtering options for textures / mipmaps. */
|
---|
| 72 | enum FilterOptions
|
---|
| 73 | {
|
---|
| 74 | /// No filtering, used for FILT_MIP to turn off mipmapping
|
---|
| 75 | FO_NONE,
|
---|
| 76 | /// Use the closest pixel
|
---|
| 77 | FO_POINT,
|
---|
| 78 | /// Average of a 2x2 pixel area, denotes bilinear for MIN and MAG, trilinear for MIP
|
---|
| 79 | FO_LINEAR,
|
---|
| 80 | /// Similar to FO_LINEAR, but compensates for the angle of the texture plane
|
---|
| 81 | FO_ANISOTROPIC
|
---|
| 82 | };
|
---|
| 83 |
|
---|
| 84 | /** Light shading modes. */
|
---|
| 85 | enum ShadeOptions
|
---|
| 86 | {
|
---|
| 87 | SO_FLAT,
|
---|
| 88 | SO_GOURAUD,
|
---|
| 89 | SO_PHONG
|
---|
| 90 | };
|
---|
| 91 |
|
---|
| 92 | /** Fog modes. */
|
---|
| 93 | enum FogMode
|
---|
| 94 | {
|
---|
| 95 | /// No fog. Duh.
|
---|
| 96 | FOG_NONE,
|
---|
| 97 | /// Fog density increases exponentially from the camera (fog = 1/e^(distance * density))
|
---|
| 98 | FOG_EXP,
|
---|
| 99 | /// Fog density increases at the square of FOG_EXP, i.e. even quicker (fog = 1/e^(distance * density)^2)
|
---|
| 100 | FOG_EXP2,
|
---|
| 101 | /// Fog density increases linearly between the start and end distances
|
---|
| 102 | FOG_LINEAR
|
---|
| 103 | };
|
---|
| 104 |
|
---|
| 105 | /** Hardware culling modes based on vertex winding.
|
---|
| 106 | This setting applies to how the hardware API culls triangles it is sent. */
|
---|
| 107 | enum CullingMode
|
---|
| 108 | {
|
---|
| 109 | /// Hardware never culls triangles and renders everything it receives.
|
---|
| 110 | CULL_NONE = 1,
|
---|
| 111 | /// Hardware culls triangles whose vertices are listed clockwise in the view (default).
|
---|
| 112 | CULL_CLOCKWISE = 2,
|
---|
| 113 | /// Hardware culls triangles whose vertices are listed anticlockwise in the view.
|
---|
| 114 | CULL_ANTICLOCKWISE = 3
|
---|
| 115 | };
|
---|
| 116 |
|
---|
| 117 | /** Manual culling modes based on vertex normals.
|
---|
| 118 | This setting applies to how the software culls triangles before sending them to the
|
---|
| 119 | hardware API. This culling mode is used by scene managers which choose to implement it -
|
---|
| 120 | normally those which deal with large amounts of fixed world geometry which is often
|
---|
| 121 | planar (software culling movable variable geometry is expensive). */
|
---|
| 122 | enum ManualCullingMode
|
---|
| 123 | {
|
---|
| 124 | /// No culling so everything is sent to the hardware.
|
---|
| 125 | MANUAL_CULL_NONE = 1,
|
---|
| 126 | /// Cull triangles whose normal is pointing away from the camera (default).
|
---|
| 127 | MANUAL_CULL_BACK = 2,
|
---|
| 128 | /// Cull triangles whose normal is pointing towards the camera.
|
---|
| 129 | MANUAL_CULL_FRONT = 3
|
---|
| 130 | };
|
---|
| 131 |
|
---|
| 132 | /** Enumerates the wave types usable with the Ogre engine. */
|
---|
| 133 | enum WaveformType
|
---|
| 134 | {
|
---|
| 135 | /// Standard sine wave which smoothly changes from low to high and back again.
|
---|
| 136 | WFT_SINE,
|
---|
| 137 | /// An angular wave with a constant increase / decrease speed with pointed peaks.
|
---|
| 138 | WFT_TRIANGLE,
|
---|
| 139 | /// Half of the time is spent at the min, half at the max with instant transition between.
|
---|
| 140 | WFT_SQUARE,
|
---|
| 141 | /// Gradual steady increase from min to max over the period with an instant return to min at the end.
|
---|
| 142 | WFT_SAWTOOTH,
|
---|
| 143 | /// Gradual steady decrease from max to min over the period, with an instant return to max at the end.
|
---|
| 144 | WFT_INVERSE_SAWTOOTH,
|
---|
| 145 | /// Pulse Width Modulation. Works like WFT_SQUARE, except the high to low transition is controlled by duty cycle.
|
---|
| 146 | /// With a duty cycle of 50% (0.5) will give the same output as WFT_SQUARE.
|
---|
| 147 | WFT_PWM
|
---|
| 148 | };
|
---|
| 149 |
|
---|
| 150 | /** The polygon mode to use when rasterising. */
|
---|
| 151 | enum PolygonMode
|
---|
| 152 | {
|
---|
| 153 | /// Only points are rendered.
|
---|
| 154 | PM_POINTS = 1,
|
---|
| 155 | /// Wireframe models are rendered.
|
---|
| 156 | PM_WIREFRAME = 2,
|
---|
| 157 | /// Solid polygons are rendered.
|
---|
| 158 | PM_SOLID = 3
|
---|
| 159 | };
|
---|
| 160 |
|
---|
| 161 | /** An enumeration of broad shadow techniques */
|
---|
| 162 | enum ShadowTechnique
|
---|
| 163 | {
|
---|
| 164 | /** No shadows */
|
---|
| 165 | SHADOWTYPE_NONE = 0x00,
|
---|
| 166 | /** Mask for additive shadows (not for direct use, use SHADOWTYPE_ enum instead)
|
---|
| 167 | */
|
---|
| 168 | SHADOWDETAILTYPE_ADDITIVE = 0x01,
|
---|
| 169 | /** Mask for modulative shadows (not for direct use, use SHADOWTYPE_ enum instead)
|
---|
| 170 | */
|
---|
| 171 | SHADOWDETAILTYPE_MODULATIVE = 0x02,
|
---|
| 172 | /** Mask for stencil shadows (not for direct use, use SHADOWTYPE_ enum instead)
|
---|
| 173 | */
|
---|
| 174 | SHADOWDETAILTYPE_STENCIL = 0x10,
|
---|
| 175 | /** Mask for texture shadows (not for direct use, use SHADOWTYPE_ enum instead)
|
---|
| 176 | */
|
---|
| 177 | SHADOWDETAILTYPE_TEXTURE = 0x20,
|
---|
| 178 |
|
---|
| 179 | /** Stencil shadow technique which renders all shadow volumes as
|
---|
| 180 | a modulation after all the non-transparent areas have been
|
---|
| 181 | rendered. This technique is considerably less fillrate intensive
|
---|
| 182 | than the additive stencil shadow approach when there are multiple
|
---|
| 183 | lights, but is not an accurate model.
|
---|
| 184 | */
|
---|
| 185 | SHADOWTYPE_STENCIL_MODULATIVE = 0x12,
|
---|
| 186 | /** Stencil shadow technique which renders each light as a separate
|
---|
| 187 | additive pass to the scene. This technique can be very fillrate
|
---|
| 188 | intensive because it requires at least 2 passes of the entire
|
---|
| 189 | scene, more if there are multiple lights. However, it is a more
|
---|
| 190 | accurate model than the modulative stencil approach and this is
|
---|
| 191 | especially apparant when using coloured lights or bump mapping.
|
---|
| 192 | */
|
---|
| 193 | SHADOWTYPE_STENCIL_ADDITIVE = 0x11,
|
---|
| 194 | /** Texture-based shadow technique which involves a monochrome render-to-texture
|
---|
| 195 | of the shadow caster and a projection of that texture onto the
|
---|
| 196 | shadow receivers as a modulative pass.
|
---|
| 197 | */
|
---|
| 198 | SHADOWTYPE_TEXTURE_MODULATIVE = 0x22,
|
---|
| 199 |
|
---|
| 200 | /** Texture-based shadow technique which involves a monochrome render-to-texture
|
---|
| 201 | of the shadow caster and a projection of that texture onto the
|
---|
| 202 | shadow receivers, built up per light as additive passes.
|
---|
| 203 | This technique can be very fillrate intensive because it requires numLights + 2
|
---|
| 204 | passes of the entire scene. However, it is a more accurate model than the
|
---|
| 205 | modulative approach and this is especially apparant when using coloured lights
|
---|
| 206 | or bump mapping.
|
---|
| 207 | */
|
---|
| 208 | SHADOWTYPE_TEXTURE_ADDITIVE = 0x21,
|
---|
| 209 | };
|
---|
| 210 |
|
---|
| 211 | /** An enumeration describing which material properties should track the vertex colours */
|
---|
| 212 | typedef int TrackVertexColourType;
|
---|
| 213 | enum TrackVertexColourEnum {
|
---|
| 214 | TVC_NONE = 0x0,
|
---|
| 215 | TVC_AMBIENT = 0x1,
|
---|
| 216 | TVC_DIFFUSE = 0x2,
|
---|
| 217 | TVC_SPECULAR = 0x4,
|
---|
| 218 | TVC_EMISSIVE = 0x8
|
---|
| 219 | };
|
---|
| 220 |
|
---|
| 221 | /** Sort mode for billboard-set and particle-system */
|
---|
| 222 | enum SortMode
|
---|
| 223 | {
|
---|
| 224 | /** Sort by direction of the camera */
|
---|
| 225 | SM_DIRECTION,
|
---|
| 226 | /** Sort by distance from the camera */
|
---|
| 227 | SM_DISTANCE
|
---|
| 228 | };
|
---|
| 229 |
|
---|
| 230 | /** Defines the frame buffer types. */
|
---|
| 231 | enum FrameBufferType {
|
---|
| 232 | FBT_COLOUR = 0x1,
|
---|
| 233 | FBT_DEPTH = 0x2,
|
---|
| 234 | FBT_STENCIL = 0x4
|
---|
| 235 | };
|
---|
| 236 |
|
---|
| 237 |
|
---|
| 238 | typedef std::vector<Light*> LightList;
|
---|
| 239 |
|
---|
| 240 | typedef std::map<String, bool> UnaryOptionList;
|
---|
| 241 | typedef std::map<String, String> BinaryOptionList;
|
---|
| 242 |
|
---|
| 243 | /// Name / value parameter pair (first = name, second = value)
|
---|
| 244 | typedef std::map<String, String> NameValuePairList;
|
---|
| 245 |
|
---|
| 246 | /// Alias / Texture name pair (first = alias, second = texture name)
|
---|
| 247 | typedef std::map<String, String> AliasTextureNamePairList;
|
---|
| 248 |
|
---|
| 249 | template< typename T > struct TRect
|
---|
| 250 | {
|
---|
| 251 | T left, top, right, bottom;
|
---|
| 252 | TRect() {}
|
---|
| 253 | TRect( T const & l, T const & t, T const & r, T const & b )
|
---|
| 254 | : left( l ), top( t ), right( r ), bottom( b )
|
---|
| 255 | {
|
---|
| 256 | }
|
---|
| 257 | TRect( TRect const & o )
|
---|
| 258 | : left( o.left ), top( o.top ), right( o.right ), bottom( o.bottom )
|
---|
| 259 | {
|
---|
| 260 | }
|
---|
| 261 | TRect & operator=( TRect const & o )
|
---|
| 262 | {
|
---|
| 263 | left = o.left;
|
---|
| 264 | top = o.top;
|
---|
| 265 | right = o.right;
|
---|
| 266 | bottom = o.bottom;
|
---|
| 267 | return *this;
|
---|
| 268 | }
|
---|
| 269 | T width() const
|
---|
| 270 | {
|
---|
| 271 | return right - left;
|
---|
| 272 | }
|
---|
| 273 | T height() const
|
---|
| 274 | {
|
---|
| 275 | return bottom - top;
|
---|
| 276 | }
|
---|
| 277 | };
|
---|
| 278 |
|
---|
| 279 | /** Structure used to define a rectangle in a 2-D floating point space.
|
---|
| 280 | */
|
---|
| 281 | typedef TRect<float> FloatRect;
|
---|
| 282 |
|
---|
| 283 | /** Structure used to define a rectangle in a 2-D integer space.
|
---|
| 284 | */
|
---|
| 285 | typedef TRect< long > Rect;
|
---|
| 286 |
|
---|
| 287 | /** Structure used to define a box in a 3-D integer space.
|
---|
| 288 | Note that the left, top, and front edges are included but the right,
|
---|
| 289 | bottom and top ones are not.
|
---|
| 290 | */
|
---|
| 291 | struct Box
|
---|
| 292 | {
|
---|
| 293 | size_t left, top, right, bottom, front, back;
|
---|
| 294 | /// Parameterless constructor for setting the members manually
|
---|
| 295 | Box()
|
---|
| 296 | {
|
---|
| 297 | }
|
---|
| 298 | /** Define a box from left, top, right and bottom coordinates
|
---|
| 299 | This box will have depth one (front=0 and back=1).
|
---|
| 300 | @param l x value of left edge
|
---|
| 301 | @param t y value of top edge
|
---|
| 302 | @param r x value of right edge
|
---|
| 303 | @param b y value of bottom edge
|
---|
| 304 | @note Note that the left, top, and front edges are included
|
---|
| 305 | but the right, bottom and top ones are not.
|
---|
| 306 | */
|
---|
| 307 | Box( size_t l, size_t t, size_t r, size_t b ):
|
---|
| 308 | left(l),
|
---|
| 309 | top(t),
|
---|
| 310 | right(r),
|
---|
| 311 | bottom(b),
|
---|
| 312 | front(0),
|
---|
| 313 | back(1)
|
---|
| 314 | {
|
---|
| 315 | assert(right >= left && bottom >= top && back >= front);
|
---|
| 316 | }
|
---|
| 317 | /** Define a box from left, top, front, right, bottom and back
|
---|
| 318 | coordinates.
|
---|
| 319 | @param l x value of left edge
|
---|
| 320 | @param t y value of top edge
|
---|
| 321 | @param ff z value of front edge
|
---|
| 322 | @param r x value of right edge
|
---|
| 323 | @param b y value of bottom edge
|
---|
| 324 | @param bb z value of back edge
|
---|
| 325 | @note Note that the left, top, and front edges are included
|
---|
| 326 | but the right, bottom and top ones are not.
|
---|
| 327 | */
|
---|
| 328 | Box( size_t l, size_t t, size_t ff, size_t r, size_t b, size_t bb ):
|
---|
| 329 | left(l),
|
---|
| 330 | top(t),
|
---|
| 331 | right(r),
|
---|
| 332 | bottom(b),
|
---|
| 333 | front(ff),
|
---|
| 334 | back(bb)
|
---|
| 335 | {
|
---|
| 336 | assert(right >= left && bottom >= top && back >= front);
|
---|
| 337 | }
|
---|
| 338 |
|
---|
| 339 | /// Return true if the other box is a part of this one
|
---|
| 340 | bool contains(const Box &def) const
|
---|
| 341 | {
|
---|
| 342 | return (def.left >= left && def.top >= top && def.front >= front &&
|
---|
| 343 | def.right <= right && def.bottom <= bottom && def.back <= back);
|
---|
| 344 | }
|
---|
| 345 |
|
---|
| 346 | /// Get the width of this box
|
---|
| 347 | size_t getWidth() const { return right-left; }
|
---|
| 348 | /// Get the height of this box
|
---|
| 349 | size_t getHeight() const { return bottom-top; }
|
---|
| 350 | /// Get the depth of this box
|
---|
| 351 | size_t getDepth() const { return back-front; }
|
---|
| 352 | };
|
---|
| 353 |
|
---|
| 354 |
|
---|
| 355 |
|
---|
| 356 | /** Locate command-line options of the unary form '-blah' and of the
|
---|
| 357 | binary form '-blah foo', passing back the index of the next non-option.
|
---|
| 358 | @param numargs, argv The standard parameters passed to the main method
|
---|
| 359 | @param unaryOptList Map of unary options (ie those that do not require a parameter).
|
---|
| 360 | Should be pre-populated with, for example '-e' in the key and false in the
|
---|
| 361 | value. Options which are found will be set to true on return.
|
---|
| 362 | @param binOptList Map of binnary options (ie those that require a parameter
|
---|
| 363 | e.g. '-e afile.txt').
|
---|
| 364 | Should be pre-populated with, for example '-e' and the default setting.
|
---|
| 365 | Options which are found will have the value updated.
|
---|
| 366 | */
|
---|
| 367 | int _OgreExport findCommandLineOpts(int numargs, char** argv, UnaryOptionList& unaryOptList,
|
---|
| 368 | BinaryOptionList& binOptList);
|
---|
| 369 |
|
---|
| 370 | }
|
---|
| 371 |
|
---|
| 372 | #endif
|
---|