00001 // Filename: eggPolygon.h 00002 // Created by: drose (16Jan99) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved 00008 // 00009 // All use of this software is subject to the terms of the Panda 3d 00010 // Software license. You should have received a copy of this license 00011 // along with this source code; you will also find a current copy of 00012 // the license at http://www.panda3d.org/license.txt . 00013 // 00014 // To contact the maintainers of this program write to 00015 // panda3d@yahoogroups.com . 00016 // 00017 //////////////////////////////////////////////////////////////////// 00018 00019 #ifndef EGGPOLYGON_H 00020 #define EGGPOLYGON_H 00021 00022 #include <pandabase.h> 00023 00024 #include "eggPrimitive.h" 00025 00026 //////////////////////////////////////////////////////////////////// 00027 // Class : EggPolygon 00028 // Description : A single polygon. 00029 //////////////////////////////////////////////////////////////////// 00030 class EXPCL_PANDAEGG EggPolygon : public EggPrimitive { 00031 public: 00032 INLINE EggPolygon(const string &name = ""); 00033 INLINE EggPolygon(const EggPolygon ©); 00034 INLINE EggPolygon &operator = (const EggPolygon ©); 00035 00036 virtual bool cleanup(); 00037 00038 bool calculate_normal(Normald &result, CoordinateSystem cs = CS_default) const; 00039 INLINE bool recompute_polygon_normal(CoordinateSystem cs = CS_default); 00040 00041 INLINE bool triangulate_into(EggGroupNode *container, bool convex_also) const; 00042 PT(EggPolygon) triangulate_in_place(bool convex_also); 00043 00044 virtual void write(ostream &out, int indent_level) const; 00045 00046 private: 00047 bool decomp_concave(EggGroupNode *container, int asum, int x, int y) const; 00048 bool triangulate_poly(EggGroupNode *container, bool convex_also); 00049 00050 public: 00051 00052 static TypeHandle get_class_type() { 00053 return _type_handle; 00054 } 00055 static void init_type() { 00056 EggPrimitive::init_type(); 00057 register_type(_type_handle, "EggPolygon", 00058 EggPrimitive::get_class_type()); 00059 } 00060 virtual TypeHandle get_type() const { 00061 return get_class_type(); 00062 } 00063 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00064 00065 private: 00066 static TypeHandle _type_handle; 00067 00068 }; 00069 00070 #include "eggPolygon.I" 00071 00072 #endif