Panda3D
|
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 CPT(RenderAttrib) compose_impl(const RenderAttrib *other) const; 00056 virtual CPT(RenderAttrib) invert_compose_impl(const RenderAttrib *other) const; 00057 00058 private: 00059 Mode _mode; 00060 bool _reverse; 00061 00062 PUBLISHED: 00063 static int get_class_slot() { 00064 return _attrib_slot; 00065 } 00066 virtual int get_slot() const { 00067 return get_class_slot(); 00068 } 00069 00070 public: 00071 static void register_with_read_factory(); 00072 virtual void write_datagram(BamWriter *manager, Datagram &dg); 00073 00074 protected: 00075 static TypedWritable *make_from_bam(const FactoryParams ¶ms); 00076 void fillin(DatagramIterator &scan, BamReader *manager); 00077 00078 public: 00079 static TypeHandle get_class_type() { 00080 return _type_handle; 00081 } 00082 static void init_type() { 00083 RenderAttrib::init_type(); 00084 register_type(_type_handle, "CullFaceAttrib", 00085 RenderAttrib::get_class_type()); 00086 _attrib_slot = register_slot(_type_handle, 100, make_default); 00087 } 00088 virtual TypeHandle get_type() const { 00089 return get_class_type(); 00090 } 00091 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00092 00093 private: 00094 static TypeHandle _type_handle; 00095 static int _attrib_slot; 00096 }; 00097 00098 #include "cullFaceAttrib.I" 00099 00100 #endif 00101