Panda3D

eggPolygon.h

00001 // Filename: eggPolygon.h
00002 // Created by:  drose (16Jan99)
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 #ifndef EGGPOLYGON_H
00016 #define EGGPOLYGON_H
00017 
00018 #include "pandabase.h"
00019 
00020 #include "eggPrimitive.h"
00021 
00022 ////////////////////////////////////////////////////////////////////
00023 //       Class : EggPolygon
00024 // Description : A single polygon.
00025 ////////////////////////////////////////////////////////////////////
00026 class EXPCL_PANDAEGG EggPolygon : public EggPrimitive {
00027 PUBLISHED:
00028   INLINE EggPolygon(const string &name = "");
00029   INLINE EggPolygon(const EggPolygon &copy);
00030   INLINE EggPolygon &operator = (const EggPolygon &copy);
00031 
00032   virtual bool cleanup();
00033 
00034   bool calculate_normal(LNormald &result, CoordinateSystem cs = CS_default) const;
00035   bool is_planar() const;
00036 
00037   INLINE bool recompute_polygon_normal(CoordinateSystem cs = CS_default);
00038 
00039   INLINE bool triangulate_into(EggGroupNode *container, bool convex_also) const;
00040   PT(EggPolygon) triangulate_in_place(bool convex_also);
00041 
00042   virtual void write(ostream &out, int indent_level) const;
00043 
00044 private:
00045   bool decomp_concave(EggGroupNode *container, int asum, int x, int y) const;
00046   bool triangulate_poly(EggGroupNode *container, bool convex_also);
00047 
00048 public:
00049 
00050   static TypeHandle get_class_type() {
00051     return _type_handle;
00052   }
00053   static void init_type() {
00054     EggPrimitive::init_type();
00055     register_type(_type_handle, "EggPolygon",
00056                   EggPrimitive::get_class_type());
00057   }
00058   virtual TypeHandle get_type() const {
00059     return get_class_type();
00060   }
00061   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00062 
00063 private:
00064   static TypeHandle _type_handle;
00065 
00066 };
00067 
00068 #include "eggPolygon.I"
00069 
00070 #endif
 All Classes Functions Variables Enumerations