Package javax.media.j3d

Examples of javax.media.j3d.BranchGroup


    /**
     * Sets the 3D model viewed by this model 
     */
    public void setModel(Content model, final UserPreferences preferences) {
      if (model == null) {
        setModel(new BranchGroup());           
      } else {
        ModelManager.getInstance().loadModel(model, new ModelManager.ModelObserver() {         
            public void modelUpdated(BranchGroup modelRoot) {
              setModel(modelRoot);           
            }
View Full Code Here


   
    /*
     *
     */
  protected float getSceneSize() {
    BranchGroup bg = scene.getBranchgroup();
    boolean autocompute = bg.getBoundsAutoCompute();
    scene.getBranchgroup().setBoundsAutoCompute(true);
    Bounds bounds = scene.getBranchgroup().getBounds();
    scene.getBranchgroup().setBoundsAutoCompute(autocompute);
    if (bounds instanceof BoundingSphere) {
      return (float)((BoundingSphere)bounds).getRadius();
View Full Code Here

        canvas3D = new Canvas3D(r);
       
        canvas3D.setDoubleBufferEnable(true);
        universe = new SimpleUniverse(canvas3D);

        rootGroup = new BranchGroup();
        rootGroup.setCapability(BranchGroup.ALLOW_DETACH);
        rootGroup.setCapability(BranchGroup.ALLOW_CHILDREN_READ);
        rootGroup.setCapability(BranchGroup.ALLOW_CHILDREN_WRITE);
        rootGroup.setCapability(BranchGroup.ALLOW_CHILDREN_EXTEND);
        branchgroup = new BranchGroup();
        branchgroup.setCapability(BranchGroup.ALLOW_AUTO_COMPUTE_BOUNDS_READ);
        branchgroup.setCapability(BranchGroup.ALLOW_BOUNDS_READ);
        branchgroup.setCapability(BranchGroup.ALLOW_AUTO_COMPUTE_BOUNDS_WRITE);
        branchgroup.setCapability(BranchGroup.ALLOW_CHILDREN_READ);
        branchgroup.setCapability(BranchGroup.ALLOW_CHILDREN_WRITE);
        branchgroup.setCapability(BranchGroup.ALLOW_CHILDREN_EXTEND);
       
        // TODO use light factories

        AmbientLight alight = new AmbientLight(true,new Color3f(0.5f,0.5f,0.5f));
        alight.setEnable(true);
        rootGroup.addChild(alight);
        BoundingSphere bounds = new BoundingSphere (new Point3d (0, 0.0, 0), 1E100);
        alight.setInfluencingBounds(bounds);

        lights = new DirectionalLight[1];

        for (int i=0; i<lights.length; ++i) {
          // TODO : position lights around the object
            lights[i] = new DirectionalLight(true,new Color3f(1.0f,1.0f,1.0f),new Vector3f(-1,-1,-1));
            lights[i].setCapability(DirectionalLight.ALLOW_DIRECTION_READ);
            lights[i].setCapability(DirectionalLight.ALLOW_DIRECTION_WRITE);
            lights[i].setCapabilityIsFrequent(DirectionalLight.ALLOW_DIRECTION_READ);
            lights[i].setCapabilityIsFrequent(DirectionalLight.ALLOW_DIRECTION_WRITE);
            lights[i].setEnable(true);
            lights[i].setInfluencingBounds(bounds);
            rootGroup.addChild(lights[i]);
        }
       
        // X axis in blue
        axisGroup = new BranchGroup();

        float[] axis = AxisMaker.makeAxis(0);
        LineArray la = new LineArray(axis.length/3, LineArray.COORDINATES);
        la.setCoordinates(0,axis);
        Appearance a = new Appearance();
View Full Code Here

        canvas3D = new Canvas3D(r);
       
        canvas3D.setDoubleBufferEnable(true);
        universe = new SimpleUniverse(canvas3D);

        rootGroup = new BranchGroup();
        rootGroup.setCapability(BranchGroup.ALLOW_DETACH);
        rootGroup.setCapability(BranchGroup.ALLOW_CHILDREN_READ);
        rootGroup.setCapability(BranchGroup.ALLOW_CHILDREN_WRITE);
        rootGroup.setCapability(BranchGroup.ALLOW_CHILDREN_EXTEND);
        branchgroup = new BranchGroup();
        branchgroup.setCapability(BranchGroup.ALLOW_AUTO_COMPUTE_BOUNDS_READ);
        branchgroup.setCapability(BranchGroup.ALLOW_BOUNDS_READ);
        branchgroup.setCapability(BranchGroup.ALLOW_AUTO_COMPUTE_BOUNDS_WRITE);
        branchgroup.setCapability(BranchGroup.ALLOW_CHILDREN_READ);
        branchgroup.setCapability(BranchGroup.ALLOW_CHILDREN_WRITE);
        branchgroup.setCapability(BranchGroup.ALLOW_CHILDREN_EXTEND);
       
        // TODO use light factories

        AmbientLight alight = new AmbientLight(true,new Color3f(0.5f,0.5f,0.5f));
        alight.setEnable(true);
        rootGroup.addChild(alight);
        BoundingSphere bounds = new BoundingSphere (new Point3d (0, 0.0, 0), 1E100);
        alight.setInfluencingBounds(bounds);

        lights = new DirectionalLight[1];

        for (int i=0; i<lights.length; ++i) {
          // TODO : position lights around the object
            lights[i] = new DirectionalLight(true,new Color3f(1.0f,1.0f,1.0f),new Vector3f(-1,-1,-1));
            lights[i].setCapability(DirectionalLight.ALLOW_DIRECTION_READ);
            lights[i].setCapability(DirectionalLight.ALLOW_DIRECTION_WRITE);
            lights[i].setCapabilityIsFrequent(DirectionalLight.ALLOW_DIRECTION_READ);
            lights[i].setCapabilityIsFrequent(DirectionalLight.ALLOW_DIRECTION_WRITE);
            lights[i].setEnable(true);
            lights[i].setInfluencingBounds(bounds);
            rootGroup.addChild(lights[i]);
        }
       
        // X axis in blue
        axisGroup = new BranchGroup();

        float[] axis = AxisMaker.makeAxis(0);
        LineArray la = new LineArray(axis.length/3, LineArray.COORDINATES);
        la.setCoordinates(0,axis);
        Appearance a = new Appearance();
View Full Code Here

 
    protected transient BranchGroup branchgroup;
   
    public BranchGroupNodeJava3D(ActiveNode parent) {
        super(parent);
        branchgroup = new BranchGroup();
        branchgroup.setUserData(this);
        branchgroup.setPickable(true);
        SceneNodeJava3D.addChildToParentGroup((Group)getParent().get3DObject(), branchgroup);
    }
View Full Code Here

    }
   
   
    private void readObject(java.io.ObjectInputStream in) throws java.lang.ClassNotFoundException, java.io.IOException {
    in.defaultReadObject();
    branchgroup = new BranchGroup();
      branchgroup.setUserData(this);
      branchgroup.setPickable(true);
  }
View Full Code Here

        return _global;
    }

    private static BranchGroup createSimpleSceneGraph() {
        // Create the root of the branch graph
        BranchGroup objRoot = new BranchGroup();
        // Create the TransformGroup node and initialize it to the
        // identity. Enable the TRANSFORM_WRITE capability so that
        // our behavior code can modify it at run time. Add it to
        // the root of the subgraph.
        TransformGroup objTrans = new TransformGroup();
        Transform3D t3dTrans = new Transform3D();
        objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
        objTrans.setTransform(t3dTrans);
        objRoot.addChild(objTrans);
        BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0),
                100.0);
        // Set up the ambient light
        Color3f ambientColor = new Color3f(0.3f, 0.3f, 0.3f);
        AmbientLight ambientLightNode = new AmbientLight(ambientColor);
        ambientLightNode.setInfluencingBounds(bounds);
        objRoot.addChild(ambientLightNode);
        // Set up one directional lights
        Color3f light1Color = new Color3f(1.0f, 1.0f, 0.9f);
        Vector3f light1Direction = new Vector3f(1.0f, 1.0f, 1.0f);
        DirectionalLight light1 = new DirectionalLight(light1Color,
                light1Direction);
        light1.setInfluencingBounds(bounds);
        objRoot.addChild(light1);
        return objRoot;
    }
View Full Code Here

    BranchGroup getRootGroup() {
        Node n = _n;
        while (n != null) {
            if (n instanceof BranchGroup) {
                BranchGroup bg = (BranchGroup) n;
                if (bg.getParent() == null) {
                    return bg;
                }
            }
            n = n.getParent();
        }
View Full Code Here

     */
    protected float getSceneSize() {
        Bounds res=null;
        Enumeration<?> e=_viewingPlatform.getLocale().getAllBranchGraphs();
        while(e.hasMoreElements()){
            BranchGroup bg=(BranchGroup)e.nextElement();
            Bounds b=bg.getBounds();
            if(res==null){
                res=b;
            }
            else{
                res.combine(b);
View Full Code Here

        public AddBranchGroupActionUniverse() {
        }

        public void actionPerformed(ActionEvent e) {
            ((Universe) getNode().getGraphObject())
                    .addBranchGraph(new BranchGroup());
            // TODO add undo
            getNode().refresh();
        }
View Full Code Here

TOP

Related Classes of javax.media.j3d.BranchGroup

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.