Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

# KeosModel.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_MODEL_H
    00022 #define KEOS_MODEL_H
    00023
    00024 #include "KeosPrerequisites.h"
    00025 #include "KeosResource.h"
    00026 #include "KeosDeclaration.h"
    00027 #include "KeosBuffer.h"
    00028 #include "KeosTexture.h"
    00029
    00030 namespace Keos
    00031 {
    00032     //-----------------------------------------------------------------------
    00037     class KEOS_EXPORT CModel : public IResource
    00038     {
    00039     public :
    00040
    00042         struct TVertex
    00043         {
    00044             TVector3F     Position;
    00045             TVector3F     Normal;
    00046             ulong         Color;
    00047             TVector2F     TexCoords;
    00048         };
    00050         typedef ushort TIndex;
    00051
    00059         CModel(const TVertex* pVertices, ulong nVerticesCount, const TIndex* pIndices, ulong nIndicesCount, const String& strTexture);
    00060
    00061         CModel(const TVertex* pVertices, ulong nVerticesCount, const TIndex* pIndices, ulong nIndicesCount, CImage* pImage);
    00062
    00065         ~CModel();
    00066
    00069         void Render() const;
    00070
    00074         CTexture* GetTexture()
    00075         { return m_pTexture; }
    00076
    00080         void SetTexture(const String& strTexture)
    00081         {
    00082             if (strTexture != "")
    00083             {
    00084                 KEOS_DELETE(m_pTexture);
    00085                 m_pTexture = new CTexture();
    00086                 m_pTexture->CreateFromFile(strTexture, PXF_A8R8G8B8);
    00087             }
    00088         }
    00089
    00090     private :
    00091
    00093         CDeclarationPtr  m_pDeclaration;
    00095         CBuffer<TVertex> m_VertexBuffer;
    00097         CBuffer<TIndex>  m_IndexBuffer;
    00099         CTexture*        m_pTexture;
    00100     };
    00101
    00103     typedef CSmartPtr<CModel, CCOMRefCounted> TModelPtr;
    00104
    00105 } // namespace Keos
    00106
    00107
    00108 #endif // KEOS_MODEL_H