Package javax.media.j3d

Examples of javax.media.j3d.Group


        @Override
        public void actionPerformed(ActionEvent e) {
           
            GroupNode gn=(GroupNode)getNode();
           
            Group g=new Group();
            // TODO i18n
            g.setName("Frame");
           
            float[] axis = makeAxis(0);
            LineArray la = new LineArray(axis.length/3, LineArray.COORDINATES);
            la.setCoordinates(0,axis);
            Appearance a = new Appearance();
            a.setPolygonAttributes(new PolygonAttributes(PolygonAttributes.POLYGON_LINE, PolygonAttributes.CULL_NONE, 0));
            ColoringAttributes ca = new ColoringAttributes();
            ca.setColor(0.0f,0.0f,1.0f);
            a.setColoringAttributes(ca);
            Shape3D saxis = new Shape3D(la, a);
            saxis.setName("X");
            g.addChild(saxis);
           
            // Y axis in green
            axis = makeAxis(1);
            la = new LineArray(axis.length/3, LineArray.COORDINATES);
            la.setCoordinates(0,axis);
            a = new Appearance();
            a.setPolygonAttributes(new PolygonAttributes(PolygonAttributes.POLYGON_LINE, PolygonAttributes.CULL_NONE, 0));
            ca = new ColoringAttributes();
            ca.setColor(0.0f,1.0f,0.0f);
            a.setColoringAttributes(ca);
            saxis = new Shape3D(la, a);
            saxis.setName("Y");
            g.addChild(saxis);
           
            // Z axis in purple
            axis = makeAxis(2);
            la = new LineArray(axis.length/3, LineArray.COORDINATES);
            la.setCoordinates(0,axis);
            a = new Appearance();
            a.setPolygonAttributes(new PolygonAttributes(PolygonAttributes.POLYGON_LINE, PolygonAttributes.CULL_NONE, 0));
            ca = new ColoringAttributes();
            ca.setColor(1.0f,0.0f,1.0f);
            a.setColoringAttributes(ca);
            saxis = new Shape3D(la, a);
            saxis.setName("Z");
            g.addChild(saxis);
           
            gn.addChild(g);
           
            AddEdit ae=new AddEdit(gn, g, null);
            getNode().getTree().getUndoableEditListener().undoableEditHappened(
View Full Code Here


        }
        throw new RuntimeException("removeSceneGraphObject invalid argument ="+obj.getClass());
    }

    public void addChild(Node n) {
        Group g=(Group)getGraphObject();
        boolean forced=forceCapability(Group.ALLOW_CHILDREN_EXTEND);
        g.addChild(n);
        if(forced) restoreCapability(Group.ALLOW_CHILDREN_EXTEND);
        if(_ad!=null){
            _ad.attach();
            _ad=null;
        }
View Full Code Here

        getTree().getUndoableEditListener().undoableEditHappened(
                new UndoableEditEvent(this, ae));
    }
   
    public void removeChild(Node n) {
        Group g=(Group)getGraphObject();
        boolean forced=forceCapability(Group.ALLOW_CHILDREN_WRITE);
        g.removeChild(n);
        if(forced) restoreCapability(Group.ALLOW_CHILDREN_WRITE);
    }
