Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

NonlinearImager Class Reference

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

#include <nonlinearImager.h>

List of all members.

Public Member Functions

 NonlinearImager ()
 ~NonlinearImager ()
int add_screen (ProjectionScreen *screen)
 Adds a new ProjectionScreen to the list of screens that will be processed by the NonlinearImager.

int find_screen (ProjectionScreen *screen) const
 Returns the index number of the first appearance of the indicated screen within the imager's list, or -1 if it does not appear.

void remove_screen (int index)
 Removes the screen with the indicated index number from the imager.

void remove_all_screens ()
 Removes all screens from the imager.

int get_num_screens () const
 Returns the number of screens that have been added to the imager.

ProjectionScreenget_screen (int index) const
 Returns the nth screen that has been added to the imager.

void set_texture_size (int index, int width, int height)
 Sets the width and height of the texture used to render the scene for the indicated screen.

void set_source_camera (int index, const NodePath &source_camera)
 Specifies the camera that will be used to render the image for this particular screen.

void set_screen_active (int index, bool active)
 Sets the active flag on the indicated screen.

bool get_screen_active (int index) const
 Returns the active flag on the indicated screen.

int add_viewer (DisplayRegion *dr)
 Adds the indicated DisplayRegion as a viewer into the NonlinearImager room.

int find_viewer (DisplayRegion *dr) const
 Returns the index number of the indicated DisplayRegion within the list of viewers, or -1 if it is not found.

void remove_viewer (int index)
 Removes the viewer with the indicated index number from the imager.

void remove_all_viewers ()
 Removes all viewers from the imager.

void set_viewer_camera (int index, const NodePath &viewer_camera)
 Specifies the LensNode that is to serve as the viewer for this screen.

NodePath get_viewer_camera (int index) const
 Returns the NodePath to the LensNode that is to serve as nth viewer for this screen.

NodePath get_internal_scene (int index) const
 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.

int get_num_viewers () const
 Returns the number of viewers that have been added to the imager.

DisplayRegionget_viewer (int index) const
 Returns the nth viewer's DisplayRegion that has been added to the imager.

void recompute ()
 Forces a regeneration of all the mesh objects, etc.

void render (GraphicsEngine *engine)
 Uses the DisplayRegion's GSG to render a scene for each ProjectionScreen, and makes our DisplayRegion ready to render the combined results.


Private Types

typedef pvector< ViewerViewers
typedef pvector< MeshMeshes
typedef pvector< ScreenScreens

Private Member Functions

void recompute_if_stale ()
 Calls recompute() if it needs to be called.

void recompute_screen (Screen &screen, size_t vi)
 Regenerates the mesh objects just for the indicated screen.

void render_screen (GraphicsEngine *engine, Screen &screen)
 Renders the scene just for the indicated screen, into the screen's own texture.


Private Attributes

Viewers _viewers
Screens _screens
GraphicsStateGuardian_gsg
GraphicsWindow_win
bool _stale


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.

Definition at line 151 of file nonlinearImager.h.


Member Typedef Documentation

typedef pvector<Mesh> NonlinearImager::Meshes [private]
 

Definition at line 202 of file nonlinearImager.h.

typedef pvector<Screen> NonlinearImager::Screens [private]
 

Definition at line 215 of file nonlinearImager.h.

typedef pvector<Viewer> NonlinearImager::Viewers [private]
 

Definition at line 195 of file nonlinearImager.h.


Constructor & Destructor Documentation

NonlinearImager::NonlinearImager  ) 
 

Definition at line 40 of file nonlinearImager.cxx.

References remove_all_screens(), and remove_all_viewers().

NonlinearImager::~NonlinearImager  ) 
 

Definition at line 54 of file nonlinearImager.cxx.

References NonlinearImager::Screen::_active, NonlinearImager::Screen::_meshes, NonlinearImager::Screen::_screen, _screens, _stale, NonlinearImager::Screen::_tex_height, NonlinearImager::Screen::_tex_width, NonlinearImager::Screen::_texture, _viewers, ProjectionScreen::get_last_screen(), NULL, and size_t.


Member Function Documentation

int NonlinearImager::add_screen ProjectionScreen screen  ) 
 

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

width and height indicate the size of the texture that will be created to render the scene for the screen. See set_texture_size().

Each ProjectionScreen object should already have some screen geometry created.

When render() is called, the graphics state guardian will be used to render a scene for each ProjectionScreen object, and then each resulting image will be applied to a mesh to be rendered to the screen.

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

Definition at line 108 of file nonlinearImager.cxx.

int NonlinearImager::add_viewer 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 GraphicsStateGuardian.

The return value is the index of the new viewer.

Definition at line 354 of file nonlinearImager.cxx.

References remove_viewer().

int NonlinearImager::find_screen ProjectionScreen screen  )  const
 

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

Definition at line 141 of file nonlinearImager.cxx.

References _screens.

int NonlinearImager::find_viewer DisplayRegion dr  )  const
 

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

Definition at line 420 of file nonlinearImager.cxx.

