Panda3D
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  */
29 class EXPCL_PANDA_PGRAPH LensNode : public PandaNode {
30 PUBLISHED:
31  explicit LensNode(const std::string &name, Lens *lens = nullptr);
32 
33 protected:
34  LensNode(const LensNode &copy);
35 public:
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 
42 PUBLISHED:
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 
61 protected:
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 
73 public:
74  static void register_with_read_factory();
75  virtual void write_datagram(BamWriter *manager, Datagram &dg);
77  BamReader *manager);
78 
79 protected:
80  static TypedWritable *make_from_bam(const FactoryParams &params);
81  void fillin(DatagramIterator &scan, BamReader *manager);
82 
83 public:
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 
97 private:
98  static TypeHandle _type_handle;
99 };
100 
101 #include "lensNode.I"
102 
103 #endif
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A basic node of the scene graph or data graph.
Definition: pandaNode.h:64
A base class for any number of different kinds of lenses, linear and otherwise.
Definition: lens.h:41
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
Definition: pandaNode.cxx:3589
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:110
A node that contains a Lens.
Definition: lensNode.h:29
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:35
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
Definition: register_type.I:22
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:63
This is our own Panda specialization on the default STL list.
Definition: plist.h:35
static void register_with_read_factory()
Tells the BamReader how to create objects of type PandaNode.
Definition: pandaNode.cxx:3580
virtual void xform(const LMatrix4 &mat)
Transforms the contents of this PandaNode by the indicated matrix, if it means anything to do so.
Definition: pandaNode.cxx:310
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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().
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition: factoryParams.h:36
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual PandaNode * make_copy() const
Returns a newly-allocated PandaNode that is a shallow copy of this one.
Definition: pandaNode.cxx:487
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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:81
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:38