Multiple Views in One Window

A place to discuss advanced projects and high-level topics.
Post Reply
jthomas
Posts: 1
Joined: Fri 25. May 2012, 23:41

Multiple Views in One Window

Post by jthomas » Sat 26. May 2012, 00:44

I'm hoping someone can give me some suggestions on an idea that I've been (unsuccessfully) trying to implement. I'm working on some software that will be used in a museum exhibit, rather like an arcade game. Through the game, visitors are supposed to get an idea of what it would be like to inhabit a piecewise-flat manifold (for the moment, of dimension 2).

Here's the problem: I would like to be able to "composite" several different views of the manifold into a single window. (An example is attached.) From this 2010 post http://www3.math.tu-berlin.de/jreality/ ... ?f=3&t=453 I know that JReality currently supports only a "1 viewer, 1 view" system. However, in the interest of a clean user-experience, I would really like to avoid having multiple windows.

Here's what I've tried/considered so far:
--------------------
1) Use swing/AWT to put multiple viewers in a JFrame:

This sort of worked, but I had a lot of trouble with views that flickered or failed to render.

2) Render the views to BufferedImages offscreen, then "blit" them together and post the result:

I found I couldn't call "renderOffscreen" successfully without having a window running for each viewer. Also, I think this may not work for performance reasons.

3) Adapt JReality's JOGLRenderer

The problem JOGLRenderer's "cross-eyed stereo" code solves seems similar to the one I'm trying to solve. After looking at the code for this class (and its helpers) I'm thinking this might be too much of a project. However, if someone has a simplified version of this code (or could tell me more about how it was implemented), maybe I could make some progress here.
--------------------

I have about 2-3 months to work on this feature (along with other responsibilities). The views that I'm trying to put together work fine individually.

Thanks,
Joseph Thomas
University of Arizona
Attachments
dodectiled.png
dodectiled.png (110.16 KiB) Viewed 2105 times

User avatar
gunn
Posts: 323
Joined: Thu 14. Dec 2006, 09:56
Location: TU Berlin
Contact:

Re: Multiple Views in One Window

Post by gunn » Thu 31. May 2012, 10:28

First, have you considered using undecorated frames to display the different views? They have no border and can be placed arbitrarily, to simulate the effect you are looking for.

If you're still interested in pursuing the JOGL backend modification, read on:

It should be possible to "extend" the JOGL viewer to render the different views you have in mind. I don't have time right now to undertake the task. The idea I have is to subclass de.jreality.jogl.Viewer, call it for example de.jreality.jogl.MultiViewer, , adding a list of Viewer instances (lightweight class, not subclasses of de.jreality.jogl.AbstractViewer), each with a subwindow specification of some sort. Then, overwrite the method Viewer.display(GLAutoDrawable arg0). The existing method just calls renderer.display(arg0). The idea is to continue to call this (see comments below on tool system), but to also add a loop over all the Viewer instances; each should be equipped with its own JOGLRenderer instance. In this loop, first set the desired viewport within the main viewport by calling the method renderer.myglViewport() on this instance, followed by renderer.display(arg0). There are details to be kept in mind, for example, any events which currently result in updating the unique JOGLRenderer will have to be extended by a loop to update the renderer of each of the Viewers in the list, etc.

Also, if you're still reading this, keep in mind that the current method for setting the viewport (myglViewport) expects the viewport to be the size of the full drawing surface. You'll have to go through the code and see how to generalize to be a real sub-viewport. There's shouldn't be much to change except introduce a more general data structure.

Also be forewarned: interaction with the tool system will only work properly in a view which fills the whole canvas, since the picking system assumes the size of the graphics window is also the size of the displayed viewport. It furthermore has no idea that you are in fact drawing several different views in a single "viewing component". So, my recommendation is to continue to draw the view in the full window (as inherited from the de.jreality.jogl.Viewer class), then add the list of "secondary" viewers with viewports arranged around the periphery of the main window, with the understanding that you can't interact with these views, only with the "primary" one.
jReality core developer

User avatar
gunn
Posts: 323
Joined: Thu 14. Dec 2006, 09:56
Location: TU Berlin
Contact:

Re: Multiple Views in One Window

Post by gunn » Thu 31. May 2012, 12:03

Here's another idea.

Use an instance of GLJPanelViewer, which is a subclass of JPanel. You can then add the viewing components of other viewers. I've worked out a simple example.

Begin with the tutorial example de.jreality.tutorial.GLJPanelViewerExample and add the following code at the end:

Code: Select all

	    System.setProperty(SystemProperties.VIEWER, "de.jreality.jogl.Viewer"); 
		world = new SceneGraphComponent();
		world.setGeometry(Primitives.coloredCube());
	    de.jreality.scene.Viewer viewer  = JRViewer.display(world);
	    Component comp = (Component) viewer.getViewingComponent();
	    comp.setSize(new Dimension(300, 200));
	    comp.repaint();
	    comp.validate();
	    glpv.getPanel().add(comp);
		world = new SceneGraphComponent();
		world.setAppearance(new Appearance());
	    world.getAppearance().setAttribute("diffuseColor", Color.white);
		world.setGeometry(Primitives.torus(1, .3, 20,20));
	    de.jreality.scene.Viewer viewer2  = JRViewer.display(world);
	    Component comp2 = (Component) viewer2.getViewingComponent();
	    comp2.setSize(new Dimension(300, 200));
	    comp2.repaint();
	    comp2.validate();
	    glpv.getPanel().add(comp2);
	    comp2.setLocation(500, 300);
You should get a picture like this:
Image
The sub-views of the cube and the torus are actually instances of GLCanvas (see first line of code above, switching back to default JOGL viewer) hence they are anti-aliased -- currently the GLJPanelViewer doesn't provide anti-aliased rendering. You could replace the icosahedron view also with the component from a GLCanvas, completely avoiding the anti-aliasing problem. A further advantage is that all the views are top-level views and interact correctly with the tool system.
jReality core developer

Post Reply