Panda3D
 All Classes Functions Variables Enumerations
lensNode.I
1 // Filename: lensNode.I
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 
16 ////////////////////////////////////////////////////////////////////
17 // Function: LensNode::copy_lens
18 // Access: Published
19 // Description: Sets up the LensNode using a copy of the
20 // indicated Lens. If the original Lens is
21 // changed or destroyed, this LensNode is not
22 // affected.
23 ////////////////////////////////////////////////////////////////////
24 INLINE void LensNode::
25 copy_lens(const Lens &lens) {
26  return copy_lens(0, lens);
27 }
28 
29 ////////////////////////////////////////////////////////////////////
30 // Function: LensNode::copy_lens
31 // Access: Published
32 // Description: Copies the indicated lens into the specified slot.
33 ////////////////////////////////////////////////////////////////////
34 INLINE void LensNode::
35 copy_lens(int index, const Lens &lens) {
36  set_lens(index, lens.make_copy());
37 }
38 
39 ////////////////////////////////////////////////////////////////////
40 // Function: LensNode::set_lens
41 // Access: Published
42 // Description: Sets up the LensNode using this particular Lens
43 // pointer. If the lens is subsequently modified, the
44 // LensNode properties immediately reflect the change.
45 ////////////////////////////////////////////////////////////////////
46 INLINE void LensNode::
47 set_lens(Lens *lens) {
48  return set_lens(0, lens);
49 }
50 
51 ////////////////////////////////////////////////////////////////////
52 // Function: LensNode::get_lens
53 // Access: Published
54 // Description: Returns a pointer to the particular Lens
55 // associated with this LensNode, or NULL if there is
56 // not yet a Lens associated. If an index number is
57 // specified, returns the nth lens.
58 ////////////////////////////////////////////////////////////////////
59 INLINE Lens *LensNode::
60 get_lens(int index) const {
61  nassertr(index >= 0 && index < max_lenses, NULL); // Sanity check
62 
63  if (index < (int)_lenses.size()) {
64  return _lenses[index]._lens;
65  }
66  return NULL;
67 }
68 
69 ////////////////////////////////////////////////////////////////////
70 // Function: LensNode::get_lens_active
71 // Access: Published
72 // Description: Returns the active flag for the nth lens.
73 ////////////////////////////////////////////////////////////////////
74 INLINE bool LensNode::
75 get_lens_active(int index) const {
76  nassertr(index >= 0 && index < max_lenses, false);
77 
78  if (index < (int)_lenses.size()) {
79  return _lenses[index]._is_active;
80  }
81  return false;
82 }
83 
84 ////////////////////////////////////////////////////////////////////
85 // Function: LensNode::activate_lens
86 // Access: Published
87 // Description: An alternate way to call set_lens_active(index,
88 // true).
89 ////////////////////////////////////////////////////////////////////
90 INLINE bool LensNode::
91 activate_lens(int index) {
92  return set_lens_active(index, true);
93 }
94 
95 ////////////////////////////////////////////////////////////////////
96 // Function: LensNode::deactivate_lens
97 // Access: Published
98 // Description: An alternate way to call set_lens_active(index,
99 // false).
100 ////////////////////////////////////////////////////////////////////
101 INLINE bool LensNode::
102 deactivate_lens(int index) {
103  return set_lens_active(index, false);
104 }
105 
106 ////////////////////////////////////////////////////////////////////
107 // Function: LensNode::is_in_view
108 // Access: Published
109 // Description: Returns true if the given point is within the bounds
110 // of the lens of the LensNode (i.e. if the camera can
111 // see the point).
112 ////////////////////////////////////////////////////////////////////
113 INLINE bool LensNode::
114 is_in_view(const LPoint3 &pos) {
115  return is_in_view(0, pos);
116 }
117 
bool is_in_view(const LPoint3 &pos)
Returns true if the given point is within the bounds of the lens of the LensNode (i.e.
Definition: lensNode.I:114
A base class for any number of different kinds of lenses, linear and otherwise.
Definition: lens.h:45
void set_lens(Lens *lens)
Sets up the LensNode using this particular Lens pointer.
Definition: lensNode.I:47
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
Definition: lpoint3.h:99
bool get_lens_active(int index) const
Returns the active flag for the nth lens.
Definition: lensNode.I:75
bool activate_lens(int index)
An alternate way to call set_lens_active(index, true).
Definition: lensNode.I:91
bool set_lens_active(int index, bool active)
Sets the active flag for the nth lens.
Definition: lensNode.cxx:117
void copy_lens(const Lens &lens)
Sets up the LensNode using a copy of the indicated Lens.
Definition: lensNode.I:25
bool deactivate_lens(int index)
An alternate way to call set_lens_active(index, false).
Definition: lensNode.I:102
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:60