/* ========================================================================== * (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; // 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); // Write Mesh Bounds. void writeMeshBounds(Mesh *geoMesh); // Calculate the mesh size in bytes. size_t calcMeshSize(const Mesh *geoMesh); // Calculate the size in bytes for the submesh. size_t calcSubMeshSize(const SubMesh *geoSubMesh); // Calculate the geometry size in bytes. size_t calcGeometrySize(const VertexBuffer* vertexBuffer); // Calculate the skeleton link size in bytes. size_t calcSkeletonLinkSize(const Mesh *geoMesh); // 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); // Write skeleton name. void writeSkeletonLink(const String &string); void writeMeshBoneAssignment(const VertexBoneAssignment& assign); void writeSubMeshBoneAssignment(const VertexBoneAssignment& assign); // unnormalize geometry model. void unnormalizeModel(Mesh *geoMesh); public: // Constructors. GeoMeshSaver(); // Destroyer. ~GeoMeshSaver(); // Sets the material of the mesh. void setMaterialName(String materialName); // Gets the material of the mesh. String getMaterialName(); // Saves a Mesh into a file. size_t save(Mesh *geoMesh, const char *fileNameMesh); // temporal members used to tweak the lodtree leaf submesh int leavesSubMesh; VertexBuffer *leavesVB; Index *indices; int numindices; }; } #endif