Panda3D

cullBinBackToFront.h

00001 // Filename: cullBinBackToFront.h
00002 // Created by:  drose (28Feb02)
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 CULLBINBACKTOFRONT_H
00016 #define CULLBINBACKTOFRONT_H
00017 
00018 #include "pandabase.h"
00019 
00020 #include "cullBin.h"
00021 #include "geom.h"
00022 #include "transformState.h"
00023 #include "renderState.h"
00024 #include "pointerTo.h"
00025 
00026 ////////////////////////////////////////////////////////////////////
00027 //       Class : CullBinBackToFront
00028 // Description : A specific kind of CullBin that sorts geometry in
00029 //               order from furthest to nearest based on the center of
00030 //               its bounding volume.  This is primarily intended for
00031 //               rendering transparent and semi-transparent geometry
00032 //               that must be sorted from back to front.
00033 ////////////////////////////////////////////////////////////////////
00034 class EXPCL_PANDA_CULL CullBinBackToFront : public CullBin {
00035 public:
00036   INLINE CullBinBackToFront(const string &name, 
00037                             GraphicsStateGuardianBase *gsg,
00038                             const PStatCollector &draw_region_pcollector);
00039   virtual ~CullBinBackToFront();
00040 
00041   static CullBin *make_bin(const string &name, 
00042                            GraphicsStateGuardianBase *gsg,
00043                            const PStatCollector &draw_region_pcollector);
00044   
00045 
00046   virtual void add_object(CullableObject *object, Thread *current_thread);
00047   virtual void finish_cull(SceneSetup *scene_setup, Thread *current_thread);
00048   virtual void draw(bool force, Thread *current_thread);
00049 
00050 protected:
00051   virtual void fill_result_graph(ResultGraphBuilder &builder);
00052 
00053 private:
00054   class ObjectData {
00055   public:
00056     INLINE ObjectData(CullableObject *object, PN_stdfloat dist);
00057     INLINE bool operator < (const ObjectData &other) const;
00058     
00059     CullableObject *_object;
00060     PN_stdfloat _dist;
00061   };
00062 
00063   typedef pvector<ObjectData> Objects;
00064   Objects _objects;
00065 
00066 public:
00067   static TypeHandle get_class_type() {
00068     return _type_handle;
00069   }
00070   static void init_type() {
00071     CullBin::init_type();
00072     register_type(_type_handle, "CullBinBackToFront",
00073                   CullBin::get_class_type());
00074   }
00075   virtual TypeHandle get_type() const {
00076     return get_class_type();
00077   }
00078   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00079 
00080 private:
00081   static TypeHandle _type_handle;
00082 };
00083 
00084 #include "cullBinBackToFront.I"
00085 
00086 #endif
00087 
00088 
00089   
 All Classes Functions Variables Enumerations