Panda3D
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions
ProjectionScreen Class Reference

A ProjectionScreen implements a simple system for projective texturing. More...

#include "projectionScreen.h"

Inheritance diagram for ProjectionScreen:
PandaNode TypedWritable Namable LinkedListNode ReferenceCount TypedObject MemoryBase MemoryBase MemoryBase

List of all members.

Public Member Functions

 ProjectionScreen (const string &name="")
virtual bool cull_callback (CullTraverser *trav, CullTraverserData &data)
 This function will be called during the cull traversal to perform any additional operations that should be performed at cull time.
virtual TypeHandle force_init_type ()
bool get_auto_recompute () const
 Returns the auto_recompute flag.
const LColorget_frame_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.
const UpdateSeqget_last_screen () const
 Returns an UpdateSeq corresponding to the last time a screen mesh was generated for the ProjectionScreen.
const NodePathget_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.
string get_texcoord_name () const
 Returns the name of the texture coordinates that will be generated by this particular ProjectionScreen, as set by set_texcoord_name().
virtual TypeHandle get_type () const
const LColorget_vignette_color () const
 Returns the color the screen will be painted at the portions outside of the lens' frustum.
bool get_vignette_on () const
 Returns true if vertex-based vignetting is on, false otherwise.
virtual PandaNodemake_copy () const
 Returns a newly-allocated Node that is a shallow copy of this one.
 PT (GeomNode) generate_screen(const NodePath &projector
 PT (PandaNode) make_flat_mesh(const NodePath &this_np
void recompute ()
 Recomputes all the UV's for geometry below the ProjectionScreen node, as if the texture were projected from the associated projector.
bool recompute_if_stale ()
 Calls recompute() only if the relative transform between the ProjectionScreen and the projector has changed, or if any other relevant property has changed.
bool recompute_if_stale (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.
void regenerate_screen (const NodePath &projector, const string &screen_name, int num_x_verts, int num_y_verts, PN_stdfloat distance, PN_stdfloat fill_ratio)
 Removes all the children from the ProjectionScreen node, and adds the newly generated child returned by generate_screen().
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.e.
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_projector (const NodePath &projector)
 Specifies the LensNode that is to serve as the projector for this screen.
void set_texcoord_name (const string &texcoord_name)
 Specifies the name of the texture coordinates that are generated by this particular ProjectionScreen.
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.e.
void set_vignette_on (bool vignette_on)
 Specifies whether vertex-based vignetting should be on.

Static Public Member Functions

static TypeHandle get_class_type ()
static void init_type ()

Public Attributes

const NodePathcamera
const string int int PN_stdfloat distance
const string int int
PN_stdfloat PN_stdfloat 
fill_ratio
const string int num_x_verts
const string int int num_y_verts
const string & screen_name

Protected Member Functions

 ProjectionScreen (const ProjectionScreen &copy)

Detailed Description

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.

Definition at line 54 of file projectionScreen.h.


Member Function Documentation

bool ProjectionScreen::cull_callback ( CullTraverser trav,
CullTraverserData data 
) [virtual]

This function will be called during the cull traversal to perform any additional operations that should be performed at cull time.

This may include additional manipulation of render state or additional visible/invisible decisions, or any other arbitrary operation.

Note that this function will *not* be called unless set_cull_callback() is called in the constructor of the derived class. It is necessary to call set_cull_callback() to indicated that we require cull_callback() to be called.

By the time this function is called, the node has already passed the bounding-volume test for the viewing frustum, and the node's transform and state have already been applied to the indicated CullTraverserData object.

The return value is true if this node should be visible, or false if it should be culled.

Reimplemented from PandaNode.

Definition at line 119 of file projectionScreen.cxx.

References WorkingNodePath::get_node_path(), and recompute_if_stale().

bool ProjectionScreen::get_auto_recompute ( ) const [inline]

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.

Definition at line 200 of file projectionScreen.I.

const LColor & ProjectionScreen::get_frame_color ( ) const [inline]

Returns the color the screen will be painted at the portions outside of the lens' frustum.

See set_frame_color().

Definition at line 171 of file projectionScreen.I.

bool ProjectionScreen::get_invert_uvs ( ) const [inline]

Returns whether this screen is compensating for a graphics driver inverting the framebuffer image.

See set_invert_uvs().

Definition at line 85 of file projectionScreen.I.

const UpdateSeq & ProjectionScreen::get_last_screen ( ) const [inline]

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.

Definition at line 216 of file projectionScreen.I.

const NodePath & ProjectionScreen::get_projector ( ) const [inline]

Returns the NodePath to the LensNode that is to serve as the projector for this screen, or empty if no projector is associated.

Definition at line 25 of file projectionScreen.I.

string ProjectionScreen::get_texcoord_name ( ) const [inline]

Returns the name of the texture coordinates that will be generated by this particular ProjectionScreen, as set by set_texcoord_name().

Definition at line 52 of file projectionScreen.I.

Referenced by set_texcoord_name().

const LColor & ProjectionScreen::get_vignette_color ( ) const [inline]

Returns the color the screen will be painted at the portions outside of the lens' frustum.

See set_vignette_color().

Definition at line 144 of file projectionScreen.I.

bool ProjectionScreen::get_vignette_on ( ) const [inline]

Returns true if vertex-based vignetting is on, false otherwise.

See set_vignette_on().

Definition at line 117 of file projectionScreen.I.

PandaNode * ProjectionScreen::make_copy ( ) const [virtual]

Returns a newly-allocated Node that is a shallow copy of this one.

It will be a different Node pointer, but its internal data may or may not be shared with that of the original Node.

Reimplemented from PandaNode.

Definition at line 89 of file projectionScreen.cxx.

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.

Definition at line 337 of file projectionScreen.cxx.

References NodePath::any_path().

Referenced by recompute_if_stale().

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.

Definition at line 352 of file projectionScreen.cxx.

References NodePath::any_path().

Referenced by cull_callback().

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.

Definition at line 367 of file projectionScreen.cxx.

References LMatrix4f::almost_equal(), NodePath::get_transform(), NodePath::is_empty(), NodePath::node(), and recompute().

void ProjectionScreen::regenerate_screen ( const NodePath projector,
const string &  screen_name,
int  num_x_verts,
int  num_y_verts,
PN_stdfloat  distance,
PN_stdfloat  fill_ratio 
)

Removes all the children from the ProjectionScreen node, and adds the newly generated child returned by generate_screen().

Definition at line 270 of file projectionScreen.cxx.

void ProjectionScreen::set_auto_recompute ( bool  auto_recompute) [inline]

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.

Definition at line 185 of file projectionScreen.I.

void ProjectionScreen::set_frame_color ( const LColor frame_color) [inline]

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().

Definition at line 158 of file projectionScreen.I.

void ProjectionScreen::set_invert_uvs ( bool  invert_uvs) [inline]

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.

Definition at line 71 of file projectionScreen.I.

void ProjectionScreen::set_projector ( 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).

Definition at line 139 of file projectionScreen.cxx.

References NodePath::is_empty(), TypedObject::is_of_type(), and NodePath::node().

void ProjectionScreen::set_texcoord_name ( const string &  texcoord_name) [inline]

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.

Definition at line 39 of file projectionScreen.I.

References get_texcoord_name().

void ProjectionScreen::set_vignette_color ( const LColor vignette_color) [inline]

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().

Definition at line 131 of file projectionScreen.I.

void ProjectionScreen::set_vignette_on ( bool  vignette_on) [inline]

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.

Definition at line 104 of file projectionScreen.I.


The documentation for this class was generated from the following files:
 All Classes Functions Variables Enumerations