Panda3D
 All Classes Functions Variables Enumerations
alphaTestAttrib.h
00001 // Filename: alphaTestAttrib.h
00002 // Created by:  drose (04Mar02)
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 ALPHATESTATTRIB_H
00016 #define ALPHATESTATTRIB_H
00017 
00018 #include "pandabase.h"
00019 #include "renderAttrib.h"
00020 
00021 class FactoryParams;
00022 
00023 ////////////////////////////////////////////////////////////////////
00024 //       Class : AlphaTestAttrib
00025 // Description : Enables or disables writing of pixel to framebuffer
00026 //               based on its alpha value relative to a reference alpha value
00027 ////////////////////////////////////////////////////////////////////
00028 class EXPCL_PANDA_PGRAPH AlphaTestAttrib : public RenderAttrib {
00029 private:
00030   INLINE AlphaTestAttrib(PandaCompareFunc mode = M_always,
00031                          PN_stdfloat reference_alpha = 1.0f);
00032 
00033 PUBLISHED:
00034   static CPT(RenderAttrib) make(PandaCompareFunc mode,
00035                                 PN_stdfloat reference_alpha);
00036   static CPT(RenderAttrib) make_default();
00037 
00038   INLINE PN_stdfloat get_reference_alpha() const;
00039   INLINE PandaCompareFunc get_mode() const;
00040 
00041 public:
00042   virtual void output(ostream &out) const;
00043 
00044 protected:
00045   virtual int compare_to_impl(const RenderAttrib *other) const;
00046   virtual size_t get_hash_impl() const;
00047   virtual CPT(RenderAttrib) get_auto_shader_attrib_impl(const RenderState *state) const;
00048 
00049 private:
00050   PandaCompareFunc _mode;
00051   PN_stdfloat _reference_alpha;  // should be in range [0.0-1.0]
00052 
00053 PUBLISHED:
00054   static int get_class_slot() {
00055     return _attrib_slot;
00056   }
00057   virtual int get_slot() const {
00058     return get_class_slot();
00059   }
00060 
00061 public:
00062   static void register_with_read_factory();
00063   virtual void write_datagram(BamWriter *manager, Datagram &dg);
00064 
00065 protected:
00066   static TypedWritable *make_from_bam(const FactoryParams &params);
00067   void fillin(DatagramIterator &scan, BamReader *manager);
00068   
00069 public:
00070   static TypeHandle get_class_type() {
00071     return _type_handle;
00072   }
00073   static void init_type() {
00074     RenderAttrib::init_type();
00075     register_type(_type_handle, "AlphaTestAttrib",
00076                   RenderAttrib::get_class_type());
00077     _attrib_slot = register_slot(_type_handle, 100, make_default);
00078   }
00079   virtual TypeHandle get_type() const {
00080     return get_class_type();
00081   }
00082   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00083 
00084 private:
00085   static TypeHandle _type_handle;
00086   static int _attrib_slot;
00087 };
00088 
00089 #include "alphaTestAttrib.I"
00090 
00091 #endif
00092 
 All Classes Functions Variables Enumerations