List of usage examples for javax.media.j3d Texture ALLOW_ENABLE_WRITE
int ALLOW_ENABLE_WRITE
To view the source code for javax.media.j3d Texture ALLOW_ENABLE_WRITE.
Click Source Link
From source file:TexBug.java
void setTexture() { // set up the image using the TextureLoader java.net.URL imageURL = null; try {//from ww w. j ava 2 s .c o m imageURL = new java.net.URL(codeBaseString + "earth.jpg"); //imageURL = new java.net.URL(codeBaseString + // "decal_textures/fish1.gif"); } catch (Exception e) { System.err.println("Exception: " + e); System.exit(1); } int flags; if (texMipMapMode == Texture.BASE_LEVEL) { flags = 0; } else { flags = TextureLoader.GENERATE_MIPMAP; } texLoader = new TextureLoader(imageURL, new String("RGBA"), //new String("LUMINANCE"), flags, this); // We could create texture from image // // Get the image from the loader. We need an image which // has power of two dimensions, so we'll get the unscaled image, // figure out what the scaled size should be and then get a scale // image //ImageComponent2D unscaledImage = texLoader.getImage(); //int width = unscaledImage.getWidth(); //int height = unscaledImage.getWidth(); // // scaled values are next power of two greater than or equal to // value //texWidth = powerOfTwo(width); //texHeight = powerOfTwo(height); // // rescale the image if necessary //ImageComponent2D texImage; //if ((texWidth == width) && (texHeight == height)) { // texImage = unscaledImage; //} else { // texImage = texLoader.getScaledImage(texWidth, texHeight); //} //texFormat = Texture.RGB; //texture = new Texture2D(texMipMapMode, texFormat, texWidth, // texHeight); //texture.setImage(0, texImage); // instead we'll just get get the texture from loader texture = (Texture2D) texLoader.getTexture(); //texture.setBoundaryColor(texBoundaryColor); texture.setBoundaryColor(1.0f, 1.0f, 1.0f, 1.0f); texture.setBoundaryModeS(texBoundaryModeS); texture.setBoundaryModeT(texBoundaryModeT); texture.setEnable(texEnable); texture.setMinFilter(texMinFilter); texture.setMagFilter(texMagFilter); // Set the capabilities to enable the changable attrs texture.setCapability(Texture.ALLOW_ENABLE_WRITE); texture.setCapability(Texture.ALLOW_IMAGE_WRITE); // connect the new texture to the appearance System.out.println("Appearance.setTexture(" + texture + ")"); appearance.setTexture(texture); }
From source file:ExTexture.java
private Texture2D loadTexture(String filename) { // Load the texture image file if (debug)//from w w w . j a v a 2 s . c o m System.err.println("Loading texture '" + filename + "'"); TextureLoader texLoader = new TextureLoader(filename, this); // If the image is NULL, something went wrong ImageComponent2D ic = texLoader.getImage(); if (ic == null) { System.err.println("Cannot load texture '" + filename + "'"); return null; } // Configure a Texture2D with the image Texture2D t = (Texture2D) texLoader.getTexture(); int mode = ((Integer) boundaries[currentBoundary].value).intValue(); t.setBoundaryModeS(mode); t.setBoundaryModeT(mode); Color3f color = (Color3f) colors[currentColor].value; t.setBoundaryColor(color.x, color.y, color.z, 0.0f); int filter = ((Integer) filters[currentFilter].value).intValue(); t.setMagFilter(filter); t.setMinFilter(filter); t.setMipMapMode(Texture.BASE_LEVEL); // Turn it on and allow future changes t.setEnable(true); t.setCapability(Texture.ALLOW_ENABLE_WRITE); return t; }
From source file:AppearanceTest.java
protected int[] getCapabilities() { return new int[] { Texture.ALLOW_ENABLE_WRITE, }; }
From source file:AppearanceExplorer.java
void setTexture() { // set up the image using the TextureLoader java.net.URL imageURL = null; try {/* w w w . ja va 2 s.c o m*/ imageURL = new java.net.URL(codeBaseString + imageFile); } catch (Exception e) { System.err.println("Exception: " + e); System.exit(1); } int flags; if (mipMapMode == Texture.BASE_LEVEL) { flags = 0; } else { flags = TextureLoader.GENERATE_MIPMAP; } texLoader = new TextureLoader(imageURL, new String("RGBA"), flags, this); // We could create texture from image // // Get the image from the loader. We need an image which // has power of two dimensions, so we'll get the unscaled image, // figure out what the scaled size should be and then get a scale // image //ImageComponent2D unscaledImage = texLoader.getImage(); //int width = unscaledImage.getWidth(); //int height = unscaledImage.getWidth(); // // scaled values are next power of two greater than or equal to // value //texWidth = powerOfTwo(width); //texHeight = powerOfTwo(height); // // rescale the image if necessary //ImageComponent2D texImage; //if ((texWidth == width) && (texHeight == height)) { // texImage = unscaledImage; //} else { // texImage = texLoader.getScaledImage(texWidth, texHeight); //} //texFormat = Texture.RGB; //texture = new Texture2D(texMipMapMode, texFormat, texWidth, // texHeight); //texture.setImage(0, texImage); // instead we'll just get get the texture from loader texture = (Texture2D) texLoader.getTexture(); texture.setBoundaryColor(boundaryColor); texture.setBoundaryModeS(boundaryModeS); texture.setBoundaryModeT(boundaryModeT); texture.setEnable(enable); texture.setMinFilter(minFilter); texture.setMagFilter(magFilter); // Set the capabilities to enable the changable attrs texture.setCapability(Texture.ALLOW_ENABLE_WRITE); texture.setCapability(Texture.ALLOW_IMAGE_WRITE); // connect the new texture to the appearance appearance.setTexture(texture); }