00001 // Filename: xFileMesh.h 00002 // Created by: drose (19Jun01) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved 00008 // 00009 // All use of this software is subject to the terms of the Panda 3d 00010 // Software license. You should have received a copy of this license 00011 // along with this source code; you will also find a current copy of 00012 // the license at http://www.panda3d.org/license.txt . 00013 // 00014 // To contact the maintainers of this program write to 00015 // panda3d@yahoogroups.com . 00016 // 00017 //////////////////////////////////////////////////////////////////// 00018 00019 #ifndef XFILEMESH_H 00020 #define XFILEMESH_H 00021 00022 #include "pandatoolbase.h" 00023 #include "pvector.h" 00024 #include "pmap.h" 00025 #include "indirectCompareTo.h" 00026 #include "namable.h" 00027 00028 class XFileMesh; 00029 class XFileVertex; 00030 class XFileNormal; 00031 class XFileMaterial; 00032 class XFileFace; 00033 class XFileToEggConverter; 00034 class EggGroupNode; 00035 class EggVertex; 00036 class EggPolygon; 00037 class EggPrimitive; 00038 class Datagram; 00039 00040 //////////////////////////////////////////////////////////////////// 00041 // Class : XFileMesh 00042 // Description : This is a collection of polygons; i.e. a polyset. 00043 //////////////////////////////////////////////////////////////////// 00044 class XFileMesh : public Namable { 00045 public: 00046 XFileMesh(); 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 bool create_polygons(EggGroupNode *egg_parent, 00061 XFileToEggConverter *converter); 00062 00063 bool has_normals() const; 00064 bool has_colors() const; 00065 bool has_uvs() const; 00066 bool has_materials() const; 00067 00068 int get_num_materials() const; 00069 XFileMaterial *get_material(int n) const; 00070 00071 void make_mesh_data(Datagram &raw_data); 00072 void make_normal_data(Datagram &raw_data); 00073 void make_color_data(Datagram &raw_data); 00074 void make_uv_data(Datagram &raw_data); 00075 void make_material_list_data(Datagram &raw_data); 00076 00077 bool read_mesh_data(const Datagram &raw_data); 00078 bool read_normal_data(const Datagram &raw_data); 00079 bool read_color_data(const Datagram &raw_data); 00080 bool read_uv_data(const Datagram &raw_data); 00081 bool read_material_list_data(const Datagram &raw_data); 00082 00083 private: 00084 typedef pvector<XFileVertex *> Vertices; 00085 typedef pvector<XFileNormal *> Normals; 00086 typedef pvector<XFileMaterial *> Materials; 00087 typedef pvector<XFileFace *> Faces; 00088 00089 Vertices _vertices; 00090 Normals _normals; 00091 Materials _materials; 00092 Faces _faces; 00093 00094 typedef pmap<XFileVertex *, int, IndirectCompareTo<XFileVertex> > UniqueVertices; 00095 typedef pmap<XFileNormal *, int, IndirectCompareTo<XFileNormal> > UniqueNormals; 00096 typedef pmap<XFileMaterial *, int, IndirectCompareTo<XFileMaterial> > UniqueMaterials; 00097 UniqueVertices _unique_vertices; 00098 UniqueNormals _unique_normals; 00099 UniqueMaterials _unique_materials; 00100 00101 bool _has_normals; 00102 bool _has_colors; 00103 bool _has_uvs; 00104 bool _has_materials; 00105 }; 00106 00107 #endif 00108