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 | };
|
---|
146 |
|
---|
147 | /** The broad type of detail for rendering. */
|
---|
148 | enum SceneDetailLevel
|
---|
149 | {
|
---|
150 | /// Only points are rendered.
|
---|
151 | SDL_POINTS = 1,
|
---|
152 | /// Wireframe models are rendered.
|
---|
153 | SDL_WIREFRAME = 2,
|
---|
154 | /// Solid polygons are rendered.
|
---|
155 | SDL_SOLID = 3
|
---|
156 | };
|
---|
157 |
|
---|
158 | /** An enumeration of broad shadow techniques */
|
---|
159 | enum ShadowTechnique
|
---|
160 | {
|
---|
161 | /** No shadows */
|
---|
162 | SHADOWTYPE_NONE,
|
---|
163 | /** Stencil shadow technique which renders all shadow volumes as
|
---|
164 | a modulation after all the non-transparent areas have been
|
---|
165 | rendered. This technique is considerably less fillrate intensive
|
---|
166 | than the additive stencil shadow approach when there are multiple
|
---|
167 | lights, but is not an accurate model.
|
---|
168 | */
|
---|
169 | SHADOWTYPE_STENCIL_MODULATIVE,
|
---|
170 | /** Stencil shadow technique which renders each light as a separate
|
---|
171 | additive pass to the scene. This technique can be very fillrate
|
---|
172 | intensive because it requires at least 2 passes of the entire
|
---|
173 | scene, more if there are multiple lights. However, it is a more
|
---|
174 | accurate model than the modulative stencil approach and this is
|
---|
175 | especially apparant when using coloured lights or bump mapping.
|
---|
176 | */
|
---|
177 | SHADOWTYPE_STENCIL_ADDITIVE,
|
---|
178 | /** Texture-based shadow technique which involves a monochrome render-to-texture
|
---|
179 | of the shadow caster and a projection of that texture onto the
|
---|
180 | shadow receivers as a modulative pass.
|
---|
181 | */
|
---|
182 | SHADOWTYPE_TEXTURE_MODULATIVE
|
---|
183 | };
|
---|
184 |
|
---|
185 | /** An enumeration describing which material properties should track the vertex colours */
|
---|
186 | typedef int TrackVertexColourType;
|
---|
187 | enum TrackVertexColourEnum {
|
---|
188 | TVC_NONE = 0x0,
|
---|
189 | TVC_AMBIENT = 0x1,
|
---|
190 | TVC_DIFFUSE = 0x2,
|
---|
191 | TVC_SPECULAR = 0x4,
|
---|
192 | TVC_EMISSIVE = 0x8
|
---|
193 | };
|
---|
194 |
|
---|
195 | typedef std::vector<Light*> LightList;
|
---|
196 |
|
---|
197 | typedef std::map<String, bool> UnaryOptionList;
|
---|
198 | typedef std::map<String, String> BinaryOptionList;
|
---|
199 |
|
---|
200 | /// Name / value parameter pair (first = name, second = value)
|
---|
201 | typedef std::map<String, String> NameValuePairList;
|
---|
202 |
|
---|
203 | /** Structure used to define a rectangle in a 2-D integer space.
|
---|
204 | */
|
---|
205 | struct Rect
|
---|
206 | {
|
---|
207 | long left, top, right, bottom;
|
---|
208 |
|
---|
209 | Rect()
|
---|
210 | {
|
---|
211 | }
|
---|
212 | Rect( long l, long t, long r, long b )
|
---|
213 | {
|
---|
214 | left = l;
|
---|
215 | top = t;
|
---|
216 | right = r;
|
---|
217 | bottom = b;
|
---|
218 | }
|
---|
219 | Rect& operator = ( const Rect& other )
|
---|
220 | {
|
---|
221 | left = other.left;
|
---|
222 | top = other.top;
|
---|
223 | right = other.right;
|
---|
224 | bottom = other.bottom;
|
---|
225 |
|
---|
226 | return *this;
|
---|
227 | }
|
---|
228 | };
|
---|
229 |
|
---|
230 | /** Structure used to define a box in a 3-D integer space.
|
---|
231 | Note that the left, top, and front edges are included but the right,
|
---|
232 | bottom and top ones are not.
|
---|
233 | */
|
---|
234 | struct Box
|
---|
235 | {
|
---|
236 | size_t left, top, right, bottom, front, back;
|
---|
237 | /// Parameterless constructor for setting the members manually
|
---|
238 | Box()
|
---|
239 | {
|
---|
240 | }
|
---|
241 | /** Define a box from left, top, right and bottom coordinates
|
---|
242 | This box will have depth one (front=0 and back=1).
|
---|
243 | @param l x value of left edge
|
---|
244 | @param t y value of top edge
|
---|
245 | @param r x value of right edge
|
---|
246 | @param b y value of bottom edge
|
---|
247 | @note Note that the left, top, and front edges are included
|
---|
248 | but the right, bottom and top ones are not.
|
---|
249 | */
|
---|
250 | Box( size_t l, size_t t, size_t r, size_t b ):
|
---|
251 | left(l),
|
---|
252 | top(t),
|
---|
253 | right(r),
|
---|
254 | bottom(b),
|
---|
255 | front(0),
|
---|
256 | back(1)
|
---|
257 | {
|
---|
258 | assert(right >= left && bottom >= top && back >= front);
|
---|
259 | }
|
---|
260 | /** Define a box from left, top, front, right, bottom and back
|
---|
261 | coordinates.
|
---|
262 | @param l x value of left edge
|
---|
263 | @param t y value of top edge
|
---|
264 | @param ff z value of front edge
|
---|
265 | @param r x value of right edge
|
---|
266 | @param b y value of bottom edge
|
---|
267 | @param bb z value of back edge
|
---|
268 | @note Note that the left, top, and front edges are included
|
---|
269 | but the right, bottom and top ones are not.
|
---|
270 | */
|
---|
271 | Box( size_t l, size_t t, size_t ff, size_t r, size_t b, size_t bb ):
|
---|
272 | left(l),
|
---|
273 | top(t),
|
---|
274 | right(r),
|
---|
275 | bottom(b),
|
---|
276 | front(ff),
|
---|
277 | back(bb)
|
---|
278 | {
|
---|
279 | assert(right >= left && bottom >= top && back >= front);
|
---|
280 | }
|
---|
281 |
|
---|
282 | /// Return true if the other box is a part of this one
|
---|
283 | bool contains(const Box &def) const
|
---|
284 | {
|
---|
285 | return (def.left >= left && def.top >= top && def.front >= front &&
|
---|
286 | def.right <= right && def.bottom <= bottom && def.back <= back);
|
---|
287 | }
|
---|
288 |
|
---|
289 | /// Get the width of this box
|
---|
290 | size_t getWidth() const { return right-left; }
|
---|
291 | /// Get the height of this box
|
---|
292 | size_t getHeight() const { return bottom-top; }
|
---|
293 | /// Get the depth of this box
|
---|
294 | size_t getDepth() const { return back-front; }
|
---|
295 | };
|
---|
296 |
|
---|
297 |
|
---|
298 |
|
---|
299 | /** Locate command-line options of the unary form '-blah' and of the
|
---|
300 | binary form '-blah foo', passing back the index of the next non-option.
|
---|
301 | @param numargs, argv The standard parameters passed to the main method
|
---|
302 | @param unaryOptList Map of unary options (ie those that do not require a parameter).
|
---|
303 | Should be pre-populated with, for example '-e' in the key and false in the
|
---|
304 | value. Options which are found will be set to true on return.
|
---|
305 | @param binOptList Map of binnary options (ie those that require a parameter
|
---|
306 | e.g. '-e afile.txt').
|
---|
307 | Should be pre-populated with, for example '-e' and the default setting.
|
---|
308 | Options which are found will have the value updated.
|
---|
309 | */
|
---|
310 | int _OgreExport findCommandLineOpts(int numargs, char** argv, UnaryOptionList& unaryOptList,
|
---|
311 | BinaryOptionList& binOptList);
|
---|
312 |
|
---|
313 | }
|
---|
314 |
|
---|
315 | #endif
|
---|