CrystalSpace

Public API Reference

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 {
00035 namespace Utility
00036 {
00037 
00042   namespace Implementation 
00043   { 
00044     class Glue;
00045     struct GluedModel;
00046   }
00047 
00053   class CS_CRYSTALSPACE_EXPORT ImportKit
00054   {
00055     Implementation::Glue* glue;
00056   public:
00060     class CS_CRYSTALSPACE_EXPORT Container
00061     {
00062     public:
00070       class CS_CRYSTALSPACE_EXPORT Model
00071       {
00072       public:
00074         const wchar_t* GetName () const { return name; }
00075 
00077         class CS_CRYSTALSPACE_EXPORT Mesh
00078         {
00079         protected:
00080           friend class Model;
00081           friend class Implementation::Glue;
00082 
00083           unsigned int vertexCount;
00084           float* verts;
00085           float* texcoords;
00086           float* normals;
00087           size_t triCount;
00088           unsigned int* tris;
00089           size_t material;
00090         public:
00092           unsigned int GetVertexCount () const { return vertexCount; }
00097           const float* GetVertices () const { return verts; }
00102           const float* GetTexCoords () const { return texcoords; }
00107           const float* GetNormals () const { return normals; }
00108         
00110           size_t GetTriangleCount () const { return triCount; }
00115           const unsigned int* GetTriangles () const { return tris; }
00116 
00121           size_t GetMaterial () const { return material; }
00122         };
00124         size_t GetMeshCount () const { return meshes.GetSize (); }
00126         const Mesh& GetMesh (size_t index) const { return meshes[index]; }
00128         enum ModelType
00129         {
00131           Factory,
00133           Object
00134         };
00135         ModelType GetType () const { return type; }
00136 
00137         ~Model();
00138         Model (const Model& other);
00139       protected:
00140         friend class Container;
00141         friend class Implementation::Glue;
00142         wchar_t* name;
00143         Implementation::GluedModel* glueModel;
00144         csArray<Mesh> meshes;
00145         ModelType type;
00146 
00147         Model () : type (Factory) {}
00148       };
00150       size_t GetModelCount () const { return models.GetSize (); }
00152       const Model& GetModel (size_t index) const { return models[index]; }
00153     
00159       class CS_CRYSTALSPACE_EXPORT Material
00160       {
00161       protected:
00162         friend class Container;
00163         friend class Implementation::Glue;
00164         wchar_t* name;
00165         char* texture;
00166 
00167         Material() {}
00168       public:
00170         const wchar_t* GetName () const { return name; }
00174         const char* GetTextureFile () const { return texture; }
00175 
00176         ~Material();
00177         Material (const Material& other);
00178       };
00180       size_t GetMaterialCount () { return materials.GetSize (); }
00182       const Material& GetMaterial (size_t index) { return materials[index]; }
00183     protected:
00184       friend class ImportKit;
00185       friend class Implementation::Glue;
00186       csArray<Model> models;
00187       csArray<Material> materials;
00188     };
00189 
00191     ImportKit (iObjectRegistry* objectReg);
00192     ~ImportKit ();
00201     Container* OpenContainer (const char* filename, 
00202       const char* path = 0);
00203   };
00204   
00205 } // namespace Utility
00206   
00211   CS_DEPRECATED_TYPE_MSG("Use CS::Utility::ImportKit")
00212   typedef CS::Utility::ImportKit ImportKit;
00213 
00214 } // namespace CS
00215 
00216 #endif // __CS_CSTOOL_IMPORTKIT_H__

Generated for Crystal Space 1.2.1 by doxygen 1.5.3