00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef EGGMESHER_H
00016 #define EGGMESHER_H
00017
00018 #include "pandabase.h"
00019 #include "eggMesherEdge.h"
00020 #include "eggMesherStrip.h"
00021 #include "eggPolygon.h"
00022 #include "pvector.h"
00023 #include "plist.h"
00024 #include "pset.h"
00025 #include "pmap.h"
00026
00027 #include <algorithm>
00028
00029
00030
00031
00032
00033
00034
00035 class EggMesher {
00036 public:
00037 EggMesher();
00038
00039 void mesh(EggGroupNode *group, bool flat_shaded);
00040
00041 void write(ostream &out) const;
00042
00043 bool _consider_fans;
00044 bool _retesselate_coplanar;
00045 bool _show_quads;
00046 bool _show_qsheets;
00047
00048 private:
00049 void clear();
00050 bool add_polygon(const EggPolygon *egg_poly,
00051 EggMesherStrip::MesherOrigin origin);
00052 void do_mesh();
00053 PT(EggPrimitive) get_prim(EggMesherStrip &strip);
00054
00055 typedef plist<EggMesherStrip> Strips;
00056 typedef pset<EggMesherEdge> Edges;
00057 typedef pset<EggMesherEdge *> EdgePtrs;
00058 typedef pmap<int, EdgePtrs> Verts;
00059
00060
00061 typedef pmap<int, LColor> ColorSheetMap;
00062
00063 int count_vert_edges(const EdgePtrs &edges) const;
00064 plist<EggMesherStrip> &choose_strip_list(const EggMesherStrip &strip);
00065
00066 void build_sheets();
00067 void find_fans();
00068 void make_quads();
00069 void mesh_list(Strips &strips);
00070 static void make_random_color(LColor &color);
00071
00072 bool _flat_shaded;
00073 Strips _tris, _quads, _strips;
00074 Strips _dead, _done;
00075 Verts _verts;
00076 Edges _edges;
00077 int _strip_index;
00078 EggVertexPool *_vertex_pool;
00079 ColorSheetMap _color_sheets;
00080
00081 friend class EggMesherStrip;
00082 friend class EggMesherFanMaker;
00083 };
00084
00085 #include "eggMesher.I"
00086
00087 #endif