Panda3D

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                          float reference_alpha = 1.0f);
00032 
00033 PUBLISHED:
00034   static CPT(RenderAttrib) make(PandaCompareFunc mode,
00035                                 float reference_alpha);
00036   static CPT(RenderAttrib) make_default();
00037 
00038   INLINE float 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 
00047 private:
00048   PandaCompareFunc _mode;
00049   float _reference_alpha;  // should be in range [0.0-1.0]
00050 
00051 PUBLISHED:
00052   static int get_class_slot() {
00053     return _attrib_slot;
00054   }
00055   virtual int get_slot() const {
00056     return get_class_slot();
00057   }
00058 
00059 public:
00060   static void register_with_read_factory();
00061   virtual void write_datagram(BamWriter *manager, Datagram &dg);
00062 
00063 protected:
00064   static TypedWritable *make_from_bam(const FactoryParams &params);
00065   void fillin(DatagramIterator &scan, BamReader *manager);
00066   
00067 public:
00068   static TypeHandle get_class_type() {
00069     return _type_handle;
00070   }
00071   static void init_type() {
00072     RenderAttrib::init_type();
00073     register_type(_type_handle, "AlphaTestAttrib",
00074                   RenderAttrib::get_class_type());
00075     _attrib_slot = register_slot(_type_handle, 100, make_default);
00076   }
00077   virtual TypeHandle get_type() const {
00078     return get_class_type();
00079   }
00080   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00081 
00082 private:
00083   static TypeHandle _type_handle;
00084   static int _attrib_slot;
00085 };
00086 
00087 #include "alphaTestAttrib.I"
00088 
00089 #endif
00090 
 All Classes Functions Variables Enumerations