00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
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
00030
00031
00032
00033
00034
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 ¶ms);
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