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_lod_center(const NodePath &lod_center);
00067   INLINE const NodePath &get_lod_center() const;
00068 
00069   INLINE void set_initial_state(const RenderState *state);
00070   INLINE CPT(RenderState) get_initial_state() const;
00071 
00072   INLINE void set_tag_state_key(const string &tag_state_key);
00073   INLINE const string &get_tag_state_key() const;
00074 
00075   void set_tag_state(const string &tag_state, const RenderState *state);
00076   void clear_tag_state(const string &tag_state);
00077   bool has_tag_state(const string &tag_state) const;
00078   CPT(RenderState) get_tag_state(const string &tag_state) const;
00079 
00080   void set_aux_scene_data(const NodePath &node_path, AuxSceneData *data);
00081   bool clear_aux_scene_data(const NodePath &node_path);
00082   AuxSceneData *get_aux_scene_data(const NodePath &node_path) const;
00083   void list_aux_scene_data(ostream &out) const;
00084   int cleanup_aux_scene_data(Thread *current_thread = Thread::get_current_thread());
00085 
00086 private:
00087   void add_display_region(DisplayRegionBase *display_region);
00088   void remove_display_region(DisplayRegionBase *display_region);
00089 
00090   bool _active;
00091   NodePath _scene;
00092   NodePath _cull_center;
00093   NodePath _lod_center;
00094 
00095   DrawMask _camera_mask;
00096 
00097   typedef pvector<DisplayRegionBase *> DisplayRegions;
00098   DisplayRegions _display_regions;
00099 
00100   CPT(RenderState) _initial_state;
00101   string _tag_state_key;
00102 
00103   typedef pmap<string, CPT(RenderState) > TagStates;
00104   TagStates _tag_states;
00105 
00106   typedef pmap<NodePath, PT(AuxSceneData) > AuxData;
00107   AuxData _aux_data;
00108 
00109 public:
00110   static void register_with_read_factory();
00111   virtual void write_datagram(BamWriter *manager, Datagram &dg);
00112 
00113 protected:
00114   static TypedWritable *make_from_bam(const FactoryParams &params);
00115   void fillin(DatagramIterator &scan, BamReader *manager);
00116 
00117 public:
00118   static TypeHandle get_class_type() {
00119     return _type_handle;
00120   }
00121   static void init_type() {
00122     LensNode::init_type();
00123     register_type(_type_handle, "Camera",
00124                   LensNode::get_class_type());
00125   }
00126   virtual TypeHandle get_type() const {
00127     return get_class_type();
00128   }
00129   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00130 
00131 private:
00132   static TypeHandle _type_handle;
00133 
00134   friend class DisplayRegion;
00135 };
00136 
00137 #include "camera.I"
00138 
00139 #endif
 All Classes Functions Variables Enumerations