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

panda/src/pgraph/transparencyAttrib.h

Go to the documentation of this file.
00001 // Filename: transparencyAttrib.h
00002 // Created by:  drose (28Feb02)
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 TRANSPARENCYATTRIB_H
00020 #define TRANSPARENCYATTRIB_H
00021 
00022 #include "pandabase.h"
00023 
00024 #include "renderAttrib.h"
00025 
00026 ////////////////////////////////////////////////////////////////////
00027 //       Class : TransparencyAttrib
00028 // Description : This controls the enabling of transparency.  Simply
00029 //               setting an alpha component to non-1 does not in
00030 //               itself make an object transparent; you must also
00031 //               enable transparency mode with a suitable
00032 //               TransparencyTransition.  Similarly, it is wasteful to
00033 //               render an object with a TransparencyTransition in
00034 //               effect unless you actually want it to be at least
00035 //               partially transparent (and it has alpha components
00036 //               less than 1).
00037 ////////////////////////////////////////////////////////////////////
00038 class EXPCL_PANDA TransparencyAttrib : public RenderAttrib {
00039 PUBLISHED:
00040   enum Mode {
00041     M_none,             // No transparency in effect.
00042     M_alpha,            // Writes to depth buffer of transp objects disabled
00043     M_alpha_sorted,     // Assumes transp objects are depth sorted
00044     M_multisample,      // Source alpha values modified to 1.0 before writing
00045     M_multisample_mask, // Source alpha values not modified
00046     M_binary,           // Only writes pixels with alpha = 1.0
00047     M_dual,             // 2-pass: draws opaque, then draws transparent
00048   };
00049 
00050 private:
00051   INLINE TransparencyAttrib(Mode mode = M_none);
00052 
00053 PUBLISHED:
00054   static CPT(RenderAttrib) make(Mode mode);
00055 
00056   INLINE Mode get_mode() const;
00057 
00058 public:
00059   virtual void issue(GraphicsStateGuardianBase *gsg) const;
00060   virtual void output(ostream &out) const;
00061 
00062 protected:
00063   virtual int compare_to_impl(const RenderAttrib *other) const;
00064   virtual RenderAttrib *make_default_impl() const;
00065 
00066 private:
00067   Mode _mode;
00068 
00069 public:
00070   static void register_with_read_factory();
00071   virtual void write_datagram(BamWriter *manager, Datagram &dg);
00072 
00073 protected:
00074   static TypedWritable *make_from_bam(const FactoryParams &params);
00075   void fillin(DatagramIterator &scan, BamReader *manager);
00076   
00077 public:
00078   static TypeHandle get_class_type() {
00079     return _type_handle;
00080   }
00081   static void init_type() {
00082     RenderAttrib::init_type();
00083     register_type(_type_handle, "TransparencyAttrib",
00084                   RenderAttrib::get_class_type());
00085   }
00086   virtual TypeHandle get_type() const {
00087     return get_class_type();
00088   }
00089   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00090 
00091 private:
00092   static TypeHandle _type_handle;
00093 };
00094 
00095 #include "transparencyAttrib.I"
00096 
00097 #endif
00098 

Generated on Fri May 2 00:42:33 2003 for Panda by doxygen1.3