Package javax.media.j3d

Examples of javax.media.j3d.TextureAttributes


    private void setEffect(Material mat, Texture tex) {
        current = mat;
        Appearance app = new Appearance();
        app.setTexture(tex);
        app.setMaterial(current);
        app.setTextureAttributes(new TextureAttributes(TextureAttributes.MODULATE, new Transform3D(), new Color4f(), TextureAttributes.NICEST));
        floor.setAppearance(app);
       
        if (surface != null) setSurfaceEffect(mat, surface.getAppearance().getTexture());
    }
View Full Code Here


    aTexture.setImage(0,textureIm);

    //An Appearance which will use the texture.
    Appearance textureApp = new Appearance();
    textureApp.setTexture(aTexture);
    TextureAttributes textureAttr = new TextureAttributes();
    textureAttr.setTextureMode(TextureAttributes.REPLACE);
    textureApp.setTextureAttributes(textureAttr);
    Material mat = new Material();
    mat.setShininess(120.0f);
    textureApp.setMaterial(mat);
    TexCoordGeneration tcg = new TexCoordGeneration(TexCoordGeneration.OBJECT_LINEAR,
View Full Code Here

     */
    protected void _setViewScreen(GRActor actor) throws IllegalActionException {
        super._setViewScreen(actor);

        URL textureURL = texture.asURL();
        TextureAttributes attributes = null;

        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);

                _appearance.setTexture(loadedTexture);
            }
        }

        // If runtime changes are allowed, then we need to set texture
        // attributes even if not needed now.
        if ((attributes == null)
                && ((BooleanToken) allowRuntimeChanges.getToken())
                        .booleanValue()) {
            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

/* 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"))
/* 271 */             ta.setTextureMode(3);
/* 272 */           appearance.setTextureAttributes(ta);
/*     */         }
/*     */         else {
/* 275 */           debugOutputLn(8, "texture == null, no texture to use");
/*     */         }
View Full Code Here

/*  58 */     super(symbol, control);
/*     */   }
/*     */
/*     */   public void writeObject(DataOutput out) throws IOException {
/*  62 */     super.writeObject(out);
/*  63 */     TextureAttributes attr = (TextureAttributes)this.node;
/*  64 */     Color4f clr = new Color4f();
/*  65 */     Matrix4d mat = new Matrix4d();
/*  66 */     Transform3D trans = new Transform3D();
/*  67 */     int tableComponents = attr.getNumTextureColorTableComponents();
/*  68 */     int tableSize = attr.getTextureColorTableSize();
/*  69 */     int[][] colorTable = new int[tableComponents][tableSize];
/*     */
/*  71 */     out.writeInt(attr.getPerspectiveCorrectionMode());
/*  72 */     attr.getTextureBlendColor(clr);
/*  73 */     this.control.writeColor4f(out, clr);
/*  74 */     out.writeInt(tableComponents);
/*  75 */     out.writeInt(tableSize);
/*  76 */     attr.getTextureColorTable(colorTable);
/*  77 */     for (int i = 0; i < tableComponents; i++) {
/*  78 */       for (int j = 0; j < tableSize; j++)
/*  79 */         out.writeInt(colorTable[i][j]);
/*     */     }
/*  81 */     out.writeInt(attr.getTextureMode());
/*  82 */     attr.getTextureTransform(trans);
/*  83 */     trans.get(mat);
/*  84 */     this.control.writeMatrix4d(out, mat);
/*     */
/*  86 */     out.writeInt(attr.getCombineRgbMode());
/*  87 */     out.writeInt(attr.getCombineAlphaMode());
/*  88 */     for (int i = 0; i < 2; i++) {
/*  89 */       out.writeInt(attr.getCombineRgbSource(i));
/*  90 */       out.writeInt(attr.getCombineAlphaSource(i));
/*  91 */       out.writeInt(attr.getCombineRgbFunction(i));
/*  92 */       out.writeInt(attr.getCombineAlphaFunction(i));
/*     */     }
/*  94 */     out.writeInt(attr.getCombineRgbScale());
/*  95 */     out.writeInt(attr.getCombineAlphaScale());
/*     */   }
View Full Code Here

/*  95 */     out.writeInt(attr.getCombineAlphaScale());
/*     */   }
/*     */
/*     */   public void readObject(DataInput in) throws IOException {
/*  99 */     super.readObject(in);
/* 100 */     TextureAttributes attr = (TextureAttributes)this.node;
/* 101 */     attr.setPerspectiveCorrectionMode(in.readInt());
/* 102 */     attr.setTextureBlendColor(this.control.readColor4f(in));
/* 103 */     int tableComponents = in.readInt();
/* 104 */     int tableSize = in.readInt();
/* 105 */     int[][] colorTable = new int[tableComponents][tableSize];
/* 106 */     for (int i = 0; i < tableComponents; i++)
/* 107 */       for (int j = 0; j < tableSize; j++)
/* 108 */         colorTable[i][j] = in.readInt();
/* 109 */     if (tableComponents != 0)
/* 110 */       attr.setTextureColorTable(colorTable);
/* 111 */     attr.setTextureMode(in.readInt());
/* 112 */     Matrix4d mat = this.control.readMatrix4d(in);
/* 113 */     Transform3D trans = new Transform3D(mat);
/* 114 */     attr.setTextureTransform(trans);
/*     */
/* 116 */     attr.setCombineRgbMode(in.readInt());
/* 117 */     attr.setCombineAlphaMode(in.readInt());
/* 118 */     for (int i = 0; i < 2; i++) {
/* 119 */       attr.setCombineRgbSource(i, in.readInt());
/* 120 */       attr.setCombineAlphaSource(i, in.readInt());
/* 121 */       attr.setCombineRgbFunction(i, in.readInt());
/* 122 */       attr.setCombineAlphaFunction(i, in.readInt());
/*     */     }
/* 124 */     attr.setCombineRgbScale(in.readInt());
/* 125 */     attr.setCombineAlphaScale(in.readInt());
/*     */   }
View Full Code Here

/* 124 */     attr.setCombineRgbScale(in.readInt());
/* 125 */     attr.setCombineAlphaScale(in.readInt());
/*     */   }
/*     */
/*     */   protected SceneGraphObject createNode() {
/* 129 */     return new TextureAttributes();
/*     */   }
View Full Code Here

    public static Appearance fromFile(String textureFileName) {
        final TextureLoader loader = new TextureLoader(textureFileName, null);
        final Texture texture = loader.getTexture();
        final Appearance appearance = new Appearance();
        final TextureAttributes ta = new TextureAttributes();
        ta.setTextureMode(TextureAttributes.COMBINE);
        appearance.setMaterial(new Material());
        appearance.setTexture(texture);
        appearance.setTextureAttributes(ta);
        return appearance;
    }
View Full Code Here

TOP

Related Classes of javax.media.j3d.TextureAttributes

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.