Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

OgreMesh.h

Go to the documentation of this file.
00001 /*
00002 -----------------------------------------------------------------------------
00003 This source file is part of OGRE
00004     (Object-oriented Graphics Rendering Engine)
00005 For the latest info, see http://ogre.sourceforge.net/
00006 
00007 Copyright © 2000-2002 The OGRE Team
00008 Also see acknowledgements in Readme.html
00009 
00010 This program is free software; you can redistribute it and/or modify it under
00011 the terms of the GNU Lesser General Public License as published by the Free Software
00012 Foundation; either version 2 of the License, or (at your option) any later
00013 version.
00014 
00015 This program is distributed in the hope that it will be useful, but WITHOUT
00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
00018 
00019 You should have received a copy of the GNU Lesser General Public License along with
00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
00022 http://www.gnu.org/copyleft/lesser.txt.
00023 -----------------------------------------------------------------------------
00024 */
00025 #ifndef __Mesh_H__
00026 #define __Mesh_H__
00027 
00028 #include "OgrePrerequisites.h"
00029 
00030 #include "OgreResource.h"
00031 #include "OgreGeometryData.h"
00032 #include "OgreAxisAlignedBox.h"
00033 #include "OgreVertexBoneAssignment.h"
00034 #include "OgreAnimationState.h"
00035 #include "OgreIteratorWrappers.h"
00036 #include "OgreProgressiveMesh.h"
00037 
00038 
00039 namespace Ogre {
00040 
00041 
00042 
00078     class _OgreExport Mesh: public Resource
00079     {
00080         friend class MeshSerializer;
00081     public:
00086         Mesh(String name);
00087         ~Mesh();
00088 
00091         virtual void load(void);
00092 
00095         virtual void unload(void);
00096 
00097         // NB All methods below are non-virtual since they will be
00098         // called in the rendering loop - speed is of the essence.
00099 
00106         SubMesh* createSubMesh(void);
00107 
00110         unsigned short getNumSubMeshes(void) const;
00111 
00114         SubMesh* getSubMesh(unsigned short index) const;
00115 
00130         GeometryData sharedGeometry;
00131 
00139         void setManuallyDefined(bool manuallyDefined);
00140 
00146         Mesh* clone(String newName);
00147 
00150         const AxisAlignedBox& getBounds(void);
00151 
00154         void _dumpContents(String filename);
00155         void _dumpGeometry(GeometryData& g, std::ofstream& of);
00156 
00161         void _updateBounds(void);
00162 
00171         void _setBounds(const AxisAlignedBox& bounds);
00172 
00183         void setSkeletonName(const String& skelName);
00184 
00186         bool hasSkeleton(void) const;
00187 
00189         Skeleton* getSkeleton(void) const;
00190 
00192         const String& getSkeletonName(void) const;
00197         void _initAnimationState(AnimationStateSet* animSet);
00198 
00211         void addBoneAssignment(const VertexBoneAssignment& vertBoneAssign);
00212 
00218         void clearBoneAssignments(void);
00219 
00224         unsigned short _getNumBoneMatrices(void);
00225 
00232         void _getBoneMatrices(const AnimationStateSet& animSet, Matrix4* pMatrices);
00233 
00240         void _notifySkeleton(Skeleton* pSkel);
00241 
00243         typedef std::multimap<unsigned short, VertexBoneAssignment> VertexBoneAssignmentList;
00244         typedef MapIterator<VertexBoneAssignmentList> BoneAssignmentIterator;
00245 
00248         BoneAssignmentIterator getBoneAssignmentIterator(void);
00249 
00250 
00252         struct MeshLodUsage
00253         {
00255             Real fromDepthSquared;
00257             String manualName;
00259             mutable Mesh* manualMesh;
00260         };
00261 
00262         typedef std::vector<Real> LodDistanceList;
00286         void generateLodLevels(const LodDistanceList& lodDistances, 
00287             ProgressiveMesh::VertexReductionQuota reductionMethod, Real reductionValue);
00288 
00293         ushort getNumLodLevels(void) const;
00295         const MeshLodUsage& getLodLevel(ushort index) const;
00309         void createManualLodLevel(Real fromDepth, const String& meshName);
00310 
00318         void updateManualLodLevel(ushort index, const String& meshName);
00319 
00322         ushort getLodIndex(Real depth) const;
00323 
00330         ushort getLodIndexSquaredDepth(Real squaredDepth) const;
00331 
00338         bool isLodManual(void) const { return mIsLodManual; }
00339 
00341         void _setLodInfo(unsigned short numLevels, bool isManual);
00343         void _setLodUsage(unsigned short level, Mesh::MeshLodUsage& usage);
00345         void _setSubMeshLodFaceList(unsigned short subIdx, unsigned short level, ProgressiveMesh::LODFaceData& facedata);
00346     private:
00347         typedef std::vector<SubMesh*> SubMeshList;
00354         SubMeshList mSubMeshList;
00355 
00357         AxisAlignedBox mAABB;
00358 
00359         bool mManuallyDefined;
00360 
00363         void cloneGeometry(GeometryData& source, GeometryData& dest);
00364 
00366         bool mUpdateBounds;
00367 
00369         String mSkeletonName;
00370         Skeleton* mSkeleton;
00371 
00372        
00373         VertexBoneAssignmentList mBoneAssignments;
00374 
00376         bool mBoneAssignmentsOutOfDate;
00378         void compileBoneAssignments(void);
00379 
00380         bool mIsLodManual;
00381         ushort mNumLods;
00382         typedef std::vector<MeshLodUsage> MeshLodUsageList;
00383         MeshLodUsageList mMeshLodUsageList;
00384 
00385 
00386     };
00387 
00388 
00389 } // namespace
00390 
00391 #endif

Copyright © 2002 by The OGRE Team