00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef XFILEMESH_H
00016 #define XFILEMESH_H
00017
00018 #include "pandatoolbase.h"
00019 #include "pvector.h"
00020 #include "pmap.h"
00021 #include "indirectCompareTo.h"
00022 #include "namable.h"
00023 #include "coordinateSystem.h"
00024
00025 class XFileNode;
00026 class XFileDataNode;
00027 class XFileMesh;
00028 class XFileVertex;
00029 class XFileNormal;
00030 class XFileMaterial;
00031 class XFileFace;
00032 class XFileToEggConverter;
00033 class XFileDataNode;
00034 class EggGroupNode;
00035 class EggVertex;
00036 class EggPolygon;
00037 class EggPrimitive;
00038 class Datagram;
00039
00040
00041
00042
00043
00044 class XFileMesh : public Namable {
00045 public:
00046 XFileMesh(CoordinateSystem cs = CS_yup_left);
00047 ~XFileMesh();
00048
00049 void clear();
00050
00051 void add_polygon(EggPolygon *egg_poly);
00052 int add_vertex(EggVertex *egg_vertex, EggPrimitive *egg_prim);
00053 int add_normal(EggVertex *egg_vertex, EggPrimitive *egg_prim);
00054 int add_material(EggPrimitive *egg_prim);
00055
00056 int add_vertex(XFileVertex *vertex);
00057 int add_normal(XFileNormal *normal);
00058 int add_material(XFileMaterial *material);
00059
00060 void set_egg_parent(EggGroupNode *egg_parent);
00061
00062 bool create_polygons(XFileToEggConverter *converter);
00063
00064 bool has_normals() const;
00065 bool has_colors() const;
00066 bool has_uvs() const;
00067 bool has_materials() const;
00068
00069 int get_num_materials() const;
00070 XFileMaterial *get_material(int n) const;
00071
00072 XFileDataNode *make_x_mesh(XFileNode *x_parent, const string &suffix);
00073 XFileDataNode *make_x_normals(XFileNode *x_mesh, const string &suffix);
00074 XFileDataNode *make_x_colors(XFileNode *x_mesh, const string &suffix);
00075 XFileDataNode *make_x_uvs(XFileNode *x_mesh, const string &suffix);
00076 XFileDataNode *make_x_material_list(XFileNode *x_mesh, const string &suffix);
00077
00078 bool fill_mesh(XFileDataNode *obj);
00079 bool fill_mesh_child(XFileDataNode *obj);
00080 bool fill_normals(XFileDataNode *obj);
00081 bool fill_colors(XFileDataNode *obj);
00082 bool fill_uvs(XFileDataNode *obj);
00083 bool fill_skin_weights(XFileDataNode *obj);
00084 bool fill_material_list(XFileDataNode *obj);
00085
00086 private:
00087 typedef pvector<XFileVertex *> Vertices;
00088 typedef pvector<XFileNormal *> Normals;
00089 typedef pvector<XFileMaterial *> Materials;
00090 typedef pvector<XFileFace *> Faces;
00091
00092 CoordinateSystem _cs;
00093
00094 Vertices _vertices;
00095 Normals _normals;
00096 Materials _materials;
00097 Faces _faces;
00098
00099 typedef pmap<int, PN_stdfloat> WeightMap;
00100
00101 class SkinWeightsData {
00102 public:
00103 LMatrix4d _matrix_offset;
00104 string _joint_name;
00105 WeightMap _weight_map;
00106 };
00107 typedef epvector<SkinWeightsData> SkinWeights;
00108 SkinWeights _skin_weights;
00109
00110 typedef pmap<XFileVertex *, int, IndirectCompareTo<XFileVertex> > UniqueVertices;
00111 typedef pmap<XFileNormal *, int, IndirectCompareTo<XFileNormal> > UniqueNormals;
00112 typedef pmap<XFileMaterial *, int, IndirectCompareTo<XFileMaterial> > UniqueMaterials;
00113 UniqueVertices _unique_vertices;
00114 UniqueNormals _unique_normals;
00115 UniqueMaterials _unique_materials;
00116
00117 bool _has_normals;
00118 bool _has_colors;
00119 bool _has_uvs;
00120 bool _has_materials;
00121
00122 EggGroupNode *_egg_parent;
00123 };
00124
00125 #endif
00126