Panda3D

Loading...
Searching...
No Matches
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
53 typedef plist<EggMesherStrip> Strips;
54 typedef pset<EggMesherEdge> Edges;
55 typedef pset<EggMesherEdge *> EdgePtrs;
56 typedef pmap<int, EdgePtrs> Verts;
57
58 // This is used for show-qsheets.
59 typedef pmap<int, LColor> ColorSheetMap;
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
EggGroupNode
A base class for nodes in the hierarchy that are not leaf nodes.
Definition eggGroupNode.h:46
EggMesher::mesh
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:49
EggPolygon
A single polygon.
Definition eggPolygon.h:24
EggPrimitive
A base class for any of a number of kinds of geometry primitives: polygons, point lights,...
Definition eggPrimitive.h:49
EggVertexPool
A collection of vertices.
Definition eggVertexPool.h:41
plist
This is our own Panda specialization on the default STL list.
Definition plist.h:35
eggMesherEdge.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
eggMesherStrip.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
eggMesher.I
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
eggPolygon.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pandabase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
plist.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pmap.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pset.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pvector.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.