Examples of Appearance


Examples of javax.media.j3d.Appearance

        float[] vectorCoords = new float[] {
            0,0,0, x,y,z
        };
        LineArray la = new LineArray(2, LineArray.COORDINATES);
        la.setCoordinates(0,vectorCoords);
        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,0.0f);
    a.setColoringAttributes(ca);
    lightVector = new Shape3D(la, a);
        rootGroup.addChild(lightVector);
        attach();
    }
View Full Code Here

Examples of javax.media.j3d.Appearance

        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();
    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);
    axisGroup.addChild(saxis);
       
        // Y axis in green
        axis = AxisMaker.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);
    axisGroup.addChild(saxis);
       
        // Z axis in purple
        axis = AxisMaker.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);
    axisGroup.addChild(saxis);
       
    mainSwitch = new Switch(Switch.CHILD_MASK);
   
View Full Code Here

Examples of javax.media.j3d.Appearance

    }

    protected void setAppearanceForHighlight(boolean on) {
        if (shape==null) return;
       
    Appearance a=new Appearance();
    a.setCapability(Appearance.ALLOW_COLORING_ATTRIBUTES_READ);
    a.setCapability(Appearance.ALLOW_COLORING_ATTRIBUTES_WRITE);
    a.setCapability(Appearance.ALLOW_LINE_ATTRIBUTES_READ);
    a.setCapability(Appearance.ALLOW_LINE_ATTRIBUTES_WRITE);
    a.setCapability(Appearance.ALLOW_MATERIAL_READ);
    a.setCapability(Appearance.ALLOW_MATERIAL_WRITE);
    a.setCapability(Appearance.ALLOW_POINT_ATTRIBUTES_READ);
    a.setCapability(Appearance.ALLOW_POINT_ATTRIBUTES_WRITE);
    a.setCapability(Appearance.ALLOW_POLYGON_ATTRIBUTES_READ);
    a.setCapability(Appearance.ALLOW_POLYGON_ATTRIBUTES_WRITE);
    a.setCapability(Appearance.ALLOW_RENDERING_ATTRIBUTES_READ);
    a.setCapability(Appearance.ALLOW_RENDERING_ATTRIBUTES_WRITE);
    a.setCapability(Appearance.ALLOW_TEXGEN_READ);
    a.setCapability(Appearance.ALLOW_TEXGEN_WRITE);
    a.setCapability(Appearance.ALLOW_TEXTURE_ATTRIBUTES_READ);
    a.setCapability(Appearance.ALLOW_TEXTURE_ATTRIBUTES_WRITE);
    a.setCapability(Appearance.ALLOW_TEXTURE_READ);
    a.setCapability(Appearance.ALLOW_TEXTURE_WRITE);
    a.setCapability(Appearance.ALLOW_TEXTURE_UNIT_STATE_READ);
    a.setCapability(Appearance.ALLOW_TEXTURE_UNIT_STATE_WRITE);
    a.setCapability(Appearance.ALLOW_TRANSPARENCY_ATTRIBUTES_READ);
    a.setCapability(Appearance.ALLOW_TRANSPARENCY_ATTRIBUTES_WRITE);
    ColoringAttributes ca = new ColoringAttributes();
    // don't use light
    if ((mode==WIREFRAME_MODE) || (mode==FILLED_MODE)) {
      int attribute = (mode==FILLED_MODE) ? PolygonAttributes.POLYGON_FILL : PolygonAttributes.POLYGON_LINE;
      PolygonAttributes pa = new PolygonAttributes(attribute, PolygonAttributes.CULL_NONE, 0);
      unlockPolygonAttributes(pa);
      pa.setPolygonOffset(polygonOffset);
      pa.setPolygonOffsetFactor(polygonOffsetFactor);
        a.setPolygonAttributes(pa);
        Color selectedColor;
      if (on) selectedColor = highlightColor;
      else selectedColor = baseColor;
      float[] colors = selectedColor.getRGBColorComponents(null);
      ca.setColor(colors[0], colors[1], colors[2]);
      a.setColoringAttributes(ca);
    }
    // use light
    if ((mode==SHADING_MODE) || (mode==FLAT_MODE)) {
      if (mode==SHADING_MODE) ca.setShadeModel(ColoringAttributes.SHADE_GOURAUD);
      if (mode==FLAT_MODE) ca.setShadeModel(ColoringAttributes.SHADE_FLAT);
      a.setColoringAttributes(ca);
      PolygonAttributes pa = new PolygonAttributes(PolygonAttributes.POLYGON_FILL, PolygonAttributes.CULL_NONE, 0);
      unlockPolygonAttributes(pa);
      pa.setPolygonOffset(polygonOffset);
      pa.setPolygonOffsetFactor(polygonOffsetFactor);
      pa.setBackFaceNormalFlip(true);
        a.setPolygonAttributes(pa);
      Material m = new Material();
        Color selectedColor;
      if (on) selectedColor = highlightColor;
      else selectedColor = baseColor;
       
      float[] colors = selectedColor.getRGBColorComponents(null);
      m.setAmbientColor(colors[0], colors[1], colors[2]);
     
      // Squash specular toward white => keep only hue
      float[] hsb = Color.RGBtoHSB(selectedColor.getRed(), selectedColor.getGreen(), selectedColor.getBlue(), null);
      Color.getHSBColor(hsb[0],hsb[1]/10,1.0f).getRGBColorComponents(colors);
      m.setSpecularColor(colors[0], colors[1], colors[2]);

      // diffuse is same hue and saturation but darker
      Color.getHSBColor(hsb[0],hsb[1],hsb[2]/2).getRGBColorComponents(colors);
      m.setDiffuseColor(colors[0], colors[1], colors[2]);
     
      // no emissive color
      m.setEmissiveColor(0f,0f,0f);

          m.setLightingEnable(true);
          a.setMaterial(m);
    }
        shape.setAppearance(a);
    }
