Examples of Shape3D


Examples of javax.media.j3d.Shape3D

    public static void makeSolidAxis(Group group, float length, float arrowLength,
            float radius, float arrowRadius, Color color, Color arrowColor, int divisions) {
       
        float l=length-arrowLength;
       
        Shape3D cy= new Shape3D(Geometries.cylinder(radius, l-arrowLength, divisions));
        group.addChild(cy);
        Shape3D bcy= new Shape3D(Geometries.disc(radius, divisions,false,0.));
        group.addChild(bcy);
        Shape3D co= new Shape3D(Geometries.cone(arrowRadius, arrowLength, divisions,true,l-arrowLength));
        group.addChild(co);
        Shape3D bco= new Shape3D(Geometries.disc(arrowRadius, divisions,false,l-arrowLength));
        group.addChild(bco);

        Color3f aColor  = new Color3f(0.1f, 0.1f, 0.1f);
        Color3f eColor  = new Color3f(0.0f, 0.0f, 0.0f);
        Color3f sColor  = new Color3f(1.0f, 1.0f, 1.0f);

        Appearance cya=new Appearance();
        cya.setColoringAttributes(new ColoringAttributes(new Color3f(color),ColoringAttributes.SHADE_GOURAUD));
        Material cym = new Material(aColor, eColor, new Color3f(color), sColor, 100.0f);
        cym.setLightingEnable(true);
        cya.setMaterial(cym);
        cy.setAppearance(cya);
        bcy.setAppearance(cya);

        Appearance coa=new Appearance();
        coa.setColoringAttributes(new ColoringAttributes(new Color3f(arrowColor),ColoringAttributes.SHADE_GOURAUD));
        Material com = new Material(aColor, eColor, new Color3f(arrowColor), sColor, 100.0f);
        com.setLightingEnable(true);
        coa.setMaterial(com);
        co.setAppearance(coa);
        bco.setAppearance(coa);
    }
View Full Code Here

Examples of javax.media.j3d.Shape3D

            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);
View Full Code Here

