source: GTP/trunk/App/Demos/Geom/OgreStuff/include/OgreStaticFaceGroup.h @ 1812

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