00001 // Filename: cullFaceAttrib.h 00002 // Created by: drose (27Feb02) 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 CULLFACEATTRIB_H 00020 #define CULLFACEATTRIB_H 00021 00022 #include "pandabase.h" 00023 00024 #include "renderAttrib.h" 00025 00026 //////////////////////////////////////////////////////////////////// 00027 // Class : CullFaceAttrib 00028 // Description : Indicates which faces should be culled based on their 00029 // vertex ordering. 00030 //////////////////////////////////////////////////////////////////// 00031 class EXPCL_PANDA CullFaceAttrib : public RenderAttrib { 00032 PUBLISHED: 00033 enum Mode { 00034 M_cull_none, // Cull no polygons 00035 M_cull_clockwise, // Cull clockwise-oriented polygons 00036 M_cull_counter_clockwise, // Cull counter-clockwise-oriented polygons 00037 M_cull_unchanged, // Do not change existing cull behavior 00038 }; 00039 00040 private: 00041 INLINE CullFaceAttrib(Mode mode, bool reverse); 00042 00043 PUBLISHED: 00044 static CPT(RenderAttrib) make(Mode mode = M_cull_clockwise); 00045 static CPT(RenderAttrib) make_reverse(); 00046 00047 INLINE Mode get_actual_mode() const; 00048 INLINE bool get_reverse() const; 00049 Mode get_effective_mode() const; 00050 00051 public: 00052 virtual void issue(GraphicsStateGuardianBase *gsg) const; 00053 virtual void output(ostream &out) const; 00054 00055 protected: 00056 virtual int compare_to_impl(const RenderAttrib *other) const; 00057 virtual CPT(RenderAttrib) compose_impl(const RenderAttrib *other) const; 00058 virtual CPT(RenderAttrib) invert_compose_impl(const RenderAttrib *other) const; 00059 virtual RenderAttrib *make_default_impl() const; 00060 00061 private: 00062 Mode _mode; 00063 bool _reverse; 00064 00065 public: 00066 static void register_with_read_factory(); 00067 virtual void write_datagram(BamWriter *manager, Datagram &dg); 00068 00069 protected: 00070 static TypedWritable *make_from_bam(const FactoryParams ¶ms); 00071 void fillin(DatagramIterator &scan, BamReader *manager); 00072 00073 public: 00074 static TypeHandle get_class_type() { 00075 return _type_handle; 00076 } 00077 static void init_type() { 00078 RenderAttrib::init_type(); 00079 register_type(_type_handle, "CullFaceAttrib", 00080 RenderAttrib::get_class_type()); 00081 } 00082 virtual TypeHandle get_type() const { 00083 return get_class_type(); 00084 } 00085 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00086 00087 private: 00088 static TypeHandle _type_handle; 00089 }; 00090 00091 #include "cullFaceAttrib.I" 00092 00093 #endif 00094