Package javax.media.j3d

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


      Shape3D clonedShape = (Shape3D)shape.cloneNode(false);
      Appearance appearance = shape.getAppearance();
      if (appearance != null) {
        // Force only duplication of node's appearance except its texture
        Appearance clonedAppearance = (Appearance)appearance.cloneNodeComponent(true);       
        Texture texture = appearance.getTexture();
        if (texture != null) {
          clonedAppearance.setTexture(texture);
        }
        clonedShape.setAppearance(clonedAppearance);
      }
View Full Code Here

    } else if (node instanceof Light) {
      ((Light)node).setEnable(false);
    } else if (node instanceof Shape3D) {
      Appearance appearance = ((Shape3D)node).getAppearance();
      if (appearance != null) {
        Texture texture = appearance.getTexture();
        if (texture != null) {
          // Share textures data as much as possible
          Texture sharedTexture = TextureManager.getInstance().shareTexture(texture);
          if (sharedTexture != texture) {
            appearance.setTexture(sharedTexture);
          }
          TextureAttributes textureAttributes = appearance.getTextureAttributes();
          if (textureAttributes == null) {
View Full Code Here

        Color3f col = new Color3f(GUIPreferences.getInstance().getMapTextColor());
        ypos = 1;

        // This is a bit convoluted in order to reduce work done on a full update,
        // which happens fairly often.
        Texture tex = tileManager.getTexture(hex, 1.0f);
        if (tex != floor.getAppearance().getTexture()) {
            setEffect(current, tex);
        }

        int keep = (surface == null?KEEP:KEEP+1);
View Full Code Here

                    if ((_viewScreen != null) && (textureURL != null)) {
                        TextureLoader loader;
                        loader = new TextureLoader(textureURL, _viewScreen
                                .getCanvas());

                        Texture loadedTexture = loader.getTexture();

                        if (loadedTexture != null) {
                            _appearance.setTexture(loadedTexture);
                        }
                    }
View Full Code Here

        if (textureURL != null) {
            TextureLoader loader;
            loader = new TextureLoader(textureURL, _viewScreen.getCanvas());

            Texture loadedTexture = loader.getTexture();

            if (loadedTexture != null) {
                attributes = new TextureAttributes();
                attributes.setTextureMode(TextureAttributes.MODULATE);
                _appearance.setTextureAttributes(attributes);
View Full Code Here

  /**
   * take care of render all texture layers including effects
   * to the global textureunistate array
   */
  private void renderTextures() {
        Texture tex;
        TextureAttributes texAttr;
       
    // absolute background
        if(layerVis[0]==false) {
          polyAttr.setPolygonMode(PolygonAttributes.POLYGON_LINE);
          return;
        }
        else {
          polyAttr.setPolygonMode(PolygonAttributes.POLYGON_FILL);
        // deactivate
          if(1==1) return;
         
          // muss die textur neu erstellt werden?
          //TODO: cache funktion ..
         
          // einmaliges pre-rendering der texturen
          BufferedImage screen, alpha, layer, tmp;
          screen = new BufferedImage(256, 256, BufferedImage.TYPE_4BYTE_ABGR_PRE);
          tmp = new BufferedImage(256, 256, BufferedImage.TYPE_4BYTE_ABGR_PRE);
         
          // graphics objekt erstellen
          Graphics2D g2 = (Graphics2D)screen.getGraphics();
          RenderingHints rh = new RenderingHints(
              RenderingHints.KEY_TEXT_ANTIALIASING,
              RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
          rh.put(RenderingHints.KEY_ALPHA_INTERPOLATION,
              RenderingHints.VALUE_ALPHA_INTERPOLATION_SPEED);
          //g2.setRenderingHints(rh);
         
         
          // bild holen
          MCLY_Entry lData = data.mcly.getLayer(0);     
          //layer = texLoader.getBitmapNo( lData.getTextureID() );
   
          // rendern
          //g2.drawImage(layer, null, 0, 0);
         
          // das selbe f�r alle layer
          for(int i=0; i<data.getNLayers()-1; i++) {           
            lData = data.mcly.getLayer(i+1);
           
            // bild holen
              //layer = texLoader.getBitmapNo( lData.getTextureID() );
             
            // lightmap holen
              //alpha = createLightMap(i); 
             
              // alpha setzen
//              NewAlphaFilter filter = new NewAlphaFilter(data.mcal.getLayerNo(i));
                //tmp = filter.createCompatibleDestImage(layer, screen.getColorModel());

               // filter.filter(layer, tmp);
             
              // rendern
              g2.drawImage(tmp, null, 0, 0);
          }
           
          // chacen
          //saveImage(screen, "screen");
         
          // screen in die textur umwandeln und anzeigen
          ImageComponent2D texImage = new ImageComponent2D(
                  ImageComponent.FORMAT_RGBA4, screen);

          tex = new Texture2D(Texture.BASE_LEVEL, Texture.RGB, 256, 256);
          tex.setImage(0, texImage);
         
          texAttr = new TextureAttributes();
      texAttr.setTextureMode(TextureAttributes.MODULATE);
      textureUnitState[0] = new TextureUnitState(tex, texAttr, null);
        textureUnitState[0].setCapability(TextureUnitState.ALLOW_STATE_WRITE);
View Full Code Here

/* 259 */           ta.setTransparencyMode(2);
/* 260 */           appearance.setTransparencyAttributes(ta);
/*     */         }
/* 262 */         if (texture != null) {
/* 263 */           debugOutputLn(8, "texture != null, enable texturing");
/* 264 */           Texture tex = texture.getTexture();
/* 265 */           tex.setEnable(true);
/* 266 */           appearance.setTexture(tex);
/* 267 */           TextureAttributes ta = new TextureAttributes();
/* 268 */           if (texture.getType().equals("DTEX"))
/* 269 */             ta.setTextureMode(2);
/* 270 */           else if (texture.getType().equals("CTEX"))
View Full Code Here

/*     */
/*     */   public void setString(String text)
/*     */   {
/* 113 */     this.text = text;
/*     */
/* 115 */     Texture tex = getAppearance().getTexture();
/* 116 */     int width = tex.getWidth();
/* 117 */     int height = tex.getHeight();
/*     */
/* 119 */     ImageComponent imageComponent = setupImage(text, this.color, this.fontName, this.fontSize, this.fontStyle);
/*     */
/* 121 */     if ((imageComponent.getWidth() == width) && (imageComponent.getHeight() == height))
/*     */     {
/* 123 */       tex.setImage(0, imageComponent);
/*     */     } else {
/* 125 */       Texture2D newTex = setupTexture(imageComponent);
/*     */
/* 129 */       newTex.setBoundaryModeS(tex.getBoundaryModeS());
/* 130 */       newTex.setBoundaryModeT(tex.getBoundaryModeT());
/* 131 */       newTex.setMinFilter(tex.getMinFilter());
/* 132 */       newTex.setMagFilter(tex.getMagFilter());
/* 133 */       newTex.setEnable(tex.getEnable());
/* 134 */       newTex.setAnisotropicFilterMode(tex.getAnisotropicFilterMode());
/* 135 */       newTex.setAnisotropicFilterDegree(tex.getAnisotropicFilterDegree());
/* 136 */       int pcount = tex.getFilter4FuncPointsCount();
/* 137 */       if (pcount > 0) {
/* 138 */         float[] weights = new float[pcount];
/* 139 */         tex.getFilter4Func(weights);
/* 140 */         newTex.setFilter4Func(weights);
/*     */       }
/* 142 */       Color4f c = new Color4f();
/* 143 */       tex.getBoundaryColor(c);
/* 144 */       newTex.setBoundaryColor(c);
/* 145 */       newTex.setUserData(tex.getUserData());
/* 146 */       getAppearance().setTexture(newTex);
/*     */     }
/*     */   }
View Full Code Here

/*  95 */     this.boundaryWidth = in.readInt();
/*     */   }
/*     */
/*     */   public void writeObject(DataOutput out) throws IOException {
/*  99 */     super.writeObject(out);
/* 100 */     Texture attr = (Texture)this.node;
/* 101 */     Color4f clr = new Color4f();
/* 102 */     attr.getBoundaryColor(clr);
/* 103 */     this.control.writeColor4f(out, clr);
/* 104 */     out.writeInt(attr.getBoundaryModeS());
/* 105 */     out.writeInt(attr.getBoundaryModeT());
/* 106 */     out.writeBoolean(attr.getEnable());
/*     */
/* 108 */     out.writeInt(this.imageComponents.length);
/* 109 */     for (int i = 0; i < this.imageComponents.length; i++) {
/* 110 */       out.writeInt(this.imageComponents[i]);
/*     */     }
/* 112 */     out.writeInt(attr.getMagFilter());
/* 113 */     out.writeInt(attr.getMinFilter());
/* 114 */     out.writeInt(attr.getBaseLevel());
/* 115 */     out.writeInt(attr.getMaximumLevel());
/* 116 */     out.writeFloat(attr.getMinimumLOD());
/* 117 */     out.writeFloat(attr.getMaximumLOD());
/*     */
/* 119 */     Point3f lodOffset = new Point3f();
/* 120 */     attr.getLodOffset(lodOffset);
/* 121 */     this.control.writePoint3f(out, lodOffset);
/*     */
/* 123 */     out.writeInt(attr.getAnisotropicFilterMode());
/* 124 */     out.writeFloat(attr.getAnisotropicFilterDegree());
/*     */
/* 126 */     int points = attr.getSharpenTextureFuncPointsCount();
/* 127 */     out.writeInt(points);
/* 128 */     if (points > 0) {
/* 129 */       float[] lod = new float[points];
/* 130 */       float[] pts = new float[points];
/* 131 */       attr.getSharpenTextureFunc(lod, pts);
/* 132 */       for (int i = 0; i < points; i++) {
/* 133 */         out.writeFloat(lod[i]);
/* 134 */         out.writeFloat(pts[i]);
/*     */       }
/*     */     }
/*     */
/* 138 */     points = attr.getFilter4FuncPointsCount();
/* 139 */     out.writeInt(points);
/* 140 */     if (points >= 4) {
/* 141 */       float[] weights = new float[points];
/* 142 */       attr.getFilter4Func(weights);
/* 143 */       for (int i = 0; i < points; i++)
/* 144 */         out.writeFloat(weights[i]);
/*     */     }
/*     */   }
View Full Code Here

TOP

Related Classes of javax.media.j3d.Texture

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.