source: GTP/trunk/App/Demos/Geom/OgreStuff/include/OgreSubMesh.h @ 1092

Revision 1092, 6.1 KB checked in by gumbau, 18 years ago (diff)

LodStrips? and LODTrees demos

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-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 __SubMesh_H_
26#define __SubMesh_H_
27
28#include "OgrePrerequisites.h"
29
30#include "OgreVertexIndexData.h"
31#include "OgreMaterial.h"
32#include "OgreRenderOperation.h"
33#include "OgreVertexBoneAssignment.h"
34#include "OgreProgressiveMesh.h"
35
36namespace Ogre {
37
38    /** Defines a part of a complete mesh.
39        @remarks
40            Meshes which make up the definition of a discrete 3D object
41            are made up of potentially multiple parts. This is because
42            different parts of the mesh may use different materials or
43            use different vertex formats, such that a rendering state
44            change is required between them.
45        @par
46            Like the Mesh class, instatiations of 3D objects in the scene
47            share the SubMesh instances, and have the option of overriding
48            their material differences on a per-object basis if required.
49            See the SubEntity class for more information.
50    */
51    class _OgreExport SubMesh
52    {
53        friend class Mesh;
54        friend class MeshSerializerImpl;
55        friend class MeshSerializerImpl_v1_2;
56        friend class MeshSerializerImpl_v1_1;
57    public:
58        SubMesh();
59        ~SubMesh();
60
61
62        /// Indicates if this submesh shares vertex data with other meshes or whether it has it's own vertices.
63        bool useSharedVertices;
64
65        /// The render operation type used to render this submesh
66        RenderOperation::OperationType operationType;
67
68        /** Dedicated vertex data (only valid if useSharedVertices = false).
69            @remarks
70                This data is completely owned by this submesh.
71            @par
72                The use of shared or non-shared buffers is determined when
73                model data is converted to the OGRE .mesh format.
74        */
75        VertexData *vertexData;
76
77        /// Face index data
78        IndexData *indexData;
79
80        ProgressiveMesh::LODFaceList mLodFaceList;
81
82        /// Reference to parent Mesh (not a smart pointer so child does not keep parent alive).
83        Mesh* parent;
84
85        /// Sets the name of the Material which this SubMesh will use
86        void setMaterialName(const String& matName);
87        const String& getMaterialName(void) const;
88
89        /** Returns true if a material has been assigned to the submesh, otherwise returns false.
90        */
91        bool isMatInitialised(void) const;
92
93        /** Returns a RenderOperation structure required to render this mesh.
94            @param
95                rend Reference to a RenderOperation structure to populate.
96            @param
97                lodIndex The index of the LOD to use.
98        */
99        void _getRenderOperation(RenderOperation& rend, ushort lodIndex = 0);
100
101        /** Assigns a vertex to a bone with a given weight, for skeletal animation.
102        @remarks   
103            This method is only valid after calling setSkeletonName.
104            Since this is a one-off process there exists only 'addBoneAssignment' and
105            'clearBoneAssignments' methods, no 'editBoneAssignment'. You should not need
106            to modify bone assignments during rendering (only the positions of bones) and OGRE
107            reserves the right to do some internal data reformatting of this information, depending
108            on render system requirements.
109        @par
110            This method is for assigning weights to the dedicated geometry of the SubMesh. To assign
111            weights to the shared Mesh geometry, see the equivalent methods on Mesh.
112        */
113        void addBoneAssignment(const VertexBoneAssignment& vertBoneAssign);
114
115        /** Removes all bone assignments for this mesh.
116        @par
117            This method is for assigning weights to the dedicated geometry of the SubMesh. To assign
118            weights to the shared Mesh geometry, see the equivalent methods on Mesh.
119        */
120        void clearBoneAssignments(void);
121
122        /// Multimap of verex bone assignments (orders by vertex index)
123        typedef std::multimap<size_t, VertexBoneAssignment> VertexBoneAssignmentList;
124        typedef MapIterator<VertexBoneAssignmentList> BoneAssignmentIterator;
125
126        /** Gets an iterator for access all bone assignments.
127        @remarks
128            Only valid if this SubMesh has dedicated geometry.
129        */
130        BoneAssignmentIterator getBoneAssignmentIterator(void);
131
132        /** Must be called once to compile bone assignments into geometry buffer. */
133        void _compileBoneAssignments(void);
134    protected:
135
136        /// Name of the material this SubMesh uses.
137        String mMaterialName;
138
139        /// Is there a material yet?
140        bool mMatInitialised;
141
142       
143        VertexBoneAssignmentList mBoneAssignments;
144
145        /// Flag indicating that bone assignments need to be recompiled
146        bool mBoneAssignmentsOutOfDate;
147
148        /// Internal method for removing LOD data
149        void removeLodLevels(void);
150
151
152
153    };
154
155} // namespace
156
157#endif
158
Note: See TracBrowser for help on using the repository browser.