Panda3D
 All Classes Functions Variables Enumerations
camera.h
1 // Filename: camera.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 CAMERA_H
16 #define CAMERA_H
17 
18 #include "pandabase.h"
19 
20 #include "lensNode.h"
21 #include "perspectiveLens.h"
22 #include "nodePath.h"
23 #include "weakNodePath.h"
24 #include "drawMask.h"
25 #include "renderState.h"
26 #include "pointerTo.h"
27 #include "pmap.h"
28 #include "auxSceneData.h"
29 #include "displayRegionBase.h"
30 
31 ////////////////////////////////////////////////////////////////////
32 // Class : Camera
33 // Description : A node that can be positioned around in the scene
34 // graph to represent a point of view for rendering a
35 // scene.
36 ////////////////////////////////////////////////////////////////////
37 class EXPCL_PANDA_PGRAPH Camera : public LensNode {
38 PUBLISHED:
39  Camera(const string &name, Lens *lens = new PerspectiveLens());
40  Camera(const Camera &copy);
41 
42 public:
43  virtual ~Camera();
44 
45  virtual PandaNode *make_copy() const;
46  virtual bool safe_to_flatten() const;
47  virtual bool safe_to_transform() const;
48 
49 PUBLISHED:
50  INLINE void set_active(bool active);
51  INLINE bool is_active() const;
52 
53  INLINE void set_scene(const NodePath &scene);
54  INLINE const NodePath &get_scene() const;
55 
56  INLINE int get_num_display_regions() const;
57  INLINE DisplayRegionBase *get_display_region(int n) const;
58  MAKE_SEQ(get_display_regions, get_num_display_regions, get_display_region);
59 
60  INLINE void set_camera_mask(DrawMask mask);
61  INLINE DrawMask get_camera_mask() const;
62 
63  INLINE void set_cull_center(const NodePath &cull_center);
64  INLINE const NodePath &get_cull_center() const;
65 
66  INLINE void set_cull_bounds(BoundingVolume *cull_bounds);
67  INLINE BoundingVolume *get_cull_bounds() const;
68 
69  INLINE void set_lod_center(const NodePath &lod_center);
70  INLINE const NodePath &get_lod_center() const;
71 
72  INLINE void set_initial_state(const RenderState *state);
73  INLINE CPT(RenderState) get_initial_state() const;
74 
75  INLINE void set_tag_state_key(const string &tag_state_key);
76  INLINE const string &get_tag_state_key() const;
77 
78  INLINE void set_lod_scale(PN_stdfloat value);
79  INLINE PN_stdfloat get_lod_scale() const;
80 
81  void set_tag_state(const string &tag_state, const RenderState *state);
82  void clear_tag_state(const string &tag_state);
83  bool has_tag_state(const string &tag_state) const;
84  CPT(RenderState) get_tag_state(const string &tag_state) const;
85 
86  void set_aux_scene_data(const NodePath &node_path, AuxSceneData *data);
87  bool clear_aux_scene_data(const NodePath &node_path);
88  AuxSceneData *get_aux_scene_data(const NodePath &node_path) const;
89  void list_aux_scene_data(ostream &out) const;
90  int cleanup_aux_scene_data(Thread *current_thread = Thread::get_current_thread());
91 
92 private:
93  void add_display_region(DisplayRegionBase *display_region);
94  void remove_display_region(DisplayRegionBase *display_region);
95 
96  bool _active;
97  NodePath _scene;
98  NodePath _cull_center;
99  PT(BoundingVolume) _cull_bounds;
100  NodePath _lod_center;
101 
102  DrawMask _camera_mask;
103  PN_stdfloat _lod_scale;
104 
106  DisplayRegions _display_regions;
107 
108  CPT(RenderState) _initial_state;
109  string _tag_state_key;
110 
112  TagStates _tag_states;
113 
115  AuxData _aux_data;
116 
117 public:
118  static void register_with_read_factory();
119  virtual void write_datagram(BamWriter *manager, Datagram &dg);
120 
121 protected:
122  static TypedWritable *make_from_bam(const FactoryParams &params);
123  void fillin(DatagramIterator &scan, BamReader *manager);
124 
125 public:
126  static TypeHandle get_class_type() {
127  return _type_handle;
128  }
129  static void init_type() {
130  LensNode::init_type();
131  register_type(_type_handle, "Camera",
132  LensNode::get_class_type());
133  }
134  virtual TypeHandle get_type() const {
135  return get_class_type();
136  }
137  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
138 
139 private:
140  static TypeHandle _type_handle;
141 
142  friend class DisplayRegion;
143 };
144 
145 #include "camera.I"
146 
147 #endif
This is a base class for a generic data structure that can be attached per-instance to the camera...
Definition: auxSceneData.h:35
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
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
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:73
static Thread * get_current_thread()
Returns a pointer to the currently-executing Thread object.
Definition: thread.I:145
This is an abstract class for any volume in any sense which can be said to define the locality of ref...
static void register_with_read_factory()
Tells the BamReader how to create objects of type LensNode.
Definition: lensNode.cxx:243
virtual bool safe_to_transform() const
Returns true if it is generally safe to transform this particular kind of PandaNode by calling the xf...
Definition: pandaNode.cxx:249
A perspective-type lens: a normal camera.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition: factoryParams.h:40
virtual PandaNode * make_copy() const
Returns a newly-allocated Node that is a shallow copy of this one.
Definition: lensNode.cxx:75
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
Definition: renderState.h:53
A thread; that is, a lightweight process.
Definition: thread.h:51
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: lensNode.cxx:254
A rectangular subregion within a window for rendering into.
Definition: displayRegion.h:61
An abstract base class for DisplayRegion, mainly so we can store DisplayRegion pointers in a Camera...
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
A node that can be positioned around in the scene graph to represent a point of view for rendering a ...
Definition: camera.h:37
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:43
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition: nodePath.h:165
virtual bool safe_to_flatten() const
Returns true if it is generally safe to flatten out this particular kind of PandaNode by duplicating ...
Definition: pandaNode.cxx:237