00001 /* 00002 ----------------------------------------------------------------------------- 00003 This source file is part of OGRE 00004 (Object-oriented Graphics Rendering Engine) 00005 For the latest info, see http://www.ogre3d.org/ 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 "OgreVertexIndexData.h" 00032 #include "OgreAxisAlignedBox.h" 00033 #include "OgreVertexBoneAssignment.h" 00034 #include "OgreAnimationState.h" 00035 #include "OgreIteratorWrappers.h" 00036 #include "OgreProgressiveMesh.h" 00037 #include "OgreHardwareVertexBuffer.h" 00038 00039 00040 namespace Ogre { 00041 00042 00043 00079 class _OgreExport Mesh: public Resource 00080 { 00081 friend class MeshSerializerImpl; 00082 friend class MeshSerializerImpl_v1; 00083 friend class SubMesh; 00084 public: 00086 struct MeshLodUsage 00087 { 00089 Real fromDepthSquared; 00091 String manualName; 00093 mutable Mesh* manualMesh; 00094 }; 00095 00096 typedef std::vector<Real> LodDistanceList; 00098 typedef std::multimap<size_t, VertexBoneAssignment> VertexBoneAssignmentList; 00099 typedef MapIterator<VertexBoneAssignmentList> BoneAssignmentIterator; 00100 00101 protected: 00102 typedef std::vector<SubMesh*> SubMeshList; 00109 SubMeshList mSubMeshList; 00110 00112 HardwareVertexBufferSharedPtr getTangentsBuffer(VertexData *vertexData, unsigned short texCoordSet); 00113 00117 typedef HashMap<String, ushort, _StringHash> SubMeshNameMap ; 00118 SubMeshNameMap mSubMeshNameMap ; 00119 00121 AxisAlignedBox mAABB; 00123 Real mBoundRadius; 00124 00125 bool mManuallyDefined; 00126 00127 00129 //bool mUpdateBounds; 00130 00132 String mSkeletonName; 00133 Skeleton* mSkeleton; 00134 00135 00136 VertexBoneAssignmentList mBoneAssignments; 00137 00139 bool mBoneAssignmentsOutOfDate; 00140 00142 void compileBoneAssignmentsSoftware(const VertexBoneAssignmentList& boneAssignments, 00143 unsigned short numBlendWeightsPerVertex, VertexData* targetVertexData); 00145 void compileBoneAssignmentsHardware(const VertexBoneAssignmentList& boneAssignments, 00146 unsigned short numBlendWeightsPerVertex, VertexData* targetVertexData); 00147 00148 HardwareVertexBufferSharedPtr mBlendingVB; 00150 bool mUseSoftwareBlending; 00151 00152 bool mIsLodManual; 00153 ushort mNumLods; 00154 typedef std::vector<MeshLodUsage> MeshLodUsageList; 00155 MeshLodUsageList mMeshLodUsageList; 00156 00157 HardwareBuffer::Usage mVertexBufferUsage; 00158 HardwareBuffer::Usage mIndexBufferUsage; 00159 bool mVertexBufferShadowBuffer; 00160 bool mIndexBufferShadowBuffer; 00161 00162 public: 00167 Mesh(const String& name); 00168 ~Mesh(); 00169 00172 virtual void load(void); 00173 00176 virtual void unload(void); 00177 00178 // NB All methods below are non-virtual since they will be 00179 // called in the rendering loop - speed is of the essence. 00180 00187 SubMesh* createSubMesh(void); 00188 00191 SubMesh* createSubMesh(const String& name); 00192 00195 void nameSubMesh(const String& name, ushort index); 00196 00202 ushort _getSubMeshIndex(const String& name) const; 00203 00206 unsigned short getNumSubMeshes(void) const; 00207 00210 SubMesh* getSubMesh(unsigned short index) const; 00211 00214 SubMesh* getSubMesh(const String& name) const ; 00215 00224 VertexData *sharedVertexData; 00225 00233 void setManuallyDefined(bool manuallyDefined); 00234 00240 Mesh* clone(const String& newName); 00241 00244 const AxisAlignedBox& getBounds(void) const; 00245 00247 Real getBoundingSphereRadius(void) const; 00248 00264 void _setBounds(const AxisAlignedBox& bounds); 00265 00273 void _setBoundingSphereRadius(Real radius); 00274 00285 void setSkeletonName(const String& skelName); 00286 00288 bool hasSkeleton(void) const; 00289 00291 Skeleton* getSkeleton(void) const; 00292 00294 const String& getSkeletonName(void) const; 00299 void _initAnimationState(AnimationStateSet* animSet); 00300 00313 void addBoneAssignment(const VertexBoneAssignment& vertBoneAssign); 00314 00320 void clearBoneAssignments(void); 00321 00326 unsigned short _getNumBoneMatrices(void) const; 00327 00334 void _getBoneMatrices(const AnimationStateSet& animSet, Matrix4* pMatrices); 00335 00342 void _notifySkeleton(Skeleton* pSkel); 00343 00344 00347 BoneAssignmentIterator getBoneAssignmentIterator(void); 00348 00349 00373 void generateLodLevels(const LodDistanceList& lodDistances, 00374 ProgressiveMesh::VertexReductionQuota reductionMethod, Real reductionValue); 00375 00380 ushort getNumLodLevels(void) const; 00382 const MeshLodUsage& getLodLevel(ushort index) const; 00396 void createManualLodLevel(Real fromDepth, const String& meshName); 00397 00405 void updateManualLodLevel(ushort index, const String& meshName); 00406 00409 ushort getLodIndex(Real depth) const; 00410 00417 ushort getLodIndexSquaredDepth(Real squaredDepth) const; 00418 00425 bool isLodManual(void) const { return mIsLodManual; } 00426 00428 void _setLodInfo(unsigned short numLevels, bool isManual); 00430 void _setLodUsage(unsigned short level, Mesh::MeshLodUsage& usage); 00432 void _setSubMeshLodFaceList(unsigned short subIdx, unsigned short level, IndexData* facedata); 00433 00435 void removeLodLevels(void); 00436 00459 void setVertexBufferPolicy(HardwareBuffer::Usage usage, bool shadowBuffer = false); 00482 void setIndexBufferPolicy(HardwareBuffer::Usage usage, bool shadowBuffer = false); 00484 HardwareBuffer::Usage getVertexBufferUsage(void) const { return mVertexBufferUsage; } 00486 HardwareBuffer::Usage getIndexBufferUsage(void) const { return mIndexBufferUsage; } 00488 bool isVertexBufferShadowed(void) const { return mVertexBufferShadowBuffer; } 00490 bool isIndexBufferShadowed(void) const { return mIndexBufferShadowBuffer; } 00491 00492 00506 unsigned short _rationaliseBoneAssignments(size_t vertexCount, VertexBoneAssignmentList& assignments); 00507 00515 void _compileBoneAssignments(void); 00516 00534 void buildTangentVectors(unsigned short sourceTexCoordSet = 0, unsigned short destTexCoordSet = 1); 00535 }; 00536 00537 00538 } // namespace 00539 00540 #endif
Copyright © 2002-2003 by The OGRE Team
Last modified Wed Jan 21 00:10:18 2004