camera.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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. #ifndef CAMERA_H
  15. #define CAMERA_H
  16. #include "pandabase.h"
  17. #include "lensNode.h"
  18. #include "perspectiveLens.h"
  19. #include "nodePath.h"
  20. #include "weakNodePath.h"
  21. #include "drawMask.h"
  22. #include "renderState.h"
  23. #include "pointerTo.h"
  24. #include "pmap.h"
  25. #include "auxSceneData.h"
  26. #include "displayRegionBase.h"
  27. ////////////////////////////////////////////////////////////////////
  28. // Class : Camera
  29. // Description : A node that can be positioned around in the scene
  30. // graph to represent a point of view for rendering a
  31. // scene.
  32. ////////////////////////////////////////////////////////////////////
  33. class EXPCL_PANDA_PGRAPH Camera : public LensNode {
  34. PUBLISHED:
  35. Camera(const string &name, Lens *lens = new PerspectiveLens());
  36. Camera(const Camera &copy);
  37. public:
  38. virtual ~Camera();
  39. virtual PandaNode *make_copy() const;
  40. virtual bool safe_to_flatten() const;
  41. virtual bool safe_to_transform() const;
  42. PUBLISHED:
  43. INLINE void set_active(bool active);
  44. INLINE bool is_active() const;
  45. INLINE void set_scene(const NodePath &scene);
  46. INLINE const NodePath &get_scene() const;
  47. INLINE int get_num_display_regions() const;
  48. INLINE DisplayRegionBase *get_display_region(int n) const;
  49. MAKE_SEQ(get_display_regions, get_num_display_regions, get_display_region);
  50. INLINE void set_camera_mask(DrawMask mask);
  51. INLINE DrawMask get_camera_mask() const;
  52. INLINE void set_cull_center(const NodePath &cull_center);
  53. INLINE const NodePath &get_cull_center() const;
  54. INLINE void set_lod_center(const NodePath &lod_center);
  55. INLINE const NodePath &get_lod_center() const;
  56. INLINE void set_initial_state(const RenderState *state);
  57. INLINE CPT(RenderState) get_initial_state() const;
  58. INLINE void set_tag_state_key(const string &tag_state_key);
  59. INLINE const string &get_tag_state_key() const;
  60. void set_tag_state(const string &tag_state, const RenderState *state);
  61. void clear_tag_state(const string &tag_state);
  62. bool has_tag_state(const string &tag_state) const;
  63. CPT(RenderState) get_tag_state(const string &tag_state) const;
  64. void set_aux_scene_data(const NodePath &node_path, AuxSceneData *data);
  65. bool clear_aux_scene_data(const NodePath &node_path);
  66. AuxSceneData *get_aux_scene_data(const NodePath &node_path) const;
  67. void list_aux_scene_data(ostream &out) const;
  68. int cleanup_aux_scene_data(Thread *current_thread = Thread::get_current_thread());
  69. private:
  70. void add_display_region(DisplayRegionBase *display_region);
  71. void remove_display_region(DisplayRegionBase *display_region);
  72. bool _active;
  73. NodePath _scene;
  74. NodePath _cull_center;
  75. NodePath _lod_center;
  76. DrawMask _camera_mask;
  77. typedef pvector<DisplayRegionBase *> DisplayRegions;
  78. DisplayRegions _display_regions;
  79. CPT(RenderState) _initial_state;
  80. string _tag_state_key;
  81. typedef pmap<string, CPT(RenderState) > TagStates;
  82. TagStates _tag_states;
  83. typedef pmap<NodePath, PT(AuxSceneData) > AuxData;
  84. AuxData _aux_data;
  85. public:
  86. static void register_with_read_factory();
  87. virtual void write_datagram(BamWriter *manager, Datagram &dg);
  88. protected:
  89. static TypedWritable *make_from_bam(const FactoryParams &params);
  90. void fillin(DatagramIterator &scan, BamReader *manager);
  91. public:
  92. static TypeHandle get_class_type() {
  93. return _type_handle;
  94. }
  95. static void init_type() {
  96. LensNode::init_type();
  97. register_type(_type_handle, "Camera",
  98. LensNode::get_class_type());
  99. }
  100. virtual TypeHandle get_type() const {
  101. return get_class_type();
  102. }
  103. virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
  104. private:
  105. static TypeHandle _type_handle;
  106. friend class DisplayRegion;
  107. };
  108. #include "camera.I"
  109. #endif