Panda3D

renderModeAttrib.h

00001 // Filename: renderModeAttrib.h
00002 // Created by:  drose (14Mar02)
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 RENDERMODEATTRIB_H
00016 #define RENDERMODEATTRIB_H
00017 
00018 #include "pandabase.h"
00019 
00020 #include "renderAttrib.h"
00021 #include "geom.h"
00022 
00023 class FactoryParams;
00024 
00025 ////////////////////////////////////////////////////////////////////
00026 //       Class : RenderModeAttrib
00027 // Description : Specifies how polygons are to be drawn.
00028 ////////////////////////////////////////////////////////////////////
00029 class EXPCL_PANDA_PGRAPH RenderModeAttrib : public RenderAttrib {
00030 PUBLISHED:
00031   enum Mode {
00032     M_unchanged,
00033 
00034     // Normal, filled polygons.
00035     M_filled,
00036 
00037     // Wireframe polygons, possibly with thickness.
00038     M_wireframe,
00039 
00040     // Points at vertices only, possibly with thickness and/or
00041     // perspective sizing.
00042     M_point,
00043 
00044     // Filled polygons, without any particular emphasis on perspective
00045     // correctness (a particularly useful designation for software
00046     // rendering sprites).
00047     M_filled_flat
00048   };
00049 
00050 private:
00051   INLINE RenderModeAttrib(Mode mode, float thickness, bool perspective);
00052 
00053 PUBLISHED:
00054   static CPT(RenderAttrib) make(Mode mode, float thickness = 1.0f,
00055                                 bool perspective = false);
00056   static CPT(RenderAttrib) make_default();
00057 
00058   INLINE Mode get_mode() const;
00059   INLINE float get_thickness() const;
00060   INLINE bool get_perspective() const;
00061 
00062   INLINE int get_geom_rendering(int geom_rendering) const;
00063 
00064 public:
00065   virtual void output(ostream &out) const;
00066 
00067 protected:
00068   virtual int compare_to_impl(const RenderAttrib *other) const;
00069   virtual CPT(RenderAttrib) compose_impl(const RenderAttrib *other) const;
00070 
00071 private:
00072   Mode _mode;
00073   float _thickness;
00074   bool _perspective;
00075 
00076 PUBLISHED:
00077   static int get_class_slot() {
00078     return _attrib_slot;
00079   }
00080   virtual int get_slot() const {
00081     return get_class_slot();
00082   }
00083 
00084 public:
00085   static void register_with_read_factory();
00086   virtual void write_datagram(BamWriter *manager, Datagram &dg);
00087 
00088 protected:
00089   static TypedWritable *make_from_bam(const FactoryParams &params);
00090   void fillin(DatagramIterator &scan, BamReader *manager);
00091   
00092 public:
00093   static TypeHandle get_class_type() {
00094     return _type_handle;
00095   }
00096   static void init_type() {
00097     RenderAttrib::init_type();
00098     register_type(_type_handle, "RenderModeAttrib",
00099                   RenderAttrib::get_class_type());
00100     _attrib_slot = register_slot(_type_handle, 100, make_default);
00101   }
00102   virtual TypeHandle get_type() const {
00103     return get_class_type();
00104   }
00105   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00106 
00107 private:
00108   static TypeHandle _type_handle;
00109   static int _attrib_slot;
00110 };
00111 
00112 #include "renderModeAttrib.I"
00113 
00114 #endif
00115 
 All Classes Functions Variables Enumerations