>
>
>
> So, what's the latest word on multiple views? I read a bit of activity
> back in September on java3d-interest. There didn't seem to be any
> resolution.
>
> I have multiple ViewPlatforms each with its own Canvas3D and its own
> behaviors to update the ViewPlatform's TransformGroup. I can set up
> whatever view I want for each window just fine, but when I let the
> behaviors do there things, well, one behavior affects all the canvases
> even though there are no connections (different canvas3d's , different
> transform groups, no static objects involved (that I know about)).
>
> Is this still a problem with Java3D? I checked the known problems list
> for the word multiple, but no luck..
>
Attached is a quick (and very ugly) test program that has multiple views.
One view is static and the other two have and animated ViewPlatform. I
do not see the behavior you are seeing.
If you still have problems sending an example program would help us
a lot.
Thanks,
Dan Petersen
Java 3D Team
Sun Microsystems
import java.awt.*;
import java.awt.event.*;
import javax.media.j3d.*;
import javax.vecmath.*;
import com.sun.j3d.utils.geometry.*;
import com.sun.j3d.utils.image.TextureLoader;
import com.sun.j3d.utils.universe.*;
public class MultViews extends Frame {
public BranchGroup createSceneGraph() {
// Create the root of the branch graph
BranchGroup objRoot = new BranchGroup();
// Create the transform group node and initialize it to the
// identity. Enable the TRANSFORM_WRITE capability so that
// our behavior code can modify it at runtime. Add it to the
// root of the subgraph.
TransformGroup objTrans = new TransformGroup();
objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
objRoot.addChild(objTrans);
// Create a simple shape leaf node, add it to the scene graph.
objTrans.addChild(new ColorCube(0.4));
// Have Java 3D perform optimizations on this scene graph.
objRoot.compile();
return objRoot;
}
BranchGroup createViewGraph(SimpleUniverse u, Canvas3D c3d, int num) {
BranchGroup viewRoot = new BranchGroup();
// use same view distance as main view
Viewer viewer = u.getViewer();
double viewDistance = viewer.getView().getFieldOfView();
// Calculate the distance from the to the imageplate.
viewDistance = 1.0/Math.tan(viewDistance/2.0);
// Assign this value to the ViewPlatform transform.
Transform3D offset = new Transform3D();
offset.set(new Vector3d(0.0, 0.0, viewDistance));
TransformGroup spinTg = new TransformGroup();
spinTg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
TransformGroup offTg = new TransformGroup();
offTg.setTransform(offset);
viewRoot.addChild(spinTg);
spinTg.addChild(offTg);
Transform3D yAxis = new Transform3D();
Transform3D xAxis = new Transform3D();
xAxis.rotZ(Math.PI/2.0d);
RotationInterpolator rotator;
if (num == 0) {
Alpha rotationAlpha = new Alpha(-1, Alpha.INCREASING_ENABLE,
0, 0,
3000, 0, 0,
0, 0, 0);
rotator =
new RotationInterpolator(rotationAlpha, spinTg, xAxis,
0.0f, (float) Math.PI*2.0f);
}
else {
Alpha rotationAlpha = new Alpha(-1, Alpha.INCREASING_ENABLE,
0, 0,
7000, 0, 0,
0, 0, 0);
rotator =
new RotationInterpolator(rotationAlpha, spinTg, yAxis,
0.0f, (float) Math.PI*2.0f);
}
BoundingSphere bounds =
new BoundingSphere(new Point3d(0.0,0.0,0.0), 100.0);
rotator.setSchedulingBounds(bounds);
spinTg.addChild(rotator);
PhysicalBody physicalBody = new PhysicalBody();
PhysicalEnvironment physicalEnvironment = new PhysicalEnvironment();
ViewPlatform viewPlatform = new ViewPlatform();
offTg.addChild(viewPlatform);
View view = new View();
view.addCanvas3D(c3d);
view.setPhysicalBody(physicalBody);
view.setPhysicalEnvironment(physicalEnvironment);
view.attachViewPlatform(viewPlatform);
return viewRoot;
}
public static void main(String args[]) {
MultViews mv = new MultViews();
mv.setLayout(new GridLayout(1, 3, 10, 0));
Canvas3D suCanvas = new Canvas3D(null);
Canvas3D viewCanvas = new Canvas3D(null);
Canvas3D view2Canvas = new Canvas3D(null);
// Handle the close event
mv.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent winEvent)
{
System.exit(0);
}
});
SimpleUniverse u = new SimpleUniverse(suCanvas);
BranchGroup objRoot = mv.createSceneGraph();
BranchGroup viewRoot = mv.createViewGraph(u, viewCanvas, 0);
BranchGroup view2Root = mv.createViewGraph(u, view2Canvas, 1);
u.getViewingPlatform().setNominalViewingTransform();
u.addBranchGraph(objRoot);
u.addBranchGraph(viewRoot);
u.addBranchGraph(view2Root);
mv.add(suCanvas);
mv.add(view2Canvas);
mv.add(viewCanvas);
mv.setTitle("Java3D");
mv.setSize(256, 256);
mv.show();
}
}