Panda3D
eggPolygon.I
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 eggPolygon.I
10  * @author drose
11  * @date 1999-02-10
12  */
13 
14 /**
15  *
16  */
17 INLINE EggPolygon::
18 EggPolygon(const std::string &name) : EggPrimitive(name) {
19 }
20 
21 /**
22  *
23  */
24 INLINE EggPolygon::
25 EggPolygon(const EggPolygon &copy) : EggPrimitive(copy) {
26 }
27 
28 /**
29  *
30  */
31 INLINE EggPolygon &EggPolygon::
32 operator = (const EggPolygon &copy) {
33  EggPrimitive::operator = (copy);
34  return *this;
35 }
36 
37 /**
38  * Recalculates the normal according to the order of the vertices, and sets
39  * it. Returns true if the normal is computed correctly, or false if the
40  * polygon is degenerate and does not have a normal.
41  */
42 INLINE bool EggPolygon::
43 recompute_polygon_normal(CoordinateSystem cs) {
44  LNormald normal;
45  if (calculate_normal(normal, cs)) {
46  set_normal(normal);
47  return true;
48  }
49  clear_normal();
50  return false;
51 }
52 
53 /**
54  * Subdivides the polygon into triangles and adds each one to the indicated
55  * container. If the polygon is already a triangle, adds an exact copy of the
56  * polygon to the container. Does not remove the polygon from its existing
57  * parent or modify it in any way.
58  *
59  * Returns true if the triangulation is successful, or false if there was some
60  * error (in which case the container may contain some partial triangulation).
61  *
62  * If convex_also is true, both concave and convex polygons will be subdivided
63  * into triangles; otherwise, only concave polygons will be subdivided, and
64  * convex polygons will be copied unchanged into the container.
65  */
66 INLINE bool EggPolygon::
67 triangulate_into(EggGroupNode *container, bool convex_also) const {
68  PT(EggPolygon) copy = new EggPolygon(*this);
69  return copy->triangulate_poly(container, convex_also);
70 }
A base class for any of a number of kinds of geometry primitives: polygons, point lights,...
Definition: eggPrimitive.h:47
A base class for nodes in the hierarchy that are not leaf nodes.
Definition: eggGroupNode.h:46
bool triangulate_into(EggGroupNode *container, bool convex_also) const
Subdivides the polygon into triangles and adds each one to the indicated container.
Definition: eggPolygon.I:67
A single polygon.
Definition: eggPolygon.h:24
bool recompute_polygon_normal(CoordinateSystem cs=CS_default)
Recalculates the normal according to the order of the vertices, and sets it.
Definition: eggPolygon.I:43
bool calculate_normal(LNormald &result, CoordinateSystem cs=CS_default) const
Calculates the true polygon normal–the vector pointing out of the front of the polygon–based on the v...
Definition: eggPolygon.cxx:57