Panda3D
Loading...
Searching...
No Matches
lensNode.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 lensNode.h
10 * @author drose
11 * @date 2002-02-26
12 */
13
14#ifndef LENSNODE_H
15#define LENSNODE_H
16
17#include "pandabase.h"
18
19#include "pandaNode.h"
20#include "lens.h"
21#include "perspectiveLens.h"
22#include "pointerTo.h"
23
24/**
25 * A node that contains a Lens. The most important example of this kind of
26 * node is a Camera, but other kinds of nodes also contain a lens (for
27 * instance, a Spotlight).
28 */
29class EXPCL_PANDA_PGRAPH LensNode : public PandaNode {
30PUBLISHED:
31 explicit LensNode(const std::string &name, Lens *lens = nullptr);
32
33protected:
34 LensNode(const LensNode &copy);
35public:
36 virtual void output(std::ostream &out) const;
37 virtual void write(std::ostream &out, int indent_level = 0) const;
38
39 virtual void xform(const LMatrix4 &mat);
40 virtual PandaNode *make_copy() const;
41
42PUBLISHED:
43 INLINE void copy_lens(const Lens &lens);
44 INLINE void copy_lens(int index, const Lens &lens);
45 INLINE void set_lens(Lens *lens);
46 void set_lens(int index, Lens *lens);
47 INLINE Lens *get_lens(int index = 0) const;
48
49 bool set_lens_active(int index, bool active);
50 INLINE bool get_lens_active(int index) const;
51
52 INLINE bool activate_lens(int index);
53 INLINE bool deactivate_lens(int index);
54
55 INLINE bool is_in_view(const LPoint3 &pos);
56 bool is_in_view(int index, const LPoint3 &pos);
57
58 void show_frustum();
59 void hide_frustum();
60
61protected:
62 PT(PandaNode) _shown_frustum;
63
64 class LensSlot {
65 public:
66 PT(Lens) _lens;
67 bool _is_active;
68 };
69
70 typedef pvector<LensSlot> Lenses;
71 Lenses _lenses;
72
73public:
74 static void register_with_read_factory();
75 virtual void write_datagram(BamWriter *manager, Datagram &dg);
76 virtual int complete_pointers(TypedWritable **plist,
77 BamReader *manager);
78
79protected:
80 static TypedWritable *make_from_bam(const FactoryParams &params);
81 void fillin(DatagramIterator &scan, BamReader *manager);
82
83public:
84 static TypeHandle get_class_type() {
85 return _type_handle;
86 }
87 static void init_type() {
88 PandaNode::init_type();
89 register_type(_type_handle, "LensNode",
90 PandaNode::get_class_type());
91 }
92 virtual TypeHandle get_type() const {
93 return get_class_type();
94 }
95 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
96
97private:
98 static TypeHandle _type_handle;
99};
100
101#include "lensNode.I"
102
103#endif
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition bamReader.h:110
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...
void hide_frustum()
Disables the drawing of the lens's frustum to aid in visualization.
Definition lensNode.cxx:164
void set_lens(Lens *lens)
Sets up the LensNode using this particular Lens pointer.
Definition lensNode.I:37
void show_frustum()
Enables the drawing of the lens's frustum to aid in visualization.
Definition lensNode.cxx:143
void copy_lens(const Lens &lens)
Sets up the LensNode using a copy of the indicated Lens.
Definition lensNode.I:19
bool is_in_view(const LPoint3 &pos)
Returns true if the given point is within the bounds of the lens of the LensNode (i....
Definition lensNode.I:90
bool set_lens_active(int index, bool active)
Sets the active flag for the nth lens.
Definition lensNode.cxx:99
Lens * get_lens(int index=0) const
Returns a pointer to the particular Lens associated with this LensNode, or NULL if there is not yet a...
Definition lensNode.I:47
bool activate_lens(int index)
An alternate way to call set_lens_active(index, true).
Definition lensNode.I:73
bool deactivate_lens(int index)
An alternate way to call set_lens_active(index, false).
Definition lensNode.I:81
bool get_lens_active(int index) const
Returns the active flag for the nth lens.
Definition lensNode.I:60
A base class for any number of different kinds of lenses, linear and otherwise.
Definition lens.h:41
static void register_with_read_factory()
Tells the BamReader how to create objects of type PandaNode.
virtual void xform(const LMatrix4 &mat)
Transforms the contents of this PandaNode by the indicated matrix, if it means anything to do so.
virtual PandaNode * make_copy() const
Returns a newly-allocated PandaNode that is a shallow copy of this one.
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
virtual int complete_pointers(TypedWritable **p_list, BamReader *manager)
Receives an array of pointers, one for each time manager->read_pointer() was called in fillin().
This is our own Panda specialization on the default STL list.
Definition plist.h:35
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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(),...