Package javax.media.j3d

Examples of javax.media.j3d.TransparencyAttributes


          // If texture image supports transparency
          if (TextureManager.getInstance().isTextureTransparent(sharedTexture)) {
            if (appearance.getTransparencyAttributes() == null) {
              // Add transparency attributes to ensure transparency works
              appearance.setTransparencyAttributes(
                  new TransparencyAttributes(TransparencyAttributes.NICEST, 0));
            }            
          }
        }
      }
    }
View Full Code Here


    } 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;
      if ((renderingAttributes == null
            || renderingAttributes.getVisible())
          && (transparencyAttributes == null
              || transparencyAttributes.getTransparency() < 1)) {
        // Compute shape geometries area
        for (int i = 0, n = shape.numGeometries(); i < n; i++) {
          Geometry geometry = shape.getGeometry(i);
          if (geometry instanceof GeometryArray) {
            GeometryArray geometryArray = (GeometryArray)geometry;     
View Full Code Here

    } 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;
      if ((renderingAttributes == null
            || renderingAttributes.getVisible())
          && (transparencyAttributes == null
              || transparencyAttributes.getTransparency() < 1)) {
        // Compute shape geometries area
        for (int i = 0, n = shape.numGeometries(); i < n; i++) {
          computeGeometryAreaOnFloor(shape.getGeometry(i), parentTransformations, nodeArea);
        }
      }
View Full Code Here

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

        this.sunflow.parameter("color", null, new float [] {color.x, color.y, color.z});
      }
      this.sunflow.shader(appearanceName, "mirror");
    } else if (texture != null) {
      // Check shape transparency
      TransparencyAttributes transparencyAttributes = appearance.getTransparencyAttributes();
      float transparency;
      if (transparencyAttributes != null
          && transparencyAttributes.getTransparency() > 0
          && !ignoreTransparency) {
        transparency = 1 - transparencyAttributes.getTransparency();
      } else {
        transparency = 1;
      }
     
      TransparentTextureKey key = new TransparentTextureKey(texture, transparency);     
      String imagePath = this.textureImagesCache.get(key);
      if (imagePath == null) {
        if (texture.getUserData() instanceof URL && transparency == 1) {
          imagePath = texture.getUserData().toString();
        } else {
          ImageComponent2D imageComponent = (ImageComponent2D)texture.getImage(0);
          RenderedImage image = imageComponent.getRenderedImage();
          if (transparency < 1) {
            // Compute a partially transparent image
            BufferedImage transparentImage = new BufferedImage(image.getWidth(),
                image.getHeight(), BufferedImage.TYPE_INT_ARGB);
            Graphics2D g2D = (Graphics2D)transparentImage.getGraphics();
            g2D.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, transparency));
            g2D.drawRenderedImage(image, null);
            g2D.dispose();
            image = transparentImage;
          }
          File imageFile = OperatingSystem.createTemporaryFile("texture", ".png");
          ImageIO.write(image, "png", imageFile);
          imagePath = imageFile.getAbsolutePath();
        }
        this.textureImagesCache.put(key, imagePath);
      }
      Material material = appearance.getMaterial();
      float shininess;
      if (material != null
          && (shininess = material.getShininess()) > 1) {
        if (silk) {
          this.sunflow.parameter("diffuse.texture", imagePath);
          Color3f color = new Color3f();
          material.getSpecularColor(color);
          float [] specularColor = new float [] {
              (float)Math.sqrt(color.x) / 2, (float)Math.sqrt(color.y) / 2, (float)Math.sqrt(color.z) / 2};
          this.sunflow.parameter("specular", null, specularColor);
          this.sunflow.parameter("glossyness", (float)Math.pow(10, -Math.log(shininess) / Math.log(5)));
          this.sunflow.parameter("samples", 1);
          this.sunflow.shader(appearanceName, "uber");
        } else {
          this.sunflow.parameter("texture", imagePath);
          this.sunflow.parameter("shiny", shininess / 512f);
          this.sunflow.shader(appearanceName, "textured_shiny_diffuse");
        }
      } else {
        this.sunflow.parameter("texture", imagePath);
        this.sunflow.shader(appearanceName, "textured_diffuse");
      }
    } else {
      Material material = appearance.getMaterial();
      if (material != null) {
        Color3f color = new Color3f();
        material.getDiffuseColor(color);
        float [] diffuseColor = new float [] {color.x, color.y, color.z};

        TransparencyAttributes transparencyAttributes = appearance.getTransparencyAttributes();
        if (transparencyAttributes != null
            && transparencyAttributes.getTransparency() > 0
            && !ignoreTransparency) {
          if (material instanceof OBJMaterial
              && ((OBJMaterial)material).isOpticalDensitySet()) {
            this.sunflow.parameter("eta", ((OBJMaterial)material).getOpticalDensity());
          } else {
            // Use glass ETA as default
            this.sunflow.parameter("eta", 1.55f);
          }
          float transparency = 1 - transparencyAttributes.getTransparency();
          this.sunflow.parameter("color", null,
              new float [] {(1 - transparency) + transparency * diffuseColor [0],
                            (1 - transparency) + transparency * diffuseColor [1],
                            (1 - transparency) + transparency * diffuseColor [2]});
          this.sunflow.parameter("absorption.color", null,
View Full Code Here

        if (entity.getECMRange() != Entity.NONE) {
            int range = entity.getECMRange();
            Appearance eapp = new Appearance();
            eapp.setColoringAttributes(new ColoringAttributes(c50, ColoringAttributes.SHADE_FLAT));
            TransparencyAttributes ta = new TransparencyAttributes(TransparencyAttributes.BLENDED, 0.90f);
            ta.setCapability(TransparencyAttributes.ALLOW_VALUE_WRITE);
            eapp.setTransparencyAttributes(ta);
            TransparencyInterpolator ti = new TransparencyInterpolator(C.halfAlpha, ta, .90f, .97f);
            ti.setSchedulingBounds(BoardModel.bounds);
            addChild(ti);
            eapp.setPolygonAttributes(C.noCull);
View Full Code Here

        destination.z += BoardModel.HEX_HEIGHT/2;

        Appearance base = new Appearance();
        base.setMaterial(new Material(color, C.black, color, C.white, 64.0f));
        base.setPolygonAttributes(C.noCull);
        TransparencyAttributes ta = new TransparencyAttributes(TransparencyAttributes.BLENDED, alpha);
        ta.setCapability(TransparencyAttributes.ALLOW_VALUE_WRITE);
        base.setTransparencyAttributes(ta);
        TransparencyInterpolator ti = new TransparencyInterpolator(C.halfAlpha, ta, alpha, .97f);
        ti.setSchedulingBounds(BoardModel.bounds);
        addChild(ti);
View Full Code Here

    private void setSurfaceEffect(Material mat, Texture tex) {
        Appearance app = new Appearance();
        app.setTexture(tex);
        app.setMaterial((mat == normal?normalWater:mat));
        app.setTransparencyAttributes(new TransparencyAttributes(TransparencyAttributes.BLENDED, 0.0f));
        app.setPolygonAttributes(C.noCull);
        app.setTextureAttributes(C.materialModulate);
        surface.setAppearance(app);
    }
View Full Code Here

    fBoxApp1.setMaterial(new Material(ambientColourFBox,emissiveColourFBox,
                          diffuseColourFBox,specularColourFBox,shininessFBox));

    //Generate interpolated transparency.
    TransparencyAttributes ta1 = new TransparencyAttributes();
    ta1.setTransparencyMode(TransparencyAttributes.BLENDED);
    ta1.setTransparency(transparencyCoefficient);

    fBoxApp1.setTransparencyAttributes(ta1);


    //Generate a cube with interpolated transparency.
    Box fBox1 = new Box(cubeEdge,cubeEdge,cubeEdge,fBoxApp1);


    //Position the cube.
    Transform3D tfFBox1 = new Transform3D();
    Transform3D rotationX = new Transform3D();
    rotationX.rotX(-Math.PI/5);
    tfFBox1.mul(rotationX);

    //The transformation group for the cube.
    TransformGroup tgFBox1 = new TransformGroup(tfFBox1);
    tgFBox1.addChild(fBox1);



    //Generate a nontransparent Appearance for the spheres.
    Color3f ambientColourBSphere = new Color3f(0.0f,0.7f,0.0f);
    Color3f emissiveColourBSphere = new Color3f(0.0f,0.0f,0.0f);
    Color3f diffuseColourBSphere = new Color3f(0.0f,0.7f,0.0f);
    Color3f specularColourBSphere = new Color3f(0.0f,0.9f,0.0f);
    float shininessBSphere = 120.0f;

    Appearance bSphereApp = new Appearance();

    bSphereApp.setMaterial(new Material(ambientColourBSphere,emissiveColourBSphere,
                          diffuseColourBSphere,specularColourBSphere,shininessBSphere));

    //The left sphere and its transformation group.
    Sphere bSphere1 = new Sphere(radius,bSphereApp);

    Transform3D tfBSphere1 = new Transform3D();
    tfBSphere1.setTranslation(new Vector3f(xShiftSphere,sphereLift,sphereBackShift));
    TransformGroup tgBSphere1 = new TransformGroup(tfBSphere1);
    tgBSphere1.addChild(bSphere1);


    //The left cube and the left sphere are combined in one transformation group
    //in order to position them jointly.
    Transform3D tf1 = new Transform3D();
    tf1.setTranslation(new Vector3f(-xShift,0.0f,0.0f));
    TransformGroup tg1 = new TransformGroup(tf1);
    tg1.addChild(tgFBox1);
    tg1.addChild(tgBSphere1);


    //The right cube with sreen door transparency.
    Appearance fBoxApp2 = new Appearance();
    fBoxApp2.setMaterial(new Material(ambientColourFBox,emissiveColourFBox,
                          diffuseColourFBox,specularColourFBox,shininessFBox));

    //Generate screen door transparency.
    TransparencyAttributes ta2 = new TransparencyAttributes();
    ta2.setTransparencyMode(TransparencyAttributes.SCREEN_DOOR);
    ta2.setTransparency(transparencyCoefficient);

    fBoxApp2.setTransparencyAttributes(ta2);

    Box fBox2 = new Box(cubeEdge,cubeEdge,cubeEdge,fBoxApp2);
View Full Code Here

            if (transparent == 0.0) {
                mode = TransparencyAttributes.NONE;
            }

            _transparencyAttributes = new TransparencyAttributes(mode,
                    transparent);
            _appearance.setTransparencyAttributes(_transparencyAttributes);
        }

        // Deal with flat attribute.
View Full Code Here

TOP

Related Classes of javax.media.j3d.TransparencyAttributes

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.