Panda3D

eggPolygon.I

00001 // Filename: eggPolygon.I
00002 // Created by:  drose (10Feb99)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 
00016 ////////////////////////////////////////////////////////////////////
00017 //     Function: EggPolygon::Constructor
00018 //       Access: Published
00019 //  Description:
00020 ////////////////////////////////////////////////////////////////////
00021 INLINE EggPolygon::
00022 EggPolygon(const string &name) : EggPrimitive(name) {
00023 }
00024 
00025 ////////////////////////////////////////////////////////////////////
00026 //     Function: EggPolygon::Copy constructor
00027 //       Access: Published
00028 //  Description:
00029 ////////////////////////////////////////////////////////////////////
00030 INLINE EggPolygon::
00031 EggPolygon(const EggPolygon &copy) : EggPrimitive(copy) {
00032 }
00033 
00034 ////////////////////////////////////////////////////////////////////
00035 //     Function: EggPolygon::Copy assignment operator
00036 //       Access: Published
00037 //  Description:
00038 ////////////////////////////////////////////////////////////////////
00039 INLINE EggPolygon &EggPolygon::
00040 operator = (const EggPolygon &copy) {
00041   EggPrimitive::operator = (copy);
00042   return *this;
00043 }
00044 
00045 ////////////////////////////////////////////////////////////////////
00046 //     Function: EggPolygon::recompute_polygon_normal
00047 //       Access: Published
00048 //  Description: Recalculates the normal according to the order of the
00049 //               vertices, and sets it.  Returns true if the normal is
00050 //               computed correctly, or false if the polygon is
00051 //               degenerate and does not have a normal.
00052 ////////////////////////////////////////////////////////////////////
00053 INLINE bool EggPolygon::
00054 recompute_polygon_normal(CoordinateSystem cs) {
00055   LNormald normal;
00056   if (calculate_normal(normal, cs)) {
00057     set_normal(normal);
00058     return true;
00059   }
00060   clear_normal();
00061   return false;
00062 }
00063 
00064 ////////////////////////////////////////////////////////////////////
00065 //     Function: EggPolygon::triangulate_into
00066 //       Access: Published
00067 //  Description: Subdivides the polygon into triangles and adds each
00068 //               one to the indicated container.  If the polygon is
00069 //               already a triangle, adds an exact copy of the polygon
00070 //               to the container.  Does not remove the polygon from
00071 //               its existing parent or modify it in any way.
00072 //
00073 //               Returns true if the triangulation is successful, or
00074 //               false if there was some error (in which case the
00075 //               container may contain some partial triangulation).
00076 //
00077 //               If convex_also is true, both concave and convex
00078 //               polygons will be subdivided into triangles;
00079 //               otherwise, only concave polygons will be subdivided,
00080 //               and convex polygons will be copied unchanged into the
00081 //               container.
00082 ////////////////////////////////////////////////////////////////////
00083 INLINE bool EggPolygon::
00084 triangulate_into(EggGroupNode *container, bool convex_also) const {
00085   PT(EggPolygon) copy = new EggPolygon(*this);
00086   return copy->triangulate_poly(container, convex_also);
00087 }
 All Classes Functions Variables Enumerations