Package javax.media.j3d

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


            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

            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

            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

      }
    } 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

        cloneTexture((Node)enumeration.nextElement(), replacedTextures);
      }
    } else if (node instanceof Link) {
      cloneTexture(((Link)node).getSharedGroup(), replacedTextures);
    } else if (node instanceof Shape3D) {
      Appearance appearance = ((Shape3D)node).getAppearance();
      if (appearance != null) {
        Texture texture = appearance.getTexture();
        if (texture != null) {
          Texture replacedTexture = replacedTextures.get(texture);
          if (replacedTexture == null) {
            replacedTexture = (Texture)texture.cloneNodeComponent(false);
            replacedTextures.put(texture, replacedTexture);
          }
          appearance.setTexture(replacedTexture);
        }
      }
    }
  }
View Full Code Here

  /**
   * Returns a new background node. 
   */
  private Node createBackgroundNode(boolean listenToHomeUpdates, final boolean waitForLoading) {
    final Appearance backgroundAppearance = new Appearance();
    ColoringAttributes backgroundColoringAttributes = new ColoringAttributes();
    backgroundAppearance.setColoringAttributes(backgroundColoringAttributes);
    // Allow background color and texture to change
    backgroundAppearance.setCapability(Appearance.ALLOW_TEXTURE_WRITE);
    backgroundAppearance.setCapability(Appearance.ALLOW_COLORING_ATTRIBUTES_READ);
    backgroundColoringAttributes.setCapability(ColoringAttributes.ALLOW_COLOR_WRITE);
   
    Geometry halfSphereGeometry = createHalfSphereGeometry();  
    final Shape3D halfSphere = new Shape3D(halfSphereGeometry, backgroundAppearance);
    BranchGroup backgroundBranch = new BranchGroup();
View Full Code Here

        stripCountsArray [i] = stripCounts.get(i);
      }
      geometryInfo.setStripCounts(stripCountsArray);
      Shape3D shadow = new Shape3D(geometryInfo.getIndexedGeometryArray());
      Appearance shadowAppearance = new Appearance();
      shadowAppearance.setColoringAttributes(new ColoringAttributes(new Color3f(), ColoringAttributes.SHADE_FLAT));
      shadowAppearance.setTransparencyAttributes(new TransparencyAttributes(TransparencyAttributes.NICEST, 0.7f));
      shadow.setAppearance(shadowAppearance);   
      homeRoot.addChild(shadow);
    }
  }
View Full Code Here

          final String effectInstanceAnchor = effectInstanceUrl.substring(1);
          this.materialEffects.put(this.materialId, effectInstanceAnchor);
        }
      } else if ("effect".equals(name)) {
        this.effectId = attributes.getValue("id");
        this.effectAppearances.put(this.effectId, new Appearance());
      } else if (this.effectId != null) {
        if ("profile_COMMON".equals(parent) && "newparam".equals(name)) {
          this.newParamSid = attributes.getValue("sid");
        } else if ("newparam".equals(parent) && "surface".equals(name)
                   && "2D".equals(attributes.getValue("type"))) {
          this.inSurface2D = true;
        } else if ("extra".equals(parent) && "technique".equals(name)) {
          this.techniqueProfile = attributes.getValue("profile");
        } else if ("phong".equals(name) || "blinn".equals(name)) {
          this.inPhongBlinnOrLambert = true;
        } else if ("lambert".equals(name)) {
          this.inPhongBlinnOrLambert = true;
          getAppearanceMaterial(this.effectId).setSpecularColor(0, 0, 0);
          getAppearanceMaterial(this.effectId).setShininess(1);
        } else if ("constant".equals(name)) {
          this.inConstant = true;
        } else if (this.inConstant || this.inPhongBlinnOrLambert
                   && ("transparent".equals(name))) {
          this.opaque = attributes.getValue("opaque");
          if (this.opaque == null) {
            this.opaque = "A_ONE";
          }
        } else if ("texture".equals(name) && "diffuse".equals(parent)) {
          final String textureId = this.surface2DIds.get(this.sampler2DIds.get(attributes.getValue("texture")));
          final Appearance appearance = this.effectAppearances.get(this.effectId);
          this.postProcessingBinders.add(new Runnable() {
              public void run() {
                // Resolve texture at the end of the document
                appearance.setTexture(textures.get(textureId));
              }
            });
        }
      } else if ("geometry".equals(name)) {
        this.geometryId = attributes.getValue("id");
View Full Code Here

            }
          }
        } else {
          transparencyValue = 0;
        }
        Appearance appearance = this.effectAppearances.get(this.effectId);
        if (transparencyValue > 0) {
          appearance.setTransparencyAttributes(new TransparencyAttributes(
              TransparencyAttributes.NICEST, transparencyValue)); // 0 means opaque in Java 3D
        } else {
          // Set default color if it doesn't exist yet
          Color3f black = new Color3f();
          if (appearance.getMaterial() == null) {
            appearance.setMaterial(new Material(black, black, black, black, 1));
            appearance.setColoringAttributes(new ColoringAttributes(black, ColoringAttributes.SHADE_GOURAUD));
          }
        }
        this.transparentColor = null;
        this.transparency = null;
       
View Full Code Here

TOP

Related Classes of javax.media.j3d.Appearance

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.