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){
}
}
}
}