Crystal Space: cstool/importkit.h Source File (Crystal Space Public API Reference)

| ## Public API Reference

- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages

- File List
- File Members

# cstool/importkit.h

Go to the documentation of this file.

    00001 /*
    00002     Copyright (C) 2005 by Jorrit Tyberghein
    00003               (C) 2005 by Frank Richter
    00004
    00005     This library is free software; you can redistribute it and/or
    00006     modify it under the terms of the GNU Library General Public
    00007     License as published by the Free Software Foundation; either
    00008     version 2 of the License, or (at your option) any later version.
    00009
    00010     This library is distributed in the hope that it will be useful,
    00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
    00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00013     Library General Public License for more details.
    00014
    00015     You should have received a copy of the GNU Library General Public
    00016     License along with this library; if not, write to the Free
    00017     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    00018 */
    00019
    00020 #ifndef __CS_CSTOOL_IMPORTKIT_H__
    00021 #define __CS_CSTOOL_IMPORTKIT_H__
    00022
    00027 #include "cssysdef.h"
    00028 #include "csextern.h"
    00029 #include "csutil/array.h"
    00030
    00031 struct iObjectRegistry;
    00032
    00033 namespace CS
    00034 {
    00039   namespace ImportKitImpl
    00040   {
    00041     class Glue;
    00042     struct GluedModel;
    00043   }
    00044
    00050   class CS_CRYSTALSPACE_EXPORT ImportKit
    00051   {
    00052     ImportKitImpl::Glue* glue;
    00053   public:
    00057     class CS_CRYSTALSPACE_EXPORT Container
    00058     {
    00059     public:
    00067       class CS_CRYSTALSPACE_EXPORT Model
    00068       {
    00069       public:
    00071         const wchar_t* GetName () const { return name; }
    00072
    00074         class CS_CRYSTALSPACE_EXPORT Mesh
    00075         {
    00076         protected:
    00077           friend class Model;
    00078           friend class ImportKitImpl::Glue;
    00079
    00080           unsigned int vertexCount;
    00081           float* verts;
    00082           float* texcoords;
    00083           float* normals;
    00084           size_t triCount;
    00085           unsigned int* tris;
    00086           size_t material;
    00087         public:
    00089           unsigned int GetVertexCount () const { return vertexCount; }
    00094           const float* GetVertices () const { return verts; }
    00099           const float* GetTexCoords () const { return texcoords; }
    00104           const float* GetNormals () const { return normals; }
    00105
    00107           size_t GetTriangleCount () const { return triCount; }
    00112           const unsigned int* GetTriangles () const { return tris; }
    00113
    00118           size_t GetMaterial () const { return material; }
    00119         };
    00121         size_t GetMeshCount () const { return meshes.Length(); }
    00123         const Mesh& GetMesh (size_t index) const { return meshes[index]; }
    00124
    00125         ~Model();
    00126         Model (const Model& other);
    00127       protected:
    00128         friend class Container;
    00129         friend class ImportKitImpl::Glue;
    00130         wchar_t* name;
    00131         ImportKitImpl::GluedModel* glueModel;
    00132         csArray<Mesh> meshes;
    00133
    00134         Model () {}
    00135       };
    00137       size_t GetModelCount () const { return models.Length(); }
    00139       const Model& GetModel (size_t index) const { return models[index]; }
    00140
    00146       class CS_CRYSTALSPACE_EXPORT Material
    00147       {
    00148       protected:
    00149         friend class Container;
    00150         friend class ImportKitImpl::Glue;
    00151         wchar_t* name;
    00152         char* texture;
    00153
    00154         Material() {}
    00155       public:
    00157         const wchar_t* GetName () const { return name; }
    00161         const char* GetTextureFile () const { return texture; }
    00162
    00163         ~Material();
    00164         Material (const Material& other);
    00165       };
    00167       size_t GetMaterialCount () { return materials.Length(); }
    00169       const Material& GetMaterial (size_t index) { return materials[index]; }
    00170     protected:
    00171       friend class ImportKit;
    00172       friend class ImportKitImpl::Glue;
    00173       csArray<Model> models;
    00174       csArray<Material> materials;
    00175     };
    00176
    00178     ImportKit (iObjectRegistry* objectReg);
    00179     ~ImportKit ();
    00188     Container* OpenContainer (const char* filename,
    00189       const char* path = 0);
    00190   };
    00191
    00192 } // namespace CrystalSpace
    00193
    00194 #endif // __CS_CSTOOL_IMPORTKIT_H__