Some quick thoughts without actual testing...

Create 2 VirtualUniverses as well (OR) use 2 ViewSpecificGroups - one for
each View (look at the Java3D docs for info. on ViewSpecificGroup) !

-Vaidya


>On Tue, 8 Jun 2004 08:21:52 -0600, Mikko Haapalehto
><[EMAIL PROTECTED]> wrote:

>Hi,
>
>  Could someone say what is wrong with my code. I'm trying to create two
>canvases and to render object( colorcube in this case) on canvas1 and
>another object (colorcube with rotation) on canvas2. But result of my code
>is that both cubes will be rendered on both canvases.
>
>  -mikko
>
>Code looks like this:
>import javax.media.j3d.*;
>import javax.vecmath.*;
>import com.sun.j3d.utils.universe.*;
>import com.sun.j3d.utils.geometry.*;
>import javax.swing.*;
>import java.awt.*;
>
>class canvases extends Canvas3D {
>    public static void main(String args[] ) {
>        JFrame frame = new JFrame();
>        frame.getContentPane().setLayout(new GridLayout(2,0));
>        VirtualUniverse u = new VirtualUniverse();
>
>        Canvas3D c1 = new canvases(0, u );
>        Canvas3D c2 = new canvases(1, u );
>
>        frame.getContentPane().add(c1);
>        frame.getContentPane().add(c2);
>        frame.setSize(400,400);
>        frame.show();
>
>    }
>    public canvases(int geom, VirtualUniverse u ) {
>        super(SimpleUniverse.getPreferredConfiguration());
>        BranchGroup scene = createSceneGraph(geom);
>        Locale locale = new Locale(u);
>
>        View view = new View();
> ViewPlatform vp = new ViewPlatform();
> PhysicalBody pb = new PhysicalBody();
> PhysicalEnvironment pe = new PhysicalEnvironment();
> view.addCanvas3D(this);
> view.attachViewPlatform(vp);
> view.setPhysicalBody(pb);
> view.setPhysicalEnvironment(pe);
>
> BranchGroup viewBranch = new BranchGroup();
> Transform3D viewXfm = new Transform3D();
>
> viewXfm.set(new Vector3f(0.0f,0.0f,5.0f));
>        TransformGroup viewXfmGroup = new TransformGroup(viewXfm);
> viewXfmGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
>
>        viewXfmGroup.addChild(vp);
>        viewBranch.addChild(viewXfmGroup);
>
> locale.addBranchGraph(scene);
> locale.addBranchGraph(viewBranch);
>     }
>
>     public BranchGroup createSceneGraph(int geom) {
>        BranchGroup objRoot = new BranchGroup();
>        if (geom==0)
>            objRoot.addChild(new ColorCube(0.4));
>        else if(geom==1) {
>            Transform3D rotate = new Transform3D();
>            Transform3D tempRotate = new Transform3D();
>            rotate.rotX(Math.PI/4.0d);
>            tempRotate.rotY(Math.PI/5.0d);
>            rotate.mul(tempRotate);
>            TransformGroup objRotate = new TransformGroup(rotate);
>            objRoot.addChild(objRotate);
>            objRotate.addChild(new ColorCube(0.4));
>        }
>        return objRoot;
>    }
>}
>
>
==========================================================================
>To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
>of the message "signoff JAVA3D-INTEREST".  For general help, send email to
>[EMAIL PROTECTED] and include in the body of the message "help".

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to