Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/pgraph/depthOffsetAttrib.h

Go to the documentation of this file.
00001 // Filename: depthOffsetAttrib.h
00002 // Created by:  drose (14Mar02)
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 DEPTHOFFSETATTRIB_H
00020 #define DEPTHOFFSETATTRIB_H
00021 
00022 #include "pandabase.h"
00023 
00024 #include "renderAttrib.h"
00025 #include "luse.h"
00026 
00027 ////////////////////////////////////////////////////////////////////
00028 //       Class : DepthOffsetAttrib
00029 // Description : This is a special kind of attribute that instructs
00030 //               the graphics driver to apply an offset or bias to the
00031 //               generated depth values for rendered polygons, before
00032 //               they are written to the depth buffer.
00033 //
00034 //               This can be used to shift polygons forward slightly,
00035 //               to resolve depth conflicts.  The cull traverser may
00036 //               optionally use this, for instance, to implement
00037 //               decals.  However, driver support for this feature
00038 //               seems to be spotty, so use with caution.
00039 //
00040 //               The bias is always an integer number, and each
00041 //               integer increment represents the smallest possible
00042 //               increment in Z that is sufficient to completely
00043 //               resolve two coplanar polygons.  Positive numbers are
00044 //               closer towards the camera.
00045 //
00046 //               Nested DepthOffsetAttrib values accumulate; that is,
00047 //               a DepthOffsetAttrib with a value of 1 beneath another
00048 //               DepthOffsetAttrib with a value of 2 presents a net
00049 //               offset of 3.  (A DepthOffsetAttrib will not, however,
00050 //               combine with any other DepthOffsetAttribs with a
00051 //               lower override parameter.)  The net value should
00052 //               probably not exceed 16 or drop below 0 for maximum
00053 //               portability.
00054 ////////////////////////////////////////////////////////////////////
00055 class EXPCL_PANDA DepthOffsetAttrib : public RenderAttrib {
00056 private:
00057   INLINE DepthOffsetAttrib(int offset);
00058 
00059 PUBLISHED:
00060   static CPT(RenderAttrib) make(int offset = 1);
00061 
00062   INLINE int get_offset() const;
00063 
00064 public:
00065   virtual void issue(GraphicsStateGuardianBase *gsg) const;
00066   virtual void output(ostream &out) const;
00067 
00068 protected:
00069   virtual int compare_to_impl(const RenderAttrib *other) const;
00070   virtual CPT(RenderAttrib) compose_impl(const RenderAttrib *other) const;
00071   virtual CPT(RenderAttrib) invert_compose_impl(const RenderAttrib *other) const;
00072   virtual RenderAttrib *make_default_impl() const;
00073 
00074 private:
00075   int _offset;
00076 
00077 public:
00078   static void register_with_read_factory();
00079   virtual void write_datagram(BamWriter *manager, Datagram &dg);
00080 
00081 protected:
00082   static TypedWritable *make_from_bam(const FactoryParams &params);
00083   void fillin(DatagramIterator &scan, BamReader *manager);
00084   
00085 public:
00086   static TypeHandle get_class_type() {
00087     return _type_handle;
00088   }
00089   static void init_type() {
00090     RenderAttrib::init_type();
00091     register_type(_type_handle, "DepthOffsetAttrib",
00092                   RenderAttrib::get_class_type());
00093   }
00094   virtual TypeHandle get_type() const {
00095     return get_class_type();
00096   }
00097   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00098 
00099 private:
00100   static TypeHandle _type_handle;
00101 };
00102 
00103 #include "depthOffsetAttrib.I"
00104 
00105 #endif
00106 

Generated on Fri May 2 00:41:32 2003 for Panda by doxygen1.3