/* ========================================================================== * (C) 2005 Universitat Jaume I * ========================================================================== * PROYECT: GAME TOOLS * =========================================================================*/ /** CONTENT: * * * @file GeoMeshSaver.h /*===========================================================================*/ #ifndef __GEO_MESH_SAVER__ #define __GEO_MESH_SAVER__ #include namespace Geometry { // Saves a Mesh. class GeoMeshSaver { private: // The mesh to write. Mesh *mGeoMesh; // Mesh Bounds. GeometryBounds mMeshBounds; // Write in the file. Serializer *mSerializer; // Flag that indicate if the mesh // is skeletally animated or not. bool mSkeletallyAnimated; // Material of the mesh. String mMaterialName; // Write the main mesh. void writeMesh(Mesh *geoMesh); // Write a submesh. void writeSubMesh(SubMesh *geoSubMesh); // Operation type void writeSubMeshOperation(const SubMesh *geoSubMesh); // Write geometry. void writeGeometry(VertexBuffer *vertexBuffer); // TODO: Write Mesh Bounds. void writeMeshBounds(GeometryBounds bounds); // Calc the mesh size in bytes. size_t calcMeshSize(const Mesh *geoMesh); // Calc the size in bytes for the submesh. size_t calcSubMeshSize(const SubMesh *geoSubMesh); // Calc the geometry size in bytes. size_t calcGeometrySize(const VertexBuffer* vertexBuffer); // Write the file header. void writeFileHeader(void); // Write a header chunk given. void writeChunkHeader( unsigned short id, unsigned long count); // Write integers into the file. void writeInts(unsigned long id, unsigned long size); // Write shorts into the file void writeShorts(unsigned short id, unsigned long count); // Write float into the file. void writeFloats(float id, unsigned long count); // Write a string into the file. void writeString(const String &string); // Write booleans into the file. void writeBools( const bool id, unsigned long count); public: // Constructors. GeoMeshSaver(); GeoMeshSaver(GeometryBounds bounds); // Destroyer. ~GeoMeshSaver(); // Sets the material of the mesh. void setMaterialName(String materialName); // Gets the material of the mesh. String getMaterialName(); // Set Mesh Bounds. void setMeshBounds(GeometryBounds bounds); // Saves a Mesh into a file. int save(Mesh *geoMesh, const char *fileNameMesh); }; } #endif