Examples of javax.media.j3d.Shape3D

                    getLocation(),"Disc"); // TODO i18n
            DiscDialog.Result n=d.getResult();
            if(n!=null){
                GroupNode gn=(GroupNode)getNode();
       
                Shape3D sd= new Shape3D(Geometries.disc(n.radius, n.divisions,n.up,0.));
                Color3f aColor  = new Color3f(0.1f, 0.1f, 0.1f);
                Color3f eColor  = new Color3f(0.0f, 0.0f, 0.0f);
                Color3f sColor  = new Color3f(1.0f, 1.0f, 1.0f);

                Appearance cya=new Appearance();
                cya.setColoringAttributes(new ColoringAttributes(new Color3f(Color.WHITE),ColoringAttributes.SHADE_GOURAUD));
                cya.setPolygonAttributes(new PolygonAttributes(PolygonAttributes.POLYGON_FILL, PolygonAttributes.CULL_NONE, 0));
                Material cym = new Material(aColor, eColor, new Color3f(Color.WHITE), sColor, 100.0f);
                cym.setLightingEnable(true);
                cya.setMaterial(cym);
                sd.setAppearance(cya);

                gn.addChild(sd);
       
                AddEdit ae=new AddEdit(gn, sd, null);
                getNode().getTree().getUndoableEditListener().undoableEditHappened(
View Full Code Here

Examples of javax.media.j3d.Shape3D

                Appearance a = new Appearance();
                a.setPolygonAttributes(new PolygonAttributes(PolygonAttributes.POLYGON_LINE, PolygonAttributes.CULL_NONE, 0));
                ColoringAttributes ca = new ColoringAttributes();
                ca.setColor(1.0f,1.0f,1.0f);
                a.setColoringAttributes(ca);
                Shape3D sd = new Shape3D(la, a);

                gn.addChild(sd);
       
                AddEdit ae=new AddEdit(gn, sd, null);
                getNode().getTree().getUndoableEditListener().undoableEditHappened(
View Full Code Here

Examples of javax.media.j3d.Shape3D

        }
       
        void apply(double[] v){
            GroupNode gn=(GroupNode)getNode();
           
            Shape3D sd= new Shape3D(Geometries.polygon(v));
            Color3f aColor  = new Color3f(0.1f, 0.1f, 0.1f);
            Color3f eColor  = new Color3f(0.0f, 0.0f, 0.0f);
            Color3f sColor  = new Color3f(1.0f, 1.0f, 1.0f);

            Appearance cya=new Appearance();
            cya.setColoringAttributes(new ColoringAttributes(new Color3f(Color.WHITE),ColoringAttributes.SHADE_GOURAUD));
            cya.setPolygonAttributes(new PolygonAttributes(PolygonAttributes.POLYGON_FILL, PolygonAttributes.CULL_NONE, 0));
            Material cym = new Material(aColor, eColor, new Color3f(Color.WHITE), sColor, 100.0f);
            cym.setLightingEnable(true);
            cya.setMaterial(cym);
            sd.setAppearance(cya);

            gn.addChild(sd);
   
            AddEdit ae=new AddEdit(gn, sd, null);
            getNode().getTree().getUndoableEditListener().undoableEditHappened(
View Full Code Here

Examples of javax.media.j3d.Shape3D

        super(tree, graphObject, getChildren);
    }

    @Override
    protected void getSceneGraphChildren(ArrayList<Object> list) {
        Shape3D s=(Shape3D)getGraphObject();
        Enumeration<?> e=s.getAllGeometries();
        while(e.hasMoreElements()){
            list.add(e.nextElement());
        }
        list.add(s.getAppearance());
    }
View Full Code Here

Examples of javax.media.j3d.Shape3D

        list.add(s.getAppearance());
    }
   
    @Override
    public SceneGraphObject addSceneGraphObject(SceneGraphObject obj){
        Shape3D s=(Shape3D)getGraphObject();
        if(obj instanceof Geometry){
            boolean forced=forceCapability(Shape3D.ALLOW_GEOMETRY_WRITE);
            s.addGeometry((Geometry)obj);
            if(forced) restoreCapability(Shape3D.ALLOW_GEOMETRY_WRITE);
            return null;
        }
        else if (obj instanceof Appearance){
            Appearance a=s.getAppearance();
            boolean forced=forceCapability(Shape3D.ALLOW_APPEARANCE_WRITE);
            s.setAppearance(a);
            if(forced) restoreCapability(Shape3D.ALLOW_APPEARANCE_WRITE);
            return a;
        }
        throw new RuntimeException("addSceneGraphObject invalid argument ="+obj.getClass());
    }
View Full Code Here

Examples of javax.media.j3d.Shape3D

          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);
View Full Code Here

Examples of javax.media.j3d.Shape3D

            if (!firstGeometryHasTextureCoordinateIndices
                && appearance.getTexture() != null) {
              appearance.setTexCoordGeneration(new TexCoordGeneration());
            }
          }
          Shape3D shape = new Shape3D(geometryArray, appearance);  
          sceneRoot.addChild(shape);
          scene.addNamedObject(group.getName() + (i == 0 ? "" : String.valueOf(i)), shape);
         
          i = max;
        }
View Full Code Here

Examples of javax.media.j3d.Shape3D

  /**
   * Returns a new wall part shape with no geometry 
   * and a default appearance with a white material.
   */
  private Node createWallPartShape(boolean outline) {
    Shape3D wallShape = new Shape3D();
    // Allow wall shape to change its geometry
    wallShape.setCapability(Shape3D.ALLOW_GEOMETRY_WRITE);
    wallShape.setCapability(Shape3D.ALLOW_GEOMETRY_READ);
    wallShape.setCapability(Shape3D.ALLOW_APPEARANCE_READ);

    Appearance wallAppearance = new Appearance();
    wallShape.setAppearance(wallAppearance);
    wallAppearance.setCapability(Appearance.ALLOW_TRANSPARENCY_ATTRIBUTES_READ);
    TransparencyAttributes transparencyAttributes = new TransparencyAttributes();
    transparencyAttributes.setCapability(TransparencyAttributes.ALLOW_VALUE_WRITE);
    transparencyAttributes.setCapability(TransparencyAttributes.ALLOW_MODE_WRITE);
    wallAppearance.setTransparencyAttributes(transparencyAttributes);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.