⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 texture.java

📁 JAVA3D矩陈的相关类
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
/* * $RCSfile: Texture.java,v $ * * Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved. * * Use is subject to license terms. * * $Revision: 1.9 $ * $Date: 2007/03/21 22:54:07 $ * $State: Exp $ */package javax.media.j3d;import javax.vecmath.*;import java.util.Hashtable;/** * The Texture object is a component object of an Appearance object * that defines the texture properties used when texture mapping is * enabled. The Texture object is an abstract class and all texture  * objects must be created as either a Texture2D object or a * Texture3D object. * <P> * Each Texture object has the following properties:<P> * <UL> * <LI>Boundary color - the texture boundary color. The texture * boundary color is used when the boundaryModeS and boundaryModeT * parameters are set to CLAMP or CLAMP_TO_BOUNDARY and if the texture * boundary is not specified. </LI><P> * <LI>Boundary Width - the texture boundary width, which must be 0 or 1. * If the texture boundary * width is 1, then all images for all mipmap levels will include a border. * The actual texture image for level 0, for example, will be of * dimension (width + 2*boundaryWidth) * (height + 2*boundaryWidth). * The boundary texels will be used when linear filtering is to be applied. * </LI><p> * <LI>Boundary ModeS and Boundary ModeT - the boundary mode for the * S and T coordinates, respectively. The boundary modes are as * follows:</LI><P> * <UL> * <LI>CLAMP - clamps texture coordinates to be in the range [0,1].  * Texture boundary texels or the constant boundary color if boundary width * is 0 will be used for U,V values that fall outside this range.</LI><P> * <LI>WRAP - repeats the texture by wrapping texture coordinates * that are outside the range [0,1]. Only the fractional portion * of the texture coordinates is used. The integer portion is * discarded</LI><P> * <LI>CLAMP_TO_EDGE - clamps texture coordinates such that filtering * will not sample a texture boundary texel. Texels at the edge of the  * texture will be used instead.</LI><P> * <LI>CLAMP_TO_BOUNDARY - clamps texture coordinates such that filtering * will sample only texture boundary texels, that is, it will never * get some samples from the boundary and some from the edge. This * will ensure clean unfiltered boundaries. If the texture does not  * have a boundary, that is the boundary width is equal to 0, then the  * constant boundary color will be used.</LI></P> * </UL> * <LI>Image - an image or an array of images for all the mipmap * levels. If only one image is provided, the MIPmap mode must be * set to BASE_LEVEL.</LI><P> * <LI>Magnification filter - the magnification filter function.  * Used when the pixel being rendered maps to an area less than or * equal to one texel. The magnification filter functions are as * follows:</LI><P> * <UL> * <LI>FASTEST - uses the fastest available method for processing * geometry.</LI><P> * <LI>NICEST - uses the nicest available method for processing * geometry.</LI><P> * <LI>BASE_LEVEL_POINT - selects the nearest texel in the base level * texture image.</LI><P> * <LI>BASE_LEVEL_LINEAR - performs a bilinear interpolation on the four * nearest texels in the base level texture image. The texture value T' is * computed as follows:</LI><P> * <UL> * i<sub>0</sub> = trunc(u - 0.5)<P> * j<sub>0</sub> = trunc(v - 0.5)<P> * i<sub>1</sub> = i<sub>0</sub> + 1<P> * j<sub>1</sub> = j<sub>0</sub> + 1<P> * a = frac(u - 0.5)<P> * b = frac(v - 0.5)<P> * T' = (1-a)*(1-b)*T<sub>i<sub>0</sub>j<sub>0</sub></sub> +  * a*(1-b)*T<sub>i<sub>1</sub>j<sub>0</sub></sub> + * (1-a)*b*T<sub>i<sub>0</sub>j<sub>1</sub></sub> + * a*b*T<sub>i<sub>1</sub>j<sub>1</sub></sub><P> * </UL> * <LI>LINEAR_SHARPEN - sharpens the resulting image by extrapolating * from the base level plus one image to the base level image of this  * texture object.</LI><P> * <LI>LINEAR_SHARPEN_RGB - performs linear sharpen filter for the rgb * components only. The alpha component is computed using BASE_LEVEL_LINEAR * filter.</LI><P> * <LI>LINEAR_SHARPEN_ALPHA - performs linear sharpen filter for the alpha * component only. The rgb components are computed using BASE_LEVEL_LINEAR * filter.</LI><P> * <LI>FILTER4 - applies an application-supplied weight function * on the nearest 4x4 texels in the base level texture image. The * texture value T' is computed as follows:</LI><P> * <UL> * <table cellspacing=10> * <td>i<sub>1</sub> = trunc(u - 0.5)</td> * <td>i<sub>2</sub> = i<sub>1</sub> + 1</td> * <td>i<sub>3</sub> = i<sub>2</sub> + 1</td> * <td>i<sub>0</sub> = i<sub>1</sub> - 1</td> * <tr> * <td>j<sub>1</sub> = trunc(v - 0.5)</td> * <td>j<sub>3</sub> = j<sub>2</sub> + 1</td> * <td>j<sub>2</sub> = j<sub>1</sub> + 1</td> * <td>j<sub>0</sub> = j<sub>1</sub> - 1</td> * <tr> * <td>a = frac(u - 0.5)</td> * <tr> * <td>b = frac(v - 0.5)</td> * </table> * f(x) : filter4 function where 0<=x<=2<P> * T' = f(1+a) * f(1+b) * T<sub>i<sub>0</sub>j<sub>0</sub></sub> +  * f(a) * f(1+b) * T<sub>i<sub>1</sub>j<sub>0</sub></sub> +  * f(1-a) * f(1+b) * T<sub>i<sub>2</sub>j<sub>0</sub></sub> +  * f(2-a) * f(1+b) * T<sub>i<sub>3</sub>j<sub>0</sub></sub> + <br> * f(1+a) * f(b) * T<sub>i<sub>0</sub>j<sub>1</sub></sub> +  * f(a) * f(b) * T<sub>i<sub>1</sub>j<sub>1</sub></sub> +  * f(1-a) * f(b) * T<sub>i<sub>2</sub>j<sub>1</sub></sub> +  * f(2-a) * f(b) * T<sub>i<sub>3</sub>j<sub>1</sub></sub> + <br> * f(1+a) * f(1-b) * T<sub>i<sub>0</sub>j<sub>2</sub></sub> +  * f(a) * f(1-b) * T<sub>i<sub>1</sub>j<sub>2</sub></sub> +  * f(1-a) * f(1-b) * T<sub>i<sub>2</sub>j<sub>2</sub></sub> +  * f(2-a) * f(1-b) * T<sub>i<sub>3</sub>j<sub>2</sub></sub> + <br> * f(1+a) * f(2-b) * T<sub>i<sub>0</sub>j<sub>3</sub></sub> +  * f(a) * f(2-b) * T<sub>i<sub>1</sub>j<sub>3</sub></sub> +  * f(1-a) * f(2-b) * T<sub>i<sub>2</sub>j<sub>3</sub></sub> +  * f(2-a) * f(2-b) * T<sub>i<sub>3</sub>j<sub>3</sub></sub> <P> * </UL> * </UL> * <LI>Minification filter - the minification filter function. Used * when the pixel being rendered maps to an area greater than one * texel. The minifaction filter functions are as follows:</LI><P> * <UL> * <LI>FASTEST - uses the fastest available method for processing * geometry.</LI><P> * <LI>NICEST - uses the nicest available method for processing * geometry.</LI><P> * <LI>BASE_LEVEL_POINT - selects the nearest level in the base level * texture map.</LI><P> *<LI>BASE_LEVEL_LINEAR - performs a bilinear interpolation on the four * nearest texels in the base level texture map.</LI><P> * <LI>MULTI_LEVEL_POINT - selects the nearest texel in the nearest * mipmap.</LI><P> * <LI>MULTI_LEVEL_LINEAR - performs trilinear interpolation of texels * between four texels each from the two nearest mipmap levels.</LI><P> * <LI>FILTER4 - applies an application-supplied weight function * on the nearest 4x4 texels in the base level texture image.</LI><P> * </UL> * <LI>MIPmap mode - the mode used for texture mapping for this * object. The mode is one of the following:</LI><P> * <UL> * <LI>BASE_LEVEL - indicates that this Texture object only has a * base-level image. If multiple levels are needed, they will be * implicitly computed.</LI><P> * <LI>MULTI_LEVEL_MIPMAP - indicates that this Texture object has * multiple images. If MIPmap mode is set * to MULTI_LEVEL_MIPMAP, images for Base Level through Max Level * must be set.</LI><P> * </UL> * <LI>Format - the data format. The format is one of the * following:</LI><P> * <UL> * <LI>INTENSITY - the texture image contains only texture * values.</LI><P> * <LI>LUMINANCE - the texture image contains only * luminance values.</LI><P> * <LI>ALPHA - the texture image contains only alpha * values.</LI><P> * <LI>LUMINANCE_ALPHA - the texture image contains * both luminance and alpha values.</LI><P> * <LI>RGB - the texture image contains red, green, * and blue values.</LI><P> * <LI>RGBA - the texture image contains red, green, blue, and alpha * values.</LI><P></UL> * <LI>Base Level - specifies the mipmap level to be used when filter * specifies BASE_LEVEL_POINT or BASE_LEVEL_LINEAR.</LI><P> * <LI>Maximum Level - specifies the maximum level of image that needs to be * defined for this texture to be valid. Note, for this texture to be valid, * images for Base Level through Maximum Level have to be defined.</LI><P> * <LI>Minimum LOD - specifies the minimum of the LOD range. LOD smaller * than this value will be clamped to this value.</LI><P> * <LI>Maximum LOD - specifies the maximum of the LOD range. LOD larger * than this value will be clamped to this value.</LI><P> * <LI>LOD offset - specifies the offset to be used in the LOD calculation * to compensate for under or over sampled texture images.</LI></P> * <LI>Anisotropic Mode - defines how anisotropic filter is applied for * this texture object. The anisotropic modes are as follows:</LI><P> * <UL> * <LI>ANISOTROPIC_NONE - no anisotropic filtering.</LI><P> * <LI>ANISOTROPIC_SINGLE_VALUE - applies the degree of anisotropic filter  * in both the minification and magnification filters.</LI><P> * </UL> * <LI>Anisotropic Filter Degree - controls the degree of anisotropy. This * property applies to both minification and magnification filtering.  * If it is equal to 1.0, then an isotropic filtering as specified in the * minification or magnification filter will be used. If it is greater  * than 1.0, and the anisotropic mode is equal to ANISOTROPIC_SINGLE_VALUE,  * then * the degree of anisotropy will also be applied in the filtering.</LI><P> * <LI>Sharpen Texture Function - specifies the function of level-of-detail * used in combining the texture value computed from the base level image * and the texture value computed from the base level plus one image. The * final texture value is computed as follows: </LI><P> * <UL> * T' = ((1 + SharpenFunc(LOD)) * T<sub>BaseLevel</sub>) - (SharpenFunc(LOD) * T<sub>BaseLevel+1</sub>) <P> * </UL> * <LI>Filter4 Function - specifies the function to be applied to the * nearest 4x4 texels.  This property includes samples of the filter * function f(x), 0<=x<=2. The number of function values supplied * has to be equal to 2<sup>m</sup> + 1 for some integer value of m * greater than or equal to 4. </LI><P> * </UL> * * <p> * Note that as of Java 3D 1.5, the texture width and height are no longer * required to be an exact power of two. However, not all graphics devices * supports non-power-of-two textures. If non-power-of-two texture mapping is * unsupported on a particular Canvas3D, textures with a width or height that * are not an exact power of two are ignored for that canvas. * * @see Canvas3D#queryProperties */public abstract class Texture extends NodeComponent {    /**     * Specifies that this Texture object allows reading its     * enable flag.     */    public static final int    ALLOW_ENABLE_READ = CapabilityBits.TEXTURE_ALLOW_ENABLE_READ;    /**     * Specifies that this Texture object allows writing its     * enable flag.     */    public static final int    ALLOW_ENABLE_WRITE = CapabilityBits.TEXTURE_ALLOW_ENABLE_WRITE;    /**     * Specifies that this Texture object allows reading its     * boundary mode information.     */    public static final int    ALLOW_BOUNDARY_MODE_READ = CapabilityBits.TEXTURE_ALLOW_BOUNDARY_MODE_READ;    /**     * Specifies that this Texture object allows reading its     * filter information.     */    public static final int    ALLOW_FILTER_READ = CapabilityBits.TEXTURE_ALLOW_FILTER_READ;    /**     * Specifies that this Texture object allows reading its     * image component information.     */    public static final int    ALLOW_IMAGE_READ = CapabilityBits.TEXTURE_ALLOW_IMAGE_READ;    /**     * Specifies that this Texture object allows writing its     * image component information.     *     * @since Java 3D 1.2     */    public static final int    ALLOW_IMAGE_WRITE = CapabilityBits.TEXTURE_ALLOW_IMAGE_WRITE;    /**     * Specifies that this Texture object allows reading its     * format information.     *     * @since Java 3D 1.2     */    public static final int    ALLOW_FORMAT_READ = CapabilityBits.TEXTURE_ALLOW_FORMAT_READ;    /**     * Specifies that this Texture object allows reading its     * size information (e.g., width, height, number of mipmap levels,     * boundary width).     *     * @since Java 3D 1.2     */    public static final int    ALLOW_SIZE_READ = CapabilityBits.TEXTURE_ALLOW_SIZE_READ;    /**     * Specifies that this Texture object allows reading its     * mipmap mode information.     */    public static final int    ALLOW_MIPMAP_MODE_READ = CapabilityBits.TEXTURE_ALLOW_MIPMAP_MODE_READ;    /**     * Specifies that this Texture object allows reading its     * boundary color information.     */    public static final int    ALLOW_BOUNDARY_COLOR_READ = CapabilityBits.TEXTURE_ALLOW_BOUNDARY_COLOR_READ;    /**     * Specifies that this Texture object allows reading its LOD range     * information (e.g., base level, maximum level, minimum lod,      * maximum lod, lod offset)     *     * @since Java 3D 1.3     */    public static final int    ALLOW_LOD_RANGE_READ = CapabilityBits.TEXTURE_ALLOW_LOD_RANGE_READ;    /**     * Specifies that this Texture object allows writing its LOD range     * information (e.g., base level, maximum level, minimum lod,      * maximum lod, lod offset)     *     * @since Java 3D 1.3     */    public static final int    ALLOW_LOD_RANGE_WRITE = CapabilityBits.TEXTURE_ALLOW_LOD_RANGE_WRITE;    /**     * Specifies that this Texture object allows reading its anistropic     * filter information (e.g., anisotropic mode, anisotropic filter)     *     * @since Java 3D 1.3     */    public static final int    ALLOW_ANISOTROPIC_FILTER_READ = CapabilityBits.TEXTURE_ALLOW_ANISOTROPIC_FILTER_READ;    /**     * Specifies that this Texture object allows reading its sharpen     * texture function information.     *     * @since Java 3D 1.3     */    public static final int    ALLOW_SHARPEN_TEXTURE_READ = CapabilityBits.TEXTURE_ALLOW_SHARPEN_TEXTURE_READ;    /**       * Specifies that this Texture object allows reading its filter4     * function information.     *     * @since Java 3D 1.3     */    public static final int    ALLOW_FILTER4_READ = CapabilityBits.TEXTURE_ALLOW_FILTER4_READ;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -