40 int index = (int)_vertices3.size();
41 _vertices3.push_back(point);
54 if (_polygon.size() < 3) {
60 LNormald normal = LNormald::zero();
66 size_t num_verts = _polygon.size();
67 for (
size_t i = 0; i < num_verts; i++) {
69 int i1 = _polygon[(i + 1) % num_verts];;;;
70 nassertv(i0 >= 0 && i0 < (
int)_vertices3.size() &&
71 i1 >= 0 && i1 < (int)_vertices3.size());
72 const LPoint3d &p0 = _vertices3[i0];
73 const LPoint3d &p1 = _vertices3[i1];
74 normal[0] += p0[1] * p1[2] - p0[2] * p1[1];
75 normal[1] += p0[2] * p1[0] - p0[0] * p1[2];
76 normal[2] += p0[0] * p1[1] - p0[1] * p1[0];
79 if (!normal.normalize()) {
85 _plane = LPlaned(normal, _vertices3[0]);
90 heads_up(mat, _vertices3[1] - _vertices3[2], normal, CS_zup_right);
91 mat.set_row(3, _vertices3[0]);
92 mat.invert_in_place();
95 for (
size_t i = 0; i < _vertices3.size(); i++) {
96 LPoint3d p = _vertices3[i] * mat;
97 _vertices.push_back(LPoint2d(p[0], p[1]));
void triangulate()
Does the work of triangulating the specified polygon.
void clear()
Removes all vertices and polygon specifications from the Triangulator, and prepares it to start over.
void triangulate()
Does the work of triangulating the specified polygon.
int add_vertex(const LPoint3d &point)
Adds a new vertex to the vertex pool.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void clear()
Removes all vertices and polygon specifications from the Triangulator, and prepares it to start over.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.