Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/ogre/OgreMain/include/OgreCommon.h @ 17

Last change on this file since 17 was 5, checked in by anonymous, 17 years ago

=hoffentlich gehts jetzt

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