Sorry my english..

 Hi all.
 I modified the HelloWorld aplication for experimentation with locales,
I undestood that the locale specifies the reference point of the objects,
so if I have two locales with two Canvas and two Views and only one scene
and the two locales are at 0,0,0 I can see the objects in the two views but
if I change the reference point in one locale the object is viewed at the same
place, I think I am doing somthing bad.

   And of curse Mery Cristmas for my Java 3D friends and my best hopes
for you for the next year. :-)


import java.applet.Applet;
import java.awt.GridLayout;
import java.awt.event.*;
import com.sun.j3d.utils.applet.MainFrame;
import com.sun.j3d.utils.geometry.ColorCube;
import com.sun.j3d.utils.universe.*;
import javax.media.j3d.*;
import javax.vecmath.*;

public class HelloUniverse extends Applet {
    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));

        // Create a new Behavior object that will perform the desired
        // operation on the specified transform object and add it into
        // the scene graph.
        Transform3D yAxis = new Transform3D();
        Alpha rotationAlpha = new Alpha(-1, Alpha.INCREASING_ENABLE,
                                        0, 0,
                                        4000, 0, 0,
                                        0, 0, 0);

        RotationInterpolator rotator =
            new RotationInterpolator(rotationAlpha, objTrans, 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);
        objTrans.addChild(rotator);

        // Have Java 3D perform optimizations on this scene graph.
        objRoot.compile();

        return objRoot;
    }

    public HelloUniverse() {


        Canvas3D c1 = new Canvas3D(null);
        Canvas3D c2 = new Canvas3D(null);

      
        int coord[]  = {0,0,0,0,0,0,0,0};
          int coord2[]  = {9,9,0,0,0,0,0,0};

        VirtualUniverse MyUniverse =  new VirtualUniverse();

        Locale locale1 = new Locale(MyUniverse);
        Locale locale2 = new Locale(MyUniverse,coord, coord, coord2);
      

        PhysicalBody body = new PhysicalBody();
        PhysicalEnvironment environment = new PhysicalEnvironment();

        View view1 = new View();
        view1.addCanvas3D(c1);
        view1.setPhysicalBody(body);
        view1.setPhysicalEnvironment(environment);

        View view2 = new View();
        view2.addCanvas3D(c2);
        view2.setPhysicalBody(body);
        view2.setPhysicalEnvironment(environment);
               
        BranchGroup vpRoot1 = new BranchGroup();
        BranchGroup vpRoot2 = new BranchGroup();


        Transform3D t1 = new Transform3D();
        t1.set(new Vector3f(0.0f, 0.0f, 2.0f));
        ViewPlatform vp1 = new ViewPlatform();
        TransformGroup vpTrans1 = new TransformGroup(t1);

        Transform3D t2 = new Transform3D();
        t2.set(new Vector3f(0.0f, 0.0f, 2.0f));
//      t2.setTranslation(new Vector3f(0.0f, 0.0f, 0.1f));

        ViewPlatform vp2 = new ViewPlatform();
        TransformGroup vpTrans2 = new TransformGroup(t2);

        vpTrans1.addChild(vp1);
        vpRoot1.addChild(vpTrans1);
        view1.attachViewPlatform(vp1);

        vpTrans2.addChild(vp2);
        vpRoot2.addChild(vpTrans2);
        view2.attachViewPlatform(vp2);

        locale1.addBranchGraph(vpRoot1);
        locale2.addBranchGraph(vpRoot2);

        setLayout(new GridLayout(1,2));
        add(c1);
        add(c2);


        // Create a simple scene and attach it to the virtual universe
        BranchGroup scene = createSceneGraph();
        locale1.addBranchGraph(scene);

        // This will move the ViewPlatform back a bit so the
        // objects in the scene can be viewed.
    }

    //
    // The following allows HelloUniverse to be run as an application
    // as well as an applet
    //
    public static void main(String[] args) {
        new MainFrame(new HelloUniverse(), 512, 512);
    }
}

-- 

  /  _  \   Manuel Antonio Picone
 |-=(_)=-|  Laboratorio de Computacion 
  \     /   [EMAIL PROTECTED]
=====================================================================
To subscribe/unsubscribe, send mail to [EMAIL PROTECTED]
Java 3D Home Page: http://java.sun.com/products/java-media/3D/

Reply via email to