Skip to main content

2 locales and 2 views

2 replies [Last post]
elemental
Offline
Joined: 2005-01-21

I have a split pane that should actually shows two different scenegrpahs.

So my understanding is that you create 2 locales with seperate view branches and two different canvas3d objects for this (Right?? ). And then you add the respective scenes to these two different locales.

But what is happening is that I see the same scene on both my different canvases. Do I have to like relocate the view to some extreme position so that they don't overlap in the universe. Doesn't Locale and a different canvas exclude the other scene on the other canvas.

Thanx and Regards

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
nitro
Offline
Joined: 2004-09-12

Do you use two separate VirtualUniverse's? If not I think you need to set the locales far apart from each other if they should not be shown both.

Below is a test programm with two VirtualUniverse's that should work:
[code]
public class TwoUniverse extends Applet {
private static final long serialVersionUID = 1L;

public TwoUniverse() {
this.setLayout(new GridLayout());
GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
Canvas3D canvas3D = new Canvas3D(config);
this.add(canvas3D);

BranchGroup scene = createSceneGraph1();
scene.compile();

SimpleUniverse simpleU = new SimpleUniverse(canvas3D);
simpleU.getViewingPlatform().setNominalViewingTransform();
simpleU.addBranchGraph(scene);

canvas3D = new Canvas3D(config);
this.add(canvas3D);

scene = createSceneGraph2();
scene.compile();

simpleU = new SimpleUniverse(canvas3D);
simpleU.getViewingPlatform().setNominalViewingTransform();
simpleU.addBranchGraph(scene);
}

public BranchGroup createSceneGraph1() {
Point3d[] myCoords = { new Point3d(1.0, 1.0, 1.0), new Point3d(100.0, 100.0, 100.0) };
LineArray myLines = new LineArray(myCoords.length, GeometryArray.COORDINATES);
myLines.setCoordinates(0, myCoords);

Color3f white = new Color3f(1.0f, 1.0f, 1.0f);
ColoringAttributes colAtr = new ColoringAttributes(white, 1);
Appearance myAppear = new Appearance();
myAppear.setColoringAttributes(colAtr);

Shape3D myShape = new Shape3D(myLines, myAppear);
myShape.setCapability(Shape3D.ALLOW_APPEARANCE_WRITE);
BranchGroup objRoot = new BranchGroup();

TransformGroup tg=new TransformGroup();
Transform3D t3d= new Transform3D();
t3d.setTranslation(new Vector3d(0,0,-10));
tg.setTransform(t3d);

tg.addChild(new ColorCube());

objRoot.addChild(tg);
objRoot.compile();
return objRoot;
}

public BranchGroup createSceneGraph2() {
Point3d[] myCoords = { new Point3d(1.0, 1.0, 1.0), new Point3d(100.0, 100.0, 100.0) };
LineArray myLines = new LineArray(myCoords.length, GeometryArray.COORDINATES);
myLines.setCoordinates(0, myCoords);

Color3f white = new Color3f(1.0f, 1.0f, 1.0f);
ColoringAttributes colAtr = new ColoringAttributes(white, 1);
Appearance myAppear = new Appearance();
myAppear.setColoringAttributes(colAtr);

Shape3D myShape = new Shape3D(myLines, myAppear);
myShape.setCapability(Shape3D.ALLOW_APPEARANCE_WRITE);
BranchGroup objRoot = new BranchGroup();

TransformGroup tg=new TransformGroup();
Transform3D t3d= new Transform3D();
t3d.setTranslation(new Vector3d(0,0,-10));
tg.setTransform(t3d);

tg.addChild(new Sphere(1, Sphere.GENERATE_NORMALS, new Appearance()));

objRoot.addChild(tg);
objRoot.compile();
return objRoot;
}

public static void main(String args[]) {
Frame frame = new MainFrame(new TwoUniverse(), 256, 256);
}

}
[/code]

elemental
Offline
Joined: 2005-01-21

Thanx,

I c no harm in using two seperate universes for my application. I'll just add another universe then. Thanx for clearing the locale thing.

Regards.