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