Panda3D
Public Member Functions | List of all members
NonlinearImager Class Reference

This class object combines the rendered output of a 3-d from one or more linear (e.g. More...

Public Member Functions

 __init__ ()
 
 __init__ (const NonlinearImager)
 
int addScreen (const NodePath screen, str name)
 Adds a new ProjectionScreen to the list of screens that will be processed by the NonlinearImager. More...
 
int addScreen (ProjectionScreen screen)
 This version of this method is deprecated and will soon be removed. More...
 
int addViewer (DisplayRegion dr)
 Adds the indicated DisplayRegion as a viewer into the NonlinearImager room. More...
 
int findScreen (const NodePath screen)
 Returns the index number of the first appearance of the indicated screen within the imager's list, or -1 if it does not appear. More...
 
int findViewer (DisplayRegion dr)
 Returns the index number of the indicated DisplayRegion within the list of viewers, or -1 if it is not found. More...
 
GraphicsOutput getBuffer (int index)
 Returns the offscreen buffer that is automatically created for the nth projection screen. More...
 
list getBuffers ()
 
NodePath getDarkRoom ()
 Returns the NodePath to the root of the dark room scene. More...
 
GraphicsEngine getGraphicsEngine ()
 Returns the GraphicsEngine that all of the viewers added to the NonlinearImager have in common. More...
 
int getNumScreens ()
 Returns the number of screens that have been added to the imager. More...
 
int getNumViewers ()
 Returns the number of viewers that have been added to the imager. More...
 
NodePath getScreen (int index)
 Returns the nth screen that has been added to the imager. More...
 
bool getScreenActive (int index)
 Returns the active flag on the indicated screen. More...
 
list getScreens ()
 
DisplayRegion getViewer (int index)
 Returns the nth viewer's DisplayRegion that has been added to the imager. More...
 
NodePath getViewerCamera (int index)
 Returns the NodePath to the LensNode that is to serve as nth viewer for this screen. More...
 
list getViewers ()
 
NodePath getViewerScene (int index)
 Returns a pointer to the root node of the internal scene graph for the nth viewer, which is used to render all of the screen meshes for this viewer. More...
 
 recompute ()
 Forces a regeneration of all the mesh objects, etc. More...
 
 removeAllScreens ()
 Removes all screens from the imager. More...
 
 removeAllViewers ()
 Removes all viewers from the imager. More...
 
 removeScreen (int index)
 Removes the screen with the indicated index number from the imager. More...
 
 removeViewer (int index)
 Removes the viewer with the indicated index number from the imager. More...
 
 setScreenActive (int index, bool active)
 Sets the active flag on the indicated screen. More...
 
 setSourceCamera (int index, const NodePath source_camera)
 Specifies the camera that will be used to render the image for this particular screen. More...
 
 setTextureSize (int index, int width, int height)
 Sets the width and height of the texture used to render the scene for the indicated screen. More...
 
 setViewerCamera (int index, const NodePath viewer_camera)
 Specifies the LensNode that is to serve as the viewer for this screen. More...
 

Detailed Description

This class object combines the rendered output of a 3-d from one or more linear (e.g.

perspective) cameras, as seen through a single, possibly nonlinear camera.

This can be used to generate real-time imagery of a 3-d scene using a nonlinear camera, for instance a fisheye camera, even though the underlying graphics engine may only support linear cameras. It can also pre-distort imagery to compensate for off-axis projectors, and/or curved screens of any complexity.

A NonlinearImager may be visualized as a dark room into which a number of projection screens have been placed, of arbitrary size and shape and at any arbitrary position and orientation to each other. Onto each of these screens is projected the view as seen by a normal perspective camera that exists in the world (that is, under render).

There also exist in the room one or more (possibly nonlinear) cameras, called viewers, that observe these screens. The image of the projection screens seen by each viewer is finally displayed on the viewer's associated DisplayRegion. By placing the viewer(s) appropriately relative to the screens, and by choosing suitable lens properties for the viewer(s), you can achieve a wide variety of distortion effects.

There are several different LensNode (Camera) objects involved at each stage in the process. To help keep them all straight, different words are used to refer to each different kind of Camera used within this object. The camera(s) under render, that capture the original view of the world to be projected onto the screens, are called source cameras, and are set per screen via set_source_camera(). The LensNode that is associated with each screen to project the image as seen from the screen's source camera is called a projector; these are set via the ProjectionScreen::set_projector() interface. Finally, the cameras that view the whole configuration of screens are called viewers; each of these is associated with a DisplayRegion, and they are set via set_viewer_camera().

Of all these lenses, only the source cameras must use linear (that is, perspective or orthographic) lenses. The projectors and viewers may be any arbitrary lens, linear or otherwise.

Member Function Documentation

◆ __init__() [1/2]

__init__ ( )

◆ __init__() [2/2]

__init__ ( const  NonlinearImager)

◆ addScreen() [1/2]

int addScreen ( const NodePath  screen,
str  name 
)

Adds a new ProjectionScreen to the list of screens that will be processed by the NonlinearImager.

Each ProjectionScreen represents a view into the world. It must be based on a linear camera (or whatever kind of camera is respected by the graphics engine).

Each ProjectionScreen object should already have some screen geometry created.

As each frame is rendered, an offscreen image will be rendered from the source camera associated with each ProjectionScreen, and the resulting image will be applied to the screen geometry.

The return value is the index number of the new screen.

◆ addScreen() [2/2]

int addScreen ( ProjectionScreen  screen)

This version of this method is deprecated and will soon be removed.

Use the version that takes two parameters instead.

◆ addViewer()

int addViewer ( DisplayRegion  dr)

Adds the indicated DisplayRegion as a viewer into the NonlinearImager room.

The camera associated with the DisplayRegion at the time add_viewer() is called is used as the initial viewer camera; it may have a nonlinear lens, like a fisheye or cylindrical lens.

This sets up a special scene graph for this DisplayRegion alone and sets up the DisplayRegion with a specialty camera. If future changes to the camera are desired, you should use the set_viewer_camera() interface.

All viewers must share the same GraphicsEngine.

The return value is the index of the new viewer.

◆ findScreen()

int findScreen ( const NodePath  screen)

Returns the index number of the first appearance of the indicated screen within the imager's list, or -1 if it does not appear.

◆ findViewer()

int findViewer ( DisplayRegion  dr)

Returns the index number of the indicated DisplayRegion within the list of viewers, or -1 if it is not found.

◆ getBuffer()

GraphicsOutput getBuffer ( int  index)

Returns the offscreen buffer that is automatically created for the nth projection screen.

This may return NULL if the screen is inactive or if it has not been rendered yet.

◆ getBuffers()

list getBuffers ( )

◆ getDarkRoom()

NodePath getDarkRoom ( )

Returns the NodePath to the root of the dark room scene.

This is the scene in which all of the ProjectionScreens and the viewer cameras reside. It's a standalone scene with a few projection screens arranged artfully around one or more viewers; it's so named because it's a little virtual theater.

Normally this scene is not rendered directly; it only exists as an abstract concept, and to define the relation between the ProjectionScreens and the viewers. But it may be rendered to help visualize the NonlinearImager's behavior.

◆ getGraphicsEngine()

GraphicsEngine getGraphicsEngine ( )

Returns the GraphicsEngine that all of the viewers added to the NonlinearImager have in common.

◆ getNumScreens()

int getNumScreens ( )

Returns the number of screens that have been added to the imager.

◆ getNumViewers()

int getNumViewers ( )

Returns the number of viewers that have been added to the imager.

◆ getScreen()

NodePath getScreen ( int  index)

Returns the nth screen that has been added to the imager.

◆ getScreenActive()

bool getScreenActive ( int  index)

Returns the active flag on the indicated screen.

◆ getScreens()

list getScreens ( )

◆ getViewer()

DisplayRegion getViewer ( int  index)

Returns the nth viewer's DisplayRegion that has been added to the imager.

◆ getViewerCamera()

NodePath getViewerCamera ( int  index)

Returns the NodePath to the LensNode that is to serve as nth viewer for this screen.

◆ getViewers()

list getViewers ( )

◆ getViewerScene()

NodePath getViewerScene ( int  index)

Returns a pointer to the root node of the internal scene graph for the nth viewer, which is used to render all of the screen meshes for this viewer.

This is the scene graph in which the screen meshes within the dark room have been flattened into the appropriate transformation according to the viewer's lens properties (and position relative to the screens). It is this scene graph that is finally rendered to the window.

◆ recompute()

recompute ( )

Forces a regeneration of all the mesh objects, etc.

◆ removeAllScreens()

removeAllScreens ( )

Removes all screens from the imager.

◆ removeAllViewers()

removeAllViewers ( )

Removes all viewers from the imager.

◆ removeScreen()

removeScreen ( int  index)

Removes the screen with the indicated index number from the imager.

◆ removeViewer()

removeViewer ( int  index)

Removes the viewer with the indicated index number from the imager.

◆ setScreenActive()

setScreenActive ( int  index,
bool  active 
)

Sets the active flag on the indicated screen.

If the active flag is true, the screen will be used; otherwise, it will not appear.

◆ setSourceCamera()

setSourceCamera ( int  index,
const NodePath  source_camera 
)

Specifies the camera that will be used to render the image for this particular screen.

The parameter must be a NodePath whose node is a Camera. The camera itself indicates the scene that is to be rendered.

◆ setTextureSize()

setTextureSize ( int  index,
int  width,
int  height 
)

Sets the width and height of the texture used to render the scene for the indicated screen.

This must be less than or equal to the window size, and it should be a power of two.

In general, the larger the texture, the greater the detail of the rendered scene.

◆ setViewerCamera()

setViewerCamera ( int  index,
const NodePath  viewer_camera 
)

Specifies the LensNode that is to serve as the viewer for this screen.

The relative position of the LensNode to the NonlinearImager, 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 NonlinearImager.

It is not necessary to call this except to change the camera after a viewer has been added, since the default is to use whatever camera is associated with the DisplayRegion at the time the viewer is added.

The NodePath must refer to a LensNode (or a Camera).