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

panda/src/pgraph/clipPlaneAttrib.h

Go to the documentation of this file.
00001 // Filename: clipPlaneAttrib.h
00002 // Created by:  drose (11Jul02)
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 CLIPPINGPLANEATTRIB_H
00020 #define CLIPPINGPLANEATTRIB_H
00021 
00022 #include "pandabase.h"
00023 
00024 #include "planeNode.h"
00025 #include "renderAttrib.h"
00026 #include "ordered_vector.h"
00027 
00028 ////////////////////////////////////////////////////////////////////
00029 //       Class : ClipPlaneAttrib
00030 // Description : This functions similarly to a LightAttrib.  It
00031 //               indicates the set of clipping planes that modify the
00032 //               geometry at this level and below.  A ClipPlaneAttrib
00033 //               can either add planes or remove planes from the total
00034 //               set of clipping planes in effect.
00035 ////////////////////////////////////////////////////////////////////
00036 class EXPCL_PANDA ClipPlaneAttrib : public RenderAttrib {
00037 private:
00038   INLINE ClipPlaneAttrib();
00039 
00040 PUBLISHED:
00041   enum Operation {
00042     O_set,
00043     O_add,
00044     O_remove
00045   };
00046 
00047   static CPT(RenderAttrib) make_all_off();
00048   static CPT(RenderAttrib) make(Operation op, 
00049                                 PlaneNode *plane);
00050   static CPT(RenderAttrib) make(Operation op, 
00051                                 PlaneNode *plane1, PlaneNode *plane2);
00052   static CPT(RenderAttrib) make(Operation op, 
00053                                 PlaneNode *plane1, PlaneNode *plane2,
00054                                 PlaneNode *plane3);
00055   static CPT(RenderAttrib) make(Operation op, 
00056                                 PlaneNode *plane1, PlaneNode *plane2,
00057                                 PlaneNode *plane3, PlaneNode *plane4);
00058 
00059   INLINE Operation get_operation() const;
00060 
00061   INLINE int get_num_planes() const;
00062   INLINE PlaneNode *get_plane(int n) const;
00063   bool has_plane(PlaneNode *plane) const;
00064 
00065   INLINE CPT(RenderAttrib) add_plane(PlaneNode *plane) const;
00066   INLINE CPT(RenderAttrib) remove_plane(PlaneNode *plane) const;
00067 
00068   INLINE bool is_identity() const;
00069   INLINE bool is_all_off() const;
00070 
00071 public:
00072   virtual void issue(GraphicsStateGuardianBase *gsg) const;
00073   virtual void output(ostream &out) const;
00074 
00075 protected:
00076   virtual int compare_to_impl(const RenderAttrib *other) const;
00077   virtual CPT(RenderAttrib) compose_impl(const RenderAttrib *other) const;
00078   virtual CPT(RenderAttrib) invert_compose_impl(const RenderAttrib *other) const;
00079   virtual RenderAttrib *make_default_impl() const;
00080 
00081 private:
00082   CPT(RenderAttrib) do_add(const ClipPlaneAttrib *other, Operation op) const;
00083   CPT(RenderAttrib) do_remove(const ClipPlaneAttrib *other, Operation op) const;
00084 
00085 private:
00086   Operation _operation;
00087   typedef ov_set< PT(PlaneNode) > Planes;
00088   Planes _planes;
00089 
00090 public:
00091   static void register_with_read_factory();
00092   virtual void write_datagram(BamWriter *manager, Datagram &dg);
00093   virtual int complete_pointers(TypedWritable **plist, BamReader *manager);
00094 
00095 protected:
00096   static TypedWritable *make_from_bam(const FactoryParams &params);
00097   void fillin(DatagramIterator &scan, BamReader *manager);
00098   
00099 public:
00100   static TypeHandle get_class_type() {
00101     return _type_handle;
00102   }
00103   static void init_type() {
00104     RenderAttrib::init_type();
00105     register_type(_type_handle, "ClipPlaneAttrib",
00106                   RenderAttrib::get_class_type());
00107   }
00108   virtual TypeHandle get_type() const {
00109     return get_class_type();
00110   }
00111   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00112 
00113 private:
00114   static TypeHandle _type_handle;
00115 };
00116 
00117 #include "clipPlaneAttrib.I"
00118 
00119 #endif
00120 

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