Panda3D
Loading...
Searching...
No Matches
camera.h
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file camera.h
10 * @author drose
11 * @date 2002-02-26
12 */
13
14#ifndef CAMERA_H
15#define CAMERA_H
16
17#include "pandabase.h"
18
19#include "lensNode.h"
20#include "perspectiveLens.h"
21#include "nodePath.h"
22#include "weakNodePath.h"
23#include "drawMask.h"
24#include "renderState.h"
25#include "pointerTo.h"
26#include "pmap.h"
27#include "auxSceneData.h"
28
29class DisplayRegion;
30
31/**
32 * A node that can be positioned around in the scene graph to represent a
33 * point of view for rendering a scene.
34 */
35class EXPCL_PANDA_PGRAPH Camera : public LensNode {
36PUBLISHED:
37 explicit Camera(const std::string &name, Lens *lens = new PerspectiveLens());
38 Camera(const Camera &copy);
39
40public:
41 virtual ~Camera();
42
43 virtual PandaNode *make_copy() const;
44 virtual bool safe_to_flatten() const;
45 virtual bool safe_to_transform() const;
46
47PUBLISHED:
48 INLINE void set_active(bool active);
49 INLINE bool is_active() const;
50 MAKE_PROPERTY(active, is_active, set_active);
51
52 INLINE void set_scene(const NodePath &scene);
53 INLINE const NodePath &get_scene() const;
54 MAKE_PROPERTY(scene, get_scene, set_scene);
55
56 INLINE size_t get_num_display_regions() const;
57 INLINE DisplayRegion *get_display_region(size_t n) const;
58 MAKE_SEQ(get_display_regions, get_num_display_regions, get_display_region);
59 MAKE_SEQ_PROPERTY(display_regions, get_num_display_regions, get_display_region);
60
61 INLINE void set_camera_mask(DrawMask mask);
62 INLINE DrawMask get_camera_mask() const;
63 MAKE_PROPERTY(camera_mask, get_camera_mask, set_camera_mask);
64
65 INLINE void set_cull_center(const NodePath &cull_center);
66 INLINE const NodePath &get_cull_center() const;
67 MAKE_PROPERTY(cull_center, get_cull_center, set_cull_center);
68
69 INLINE void set_cull_bounds(BoundingVolume *cull_bounds);
70 INLINE BoundingVolume *get_cull_bounds() const;
71 MAKE_PROPERTY(cull_bounds, get_cull_bounds, set_cull_bounds);
72
73 INLINE void set_lod_center(const NodePath &lod_center);
74 INLINE const NodePath &get_lod_center() const;
75 MAKE_PROPERTY(lod_center, get_lod_center, set_lod_center);
76
77 INLINE void set_initial_state(const RenderState *state);
78 INLINE CPT(RenderState) get_initial_state() const;
79 MAKE_PROPERTY(initial_state, get_initial_state, set_initial_state);
80
81 INLINE void set_tag_state_key(const std::string &tag_state_key);
82 INLINE const std::string &get_tag_state_key() const;
83 MAKE_PROPERTY(tag_state_key, get_tag_state_key, set_tag_state_key);
84
85 INLINE void set_lod_scale(PN_stdfloat value);
86 INLINE PN_stdfloat get_lod_scale() const;
87 MAKE_PROPERTY(lod_scale, get_lod_scale, set_lod_scale);
88
89 void set_tag_state(const std::string &tag_state, const RenderState *state);
90 void clear_tag_state(const std::string &tag_state);
91 void clear_tag_states();
92 bool has_tag_state(const std::string &tag_state) const;
93 CPT(RenderState) get_tag_state(const std::string &tag_state) const;
94 MAKE_MAP_PROPERTY(tag_states, has_tag_state, get_tag_state,
95 set_tag_state, clear_tag_state);
96
97 void set_aux_scene_data(const NodePath &node_path, AuxSceneData *data);
98 bool clear_aux_scene_data(const NodePath &node_path);
99 AuxSceneData *get_aux_scene_data(const NodePath &node_path) const;
100 void list_aux_scene_data(std::ostream &out) const;
101 int cleanup_aux_scene_data(Thread *current_thread = Thread::get_current_thread());
102 MAKE_MAP_PROPERTY(aux_scene_data, get_aux_scene_data, get_aux_scene_data,
103 set_aux_scene_data, clear_aux_scene_data);
104
105private:
106 void add_display_region(DisplayRegion *display_region);
107 void remove_display_region(DisplayRegion *display_region);
108
109 bool _active;
110 NodePath _scene;
111 NodePath _cull_center;
112 PT(BoundingVolume) _cull_bounds;
113 NodePath _lod_center;
114
115 DrawMask _camera_mask;
116 PN_stdfloat _lod_scale;
117
119 DisplayRegions _display_regions;
120
121 CPT(RenderState) _initial_state;
122 std::string _tag_state_key;
123
124 typedef pmap<std::string, CPT(RenderState) > TagStates;
125 TagStates _tag_states;
126
127 typedef pmap<NodePath, PT(AuxSceneData) > AuxData;
128 AuxData _aux_data;
129
130public:
131 static void register_with_read_factory();
132 virtual void write_datagram(BamWriter *manager, Datagram &dg);
134 BamReader *manager);
135
136protected:
137 static TypedWritable *make_from_bam(const FactoryParams &params);
138 void fillin(DatagramIterator &scan, BamReader *manager);
139
140public:
141 static TypeHandle get_class_type() {
142 return _type_handle;
143 }
144 static void init_type() {
145 LensNode::init_type();
146 register_type(_type_handle, "Camera",
147 LensNode::get_class_type());
148 }
149 virtual TypeHandle get_type() const {
150 return get_class_type();
151 }
152 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
153
154private:
155 static TypeHandle _type_handle;
156
157 friend class DisplayRegion;
158};
159
160#include "camera.I"
161
162#endif
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is a base class for a generic data structure that can be attached per- instance to the camera,...
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition bamReader.h:110
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition bamWriter.h:63
This is an abstract class for any volume in any sense which can be said to define the locality of ref...
A node that can be positioned around in the scene graph to represent a point of view for rendering a ...
Definition camera.h:35
A class to retrieve the individual data elements previously stored in a Datagram.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition datagram.h:38
A rectangular subregion within a window for rendering into.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
A node that contains a Lens.
Definition lensNode.h:29
virtual int complete_pointers(TypedWritable **plist, BamReader *manager)
Receives an array of pointers, one for each time manager->read_pointer() was called in fillin().
Definition lensNode.cxx:241
static void register_with_read_factory()
Tells the BamReader how to create objects of type LensNode.
Definition lensNode.cxx:210
virtual PandaNode * make_copy() const
Returns a newly-allocated Node that is a shallow copy of this one.
Definition lensNode.cxx:64
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:219
A base class for any number of different kinds of lenses, linear and otherwise.
Definition lens.h:41
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition nodePath.h:159
A basic node of the scene graph or data graph.
Definition pandaNode.h:65
virtual bool safe_to_transform() const
Returns true if it is generally safe to transform this particular kind of PandaNode by calling the xf...
virtual bool safe_to_flatten() const
Returns true if it is generally safe to flatten out this particular kind of PandaNode by duplicating ...
A perspective-type lens: a normal camera.
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
Definition renderState.h:47
A thread; that is, a lightweight process.
Definition thread.h:46
get_current_thread
Returns a pointer to the currently-executing Thread object.
Definition thread.h:109
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
Base class for objects that can be written to and read from Bam files.
This is our own Panda specialization on the default STL list.
Definition plist.h:35
This is our own Panda specialization on the default STL map.
Definition pmap.h:49
This is our own Panda specialization on the default STL vector.
Definition pvector.h:42
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.