NodePath NonlinearImager::get_internal_scene int  index  )  const
 

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.

Definition at line 546 of file nonlinearImager.cxx.

References NonlinearImager::Screen::_active, NonlinearImager::Viewer::_internal_scene, NonlinearImager::Screen::_meshes, NonlinearImager::Screen::_screen, NonlinearImager::Viewer::_viewer, NodePath::attach_new_node(), nassertv, NULL, and PT.

int NonlinearImager::get_num_screens  )  const
 

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

Definition at line 197 of file nonlinearImager.cxx.

References _screens.

int NonlinearImager::get_num_viewers  )  const
 

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

Definition at line 562 of file nonlinearImager.cxx.

ProjectionScreen * NonlinearImager::get_screen int  index  )  const
 

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

Definition at line 212 of file nonlinearImager.cxx.

References NonlinearImager::Screen::_meshes, _screens, NonlinearImager::Screen::_texture, PointerTo< Texture >::clear(), and size_t.

bool NonlinearImager::get_screen_active int  index  )  const
 

Returns the active flag on the indicated screen.

Definition at line 309 of file nonlinearImager.cxx.

DisplayRegion * NonlinearImager::get_viewer int  index  )  const
 

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

Definition at line 577 of file nonlinearImager.cxx.

NodePath NonlinearImager::get_viewer_camera int  index  )  const
 

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

Definition at line 528 of file nonlinearImager.cxx.

References _screens.

void NonlinearImager::recompute  ) 
 

Forces a regeneration of all the mesh objects, etc.

Definition at line 591 of file nonlinearImager.cxx.

References NonlinearImager::Screen::_screen.

Referenced by set_viewer_camera().

void NonlinearImager::recompute_if_stale  )  [private]
 

Calls recompute() if it needs to be called.

Definition at line 659 of file nonlinearImager.cxx.

void NonlinearImager::recompute_screen NonlinearImager::Screen screen,
size_t  vi
[private]
 

Regenerates the mesh objects just for the indicated screen.

Definition at line 708 of file nonlinearImager.cxx.

void NonlinearImager::remove_all_screens  ) 
 

Removes all screens from the imager.

Definition at line 180 of file nonlinearImager.cxx.

References _screens, and height.

Referenced by NonlinearImager().

void NonlinearImager::remove_all_viewers  ) 
 

Removes all viewers from the imager.

Definition at line 468 of file nonlinearImager.cxx.

References NULL.

Referenced by NonlinearImager().

void NonlinearImager::remove_screen int  index  ) 
 

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

Definition at line 162 of file nonlinearImager.cxx.

References _screens.

void NonlinearImager::remove_viewer int  index  ) 
 

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

Definition at line 441 of file nonlinearImager.cxx.

Referenced by add_viewer().

void NonlinearImager::render GraphicsEngine engine  ) 
 

Uses the DisplayRegion's GSG to render a scene for each ProjectionScreen, and makes our DisplayRegion ready to render the combined results.

This will destroy the contents of the frame buffer; it should be done before any of the actual frame has started rendering.

Definition at line 639 of file nonlinearImager.cxx.

void NonlinearImager::render_screen GraphicsEngine engine,
NonlinearImager::Screen screen
[private]
 

Renders the scene just for the indicated screen, into the screen's own texture.

Definition at line 751 of file nonlinearImager.cxx.

void NonlinearImager::set_screen_active 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.

Definition at line 283 of file nonlinearImager.cxx.

void NonlinearImager::set_source_camera 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.

Definition at line 263 of file nonlinearImager.cxx.

References _gsg, _win, and win.

void NonlinearImager::set_texture_size 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.

Definition at line 238 of file nonlinearImager.cxx.

References _gsg, _viewers, _win, GraphicsWindow::get_gsg(), DisplayRegion::get_window(), nassertr, and win.

void NonlinearImager::set_viewer_camera 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).

Definition at line 507 of file nonlinearImager.cxx.

References recompute().


Member Data Documentation

GraphicsStateGuardian* NonlinearImager::_gsg [private]
 

Definition at line 223 of file nonlinearImager.h.

Referenced by set_source_camera(), and set_texture_size().

Screens NonlinearImager::_screens [private]
 

Definition at line 222 of file nonlinearImager.h.

Referenced by find_screen(), get_num_screens(), get_screen(), get_viewer_camera(), remove_all_screens(), remove_screen(), and ~NonlinearImager().

bool NonlinearImager::_stale [private]
 

Definition at line 226 of file nonlinearImager.h.

Referenced by ~NonlinearImager().

Viewers NonlinearImager::_viewers [private]
 

Definition at line 221 of file nonlinearImager.h.

Referenced by set_texture_size(), and ~NonlinearImager().

GraphicsWindow* NonlinearImager::_win [private]
 

Definition at line 224 of file nonlinearImager.h.

Referenced by set_source_camera(), and set_texture_size().


The documentation for this class was generated from the following files:
Generated on Fri May 2 00:52:38 2003 for Panda by doxygen1.3