Panda3D

shadeModelAttrib.h

00001 // Filename: shadeModelAttrib.h
00002 // Created by:  drose (14Mar05)
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 SHADEMODELATTRIB_H
00016 #define SHADEMODELATTRIB_H
00017 
00018 #include "pandabase.h"
00019 
00020 #include "renderAttrib.h"
00021 
00022 class FactoryParams;
00023 
00024 ////////////////////////////////////////////////////////////////////
00025 //       Class : ShadeModelAttrib
00026 // Description : Specifies whether flat shading (per-polygon) or
00027 //               smooth shading (per-vertex) is in effect.
00028 ////////////////////////////////////////////////////////////////////
00029 class EXPCL_PANDA_PGRAPH ShadeModelAttrib : public RenderAttrib {
00030 PUBLISHED:
00031   enum Mode {
00032     M_flat,
00033     M_smooth,
00034   };
00035 
00036 private:
00037   INLINE ShadeModelAttrib(Mode mode);
00038 
00039 PUBLISHED:
00040   static CPT(RenderAttrib) make(Mode mode);
00041   static CPT(RenderAttrib) make_default();
00042 
00043   INLINE Mode get_mode() const;
00044 
00045 public:
00046   virtual void output(ostream &out) const;
00047 
00048 protected:
00049   virtual int compare_to_impl(const RenderAttrib *other) const;
00050   virtual size_t get_hash_impl() const;
00051   virtual CPT(RenderAttrib) compose_impl(const RenderAttrib *other) const;
00052 
00053 private:
00054   Mode _mode;
00055 
00056 PUBLISHED:
00057   static int get_class_slot() {
00058     return _attrib_slot;
00059   }
00060   virtual int get_slot() const {
00061     return get_class_slot();
00062   }
00063 
00064 public:
00065   static void register_with_read_factory();
00066   virtual void write_datagram(BamWriter *manager, Datagram &dg);
00067 
00068 protected:
00069   static TypedWritable *make_from_bam(const FactoryParams &params);
00070   void fillin(DatagramIterator &scan, BamReader *manager);
00071   
00072 public:
00073   static TypeHandle get_class_type() {
00074     return _type_handle;
00075   }
00076   static void init_type() {
00077     RenderAttrib::init_type();
00078     register_type(_type_handle, "ShadeModelAttrib",
00079                   RenderAttrib::get_class_type());
00080     _attrib_slot = register_slot(_type_handle, 100, make_default);
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   static int _attrib_slot;
00090 };
00091 
00092 #include "shadeModelAttrib.I"
00093 
00094 #endif
00095 
 All Classes Functions Variables Enumerations