xFileMesh.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. // Filename: xFileMesh.h
  2. // Created by: drose (19Jun01)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. // PANDA 3D SOFTWARE
  7. // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
  8. //
  9. // All use of this software is subject to the terms of the Panda 3d
  10. // Software license. You should have received a copy of this license
  11. // along with this source code; you will also find a current copy of
  12. // the license at http://www.panda3d.org/license.txt .
  13. //
  14. // To contact the maintainers of this program write to
  15. // [email protected] .
  16. //
  17. ////////////////////////////////////////////////////////////////////
  18. #ifndef XFILEMESH_H
  19. #define XFILEMESH_H
  20. #include "pandatoolbase.h"
  21. #include "pvector.h"
  22. #include "pmap.h"
  23. #include "indirectCompareTo.h"
  24. #include "namable.h"
  25. class XFileMesh;
  26. class XFileVertex;
  27. class XFileNormal;
  28. class XFileMaterial;
  29. class XFileFace;
  30. class EggGroupNode;
  31. class EggVertex;
  32. class EggPolygon;
  33. class EggPrimitive;
  34. class EggTextureCollection;
  35. class EggMaterialCollection;
  36. class Datagram;
  37. ////////////////////////////////////////////////////////////////////
  38. // Class : XFileMesh
  39. // Description : This is a collection of polygons; i.e. a polyset.
  40. ////////////////////////////////////////////////////////////////////
  41. class XFileMesh : public Namable {
  42. public:
  43. XFileMesh();
  44. ~XFileMesh();
  45. void clear();
  46. void add_polygon(EggPolygon *egg_poly);
  47. int add_vertex(EggVertex *egg_vertex, EggPrimitive *egg_prim);
  48. int add_normal(EggVertex *egg_vertex, EggPrimitive *egg_prim);
  49. int add_material(EggPrimitive *egg_prim);
  50. int add_vertex(XFileVertex *vertex);
  51. int add_normal(XFileNormal *normal);
  52. int add_material(XFileMaterial *material);
  53. bool create_polygons(EggGroupNode *egg_parent,
  54. EggTextureCollection &textures,
  55. EggMaterialCollection &materials);
  56. bool has_normals() const;
  57. bool has_colors() const;
  58. bool has_uvs() const;
  59. bool has_materials() const;
  60. int get_num_materials() const;
  61. XFileMaterial *get_material(int n) const;
  62. void make_mesh_data(Datagram &raw_data);
  63. void make_normal_data(Datagram &raw_data);
  64. void make_color_data(Datagram &raw_data);
  65. void make_uv_data(Datagram &raw_data);
  66. void make_material_list_data(Datagram &raw_data);
  67. bool read_mesh_data(const Datagram &raw_data);
  68. bool read_normal_data(const Datagram &raw_data);
  69. bool read_color_data(const Datagram &raw_data);
  70. bool read_uv_data(const Datagram &raw_data);
  71. bool read_material_list_data(const Datagram &raw_data);
  72. private:
  73. typedef pvector<XFileVertex *> Vertices;
  74. typedef pvector<XFileNormal *> Normals;
  75. typedef pvector<XFileMaterial *> Materials;
  76. typedef pvector<XFileFace *> Faces;
  77. Vertices _vertices;
  78. Normals _normals;
  79. Materials _materials;
  80. Faces _faces;
  81. private:
  82. typedef pmap<XFileVertex *, int, IndirectCompareTo<XFileVertex> > UniqueVertices;
  83. typedef pmap<XFileNormal *, int, IndirectCompareTo<XFileNormal> > UniqueNormals;
  84. typedef pmap<XFileMaterial *, int, IndirectCompareTo<XFileMaterial> > UniqueMaterials;
  85. UniqueVertices _unique_vertices;
  86. UniqueNormals _unique_normals;
  87. UniqueMaterials _unique_materials;
  88. bool _has_normals;
  89. bool _has_colors;
  90. bool _has_uvs;
  91. bool _has_materials;
  92. };
  93. #endif