43 if (_recompute_task !=
nullptr) {
45 task_mgr->
remove(_recompute_task);
78 screen.
node()->
is_of_type(ProjectionScreen::get_class_type()), -1);
82 _screens.push_back(Screen());
83 Screen &new_screen = _screens.back();
84 new_screen._screen = screen;
85 new_screen._screen_node = screen_node;
86 new_screen._name = name;
87 new_screen._buffer =
nullptr;
88 new_screen._tex_width = 256;
89 new_screen._tex_height = 256;
90 new_screen._active =
true;
94 for (vi = 0; vi < _viewers.size(); ++vi) {
95 new_screen._meshes.push_back(Mesh());
104 nassertr(_dark_room.
is_same_graph(screen), _screens.size() - 1);
107 return _screens.size() - 1;
116 for (
size_t i = 0; i < _screens.size(); i++) {
117 if (_screens[i]._screen == screen) {
130 nassertv_always(index >= 0 && index < (
int)_screens.size());
131 Screen &screen = _screens[index];
132 for (
size_t vi = 0; vi < screen._meshes.size(); vi++) {
133 screen._meshes[vi]._mesh.remove_node();
135 _screens.erase(_screens.begin() + index);
143 while (!_screens.empty()) {
153 return _screens.size();
161 nassertr(index >= 0 && index < (
int)_screens.size(),
NodePath());
162 return _screens[index]._screen;
172 nassertr(index >= 0 && index < (
int)_screens.size(),
nullptr);
173 return _screens[index]._buffer;
186 nassertv(index >= 0 && index < (
int)_screens.size());
188 Screen &screen = _screens[index];
190 screen._tex_width = width;
191 screen._tex_height = height;
193 if (screen._buffer !=
nullptr) {
194 bool removed = _engine->remove_window(screen._buffer);
195 screen._buffer =
nullptr;
211 nassertv(index >= 0 && index < (
int)_screens.size());
212 nassertv(!source_camera.
is_empty() &&
214 _screens[index]._source_camera = source_camera;
223 nassertv(index >= 0 && index < (
int)_screens.size());
225 Screen &screen = _screens[index];
226 screen._active = active;
230 for (
size_t vi = 0; vi < screen._meshes.size(); vi++) {
231 screen._meshes[vi]._mesh.remove_node();
235 if (screen._buffer !=
nullptr) {
236 bool removed = _engine->remove_window(screen._buffer);
237 screen._buffer =
nullptr;
244 screen._screen.
hide();
250 screen._screen.
show();
259 nassertr(index >= 0 && index < (
int)_screens.size(),
false);
260 return _screens[index]._active;
281 nassertr(window !=
nullptr, -1);
284 nassertr(gsg !=
nullptr, -1);
287 nassertr(engine !=
nullptr, -1);
289 nassertr(_viewers.empty() || (engine == _engine), -1);
290 if (_engine ==
nullptr) {
294 if (_recompute_task ==
nullptr) {
298 task_mgr->
add(_recompute_task);
302 if (previous_vi >= 0) {
306 size_t vi = _viewers.size();
307 _viewers.push_back(Viewer());
308 Viewer &viewer = _viewers[vi];
315 viewer._viewer_node =
nullptr;
317 viewer._viewer_node = DCAST(
LensNode, viewer._viewer.
node());
322 viewer._internal_camera =
new Camera(
"internal_camera");
323 viewer._internal_camera->set_lens(
new MatrixLens);
324 viewer._internal_scene =
NodePath(
"internal_screens");
325 viewer._internal_camera->set_scene(viewer._internal_scene);
328 viewer._dr->set_camera(camera_np);
336 Screens::iterator si;
337 for (si = _screens.begin(); si != _screens.end(); ++si) {
338 Screen &screen = (*si);
339 screen._meshes.push_back(Mesh());
340 nassertr(screen._meshes.size() == _viewers.size(), -1);
346 _dark_room = viewer._viewer.
get_top();
360 for (
size_t vi = 0; vi < _viewers.size(); vi++) {
361 if (_viewers[vi]._dr == dr) {
374 nassertv_always(index >= 0 && index < (
int)_viewers.size());
375 Viewer &viewer = _viewers[index];
376 viewer._internal_camera->set_scene(
NodePath());
377 viewer._dr->set_camera(viewer._viewer);
380 Screens::iterator si;
381 for (si = _screens.begin(); si != _screens.end(); ++si) {
382 Screen &screen = (*si);
383 nassertv(index < (
int)screen._meshes.size());
384 screen._meshes[index]._mesh.remove_node();
385 screen._meshes.erase(screen._meshes.begin() + index);
388 _viewers.erase(_viewers.begin() + index);
396 while (!_viewers.empty()) {
415 nassertv(index >= 0 && index < (
int)_viewers.size());
416 nassertv(!viewer_camera.
is_empty() &&
418 Viewer &viewer = _viewers[index];
419 viewer._viewer = viewer_camera;
420 viewer._viewer_node = DCAST(
LensNode, viewer_camera.
node());
424 _dark_room = viewer._viewer.
get_top();
436 nassertr(index >= 0 && index < (
int)_viewers.size(),
NodePath());
437 return _viewers[index]._viewer;
451 nassertr(index >= 0 && index < (
int)_viewers.size(),
NodePath());
452 return _viewers[index]._internal_scene;
460 return _viewers.size();
468 nassertr(index >= 0 && index < (
int)_viewers.size(),
nullptr);
469 return _viewers[index]._dr;
503 for (vi = 0; vi < _viewers.size(); ++vi) {
504 Viewer &viewer = _viewers[vi];
506 Screens::iterator si;
507 for (si = _screens.begin(); si != _screens.end(); ++si) {
508 Screen &screen = (*si);
509 if (screen._active) {
510 recompute_screen(screen, vi);
514 if (viewer._viewer_node !=
nullptr &&
515 viewer._viewer_node->get_lens() !=
nullptr) {
516 viewer._viewer_lens_change =
517 viewer._viewer_node->get_lens()->get_last_change();
531 return AsyncTask::DS_cont;
543 for (vi = 0; vi < _viewers.size(); ++vi) {
544 Viewer &viewer = _viewers[vi];
545 if (viewer._viewer_node !=
nullptr) {
547 viewer._viewer_node->get_lens()->get_last_change();
548 if (lens_change != viewer._viewer_lens_change) {
551 Screens::iterator si;
552 for (si = _screens.begin(); si != _screens.end(); ++si) {
553 Screen &screen = (*si);
554 if (screen._active) {
555 recompute_screen(screen, vi);
561 Screens::iterator si;
562 for (si = _screens.begin(); si != _screens.end(); ++si) {
563 Screen &screen = (*si);
564 if (screen._active &&
565 screen._meshes[vi]._last_screen != screen._screen_node->get_last_screen()) {
566 recompute_screen(screen, vi);
568 screen._screen_node->recompute_if_stale(screen._screen);
580void NonlinearImager::
581recompute_screen(NonlinearImager::Screen &screen,
size_t vi) {
582 nassertv(vi < screen._meshes.size());
583 screen._meshes[vi]._mesh.remove_node();
584 if (!screen._active) {
588 screen._screen_node->recompute_if_stale(screen._screen);
590 Viewer &viewer = _viewers[vi];
592 screen._screen_node->make_flat_mesh(screen._screen, viewer._viewer);
593 if (mesh !=
nullptr) {
594 screen._meshes[vi]._mesh = viewer._internal_scene.attach_new_node(mesh);
597 if (screen._buffer ==
nullptr) {
600 (screen._name, screen._tex_width, screen._tex_height,
nullptr,
false);
602 if (buffer !=
nullptr) {
603 screen._buffer = buffer;
608 screen._meshes[vi]._mesh.clear_texture();
612 if (screen._buffer !=
nullptr) {
613 screen._meshes[vi]._mesh.set_texture(screen._buffer->get_texture());
619 screen._screen.
set_texture(screen._buffer->get_texture());
622 screen._meshes[vi]._last_screen = screen._screen_node->get_last_screen();
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A class to manage a loose queue of isolated tasks, which can be performed either synchronously (in th...
bool remove(AsyncTask *task)
Removes the indicated task from the active queue.
void add(AsyncTask *task)
Adds the indicated task to the active queue.
static AsyncTaskManager * get_global_ptr()
Returns a pointer to the global AsyncTaskManager.
A node that can be positioned around in the scene graph to represent a point of view for rendering a ...
A rectangular subregion within a window for rendering into.
set_camera
Sets the camera that is associated with this DisplayRegion.
get_camera
Returns the camera associated with this DisplayRegion, or an empty NodePath if no camera is associate...
get_window
Returns the GraphicsOutput that this DisplayRegion is ultimately associated with, or NULL if no windo...
Associates a generic C-style function pointer with an AsyncTask object.
This class is the main interface to controlling the render process.
This is a base class for the various different classes that represent the result of a frame of render...
get_gsg
Returns the GSG that is associated with this window.
DisplayRegion * make_display_region()
Creates a new DisplayRegion that covers the entire window.
Encapsulates all the communication with a particular instance of a given rendering backend.
GraphicsEngine * get_engine() const
Returns the graphics engine that created this GSG.
A node that contains a Lens.
A completely generic linear lens.
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
bool is_same_graph(const NodePath &other, Thread *current_thread=Thread::get_current_thread()) const
Returns true if the node represented by this NodePath is parented within the same graph as that of th...
void show()
Undoes the effect of a previous hide() on this node: makes the referenced node (and the entire subgra...
void hide()
Makes the referenced node (and the entire subgraph below this node) invisible to all cameras.
void set_texture(Texture *tex, int priority=0)
Adds the indicated texture to the list of textures that will be rendered on the default texture stage...
bool is_empty() const
Returns true if the NodePath contains no nodes.
PandaNode * node() const
Returns the referenced node of the path.
NodePath get_top(Thread *current_thread=Thread::get_current_thread()) const
Returns a singleton NodePath that represents the top of the path, or empty NodePath if this path is e...
NodePath attach_new_node(PandaNode *node, int sort=0, Thread *current_thread=Thread::get_current_thread()) const
Attaches a new node, with or without existing parents, to the scene graph below the referenced node o...
void set_two_sided(bool two_sided, int priority=0)
Specifically sets or disables two-sided rendering mode on this particular node.
This class object combines the rendered output of a 3-d from one or more linear (e....
get_screen
Returns the nth screen that has been added to the imager.
void remove_all_viewers()
Removes all viewers from the imager.
get_num_screens
Returns the number of screens that have been added to the imager.
void recompute()
Forces a regeneration of all the mesh objects, etc.
static AsyncTask::DoneStatus recompute_callback(GenericAsyncTask *task, void *data)
This function is added as a task, to ensure that all frames are up-to-date.
void set_viewer_camera(int index, const NodePath &viewer_camera)
Specifies the LensNode that is to serve as the viewer for this screen.
int find_screen(const NodePath &screen) const
Returns the index number of the first appearance of the indicated screen within the imager's list,...
get_viewer
Returns the nth viewer's DisplayRegion that has been added to the imager.
void recompute_if_stale()
Calls recompute() if it needs to be called.
GraphicsEngine * get_graphics_engine() const
Returns the GraphicsEngine that all of the viewers added to the NonlinearImager have in common.
void set_screen_active(int index, bool active)
Sets the active flag on the indicated screen.
int add_screen(ProjectionScreen *screen)
This version of this method is deprecated and will soon be removed.
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 remove_all_screens()
Removes all screens from the imager.
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,...
NodePath get_viewer_scene(int index) const
Returns a pointer to the root node of the internal scene graph for the nth viewer,...
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.
bool get_screen_active(int index) const
Returns the active flag on the indicated screen.
void remove_viewer(int index)
Removes the viewer with the indicated index number from the imager.
get_num_viewers
Returns the number of viewers that have been added to the imager.
void remove_screen(int index)
Removes the screen with the indicated index number from the imager.
NodePath get_viewer_camera(int index) const
Returns the NodePath to the LensNode that is to serve as nth viewer for this screen.
get_buffer
Returns the offscreen buffer that is automatically created for the nth projection screen.
NodePath get_dark_room() const
Returns the NodePath to the root of the dark room scene.
A basic node of the scene graph or data graph.
A ProjectionScreen implements a simple system for projective texturing.
const UpdateSeq & get_last_screen() const
Returns an UpdateSeq corresponding to the last time a screen mesh was generated for the ProjectionScr...
bool is_of_type(TypeHandle handle) const
Returns true if the current object is or derives from the indicated type.
This is a sequence number that increments monotonically.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.