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 |
|
---|
17 | namespace Geometry
|
---|
18 | {
|
---|
19 | // Saves a Mesh.
|
---|
20 | class GeoMeshSaver
|
---|
21 | {
|
---|
22 | private:
|
---|
23 | // The mesh to write.
|
---|
24 | Mesh *mGeoMesh;
|
---|
25 |
|
---|
26 | // Mesh Bounds.
|
---|
27 | //GeometryBounds mMeshBounds;
|
---|
28 |
|
---|
29 | // Write in the file.
|
---|
30 | Serializer *mSerializer;
|
---|
31 |
|
---|
32 | // Flag that indicate if the mesh
|
---|
33 | // is skeletally animated or not.
|
---|
34 | bool mSkeletallyAnimated;
|
---|
35 |
|
---|
36 | // Write the main mesh.
|
---|
37 | void writeMesh(Mesh *geoMesh);
|
---|
38 |
|
---|
39 | // Write a submesh.
|
---|
40 | void writeSubMesh(SubMesh *geoSubMesh);
|
---|
41 |
|
---|
42 | // Operation type
|
---|
43 | void writeSubMeshOperation(const SubMesh *geoSubMesh);
|
---|
44 |
|
---|
45 | // Write geometry.
|
---|
46 | void writeGeometry(VertexBuffer *vertexBuffer);
|
---|
47 |
|
---|
48 | // Write Mesh Bounds.
|
---|
49 | void writeMeshBounds(Mesh *geoMesh);
|
---|
50 |
|
---|
51 | // Calculate the mesh size in bytes.
|
---|
52 | size_t calcMeshSize(const Mesh *geoMesh);
|
---|
53 |
|
---|
54 | // Calculate the size in bytes for the submesh.
|
---|
55 | size_t calcSubMeshSize(const SubMesh *geoSubMesh);
|
---|
56 |
|
---|
57 | // Calculate the geometry size in bytes.
|
---|
58 | size_t calcGeometrySize(const VertexBuffer* vertexBuffer);
|
---|
59 |
|
---|
60 | // Calculate the skeleton link size in bytes.
|
---|
61 | size_t calcSkeletonLinkSize(const Mesh *geoMesh);
|
---|
62 |
|
---|
63 | // Write the file header.
|
---|
64 | void writeFileHeader(void);
|
---|
65 |
|
---|
66 | // Write a header chunk given.
|
---|
67 | void writeChunkHeader( unsigned short id,
|
---|
68 | unsigned long count);
|
---|
69 |
|
---|
70 | // Write integers into the file.
|
---|
71 | void writeInts(unsigned long id,
|
---|
72 | unsigned long size);
|
---|
73 |
|
---|
74 | // Write shorts into the file
|
---|
75 | void writeShorts(unsigned short id,
|
---|
76 | unsigned long count);
|
---|
77 |
|
---|
78 | // Write float into the file.
|
---|
79 | void writeFloats(float id,
|
---|
80 | unsigned long count);
|
---|
81 |
|
---|
82 | // Write a string into the file.
|
---|
83 | void writeString(const String &string);
|
---|
84 |
|
---|
85 | // Write booleans into the file.
|
---|
86 | void writeBools( const bool id,
|
---|
87 | unsigned long count);
|
---|
88 |
|
---|
89 | // Write skeleton name.
|
---|
90 | void writeSkeletonLink(const String &string);
|
---|
91 |
|
---|
92 | void writeMeshBoneAssignment(const VertexBoneAssignment& assign);
|
---|
93 |
|
---|
94 | void writeSubMeshBoneAssignment(const VertexBoneAssignment& assign);
|
---|
95 |
|
---|
96 | // unnormalize geometry model.
|
---|
97 | void unnormalizeModel(Mesh *geoMesh);
|
---|
98 |
|
---|
99 | public:
|
---|
100 |
|
---|
101 | // Constructors.
|
---|
102 | GeoMeshSaver();
|
---|
103 |
|
---|
104 | // Destroyer.
|
---|
105 | ~GeoMeshSaver();
|
---|
106 |
|
---|
107 | // Sets the material of the mesh.
|
---|
108 | void setMaterialName(String materialName);
|
---|
109 |
|
---|
110 | // Gets the material of the mesh.
|
---|
111 | String getMaterialName();
|
---|
112 |
|
---|
113 | // Saves a Mesh into a file.
|
---|
114 | size_t save(Mesh *geoMesh, const char *fileNameMesh);
|
---|
115 |
|
---|
116 | // temporal members used to tweak the lodtree leaf submesh
|
---|
117 | int leavesSubMesh;
|
---|
118 | VertexBuffer *leavesVB;
|
---|
119 | Index *indices;
|
---|
120 | int numindices;
|
---|
121 | };
|
---|
122 | }
|
---|
123 | #endif
|
---|
124 |
|
---|