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