Panda3D
 All Classes Functions Variables Enumerations
projectionScreen.I
1 // Filename: projectionScreen.I
2 // Created by: drose (11Dec01)
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 
16 
17 ////////////////////////////////////////////////////////////////////
18 // Function: ProjectionScreen::get_projector
19 // Access: Published
20 // Description: Returns the NodePath to the LensNode that is to serve
21 // as the projector for this screen, or empty if no
22 // projector is associated.
23 ////////////////////////////////////////////////////////////////////
24 INLINE const NodePath &ProjectionScreen::
25 get_projector() const {
26  return _projector;
27 }
28 
29 ////////////////////////////////////////////////////////////////////
30 // Function: ProjectionScreen::clear_undist_lut
31 // Access: Published
32 // Description: Removes the distortion lookup table from the
33 // projector, if specified.
34 ////////////////////////////////////////////////////////////////////
35 INLINE void ProjectionScreen::
37  _has_undist_lut = false;
38  _undist_lut = PfmFile();
39 }
40 
41 ////////////////////////////////////////////////////////////////////
42 // Function: ProjectionScreen::set_undist_lut
43 // Access: Published
44 // Description: Applies a distortion lookup table to the
45 // projector. This mapping warps the lens effect by
46 // passing each ray through an indirection table: the
47 // point (u,v) in the indicated lookup table stores the
48 // actual (u,v) that the lens produces.
49 //
50 // This does not affect the operation of
51 // generate_screen().
52 ////////////////////////////////////////////////////////////////////
53 INLINE void ProjectionScreen::
54 set_undist_lut(const PfmFile &undist_lut) {
55  _has_undist_lut = undist_lut.is_valid();
56  _undist_lut = undist_lut;
57 }
58 
59 ////////////////////////////////////////////////////////////////////
60 // Function: ProjectionScreen::has_undist_lut
61 // Access: Published
62 // Description: Returns true if a valid distortion lookup table was
63 // provided via set_undist_lut(), false otherwise.
64 ////////////////////////////////////////////////////////////////////
65 INLINE bool ProjectionScreen::
66 has_undist_lut() const {
67  return _has_undist_lut;
68 }
69 
70 ////////////////////////////////////////////////////////////////////
71 // Function: ProjectionScreen::get_undist_lut
72 // Access: Published
73 // Description: Returns the distortion lookup table provided via
74 // set_undist_lut(), if any.
75 ////////////////////////////////////////////////////////////////////
76 INLINE const PfmFile &ProjectionScreen::
77 get_undist_lut() const {
78  return _undist_lut;
79 }
80 
81 ////////////////////////////////////////////////////////////////////
82 // Function: ProjectionScreen::set_texcoord_name
83 // Access: Published
84 // Description: Specifies the name of the texture coordinates that
85 // are generated by this particular ProjectionScreen.
86 // This can be used in the presence of multitexturing to
87 // compute the UV's for just a subset of all of the
88 // active stages of the multitexture pipeline.
89 ////////////////////////////////////////////////////////////////////
90 INLINE void ProjectionScreen::
91 set_texcoord_name(const string &texcoord_name) {
92  _texcoord_name = InternalName::get_texcoord_name(texcoord_name);
93  _stale = true;
94 }
95 
96 ////////////////////////////////////////////////////////////////////
97 // Function: ProjectionScreen::get_texcoord_name
98 // Access: Published
99 // Description: Returns the name of the texture coordinates that
100 // will be generated by this particular
101 // ProjectionScreen, as set by set_texcoord_name().
102 ////////////////////////////////////////////////////////////////////
103 INLINE string ProjectionScreen::
105  return _texcoord_name->get_name();
106 }
107 
108 ////////////////////////////////////////////////////////////////////
109 // Function: ProjectionScreen::set_invert_uvs
110 // Access: Published
111 // Description: Some OpenGL graphics drivers are known to invert the
112 // framebuffer image when they copy it to texture.
113 // (This is arguably a problem with the OpenGL spec,
114 // which seems to be unclear about the proper ordering
115 // of pixels in this operation.)
116 //
117 // In any case, set this true to compensate for this
118 // effect by inverting the UV's of the projection
119 // screen. The default is taken from the Configrc
120 // variable project-invert-uvs.
121 ////////////////////////////////////////////////////////////////////
122 INLINE void ProjectionScreen::
123 set_invert_uvs(bool invert_uvs) {
124  _invert_uvs = invert_uvs;
125  _stale = true;
126 }
127 
128 
129 ////////////////////////////////////////////////////////////////////
130 // Function: ProjectionScreen::get_invert_uvs
131 // Access: Published
132 // Description: Returns whether this screen is compensating for a
133 // graphics driver inverting the framebuffer image. See
134 // set_invert_uvs().
135 ////////////////////////////////////////////////////////////////////
136 INLINE bool ProjectionScreen::
137 get_invert_uvs() const {
138  return _invert_uvs;
139 }
140 
141 ////////////////////////////////////////////////////////////////////
142 // Function: ProjectionScreen::set_texcoord_3d
143 // Access: Published
144 // Description: Set this true to force 3-D texture coordinates to be
145 // created for the geometry. When this is true and the
146 // geometry has only 2-D texture coordinates, those
147 // texture coordinates are dumped in favor of 3-D
148 // coordinates. When this is false, whatever texture
149 // coordinates already exist are preserved as-is.
150 ////////////////////////////////////////////////////////////////////
151 INLINE void ProjectionScreen::
152 set_texcoord_3d(bool texcoord_3d) {
153  _texcoord_3d = texcoord_3d;
154  _stale = true;
155 }
156 
157 
158 ////////////////////////////////////////////////////////////////////
159 // Function: ProjectionScreen::get_texcoord_3d
160 // Access: Published
161 // Description: See set_texcoord_3d().
162 ////////////////////////////////////////////////////////////////////
163 INLINE bool ProjectionScreen::
165  return _texcoord_3d;
166 }
167 
168 ////////////////////////////////////////////////////////////////////
169 // Function: ProjectionScreen::set_vignette_on
170 // Access: Published
171 // Description: Specifies whether vertex-based vignetting should be
172 // on. When this is enabled, vertex color will be set
173 // on the screen vertices to color the screen two
174 // distinct colors, usually white and black, for the
175 // parts of the screen in front of and outside the lens'
176 // frustum, respectively. When this is not enabled, the
177 // screen color will be left alone.
178 //
179 // This effect generally looks terrible, but it does
180 // at least make the boundaries of the lens clear.
181 ////////////////////////////////////////////////////////////////////
182 INLINE void ProjectionScreen::
183 set_vignette_on(bool vignette_on) {
184  _vignette_on = vignette_on;
185  _stale = true;
186 }
187 
188 
189 ////////////////////////////////////////////////////////////////////
190 // Function: ProjectionScreen::get_vignette_on
191 // Access: Published
192 // Description: Returns true if vertex-based vignetting is on, false
193 // otherwise. See set_vignette_on().
194 ////////////////////////////////////////////////////////////////////
195 INLINE bool ProjectionScreen::
197  return _vignette_on;
198 }
199 
200 ////////////////////////////////////////////////////////////////////
201 // Function: ProjectionScreen::set_vignette_color
202 // Access: Published
203 // Description: Specifies the color the screen will be painted at the
204 // portions outside of the lens' frustum; i.e. where the
205 // lens can't see it or illuminate it. This color is
206 // only used if the vignette_on flag is true; see
207 // set_vignette_on().
208 ////////////////////////////////////////////////////////////////////
209 INLINE void ProjectionScreen::
210 set_vignette_color(const LColor &vignette_color) {
211  _vignette_color = vignette_color;
212  _stale = true;
213 }
214 
215 ////////////////////////////////////////////////////////////////////
216 // Function: ProjectionScreen::get_vignette_color
217 // Access: Published
218 // Description: Returns the color the screen will be painted at the
219 // portions outside of the lens' frustum. See
220 // set_vignette_color().
221 ////////////////////////////////////////////////////////////////////
222 INLINE const LColor &ProjectionScreen::
224  return _vignette_color;
225 }
226 
227 ////////////////////////////////////////////////////////////////////
228 // Function: ProjectionScreen::set_frame_color
229 // Access: Published
230 // Description: Specifies the color the screen will be painted at the
231 // portions outside of the lens' frustum; i.e. where the
232 // lens can't see it or illuminate it. This color is
233 // only used if the vignette_on flag is true; see
234 // set_vignette_on().
235 ////////////////////////////////////////////////////////////////////
236 INLINE void ProjectionScreen::
237 set_frame_color(const LColor &frame_color) {
238  _frame_color = frame_color;
239  _stale = true;
240 }
241 
242 ////////////////////////////////////////////////////////////////////
243 // Function: ProjectionScreen::get_frame_color
244 // Access: Published
245 // Description: Returns the color the screen will be painted at the
246 // portions outside of the lens' frustum. See
247 // set_frame_color().
248 ////////////////////////////////////////////////////////////////////
249 INLINE const LColor &ProjectionScreen::
251  return _frame_color;
252 }
253 
254 ////////////////////////////////////////////////////////////////////
255 // Function: ProjectionScreen::set_auto_recompute
256 // Access: Published
257 // Description: Sets the auto_recompute flag. When this is true,
258 // the ProjectionScreen will always be recomputed if
259 // necessary before the frame is drawn; when it is
260 // false, an explicit call to recompute_if_stale() may
261 // be required.
262 ////////////////////////////////////////////////////////////////////
263 INLINE void ProjectionScreen::
264 set_auto_recompute(bool auto_recompute) {
265  _auto_recompute = auto_recompute;
266 }
267 
268 
269 ////////////////////////////////////////////////////////////////////
270 // Function: ProjectionScreen::set_auto_recompute
271 // Access: Published
272 // Description: Returns the auto_recompute flag. When this is true,
273 // the ProjectionScreen will always be recomputed if
274 // necessary before the frame is drawn; when it is
275 // false, an explicit call to recompute_if_stale() may
276 // be required.
277 ////////////////////////////////////////////////////////////////////
278 INLINE bool ProjectionScreen::
280  return _auto_recompute;
281 }
282 
283 
284 ////////////////////////////////////////////////////////////////////
285 // Function: ProjectionScreen::get_last_screen
286 // Access: Published
287 // Description: Returns an UpdateSeq corresponding to the last time a
288 // screen mesh was generated for the ProjectionScreen.
289 // Each time generate_screen() is called, this number is
290 // incremented; this allows other objects (like
291 // NonlinearImager) to know when they need to recompute
292 // themselves.
293 ////////////////////////////////////////////////////////////////////
294 INLINE const UpdateSeq &ProjectionScreen::
296  return _last_screen;
297 }
298 
bool get_texcoord_3d() const
See set_texcoord_3d().
bool has_undist_lut() const
Returns true if a valid distortion lookup table was provided via set_undist_lut(), false otherwise.
const LColor & get_frame_color() const
Returns the color the screen will be painted at the portions outside of the lens' frustum...
void set_texcoord_name(const string &texcoord_name)
Specifies the name of the texture coordinates that are generated by this particular ProjectionScreen...
const PfmFile & get_undist_lut() const
Returns the distortion lookup table provided via set_undist_lut(), if any.
void set_texcoord_3d(bool texcoord_3d)
Set this true to force 3-D texture coordinates to be created for the geometry.
void set_invert_uvs(bool invert_uvs)
Some OpenGL graphics drivers are known to invert the framebuffer image when they copy it to texture...
void clear_undist_lut()
Removes the distortion lookup table from the projector, if specified.
void set_vignette_on(bool vignette_on)
Specifies whether vertex-based vignetting should be on.
bool get_vignette_on() const
Returns true if vertex-based vignetting is on, false otherwise.
string get_texcoord_name() const
Returns the name of the texture coordinates that will be generated by this particular ProjectionScree...
Defines a pfm file, a 2-d table of floating-point numbers, either 3-component or 1-component, or with a special extension, 2- or 4-component.
Definition: pfmFile.h:34
const UpdateSeq & get_last_screen() const
Returns an UpdateSeq corresponding to the last time a screen mesh was generated for the ProjectionScr...
void set_auto_recompute(bool auto_recompute)
Sets the auto_recompute flag.
void set_frame_color(const LColor &frame_color)
Specifies the color the screen will be painted at the portions outside of the lens' frustum; i...
void set_vignette_color(const LColor &vignette_color)
Specifies the color the screen will be painted at the portions outside of the lens' frustum; i...
This is the base class for all three-component vectors and points.
Definition: lvecBase4.h:111
const LColor & get_vignette_color() const
Returns the color the screen will be painted at the portions outside of the lens' frustum...
bool get_invert_uvs() const
Returns whether this screen is compensating for a graphics driver inverting the framebuffer image...
bool get_auto_recompute() const
Returns the auto_recompute flag.
void set_undist_lut(const PfmFile &undist_lut)
Applies a distortion lookup table to the projector.
This is a sequence number that increments monotonically.
Definition: updateSeq.h:43
const NodePath & get_projector() const
Returns the NodePath to the LensNode that is to serve as the projector for this screen, or empty if no projector is associated.
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition: nodePath.h:165