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

# OgreSubMesh.cpp

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://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 #include "OgreStableHeaders.h"
    00026 #include "OgreSubMesh.h"
    00027
    00028 #include "OgreMesh.h"
    00029 #include "OgreException.h"
    00030 #include "OgreMeshManager.h"
    00031
    00032 namespace Ogre {
    00033     //-----------------------------------------------------------------------
    00034     SubMesh::SubMesh()
    00035     {
    00036         useSharedVertices = true;
    00037         vertexData = NULL;
    00038         indexData = new IndexData();
    00039         mMatInitialised = false;
    00040         mBoneAssignmentsOutOfDate = false;
    00041         operationType = RenderOperation::OT_TRIANGLE_LIST;
    00042
    00043     }
    00044     //-----------------------------------------------------------------------
    00045     SubMesh::~SubMesh()
    00046     {
    00047         if (vertexData)
    00048         {
    00049             delete vertexData;
    00050         }
    00051         delete indexData;
    00052
    00053         removeLodLevels();
    00054     }
    00055
    00056     //-----------------------------------------------------------------------
    00057     void SubMesh::setMaterialName(const String& name)
    00058     {
    00059         mMaterialName = name;
    00060         mMatInitialised = true;
    00061     }
    00062     //-----------------------------------------------------------------------
    00063     const String& SubMesh::getMaterialName() const
    00064     {
    00065         return mMaterialName;
    00066     }
    00067     //-----------------------------------------------------------------------
    00068     bool SubMesh::isMatInitialised(void) const
    00069     {
    00070         return mMatInitialised;
    00071
    00072     }
    00073     //-----------------------------------------------------------------------
    00074     void SubMesh::_getRenderOperation(RenderOperation& ro, ushort lodIndex)
    00075     {
    00076
    00077         // SubMeshes always use indexes
    00078         ro.useIndexes = true;
    00079         if (lodIndex > 0 && static_cast< size_t >( lodIndex - 1 ) < mLodFaceList.size())
    00080         {
    00081             // lodIndex - 1 because we don't store full detail version in mLodFaceList
    00082             ro.indexData = mLodFaceList[lodIndex-1];
    00083         }
    00084         else
    00085         {
    00086             ro.indexData = indexData;
    00087         }
    00088         ro.operationType = operationType;
    00089         ro.vertexData = useSharedVertices? parent->sharedVertexData : vertexData;
    00090
    00091     }
    00092     //-----------------------------------------------------------------------
    00093     void SubMesh::addBoneAssignment(const VertexBoneAssignment& vertBoneAssign)
    00094     {
    00095         if (useSharedVertices)
    00096         {
    00097             Except(Exception::ERR_INVALIDPARAMS, "This SubMesh uses shared geometry,  you "
    00098                 "must assign bones to the Mesh, not the SubMesh", "SubMesh.addBoneAssignment");
    00099         }
    00100         mBoneAssignments.insert(
    00101             VertexBoneAssignmentList::value_type(vertBoneAssign.vertexIndex, vertBoneAssign));
    00102         mBoneAssignmentsOutOfDate = true;
    00103     }
    00104     //-----------------------------------------------------------------------
    00105     void SubMesh::clearBoneAssignments(void)
    00106     {
    00107         mBoneAssignments.clear();
    00108         mBoneAssignmentsOutOfDate = true;
    00109     }
    00110
    00111     //-----------------------------------------------------------------------
    00112     void SubMesh::_compileBoneAssignments(void)
    00113     {
    00114         unsigned short maxBones =
    00115             parent->_rationaliseBoneAssignments(vertexData->vertexCount, mBoneAssignments);
    00116
    00117         if (maxBones == 0)
    00118         {
    00119             // No bone assignments
    00120             return;
    00121         }
    00122
    00123         parent->compileBoneAssignments(mBoneAssignments, maxBones,
    00124             vertexData);
    00125
    00126         /*
    00127         if (parent->mUseSoftwareBlending)
    00128         {
    00129             parent->compileBoneAssignmentsSoftware(mBoneAssignments, maxBones, vertexData);
    00130         }
    00131         else
    00132         {
    00133             parent->compileBoneAssignmentsHardware(mBoneAssignments, maxBones, vertexData);
    00134         }
    00135         */
    00136
    00137         mBoneAssignmentsOutOfDate = false;
    00138     }
    00139     //---------------------------------------------------------------------
    00140     SubMesh::BoneAssignmentIterator SubMesh::getBoneAssignmentIterator(void)
    00141     {
    00142         return BoneAssignmentIterator(mBoneAssignments.begin(),
    00143             mBoneAssignments.end());
    00144     }
    00145     //---------------------------------------------------------------------
    00146     void SubMesh::removeLodLevels(void)
    00147     {
    00148         ProgressiveMesh::LODFaceList::iterator lodi, lodend;
    00149         lodend = mLodFaceList.end();
    00150         for (lodi = mLodFaceList.begin(); lodi != lodend; ++lodi)
    00151         {
    00152             delete *lodi;
    00153         }
    00154
    00155         mLodFaceList.clear();
    00156
    00157     }
    00158
    00159
    00160
    00161 }
    00162

Copyright © 2002-2003 by The OGRE Team
Last modified Sun Nov 28 19:48:48 2004