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