Examples of Texture


Examples of javax.media.j3d.Texture

      } 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

Examples of javax.media.j3d.Texture

            if (appearanceName == null) {
              // Store appearance
              appearanceName = objectName;
              this.appearances.put(comparableAppearance, appearanceName);
             
              Texture texture = appearance.getTexture();
              if (texture != null) {
                File textureFile = this.textures.get(texture);
                if (textureFile == null) {
                  // Store texture
                  textureFile = new File(this.mtlFileName.substring(0, this.mtlFileName.length() - 4)
View Full Code Here

Examples of javax.media.j3d.Texture

          if (!(material instanceof OBJMaterial)) {
            writer.write("Ni 1\n");
          }
          writer.write("d " + format(1f - transparency.getTransparency()) + "\n");
        }
        Texture texture = appearance.getTexture();
        if (texture != null) {
          writer.write("map_Kd " + this.textures.get(texture).getName() + "\n");
        }
      }
     
      for (Map.Entry<Texture, File> textureEntry : this.textures.entrySet()) {
        Texture texture = textureEntry.getKey();
        ImageComponent2D imageComponent = (ImageComponent2D)texture.getImage(0);
        RenderedImage image = imageComponent.getRenderedImage();
        ImageIO.write(image, "png", textureEntry.getValue());       
      }
    } finally {
      if (writer != null) {
View Full Code Here

Examples of javax.media.j3d.Texture

    BufferedImage image = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB);
    Graphics g = image.getGraphics();
    g.setColor(color);
    g.drawLine(0, 0, 0, 0);
    g.dispose();
    Texture texture = new TextureLoader(image).getTexture();
    texture.setCapability(Texture.ALLOW_IMAGE_READ);
    texture.setCapability(Texture.ALLOW_FORMAT_READ);
    texture.getImage(0).setCapability(ImageComponent2D.ALLOW_IMAGE_READ);
    texture.getImage(0).setCapability(ImageComponent2D.ALLOW_FORMAT_READ);
    return texture;
  }
View Full Code Here

Examples of javax.media.j3d.Texture

   *    the Event Dispatch Thread. 
   */
  public void loadTexture(final Content content,
                          boolean synchronous,
                          final TextureObserver textureObserver) {
    Texture texture;
    TextureKey textureKey;
    synchronized (this.textures) { // Use one mutex for both maps
      textureKey = this.contentTextureKeys.get(content);
      if (textureKey == null) {
        texture = this.textures.get(textureKey);
      } else {
        texture = null;
      }
    }
    if (texture == null) {
      if (synchronous) {
        texture = shareTexture(loadTexture(content), content);
        // Notify loaded texture to observer
        textureObserver.textureUpdated(texture);
      } else if (!EventQueue.isDispatchThread()) {
        throw new IllegalStateException("Asynchronous call out of Event Dispatch Thread");
      } else {
        // Notify wait texture to observer
        textureObserver.textureUpdated(this.waitTexture);
        if (this.texturesLoader == null) {
          this.texturesLoader = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
        }
       
        List<TextureObserver> observers = this.loadingTextureObservers.get(content);
        if (observers != null) {
          // If observers list exists, content texture is already being loaded
          // register observer for future notification
          observers.add(textureObserver);
        } else {
          // Create a list of observers that will be notified once content texture is loaded
          observers = new ArrayList<TextureObserver>();
          observers.add(textureObserver);
          this.loadingTextureObservers.put(content, observers);

          // Load the image in a different thread
          this.texturesLoader.execute(new Runnable () {
              public void run() {
                final Texture texture = shareTexture(loadTexture(content), content);
                EventQueue.invokeLater(new Runnable() {
                    public void run() {
                      // Notify loaded texture to observer
                      for (TextureObserver observer : loadingTextureObservers.remove(content)) {
                        observer.textureUpdated(texture);
View Full Code Here

Examples of javax.media.j3d.Texture

      image = ImageIO.read(contentStream);
      contentStream.close();
    } catch (IOException ex) {
      // Too bad, we'll use errorTexture
    }           
    final Texture texture;
    if (image == null) {
      texture = errorTexture;
    } else {
      texture = new TextureLoader(image).getTexture();
      // Keep in user data the URL of the texture image
      if (content instanceof URLContent) {
        texture.setUserData(((URLContent)content).getURL());
      }
    }
    return texture;
  }
View Full Code Here

Examples of javax.media.j3d.Texture

   * same texture as the one in parameter is already shared.
   */
  private Texture shareTexture(final Texture texture,
                               final Content content) {
    TextureKey textureKey = new TextureKey(texture);
    Texture sharedTexture;
    synchronized (this.textures) { // Use one mutex for both maps
      sharedTexture = this.textures.get(textureKey);
      if (sharedTexture == null) {
        sharedTexture = texture;
        setSharedTextureAttributesAndCapabilities(sharedTexture);
View Full Code Here

Examples of javax.media.j3d.Texture

          if (transparency1.getTransparency() != transparency2.getTransparency()) {
            return false;
          }
        }
        // Compare texture
        Texture texture1 = this.appearance.getTexture();
        Texture texture2 = appearance2.getTexture();
        if ((texture1 == null) ^ (texture2 == null)) {
          return false;
        } else if (texture1 != texture2) {
          if (texture1.getImage(0) != texture2.getImage(0)) {
            return false;
          }
        }
        return true;
      }
View Full Code Here

Examples of javax.media.j3d.Texture

      }
      TransparencyAttributes transparency = this.appearance.getTransparencyAttributes();
      if (transparency != null) {
        code += Float.floatToIntBits(transparency.getTransparency());
      }
      Texture texture = this.appearance.getTexture();
      if (texture != null) {
        code += texture.getImage(0).hashCode();
      }
      return code;
    }
View Full Code Here

Examples of javax.media.j3d.Texture

        try {
          URL textureImageUrl = new URL(baseUrl, getCharacters());
          BufferedImage textureImage = ImageIO.read(textureImageUrl);
          if (textureImage != null) {
            TextureLoader textureLoader = new TextureLoader(textureImage);
            Texture texture = textureLoader.getTexture();
            // Keep in user data the URL of the texture image
            texture.setUserData(textureImageUrl);
            this.textures.put(this.imageId, texture);
          }
        } catch (IOException ex) {
          // Ignore images at other format or not found
        }
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.