00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef SCISSOREFFECT_H
00016 #define SCISSOREFFECT_H
00017
00018 #include "pandabase.h"
00019
00020 #include "renderEffect.h"
00021 #include "luse.h"
00022 #include "nodePath.h"
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 class EXPCL_PANDA_PGRAPH ScissorEffect : public RenderEffect {
00033 private:
00034 class PointDef {
00035 public:
00036 LPoint3 _p;
00037 NodePath _node;
00038 };
00039
00040 ScissorEffect(bool screen, const LVecBase4 &frame,
00041 const PointDef *points, int num_points, bool clip);
00042 ScissorEffect(const ScissorEffect ©);
00043
00044 PUBLISHED:
00045 static CPT(RenderEffect) make_screen(const LVecBase4 &frame, bool clip = true);
00046 static CPT(RenderEffect) make_node(bool clip = true);
00047 static CPT(RenderEffect) make_node(const LPoint3 &a, const LPoint3 &b, const NodePath &node = NodePath());
00048 static CPT(RenderEffect) make_node(const LPoint3 &a, const LPoint3 &b, const LPoint3 &c, const LPoint3 &d, const NodePath &node = NodePath());
00049 CPT(RenderEffect) add_point(const LPoint3 &point, const NodePath &node = NodePath()) const;
00050
00051 INLINE bool is_screen() const;
00052 INLINE const LVecBase4 &get_frame() const;
00053
00054 INLINE int get_num_points() const;
00055 INLINE const LPoint3 &get_point(int n) const;
00056 MAKE_SEQ(get_points, get_num_points, get_point);
00057 INLINE NodePath get_node(int n) const;
00058 MAKE_SEQ(get_nodes, get_num_points, get_node);
00059
00060 INLINE bool get_clip() const;
00061
00062 public:
00063 virtual CPT(RenderEffect) xform(const LMatrix4 &mat) const;
00064 virtual void output(ostream &out) const;
00065
00066 virtual bool has_cull_callback() const;
00067 virtual void cull_callback(CullTraverser *trav, CullTraverserData &data,
00068 CPT(TransformState) &node_transform,
00069 CPT(RenderState) &node_state) const;
00070
00071 protected:
00072 virtual int compare_to_impl(const RenderEffect *other) const;
00073
00074 private:
00075 PT(GeometricBoundingVolume) make_frustum(const Lens *lens, const LVecBase4 &frame) const;
00076
00077 private:
00078 bool _screen;
00079 LVecBase4 _frame;
00080 typedef pvector<PointDef> Points;
00081 Points _points;
00082 bool _clip;
00083
00084 public:
00085 static void register_with_read_factory();
00086 virtual void write_datagram(BamWriter *manager, Datagram &dg);
00087
00088 protected:
00089 static TypedWritable *make_from_bam(const FactoryParams ¶ms);
00090 void fillin(DatagramIterator &scan, BamReader *manager);
00091
00092 public:
00093 static TypeHandle get_class_type() {
00094 return _type_handle;
00095 }
00096 static void init_type() {
00097 RenderEffect::init_type();
00098 register_type(_type_handle, "ScissorEffect",
00099 RenderEffect::get_class_type());
00100 }
00101 virtual TypeHandle get_type() const {
00102 return get_class_type();
00103 }
00104 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00105
00106 private:
00107 static TypeHandle _type_handle;
00108 };
00109
00110 #include "scissorEffect.I"
00111
00112 #endif
00113