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