View Full Code Here

Examples of javax.media.j3d.Appearance

        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.Appearance

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

Examples of javax.media.j3d.Appearance

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

Examples of javax.media.j3d.Appearance

            if(v!=null){
                GroupNode gn=(GroupNode)getNode();
       
                LineArray la = new LineArray(2, LineArray.COORDINATES);
                la.setCoordinates(0,v);
                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);
View Full Code Here

Examples of javax.media.j3d.Appearance

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

Examples of javax.media.j3d.Appearance

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

Examples of javax.media.j3d.Appearance

      }
    } else if (node instanceof Link) {
      exportNode(((Link)node).getSharedGroup(), ignoreTransparency, ignoreConstantShader, silk, parentTransformations);
    } else if (node instanceof Shape3D) {
      Shape3D shape = (Shape3D)node;
      Appearance appearance = shape.getAppearance();
      RenderingAttributes renderingAttributes = appearance != null
          ? appearance.getRenderingAttributes() : null;
      TransparencyAttributes transparencyAttributes = appearance != null
          ? appearance.getTransparencyAttributes() : null;
      // Ignore invisible shapes and fully transparency shapes without a texture
      if ((renderingAttributes == null
              || renderingAttributes.getVisible())
          && (transparencyAttributes == null
              || transparencyAttributes.getTransparency() != 1)) {
        String shapeName = (String)shape.getUserData();
        // Build a unique object name
        String uuid = UUID.randomUUID().toString();
 
        String appearanceName = null;
        TexCoordGeneration texCoordGeneration = null;
        if (appearance != null) {
          texCoordGeneration = appearance.getTexCoordGeneration();
          appearanceName = "shader" + uuid;
          boolean mirror = shapeName != null
              && shapeName.startsWith(ModelManager.MIRROR_SHAPE_PREFIX);
          exportAppearance(appearance, appearanceName, mirror, ignoreTransparency, ignoreConstantShader, silk);
        }
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.