KeosMeshGeom.h

Go to the documentation of this file.
00001 /*
00002  * This source file is part of KEOS (Free 3D Engine)
00003  * For the latest info, see http://www.keosengine.org/
00004  * E-mails : thierry.vouriot@keosengine.org, yeri@keosengine.org
00005  *
00006  * This program is free software; you can redistribute it and/or modify it under
00007  * the terms of the GNU Lesser General Public License as published by the Free Software
00008  * Foundation; either version 2 of the License, or (at your option) any later
00009  * version.
00010  *
00011  * This program is distributed in the hope that it will be useful, but WITHOUT
00012  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00013  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU Lesser General Public License along with
00016  * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
00017  * Place - Suite 330, Boston, MA 02111-1307, USA, or go to
00018  * http://www.gnu.org/copyleft/lesser.txt.
00019  *
00020  */
00021 #ifndef KEOS_MESHGEOM_H
00022 #define KEOS_MESHGEOM_H
00023 
00024 #include "KeosPrerequisites.h"
00025 #include "KeosDeclaration.h"
00026 #include "KeosBuffer.h"
00027 
00028 
00029 namespace Keos
00030 {     
00031 
00032   //-----------------------------------------------------------------------
00036   class KEOS_EXPORT CMeshGeom
00037   {
00038     friend class CMesh;
00039     friend class CAnimatedMeshKF;
00040 
00041   public :
00042 
00044     struct TVertex
00045     {
00046       TVector3F     Position;
00047       TVector3F     Normal;
00048       ulong         Color;
00049       TVector2F     TexCoords;
00050     };
00052     typedef ushort TIndex;
00053 
00060     CMeshGeom( const TVertex* pVertices,
00061                ulong nVerticesCount,
00062                const TIndex* pIndices,
00063                ulong nIndicesCount,
00064                TPrimitiveType PrimitiveType = PT_TRIANGLELIST);
00065 
00066 #if KEOS_MESH_SHARED_VERTEX_BUFFER
00067 
00071     CMeshGeom(const TIndex* pIndices, ulong nIndicesCount, TPrimitiveType PrimitiveType = PT_TRIANGLELIST);
00072 #endif
00073 
00076     ~CMeshGeom();
00077 
00080     uint GetTrianglesCount(void)
00081     { 
00082       return m_IndexBuffer.GetCount() / 3;
00083     }
00084 
00085 #if KEOS_DEBUG_MODE
00086 
00088     void SetMaterialIndex(int nIndex);
00089 #else // In release this function is inline
00090 
00092     void SetMaterialIndex(int nIndex)
00093     {
00094       m_nMaterialIndex = nIndex;
00095     }
00096 #endif
00097 
00100     int GetMaterialIndex(void)
00101     {
00102       return m_nMaterialIndex;
00103     }
00104 
00107     void AssignMaterialColor();
00108 
00111     void AssignColor(const CColor& Color);
00112 
00113   protected :
00114 
00116     CDeclarationPtr  m_pDeclaration;
00118     CBuffer<TVertex> m_VertexBuffer;
00120     CBuffer<TIndex>  m_IndexBuffer;
00121 
00123     TPrimitiveType m_PrimitiveType;
00125     int m_nPrimitivesCount;
00127     int GetPrimitivesCount(TPrimitiveType PrimitiveType);
00128 
00130     CMesh* m_pParentMesh;
00131 
00133     int m_nMaterialIndex;
00134 
00136     bool m_bUseSharedVertexBuffer;
00137   };
00138 
00140   typedef CSmartPtr<CMeshGeom, CRefCount> TMeshGeomPtr;
00141 
00143   typedef std::vector<CMeshGeom::TIndex>  TIndexList;
00145   typedef std::vector<CMeshGeom::TVertex> TVertexList;
00146 
00147 } // namespace Keos
00148 
00149 #endif // KEOS_MESHGEOM_H

Generated on Fri Mar 9 14:29:02 2007 for Keos by  doxygen 1.5.1-p1