ProjectionScreen
from panda3d.fx import ProjectionScreen
- class ProjectionScreen
Bases:
PandaNode
A ProjectionScreen implements a simple system for projective texturing. The ProjectionScreen node is the parent of a hierarchy of geometry that is considered a “screen”; the ProjectionScreen will automatically recompute all the UV’s (for a particular texture stage) on its subordinate geometry according to the relative position and lens parameters of the indicated LensNode.
All this does is recompute UV’s; the caller is responsible for applying the appropriate texture(s) to the geometry.
This does not take advantage of any hardware-assisted projective texturing; all of the UV’s are computed in the CPU. (Use NodePath::project_texture() to enable hardware-assisted projective texturing.) However, the ProjectionScreen interface does support any kind of lens, linear or nonlinear, that might be defined using the Lens interface, including fisheye and cylindrical lenses.
Inheritance diagram
- __init__(*args, **kwargs)
- clearUndistLut()
C++ Interface: clear_undist_lut(const ProjectionScreen self)
- /**
Removes the distortion lookup table from the projector, if specified.
*/
- clear_undist_lut()
C++ Interface: clear_undist_lut(const ProjectionScreen self)
- /**
Removes the distortion lookup table from the projector, if specified.
*/
- generateScreen()
C++ Interface: generate_screen(const ProjectionScreen self, const NodePath projector, str screen_name, int num_x_verts, int num_y_verts, float distance, float fill_ratio)
- /**
Synthesizes a polygon mesh based on the projection area of the indicated
projector. This generates and returns a new GeomNode but does not
automatically parent it to the ProjectionScreen node; see
regenerate_screen().
The specified projector need not be the same as the projector given to the
ProjectionScreen with set_projector() (although this is often what you
want).
num_x_verts and num_y_verts specify the number of vertices to make in the
grid across the horizontal and vertical dimension of the projector,
respectively; distance represents the approximate distance of the screen
from the lens center.
The fill_ratio parameter specifies the fraction of the image to cover. If
it is 1.0, the entire image is shown full-size; if it is 0.9, 10% of the
image around the edges is not part of the grid (and the grid is drawn
smaller by the same 10%). This is intended to work around graphics drivers
that tend to show dark edges or other unsatisfactory artifacts around the
edges of textures: render the texture larger than necessary by a certain
fraction, and make the screen smaller by the inverse fraction.
*/
- generate_screen()
C++ Interface: generate_screen(const ProjectionScreen self, const NodePath projector, str screen_name, int num_x_verts, int num_y_verts, float distance, float fill_ratio)
- /**
Synthesizes a polygon mesh based on the projection area of the indicated
projector. This generates and returns a new GeomNode but does not
automatically parent it to the ProjectionScreen node; see
regenerate_screen().
The specified projector need not be the same as the projector given to the
ProjectionScreen with set_projector() (although this is often what you
want).
num_x_verts and num_y_verts specify the number of vertices to make in the
grid across the horizontal and vertical dimension of the projector,
respectively; distance represents the approximate distance of the screen
from the lens center.
The fill_ratio parameter specifies the fraction of the image to cover. If
it is 1.0, the entire image is shown full-size; if it is 0.9, 10% of the
image around the edges is not part of the grid (and the grid is drawn
smaller by the same 10%). This is intended to work around graphics drivers
that tend to show dark edges or other unsatisfactory artifacts around the
edges of textures: render the texture larger than necessary by a certain
fraction, and make the screen smaller by the inverse fraction.
*/
- getAutoRecompute()
C++ Interface: get_auto_recompute(ProjectionScreen self)
- /**
Returns the auto_recompute flag. When this is true, the ProjectionScreen
will always be recomputed if necessary before the frame is drawn; when it
is false, an explicit call to recompute_if_stale() may be required.
*/
- getClassType()
C++ Interface: get_class_type()
- getFrameColor()
C++ Interface: get_frame_color(ProjectionScreen self)
- /**
Returns the color the screen will be painted at the portions outside of the
lens’ frustum. See set_frame_color().
*/
- getInvertUvs()
C++ Interface: get_invert_uvs(ProjectionScreen self)
- /**
Returns whether this screen is compensating for a graphics driver inverting
the framebuffer image. See set_invert_uvs().
*/
- getLastScreen()
C++ Interface: get_last_screen(ProjectionScreen self)
- /**
Returns an UpdateSeq corresponding to the last time a screen mesh was
generated for the ProjectionScreen. Each time generate_screen() is called,
this number is incremented; this allows other objects (like
NonlinearImager) to know when they need to recompute themselves.
*/
- getProjector()
C++ Interface: get_projector(ProjectionScreen self)
- /**
Returns the NodePath to the LensNode that is to serve as the projector for
this screen, or empty if no projector is associated.
*/
- getTexcoord3d()
C++ Interface: get_texcoord_3d(ProjectionScreen self)
- /**
See set_texcoord_3d().
*/
- getTexcoordName()
C++ Interface: get_texcoord_name(ProjectionScreen self)
- /**
Returns the name of the texture coordinates that will be generated by this
particular ProjectionScreen, as set by set_texcoord_name().
*/
- getUndistLut()
C++ Interface: get_undist_lut(ProjectionScreen self)
- /**
Returns the distortion lookup table provided via set_undist_lut(), if any.
*/
- getVignetteColor()
C++ Interface: get_vignette_color(ProjectionScreen self)
- /**
Returns the color the screen will be painted at the portions outside of the
lens’ frustum. See set_vignette_color().
*/
- getVignetteOn()
C++ Interface: get_vignette_on(ProjectionScreen self)
- /**
Returns true if vertex-based vignetting is on, false otherwise. See
set_vignette_on().
*/
- get_auto_recompute()
C++ Interface: get_auto_recompute(ProjectionScreen self)
- /**
Returns the auto_recompute flag. When this is true, the ProjectionScreen
will always be recomputed if necessary before the frame is drawn; when it
is false, an explicit call to recompute_if_stale() may be required.
*/
- get_class_type()
C++ Interface: get_class_type()
- get_frame_color()
C++ Interface: get_frame_color(ProjectionScreen self)
- /**
Returns the color the screen will be painted at the portions outside of the
lens’ frustum. See set_frame_color().
*/
- get_invert_uvs()
C++ Interface: get_invert_uvs(ProjectionScreen self)
- /**
Returns whether this screen is compensating for a graphics driver inverting
the framebuffer image. See set_invert_uvs().
*/
- get_last_screen()
C++ Interface: get_last_screen(ProjectionScreen self)
- /**
Returns an UpdateSeq corresponding to the last time a screen mesh was
generated for the ProjectionScreen. Each time generate_screen() is called,
this number is incremented; this allows other objects (like
NonlinearImager) to know when they need to recompute themselves.
*/
- get_projector()
C++ Interface: get_projector(ProjectionScreen self)
- /**
Returns the NodePath to the LensNode that is to serve as the projector for
this screen, or empty if no projector is associated.
*/
- get_texcoord_3d()
C++ Interface: get_texcoord_3d(ProjectionScreen self)
- /**
See set_texcoord_3d().
*/
- get_texcoord_name()
C++ Interface: get_texcoord_name(ProjectionScreen self)
- /**
Returns the name of the texture coordinates that will be generated by this
particular ProjectionScreen, as set by set_texcoord_name().
*/
- get_undist_lut()
C++ Interface: get_undist_lut(ProjectionScreen self)
- /**
Returns the distortion lookup table provided via set_undist_lut(), if any.
*/
- get_vignette_color()
C++ Interface: get_vignette_color(ProjectionScreen self)
- /**
Returns the color the screen will be painted at the portions outside of the
lens’ frustum. See set_vignette_color().
*/
- get_vignette_on()
C++ Interface: get_vignette_on(ProjectionScreen self)
- /**
Returns true if vertex-based vignetting is on, false otherwise. See
set_vignette_on().
*/
- hasUndistLut()
C++ Interface: has_undist_lut(ProjectionScreen self)
- /**
Returns true if a valid distortion lookup table was provided via
set_undist_lut(), false otherwise.
*/
- has_undist_lut()
C++ Interface: has_undist_lut(ProjectionScreen self)
- /**
Returns true if a valid distortion lookup table was provided via
set_undist_lut(), false otherwise.
*/
- makeFlatMesh()
C++ Interface: make_flat_mesh(const ProjectionScreen self, const NodePath this_np, const NodePath camera)
- /**
Generates a deep copy of the hierarchy at the ProjectionScreen node and
below, with vertices flattened into two dimensions as if they were seen by
the indicated camera node.
This is useful for rendering an image as seen through a non-linear lens.
The resulting mesh will have vertices in the range [-1, 1] in both x and y,
and may be then rendered with an ordinary orthographic lens, to generate
the effect of seeing the image through the specified non-linear lens.
The returned node has no parent; it is up to the caller to parent it
somewhere or store it so that it does not get dereferenced and deleted.
*/
- make_flat_mesh()
C++ Interface: make_flat_mesh(const ProjectionScreen self, const NodePath this_np, const NodePath camera)
- /**
Generates a deep copy of the hierarchy at the ProjectionScreen node and
below, with vertices flattened into two dimensions as if they were seen by
the indicated camera node.
This is useful for rendering an image as seen through a non-linear lens.
The resulting mesh will have vertices in the range [-1, 1] in both x and y,
and may be then rendered with an ordinary orthographic lens, to generate
the effect of seeing the image through the specified non-linear lens.
The returned node has no parent; it is up to the caller to parent it
somewhere or store it so that it does not get dereferenced and deleted.
*/
- recompute()
C++ Interface: recompute(const ProjectionScreen self)
- /**
Recomputes all the UV’s for geometry below the ProjectionScreen node, as if
the texture were projected from the associated projector.
This function is normally called automatically whenever the relevant
properties change, so it should not normally need to be called directly by
the user. However, it does no harm to call this if there is any doubt.
*/
- recomputeIfStale()
C++ Interface: recompute_if_stale(const ProjectionScreen self) recompute_if_stale(const ProjectionScreen self, const NodePath this_np)
- /**
Calls recompute() only if the relative transform between the
ProjectionScreen and the projector has changed, or if any other relevant
property has changed. Returns true if recomputed, false otherwise.
*/
- /**
Calls recompute() only if the relative transform between the
ProjectionScreen and the projector has changed, or if any other relevant
property has changed. Returns true if recomputed, false otherwise.
*/
- recompute_if_stale()
C++ Interface: recompute_if_stale(const ProjectionScreen self) recompute_if_stale(const ProjectionScreen self, const NodePath this_np)
- /**
Calls recompute() only if the relative transform between the
ProjectionScreen and the projector has changed, or if any other relevant
property has changed. Returns true if recomputed, false otherwise.
*/
- /**
Calls recompute() only if the relative transform between the
ProjectionScreen and the projector has changed, or if any other relevant
property has changed. Returns true if recomputed, false otherwise.
*/
- regenerateScreen()
C++ Interface: regenerate_screen(const ProjectionScreen self, const NodePath projector, str screen_name, int num_x_verts, int num_y_verts, float distance, float fill_ratio)
- /**
Removes all the children from the ProjectionScreen node, and adds the newly
generated child returned by generate_screen().
*/
- regenerate_screen()
C++ Interface: regenerate_screen(const ProjectionScreen self, const NodePath projector, str screen_name, int num_x_verts, int num_y_verts, float distance, float fill_ratio)
- /**
Removes all the children from the ProjectionScreen node, and adds the newly
generated child returned by generate_screen().
*/
- setAutoRecompute()
C++ Interface: set_auto_recompute(const ProjectionScreen self, bool auto_recompute)
- /**
Sets the auto_recompute flag. When this is true, the ProjectionScreen will
always be recomputed if necessary before the frame is drawn; when it is
false, an explicit call to recompute_if_stale() may be required.
*/
- setFrameColor()
C++ Interface: set_frame_color(const ProjectionScreen self, const LVecBase4f frame_color)
- /**
Specifies the color the screen will be painted at the portions outside of
the lens’ frustum; i.e. where the lens can’t see it or illuminate it.
This color is only used if the vignette_on flag is true; see
set_vignette_on().
*/
- setInvertUvs()
C++ Interface: set_invert_uvs(const ProjectionScreen self, bool invert_uvs)
- /**
Some OpenGL graphics drivers are known to invert the framebuffer image when
they copy it to texture. (This is arguably a problem with the OpenGL spec,
which seems to be unclear about the proper ordering of pixels in this
operation.)
In any case, set this true to compensate for this effect by inverting the
UV’s of the projection screen. The default is taken from the Configrc
variable project-invert-uvs.
*/
- setProjector()
C++ Interface: set_projector(const ProjectionScreen self, const NodePath projector)
- /**
Specifies the LensNode that is to serve as the projector for this screen.
The relative position of the LensNode to the ProjectionScreen, as well as
the properties of the lens associated with the LensNode, determines the
UV’s that will be assigned to the geometry within the ProjectionScreen.
The NodePath must refer to a LensNode (or a Camera).
*/
- setTexcoord3d()
C++ Interface: set_texcoord_3d(const ProjectionScreen self, bool texcoord_3d)
- /**
Set this true to force 3-D texture coordinates to be created for the
geometry. When this is true and the geometry has only 2-D texture
coordinates, those texture coordinates are dumped in favor of 3-D
coordinates. When this is false, whatever texture coordinates already
exist are preserved as-is.
*/
- setTexcoordName()
C++ Interface: set_texcoord_name(const ProjectionScreen self, str texcoord_name)
- /**
Specifies the name of the texture coordinates that are generated by this
particular ProjectionScreen. This can be used in the presence of
multitexturing to compute the UV’s for just a subset of all of the active
stages of the multitexture pipeline.
*/
- setUndistLut()
C++ Interface: set_undist_lut(const ProjectionScreen self, const PfmFile undist_lut)
- /**
Applies a distortion lookup table to the projector. This mapping warps the
lens effect by passing each ray through an indirection table: the point
(u,v) in the indicated lookup table stores the actual (u,v) that the lens
produces.
This does not affect the operation of generate_screen().
*/
- setVignetteColor()
C++ Interface: set_vignette_color(const ProjectionScreen self, const LVecBase4f vignette_color)
- /**
Specifies the color the screen will be painted at the portions outside of
the lens’ frustum; i.e. where the lens can’t see it or illuminate it.
This color is only used if the vignette_on flag is true; see
set_vignette_on().
*/
- setVignetteOn()
C++ Interface: set_vignette_on(const ProjectionScreen self, bool vignette_on)
- /**
Specifies whether vertex-based vignetting should be on. When this is
enabled, vertex color will be set on the screen vertices to color the
screen two distinct colors, usually white and black, for the parts of the
screen in front of and outside the lens’ frustum, respectively. When this
is not enabled, the screen color will be left alone.
This effect generally looks terrible, but it does at least make the
boundaries of the lens clear.
*/
- set_auto_recompute()
C++ Interface: set_auto_recompute(const ProjectionScreen self, bool auto_recompute)
- /**
Sets the auto_recompute flag. When this is true, the ProjectionScreen will
always be recomputed if necessary before the frame is drawn; when it is
false, an explicit call to recompute_if_stale() may be required.
*/
- set_frame_color()
C++ Interface: set_frame_color(const ProjectionScreen self, const LVecBase4f frame_color)
- /**
Specifies the color the screen will be painted at the portions outside of
the lens’ frustum; i.e. where the lens can’t see it or illuminate it.
This color is only used if the vignette_on flag is true; see
set_vignette_on().
*/
- set_invert_uvs()
C++ Interface: set_invert_uvs(const ProjectionScreen self, bool invert_uvs)
- /**
Some OpenGL graphics drivers are known to invert the framebuffer image when
they copy it to texture. (This is arguably a problem with the OpenGL spec,
which seems to be unclear about the proper ordering of pixels in this
operation.)
In any case, set this true to compensate for this effect by inverting the
UV’s of the projection screen. The default is taken from the Configrc
variable project-invert-uvs.
*/
- set_projector()
C++ Interface: set_projector(const ProjectionScreen self, const NodePath projector)
- /**
Specifies the LensNode that is to serve as the projector for this screen.
The relative position of the LensNode to the ProjectionScreen, as well as
the properties of the lens associated with the LensNode, determines the
UV’s that will be assigned to the geometry within the ProjectionScreen.
The NodePath must refer to a LensNode (or a Camera).
*/
- set_texcoord_3d()
C++ Interface: set_texcoord_3d(const ProjectionScreen self, bool texcoord_3d)
- /**
Set this true to force 3-D texture coordinates to be created for the
geometry. When this is true and the geometry has only 2-D texture
coordinates, those texture coordinates are dumped in favor of 3-D
coordinates. When this is false, whatever texture coordinates already
exist are preserved as-is.
*/
- set_texcoord_name()
C++ Interface: set_texcoord_name(const ProjectionScreen self, str texcoord_name)
- /**
Specifies the name of the texture coordinates that are generated by this
particular ProjectionScreen. This can be used in the presence of
multitexturing to compute the UV’s for just a subset of all of the active
stages of the multitexture pipeline.
*/
- set_undist_lut()
C++ Interface: set_undist_lut(const ProjectionScreen self, const PfmFile undist_lut)
- /**
Applies a distortion lookup table to the projector. This mapping warps the
lens effect by passing each ray through an indirection table: the point
(u,v) in the indicated lookup table stores the actual (u,v) that the lens
produces.
This does not affect the operation of generate_screen().
*/
- set_vignette_color()
C++ Interface: set_vignette_color(const ProjectionScreen self, const LVecBase4f vignette_color)
- /**
Specifies the color the screen will be painted at the portions outside of
the lens’ frustum; i.e. where the lens can’t see it or illuminate it.
This color is only used if the vignette_on flag is true; see
set_vignette_on().
*/
- set_vignette_on()
C++ Interface: set_vignette_on(const ProjectionScreen self, bool vignette_on)
- /**
Specifies whether vertex-based vignetting should be on. When this is
enabled, vertex color will be set on the screen vertices to color the
screen two distinct colors, usually white and black, for the parts of the
screen in front of and outside the lens’ frustum, respectively. When this
is not enabled, the screen color will be left alone.
This effect generally looks terrible, but it does at least make the
boundaries of the lens clear.
*/