Panda3D
 All Classes Functions Variables Enumerations
eggMesher.h
1 // Filename: eggMesher.h
2 // Created by: drose (13Mar05)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef EGGMESHER_H
16 #define EGGMESHER_H
17 
18 #include "pandabase.h"
19 #include "eggMesherEdge.h"
20 #include "eggMesherStrip.h"
21 #include "eggPolygon.h"
22 #include "pvector.h"
23 #include "plist.h"
24 #include "pset.h"
25 #include "pmap.h"
26 
27 #include <algorithm>
28 
29 ////////////////////////////////////////////////////////////////////
30 // Class : EggMesher
31 // Description : Collects together unrelated EggPrimitives, determines
32 // their edge connectivity, and generates a set of
33 // EggTriangleStrips that represent the same geometry.
34 ////////////////////////////////////////////////////////////////////
35 class EggMesher {
36 public:
37  EggMesher();
38 
39  void mesh(EggGroupNode *group, bool flat_shaded);
40 
41  void write(ostream &out) const;
42 
43  bool _consider_fans;
44  bool _retesselate_coplanar;
45  bool _show_quads;
46  bool _show_qsheets;
47 
48 private:
49  void clear();
50  bool add_polygon(const EggPolygon *egg_poly,
51  EggMesherStrip::MesherOrigin origin);
52  void do_mesh();
53  PT(EggPrimitive) get_prim(EggMesherStrip &strip);
54 
56  typedef pset<EggMesherEdge> Edges;
58  typedef pmap<int, EdgePtrs> Verts;
59 
60  // This is used for show-qsheets.
62 
63  int count_vert_edges(const EdgePtrs &edges) const;
64  plist<EggMesherStrip> &choose_strip_list(const EggMesherStrip &strip);
65 
66  void build_sheets();
67  void find_fans();
68  void make_quads();
69  void mesh_list(Strips &strips);
70  static void make_random_color(LColor &color);
71 
72  bool _flat_shaded;
73  Strips _tris, _quads, _strips;
74  Strips _dead, _done;
75  Verts _verts;
76  Edges _edges;
77  int _strip_index;
78  EggVertexPool *_vertex_pool;
79  ColorSheetMap _color_sheets;
80 
81  friend class EggMesherStrip;
82  friend class EggMesherFanMaker;
83 };
84 
85 #include "eggMesher.I"
86 
87 #endif
A base class for any of a number of kinds of geometry primitives: polygons, point lights...
Definition: eggPrimitive.h:51
A base class for nodes in the hierarchy that are not leaf nodes.
Definition: eggGroupNode.h:51
void mesh(EggGroupNode *group, bool flat_shaded)
Accepts an EggGroupNode, which contains a set of EggPrimitives–typically, triangles and quads–as chil...
Definition: eggMesher.cxx:56
This class is used by EggMesher::find_fans() to attempt to make an EggTriangleFan out of the polygons...
Collects together unrelated EggPrimitives, determines their edge connectivity, and generates a set of...
Definition: eggMesher.h:35
A single polygon.
Definition: eggPolygon.h:26
This is the base class for all three-component vectors and points.
Definition: lvecBase4.h:111
Represents a triangle strip or quad strip in progress, as assembled by the mesher.
A collection of vertices.
Definition: eggVertexPool.h:46