Panda3D
 All Classes Functions Variables Enumerations
lensNode.h
1 // Filename: lensNode.h
2 // Created by: drose (26Feb02)
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 LENSNODE_H
16 #define LENSNODE_H
17 
18 #include "pandabase.h"
19 
20 #include "pandaNode.h"
21 #include "lens.h"
22 #include "perspectiveLens.h"
23 #include "pointerTo.h"
24 
25 ////////////////////////////////////////////////////////////////////
26 // Class : LensNode
27 // Description : A node that contains a Lens. The most important
28 // example of this kind of node is a Camera, but other
29 // kinds of nodes also contain a lens (for instance, a
30 // Spotlight).
31 ////////////////////////////////////////////////////////////////////
32 class EXPCL_PANDA_PGRAPH LensNode : public PandaNode {
33 PUBLISHED:
34  LensNode(const string &name, Lens *lens = NULL);
35 
36 protected:
37  LensNode(const LensNode &copy);
38 public:
39  virtual void output(ostream &out) const;
40  virtual void write(ostream &out, int indent_level = 0) const;
41 
42  virtual void xform(const LMatrix4 &mat);
43  virtual PandaNode *make_copy() const;
44 
45 PUBLISHED:
46  INLINE void copy_lens(const Lens &lens);
47  INLINE void copy_lens(int index, const Lens &lens);
48  INLINE void set_lens(Lens *lens);
49  void set_lens(int index, Lens *lens);
50  INLINE Lens *get_lens(int index = 0) const;
51 
52  bool set_lens_active(int index, bool active);
53  INLINE bool get_lens_active(int index) const;
54 
55  INLINE bool activate_lens(int index);
56  INLINE bool deactivate_lens(int index);
57 
58  INLINE bool is_in_view(const LPoint3 &pos);
59  bool is_in_view(int index, const LPoint3 &pos);
60 
61  void show_frustum();
62  void hide_frustum();
63 
64 protected:
65  PT(PandaNode) _shown_frustum;
66 
67  class LensSlot {
68  public:
69  PT(Lens) _lens;
70  bool _is_active;
71  };
72 
73  typedef pvector<LensSlot> Lenses;
74  Lenses _lenses;
75 
76 public:
77  static void register_with_read_factory();
78  virtual void write_datagram(BamWriter *manager, Datagram &dg);
80  BamReader *manager);
81 
82 protected:
83  static TypedWritable *make_from_bam(const FactoryParams &params);
84  void fillin(DatagramIterator &scan, BamReader *manager);
85 
86 public:
87  static TypeHandle get_class_type() {
88  return _type_handle;
89  }
90  static void init_type() {
91  PandaNode::init_type();
92  register_type(_type_handle, "LensNode",
93  PandaNode::get_class_type());
94  }
95  virtual TypeHandle get_type() const {
96  return get_class_type();
97  }
98  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
99 
100 private:
101  static TypeHandle _type_handle;
102 };
103 
104 #include "lensNode.I"
105 
106 #endif
A basic node of the scene graph or data graph.
Definition: pandaNode.h:72
A base class for any number of different kinds of lenses, linear and otherwise.
Definition: lens.h:45
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:4164
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:122
A node that contains a Lens.
Definition: lensNode.h:32
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:37
virtual PandaNode * make_copy() const
Returns a newly-allocated PandaNode that is a shallow copy of this one.
Definition: pandaNode.cxx:604
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 our own Panda specialization on the default STL list.
Definition: plist.h:38
static void register_with_read_factory()
Tells the BamReader how to create objects of type PandaNode.
Definition: pandaNode.cxx:4153
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:377
virtual int complete_pointers(TypedWritable **p_list, BamReader *manager)
Receives an array of pointers, one for each time manager-&gt;read_pointer() was called in fillin()...
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
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