Panda3D
scissorEffect.h
1 // Filename: scissorEffect.h
2 // Created by: drose (30Jul08)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef SCISSOREFFECT_H
16 #define SCISSOREFFECT_H
17 
18 #include "pandabase.h"
19 
20 #include "renderEffect.h"
21 #include "luse.h"
22 #include "nodePath.h"
23 
24 // Forward declarations
25 class Lens;
26 
27 ////////////////////////////////////////////////////////////////////
28 // Class : ScissorEffect
29 // Description : This provides a higher-level wrapper around
30 // ScissorAttrib. It allows for the scissor region to
31 // be defined via points relative to the current node,
32 // and also performs culling based on the scissor
33 // region.
34 ////////////////////////////////////////////////////////////////////
35 class EXPCL_PANDA_PGRAPH ScissorEffect : public RenderEffect {
36 private:
37  class PointDef {
38  public:
39  LPoint3 _p;
40  NodePath _node;
41  };
42 
43  ScissorEffect(bool screen, const LVecBase4 &frame,
44  const PointDef *points, int num_points, bool clip);
45  ScissorEffect(const ScissorEffect &copy);
46 
47 PUBLISHED:
48  static CPT(RenderEffect) make_screen(const LVecBase4 &frame, bool clip = true);
49  static CPT(RenderEffect) make_node(bool clip = true);
50  static CPT(RenderEffect) make_node(const LPoint3 &a, const LPoint3 &b, const NodePath &node = NodePath());
51  static CPT(RenderEffect) make_node(const LPoint3 &a, const LPoint3 &b, const LPoint3 &c, const LPoint3 &d, const NodePath &node = NodePath());
52  CPT(RenderEffect) add_point(const LPoint3 &point, const NodePath &node = NodePath()) const;
53 
54  INLINE bool is_screen() const;
55  INLINE const LVecBase4 &get_frame() const;
56 
57  INLINE int get_num_points() const;
58  INLINE const LPoint3 &get_point(int n) const;
59  MAKE_SEQ(get_points, get_num_points, get_point);
60  INLINE NodePath get_node(int n) const;
61  MAKE_SEQ(get_nodes, get_num_points, get_node);
62 
63  INLINE bool get_clip() const;
64 
65 public:
66  virtual CPT(RenderEffect) xform(const LMatrix4 &mat) const;
67  virtual void output(ostream &out) const;
68 
69  virtual bool has_cull_callback() const;
70  virtual void cull_callback(CullTraverser *trav, CullTraverserData &data,
71  CPT(TransformState) &node_transform,
72  CPT(RenderState) &node_state) const;
73 
74 protected:
75  virtual int compare_to_impl(const RenderEffect *other) const;
76 
77 private:
78  PT(GeometricBoundingVolume) make_frustum(const Lens *lens, const LVecBase4 &frame) const;
79 
80 private:
81  bool _screen;
82  LVecBase4 _frame;
83  typedef pvector<PointDef> Points;
84  Points _points;
85  bool _clip;
86 
87 public:
88  static void register_with_read_factory();
89  virtual void write_datagram(BamWriter *manager, Datagram &dg);
90 
91 protected:
92  static TypedWritable *make_from_bam(const FactoryParams &params);
93  void fillin(DatagramIterator &scan, BamReader *manager);
94 
95 public:
96  static TypeHandle get_class_type() {
97  return _type_handle;
98  }
99  static void init_type() {
100  RenderEffect::init_type();
101  register_type(_type_handle, "ScissorEffect",
102  RenderEffect::get_class_type());
103  }
104  virtual TypeHandle get_type() const {
105  return get_class_type();
106  }
107  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
108 
109 private:
110  static TypeHandle _type_handle;
111 };
112 
113 #include "scissorEffect.I"
114 
115 #endif
116 
This provides a higher-level wrapper around ScissorAttrib.
Definition: scissorEffect.h:35
A base class for any number of different kinds of lenses, linear and otherwise.
Definition: lens.h:45
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:122
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:37
This collects together the pieces of data that are accumulated for each node while walking the scene ...
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
Definition: lpoint3.h:99
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:73
This is the base class for a number of special render effects that may be set on scene graph nodes to...
Definition: renderEffect.h:56
This is another abstract class, for a general class of bounding volumes that actually enclose points ...
This is a 4-by-4 transform matrix.
Definition: lmatrix.h:451
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition: factoryParams.h:40
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
Definition: renderState.h:53
This is the base class for all three-component vectors and points.
Definition: lvecBase4.h:111
A class to retrieve the individual data elements previously stored in a Datagram. ...
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:43
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition: nodePath.h:165
This object performs a depth-first traversal of the scene graph, with optional view-frustum culling...
Definition: cullTraverser.h:48