View Full Code Here

    static class AddGroupAction extends AbstractNodeAction {
        // required for dynamic action creation
        public AddGroupAction() {
        }
        public void actionPerformed(ActionEvent e) {
            ((GroupNode)getNode()).addChildUndoable(new Group());
            getNode().refresh();
        }
View Full Code Here

      } else if ("node".equals(parent) && "instance_geometry".equals(name)) {
        String geometryInstanceUrl = attributes.getValue("url");
        if (geometryInstanceUrl.startsWith("#")) {
          final String geometryInstanceAnchor = geometryInstanceUrl.substring(1);
          final String nodeName = attributes.getValue("name");
          final Group parentGroup = new Group();
          this.parentGroups.peek().addChild(parentGroup);
          this.parentGroups.push(parentGroup);
          this.postProcessingBinders.add(new Runnable() {
              public void run() {
                int nameSuffix = 0;
                // Resolve URL at the end of the document
                for (Geometry geometry : geometries.get(geometryInstanceAnchor)) {
                  Shape3D shape = new Shape3D(geometry);
                  parentGroup.addChild(shape);
                  // Give a name to shape
                  if (nodeName != null) {
                    if (nameSuffix == 0) {
                      scene.addNamedObject(nodeName, shape);
                    } else {
                      scene.addNamedObject(nodeName + "_" + nameSuffix, shape);
                    }
                    nameSuffix++;
                  }
                }
              }
            });
        }
      } else if ("instance_node".equals(name)) {
        String nodeInstanceUrl = attributes.getValue("url");
        if (nodeInstanceUrl.startsWith("#")) {
          final String nodeInstanceAnchor = nodeInstanceUrl.substring(1);
          final Group parentTransformGroup = this.parentGroups.peek();
          this.postProcessingBinders.add(new Runnable() {
              public void run() {
                // Resolve URL at the end of the document
                SharedGroup sharedGroup = instantiatedNodes.get(nodeInstanceAnchor);
                if (sharedGroup == null) {
                  sharedGroup = new SharedGroup();
                  sharedGroup.addChild(nodes.get(nodeInstanceAnchor));
                  instantiatedNodes.put(nodeInstanceAnchor, sharedGroup);
                }
                parentTransformGroup.addChild(new Link(sharedGroup));
              }
            });
        }
      } else if ("instance_material".equals(name) && !this.parentGroups.empty()) {
        String materialInstanceTarget = attributes.getValue("target");
        if (materialInstanceTarget.startsWith("#")) {
          final String materialInstanceAnchor = materialInstanceTarget.substring(1);
          final String materialInstanceSymbol = attributes.getValue("symbol");
          final Group group = this.parentGroups.peek();
          this.postProcessingBinders.add(new Runnable() {
              public void run() {
                updateShapeAppearance(group,
                    effectAppearances.get(materialEffects.get(materialInstanceAnchor)));
              }
View Full Code Here

   * and piece of furniture of <code>home</code>.
   */
  private Node createHomeTree(boolean displayShadowOnFloor,
                              boolean listenToHomeUpdates,
                              boolean waitForLoading) {
    Group homeRoot = createHomeRoot();
    // Add walls, pieces and rooms already available
    for (Room room : this.home.getRooms()) {
      addObject(homeRoot, room, listenToHomeUpdates, waitForLoading);
    }   
    for (Wall wall : this.home.getWalls()) {
View Full Code Here

  /**
   * Returns a new group at home subtree root.
   */
  private Group createHomeRoot() {
    Group homeGroup = new Group();   
    //  Allow group to have new children
    homeGroup.setCapability(Group.ALLOW_CHILDREN_WRITE);
    homeGroup.setCapability(Group.ALLOW_CHILDREN_EXTEND);
    return homeGroup;
  }
View Full Code Here

      }
      return clonedLink;
    } else {
      Node clonedNode = node.cloneNode(true);
      if (node instanceof Group) {
        Group group = (Group)node;
        Group clonedGroup = (Group)clonedNode;
        for (int i = 0, n = group.numChildren(); i < n; i++) {
          Node clonedChild = cloneNode(group.getChild(i), clonedSharedGroups);
          clonedGroup.addChild(clonedChild);
        }
      }
      return clonedNode;
    }
  }
View Full Code Here

        if (branchPart == null) {
            throw new IllegalArgumentException("Null tree branch part");
        }
        this.branchPart = branchPart;
        this.endPoint = state.getEndPoint().toPointValue();
        this.group = new Group();
        group.setCapability(Group.ALLOW_CHILDREN_WRITE);
        group.setCapability(Group.ALLOW_CHILDREN_EXTEND);
        createFullTreeBranch(branchPart);
    }
View Full Code Here

        trunkCylinder = new Cylinder(trunk.getRadius(), trunk.getHeight(), trunkAppearance);
        Vector3d translationVector = new Vector3d();
        translationVector.setY(trunk.getHeight() / 2);
        TransformGroup transformGroup = TransformerHelper.getTranslationTransformGroup(translationVector);
        transformGroup.addChild(trunkCylinder);
        this.group = new Group();
        group.addChild(transformGroup);
    }
View Full Code Here

TOP

Related Classes of javax.media.j3d.Group

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.