Using multiple views

I would like to create several views to display one or several universes.

Is there any limitation to do that using a different java window per view or using only one java window ?

I made a test (using jogl) with 2 Frame and one View in each an a loop to render the two views one after each other but only one of the view was refreshed.

Thanks for your help.

Here is the source code to demonstrate that I can’t use 2 View in parallel.
Would/Could/Should it be possible to make it working or is it outside the scope of Xith3d ?

import javax.vecmath.;
import com.xith3d.render.
;
import com.xith3d.scenegraph.*;
import com.xith3d.test.TestUtils;

public class TestMultiView {
RenderPeer peer;
CanvasPeer canvasPeer;
Canvas3D canvas = new Canvas3D();
View view;

public TestMultiView(Object owner, int x, int y, int width, int height) {
peer = new com.xith3d.render.jogl.RenderPeerImpl();
canvasPeer =peer.makeCanvas(owner, width, height, 16, false);
if(canvasPeer.getWindow()!=null){
canvasPeer.getWindow().setLocation(x, y);
}
canvas.set3DPeer(canvasPeer);

view = new View();
view.setProjectionPolicy(View.PERSPECTIVE_PROJECTION);
view.addCanvas3D(canvas);
        
Transform3D transform=new Transform3D();
transform.lookAt(new Vector3f(0.f,0.f,2.f),
  new Vector3f(0.f,0.f,0.f),
  new Vector3f(0.f,1.f,0.f));
view.setTransform(transform);

}

public static void main(String[] args) {
VirtualUniverse universe = new VirtualUniverse();
Locale locale = new Locale();
universe.addLocale(locale);

BranchGroup objRoot = new BranchGroup();

Appearance a = new Appearance();
a.setPolygonAttributes(new PolygonAttributes(PolygonAttributes.POLYGON_LINE, PolygonAttributes.CULL_NONE, 0));
Shape3D sph = new Shape3D(TestUtils.createSphere(1.0f, 20), a);
TransformGroup sphereTrans = new TransformGroup();
sphereTrans.addChild(sph);

objRoot.addChild(sphereTrans);

AmbientLight aLgt = new AmbientLight(new Color3f(0.2f, 0.2f, 0.2f));
objRoot.addChild(aLgt);

locale.addBranchGraph(objRoot);
        
TestMultiView f1=new TestMultiView(null,0,0,600,400);
universe.addView(f1.view);

TestMultiView f2=new TestMultiView(null,0,0,300,300);
universe.addView(f2.view);
                    
while(true){
  f1.view.renderOnce();
  f2.view.renderOnce();
  try{
    Thread.sleep(10);
  }
  catch(InterruptedException e){
  }
}            

}
}

Well, this is not so well tested and developer area of Xith3D. Theoretically, everything should work, but there are also alternative ways - you can potentially attach multiple canvases to single View using View.addCanvas3D(…).

We definitely have to work on this to make this functionality usable.

Yuri

At some point it would be nice if multiple universes could be rendered. I think the following statements are true, could someone please verify them for me.

1> All Locales in a VirtualUniverse should be rendered to all Views in the same VirtualUniverse, if they are not culled.
2> Each View in a VirtualUniverse can have a different view point on the VirtualUniverse.
3> Currently #1 is not quite functional.
4> Currently there is only ever one render engine.

It would be very cool to be able to assign an instance of a render engine to a Universe. I think this would allow for quicker rendering under certain circumstances. This may be a bad example but would this help in the situation below?

One renderer handling a radar screen and another handling the main game display and yet another handling a chat area. Each, of course, outputting to a separate canvas.

Wouldn’t that help keep state changes (inside the render engine, not in OGL) to a minimum and therefore increase render speed? I’m I completely out to lunch here?

Edit: A better example. Two adventure player game, one person is in one universe the other in a different universe. The universes share very little in common as far as textures and models. Both are displayed on screen in a split-screen mode.

Well, of course, earlier or later we will add this functionality.

The points above seem to be correct.

Point 4 is not so important, question is if it is possible to perform rendering to different CanvasPeers.

There are several issues related to this:
a). Multithreaded rendering. Potentially, it should be possible to run rendering on multiple threads. This is quite important for multihead stereo rendering. One of the stoppers for this is use of static fields inside rendering code.
b). Geometry and texture caches. This is a question of re-using the same texture or VBO in different CanvasPeers (GL contexts).

There are some other issues which are known for now, so if somebody has need for this and has resources to make it working, it would be great.

I personally will come to the issues with multi-view rendering (for multiheaded systems) in 1-2 months I guess. So that time I will definitely do something on this, if somebody will not fix this before, which will be a big luck.

Yuri

If I comment out the following line in CanvasPeerImpl then both windows will update for a couple of seconds before the app dies with an access violation.

    if (renderFrame == null) canvas.setRenderingThread(Thread.currentThread());

Not knowing much about Jogl (more of a lwjgl man myself, thought I’d have a look and see how Xith worked), does this give anyone any clues as to where to start looking to make this work.

I find interesting to point this problem.

How to display multiple views of the same scene? It becomes usual today in many online games to have a spectator view. So it could be interesting to have on the same screen a view from a player, a view from another player but in chase mode, etc…

Some further info on this topic, hopefully this will help determine the problem.

As Jacko noted above commenting out the line:

if (renderFrame == null) canvas.setRenderingThread(Thread.currentThread());

will allow more than a single view to rendered at a time, in my case I have two completely separate universes rendering in two separate windows. (See the thread at http://www.java-gaming.org/cgi-bin/JGNetForums/YaBB.cgi?board=xith3d;action=display;num=1075405999)

Without that line commented out this is what happens:

1> Open the first window and create and render the view, works fine.
2> Open the second window and create and render the view, works fine.
3> After second view has been rendered the first view will no longer take changes to the universe. It always renders exactly as it did before the second window was opened. As if the frame was stored and that is what keeps getting rendered back to the canvas. However the second view continues to accept changes.

It seems that the Java3D folks is requiring the same. Maybe this will be of any interest:

Java XTools 1.16 by Oxygenic (http://freshmeat.net/users/oxygenic/)
Tuesday, January 27th 2004 02:58

Communications
Desktop Environment
Games/Entertainment

About: The Java XTools are an extensive collection of enhanced functions and features for Java and Java 3D. It includes an enhanced BranchGroup Node, object loaders for Renderware .rwx files and Caligari TrueSpace .cob
and .scn files, RotationInterpolators for combinations of the X-, Y-, and Z-axes, enhanced keyboard navigation, a multiple-view universe, and a text to texture converter. It also includes functions and classes for images and PNG files, a ByteArrayReader, data download including a disk caching mechanism, and enhancements for Swing components.

Changes: A new class “MultiUniverse” was added. It provides a universe which supports several Views/Canvas3D for the same SceneGraph. The complete sourcecode was overworked and is now fully compatible with Java 1.3.1.
License: GNU General Public License (GPL)

URL: http://freshmeat.net/projects/xtools/

[quote]I find interesting to point this problem.

How to display multiple views of the same scene? It becomes usual today in many online games to have a spectator view. So it could be interesting to have on the same screen a view from a player, a view from another player but in chase mode, etc…
[/quote]
Is anybody presently working towards this? I have a scene that I’d like to render a miniature overview of. It would be great if I could render two separate views (one from ground level, one from above) and then use the above ground view as a UIOverlay. If the problem with multiple views was resolved would there be any additional problems rendering to canvas on a JPanel that was in turn being used as a UIOverlay?