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-2006 Torus Knot Software Ltd |
---|
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 | You may alternatively use this source under the terms of a specific version of |
---|
25 | the OGRE Unrestricted License provided you have obtained such a license from |
---|
26 | Torus Knot Software Ltd. |
---|
27 | ----------------------------------------------------------------------------- |
---|
28 | */ |
---|
29 | #ifndef __StaticFaceGroup_H__ |
---|
30 | #define __StaticFaceGroup_H__ |
---|
31 | |
---|
32 | #include "OgrePrerequisites.h" |
---|
33 | |
---|
34 | #include "OgrePlane.h" |
---|
35 | #include "OgrePatchSurface.h" |
---|
36 | |
---|
37 | namespace Ogre { |
---|
38 | |
---|
39 | /** A type of face group, ie face list of procedural etc */ |
---|
40 | enum FaceGroupType { |
---|
41 | FGT_FACE_LIST, |
---|
42 | FGT_PATCH, |
---|
43 | FGT_UNKNOWN |
---|
44 | }; |
---|
45 | |
---|
46 | /** Collectes a group of static ie immovable faces together which have common |
---|
47 | properties like the material they use, the plane they lie on. |
---|
48 | @remarks |
---|
49 | Whilst for discrete geometry (i.e. movable objects) groups of faces are |
---|
50 | held in the SubMesh class, for immovable objects like scenery there |
---|
51 | needs to ba little more flexibility in the grouping since the group is |
---|
52 | likely to be a small part of a huge set of geometry. In addition, because |
---|
53 | the faces are unmoving certain optimisations can be performed, e.g. |
---|
54 | precalculating a world-coordinate bounding box and normal. |
---|
55 | @par |
---|
56 | Exactly how this class is used depends on the format of the large |
---|
57 | static geometry used in the level. An example would be the use of this |
---|
58 | class in the BspNode class for indoor levels. |
---|
59 | For flexibility and efficiency, it is not assumed that this class holds |
---|
60 | details of the vertices itself, or in fact that it holds the vertex indices |
---|
61 | itself. Everything is manipulated via pointers so if you want this |
---|
62 | class to point into a block of geometry data it can. |
---|
63 | */ |
---|
64 | struct StaticFaceGroup { |
---|
65 | // Type of face group. |
---|
66 | FaceGroupType fType; |
---|
67 | |
---|
68 | /// Is this a sky surface? |
---|
69 | bool isSky; |
---|
70 | |
---|
71 | /** Index into a buffer containing vertex definitions. Because we're |
---|
72 | dealing with subsets of large levels this is likely to be part-way |
---|
73 | through a huge vertex buffer. */ |
---|
74 | int vertexStart; |
---|
75 | |
---|
76 | /** The range of vertices in the buffer this facegroup references. |
---|
77 | This is really for copying purposes only, so that we know which |
---|
78 | subset of vertices to copy from our large-level buffer into the rendering buffer. |
---|
79 | */ |
---|
80 | int numVertices; |
---|
81 | |
---|
82 | /** Index into a buffer containing vertex indices. This buffer |
---|
83 | may be individual to this group or shared for memory allocation |
---|
84 | efficiency.The vertex indexes are relative the the mVertexStart pointer, |
---|
85 | not to the start of the large-level buffer, allowing simple reindexing |
---|
86 | when copying data into rendering buffers. |
---|
87 | This is only applicable to FGT_FACE_LIST face group types. |
---|
88 | */ |
---|
89 | int elementStart; |
---|
90 | |
---|
91 | /** The number of vertex indices. |
---|
92 | This is only applicable to FGT_FACE_LIST face group types. |
---|
93 | */ |
---|
94 | int numElements; |
---|
95 | |
---|
96 | /** Handle to material used by this group. |
---|
97 | Note the use of the material handle rather than the material |
---|
98 | name - this is for efficiency since there will be many of these. |
---|
99 | */ |
---|
100 | int materialHandle; |
---|
101 | |
---|
102 | Plane plane; |
---|
103 | |
---|
104 | /// Patch surface (only applicable when fType = FGT_PATCH) |
---|
105 | PatchSurface* patchSurf; |
---|
106 | |
---|
107 | |
---|
108 | _OgreExport friend std::ostream& operator<<(std::ostream& o, const StaticFaceGroup& s) |
---|
109 | { |
---|
110 | o << "StaticFaceGroup("; |
---|
111 | if (s.fType == FGT_FACE_LIST) |
---|
112 | { |
---|
113 | o << "faceList, numVertices=" << s.numVertices << ", vertexStart=" << s.vertexStart; |
---|
114 | o << ", numElements=" << s.numElements << ", elementStart=" << s.elementStart; |
---|
115 | o << ", normal=" << s.plane.normal; |
---|
116 | } |
---|
117 | else if (s.fType == FGT_PATCH) |
---|
118 | { |
---|
119 | o << "bezierPatch, numVertices=" << s.numVertices << ", vertexStart=" << s.vertexStart; |
---|
120 | // TODO |
---|
121 | } |
---|
122 | |
---|
123 | o << ", materialHandle=" << s.materialHandle; |
---|
124 | o << ")"; |
---|
125 | |
---|
126 | return o; |
---|
127 | } |
---|
128 | |
---|
129 | |
---|
130 | }; |
---|
131 | |
---|
132 | } // namespace |
---|
133 | |
---|
134 | #endif |
---|