source: GTP/trunk/Lib/Geom/shared/GTGeometry/include/GeoMeshSaver.h @ 2341

Revision 2341, 3.2 KB checked in by gumbau, 17 years ago (diff)
Line 
1/*=======================================================================
2 *      (C) 2005 Universitat Jaume I
3 *=======================================================================
4 *      PROYECT:        GAME TOOLS
5 *=======================================================================
6 *      CONTENT:       
7 *
8 *
9 *      @file   GeoMeshSaver.h
10 *=======================================================================*/
11
12#ifndef __GEO_MESH_SAVER__
13#define __GEO_MESH_SAVER__
14
15#include        <GeoMeshLoader.h>
16
17namespace Geometry
18{
19        //      Saves a Mesh.
20        class   GeoMeshSaver
21        {
22                private:
23
24                        //      The mesh to write.
25                        Mesh    *mGeoMesh;
26                       
27                        //      Mesh Bounds.
28                        //GeometryBounds        mMeshBounds;
29                       
30                        //      Write in the file.
31                        Serializer      *mSerializer;
32
33                        //      Flag that indicate if the mesh
34                        //      is skeletally animated or not.
35                        bool    mSkeletallyAnimated;
36                       
37                        //      Write the main mesh.
38                        void    writeMesh(Mesh  *geoMesh);
39
40                        //      Write a submesh.
41                        void    writeSubMesh(SubMesh    *geoSubMesh);
42
43                        // Operation type
44                        void    writeSubMeshOperation(const     SubMesh *geoSubMesh);
45                       
46                        //      Write geometry.
47                        void    writeGeometry(VertexBuffer      *vertexBuffer);
48
49                        //      Write Mesh Bounds.
50                        void    writeMeshBounds(Mesh    *geoMesh);
51
52                        // Write submesh name table.
53                        void    writeSubMeshNameTable(Mesh      *geoMesh);
54       
55                        //      Calculate the mesh size in bytes.
56                        size_t  calcMeshSize(const Mesh *geoMesh);
57
58                        //      Calculate the size in bytes for the submesh.
59                        size_t  calcSubMeshSize(const SubMesh   *geoSubMesh);
60
61                        //      Calculate the geometry size in bytes.
62                        size_t  calcGeometrySize(const VertexBuffer* vertexBuffer);
63
64                        //      Calculate the skeleton link size in bytes.
65                        size_t  calcSkeletonLinkSize(const Mesh *geoMesh);
66
67                        //      Write the file header.
68                        void    writeFileHeader(void);
69
70                        //      Write a header chunk given.
71                        void    writeChunkHeader(       unsigned short  id,
72                                                                                                                        unsigned long           count);
73
74                        //      Write integers into the file.
75                        void    writeInts(unsigned long id,
76                                                                                        unsigned long   size);
77
78                        //      Write shorts into the file
79                        void    writeShorts(unsigned short      id,
80                                                                                                unsigned long           count);
81
82                        //      Write float into the file.
83                        void    writeFloats(float                                               id,
84                                                                                                unsigned long           count);
85
86                        //      Write a string into the file.
87                        void    writeString(const       String  &string);
88
89                        //      Write booleans into the file.
90                        void    writeBools(     const bool id,
91                                                                                                unsigned        long            count);
92
93                        //      Write skeleton name.
94                        void    writeSkeletonLink(const String  &string);
95
96                        void    writeMeshBoneAssignment(const VertexBoneAssignment& assign);
97
98                        void    writeSubMeshBoneAssignment(const VertexBoneAssignment& assign);
99
100                        //      unnormalize geometry model.
101                        void    unnormalizeModel(Mesh   *geoMesh);
102                       
103                public:
104
105                        //      Constructors.
106                        GeoMeshSaver();
107
108                        //      Destroyer.
109                        ~GeoMeshSaver();
110
111                        //      Sets the material of the mesh.
112                        void    setMaterialName(String  materialName);
113
114                        //      Gets the material of the mesh.
115                        String  getMaterialName();
116                       
117                        //      Saves a Mesh into a file.
118                        size_t  save(Mesh       *geoMesh,       const   char    *fileNameMesh);
119
120                        // temporal members used to tweak the lodtree leaf submesh
121                        int leavesSubMesh;
122                        VertexBuffer *leavesVB;
123                        Index *indices;
124                        int numindices;
125        };
126}
127#endif
128
Note: See TracBrowser for help on using the repository browser.