Panda3D

camera.h

00001 // Filename: camera.h
00002 // Created by:  drose (26Feb02)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #ifndef CAMERA_H
00016 #define CAMERA_H
00017 
00018 #include "pandabase.h"
00019 
00020 #include "lensNode.h"
00021 #include "perspectiveLens.h"
00022 #include "nodePath.h"
00023 #include "weakNodePath.h"
00024 #include "drawMask.h"
00025 #include "renderState.h"
00026 #include "pointerTo.h"
00027 #include "pmap.h"
00028 #include "auxSceneData.h"
00029 #include "displayRegionBase.h"
00030 
00031 ////////////////////////////////////////////////////////////////////
00032 //       Class : Camera
00033 // Description : A node that can be positioned around in the scene
00034 //               graph to represent a point of view for rendering a
00035 //               scene.
00036 ////////////////////////////////////////////////////////////////////
00037 class EXPCL_PANDA_PGRAPH Camera : public LensNode {
00038 PUBLISHED:
00039   Camera(const string &name, Lens *lens = new PerspectiveLens());
00040   Camera(const Camera &copy);
00041 
00042 public:
00043   virtual ~Camera();
00044 
00045   virtual PandaNode *make_copy() const;
00046   virtual bool safe_to_flatten() const;
00047   virtual bool safe_to_transform() const;
00048 
00049 PUBLISHED:
00050   INLINE void set_active(bool active);
00051   INLINE bool is_active() const;
00052 
00053   INLINE void set_scene(const NodePath &scene);
00054   INLINE const NodePath &get_scene() const;
00055 
00056   INLINE int get_num_display_regions() const;
00057   INLINE DisplayRegionBase *get_display_region(int n) const;
00058   MAKE_SEQ(get_display_regions, get_num_display_regions, get_display_region);
00059 
00060   INLINE void set_camera_mask(DrawMask mask);
00061   INLINE DrawMask get_camera_mask() const;
00062 
00063   INLINE void set_cull_center(const NodePath &cull_center);
00064   INLINE const NodePath &get_cull_center() const;
00065 
00066   INLINE void set_cull_bounds(BoundingVolume *cull_bounds);
00067   INLINE BoundingVolume *get_cull_bounds() const;
00068 
00069   INLINE void set_lod_center(const NodePath &lod_center);
00070   INLINE const NodePath &get_lod_center() const;
00071 
00072   INLINE void set_initial_state(const RenderState *state);
00073   INLINE CPT(RenderState) get_initial_state() const;
00074 
00075   INLINE void set_tag_state_key(const string &tag_state_key);
00076   INLINE const string &get_tag_state_key() const;
00077 
00078   void set_tag_state(const string &tag_state, const RenderState *state);
00079   void clear_tag_state(const string &tag_state);
00080   bool has_tag_state(const string &tag_state) const;
00081   CPT(RenderState) get_tag_state(const string &tag_state) const;
00082 
00083   void set_aux_scene_data(const NodePath &node_path, AuxSceneData *data);
00084   bool clear_aux_scene_data(const NodePath &node_path);
00085   AuxSceneData *get_aux_scene_data(const NodePath &node_path) const;
00086   void list_aux_scene_data(ostream &out) const;
00087   int cleanup_aux_scene_data(Thread *current_thread = Thread::get_current_thread());
00088 
00089 private:
00090   void add_display_region(DisplayRegionBase *display_region);
00091   void remove_display_region(DisplayRegionBase *display_region);
00092 
00093   bool _active;
00094   NodePath _scene;
00095   NodePath _cull_center;
00096   PT(BoundingVolume) _cull_bounds;
00097   NodePath _lod_center;
00098 
00099   DrawMask _camera_mask;
00100 
00101   typedef pvector<DisplayRegionBase *> DisplayRegions;
00102   DisplayRegions _display_regions;
00103 
00104   CPT(RenderState) _initial_state;
00105   string _tag_state_key;
00106 
00107   typedef pmap<string, CPT(RenderState) > TagStates;
00108   TagStates _tag_states;
00109 
00110   typedef pmap<NodePath, PT(AuxSceneData) > AuxData;
00111   AuxData _aux_data;
00112 
00113 public:
00114   static void register_with_read_factory();
00115   virtual void write_datagram(BamWriter *manager, Datagram &dg);
00116 
00117 protected:
00118   static TypedWritable *make_from_bam(const FactoryParams &params);
00119   void fillin(DatagramIterator &scan, BamReader *manager);
00120 
00121 public:
00122   static TypeHandle get_class_type() {
00123     return _type_handle;
00124   }
00125   static void init_type() {
00126     LensNode::init_type();
00127     register_type(_type_handle, "Camera",
00128                   LensNode::get_class_type());
00129   }
00130   virtual TypeHandle get_type() const {
00131     return get_class_type();
00132   }
00133   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00134 
00135 private:
00136   static TypeHandle _type_handle;
00137 
00138   friend class DisplayRegion;
00139 };
00140 
00141 #include "camera.I"
00142 
00143 #endif
 All Classes Functions Variables Enumerations