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

📄 texture.java

📁 java 3d game jme 工程开发源代码
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
        TextureUnit15,
        /** The texture bound on texture unit 16. */
        TextureUnit16,
        /** The texture bound on texture unit 17. */
        TextureUnit17,
        /** The texture bound on texture unit 18. */
        TextureUnit18,
        /** The texture bound on texture unit 19. */
        TextureUnit19,
        /** The texture bound on texture unit 20. */
        TextureUnit20,
        /** The texture bound on texture unit 21. */
        TextureUnit21,
        /** The texture bound on texture unit 22. */
        TextureUnit22,
        /** The texture bound on texture unit 23. */
        TextureUnit23,
        /** The texture bound on texture unit 24. */
        TextureUnit24,
        /** The texture bound on texture unit 25. */
        TextureUnit25,
        /** The texture bound on texture unit 26. */
        TextureUnit26,
        /** The texture bound on texture unit 27. */
        TextureUnit27,
        /** The texture bound on texture unit 28. */
        TextureUnit28,
        /** The texture bound on texture unit 29. */
        TextureUnit29,
        /** The texture bound on texture unit 30. */
        TextureUnit30,
        /** The texture bound on texture unit 31. */
        TextureUnit31;
    }

    public enum CombinerOperandRGB {
        SourceColor, OneMinusSourceColor, SourceAlpha, OneMinusSourceAlpha;
    }

    public enum CombinerOperandAlpha {
        SourceAlpha, OneMinusSourceAlpha;
    }

    public enum CombinerScale {
        /** No scale (1.0x) */
        One(1.0f),
        /** 2.0x */
        Two(2.0f),
        /** 4.0x */
        Four(4.0f);

        private float scale;

        private CombinerScale(float scale) {
            this.scale = scale;
        }

        public float floatValue() {
            return scale;
        }
    }

    /**
     * When doing RenderToTexture operations with this texture, this value
     * indicates what content to render into this texture.
     */
    public enum RenderToTextureType {
        /**
         *Each element is an RGB triple. OpenGL converts it to fixed-point or floating-point and assembles it into an RGBA element by attaching 1 for alpha. 
         *Each component is then clamped to the range [0,1].
         */
    	RGB, 
    	/**
    	 * Each element contains all four components. OpenGL converts it to fixed-point or floating-point. 
    	 * Each component is then clamped to the range [0,1].
    	 */
    	RGBA, 
    	/**
    	 * Each element is a single depth component clamped to the range [0, 1].
    	 * Each component is then clamped to the range [0,1].
    	 */
    	Depth, 
    	/**
    	 * Each element is a luminance/alpha pair. OpenGL converts it to fixed-point or floating point, then assembles it into an RGBA element by replicating the luminance value three times for red, green, and blue.
    	 * Each component is then clamped to the range [0,1].
    	 */
    	Alpha, 
    	/**
    	 * Each element is a single luminance value. OpenGL converts it to fixed-point or floating-point, then assembles it into an RGBA element by replicating the luminance value three times for red, green, and blue and attaching 1 for alpha.
    	 * Each component is then clamped to the range [0,1].
    	 */
    	Luminance, 
    	/**
    	 * Each element is a luminance/alpha pair. OpenGL converts it to fixed-point or floating point, then assembles it into an RGBA element by replicating the luminance value three times for red, green, and blue.
    	 * Each component is then clamped to the range [0,1].
    	 */
    	LuminanceAlpha, 
    	/**
    	 * Each element has both luminance (grayness) and alpha (transparency) information, but the luminance and alpha values at every texel are the same.
    	 * Each component is then clamped to the range [0,1].
    	 */
    	Intensity,
    	Alpha4, Alpha8, Alpha12, Alpha16, 
    	Luminance4, Luminance8, Luminance12, Luminance16, 
		  Luminance4Alpha4,Luminance6Alpha2, Luminance8Alpha8,Luminance12Alpha4,
		  Luminance12Alpha12, Luminance16Alpha16, 
		  Intensity4, Intensity8, Intensity12, Intensity16, 
		  R3_G3_B2, RGB4, RGB5, RGB8, RGB10, RGB12, RGB16, 
		  RGBA2, RGBA4, RGB5_A1, RGBA8, RGB10_A2, RGBA12, RGBA16,
		  //floats
		  RGBA32F, RGB32F, Alpha32F, Intensity32F, Luminance32F, LuminanceAlpha32F,
		  RGBA16F, RGB16F, Alpha16F, Intensity16F, Luminance16F, LuminanceAlpha16F;
    	
    }
    
    /**
     * The shadowing texture compare mode
     */
    public enum DepthTextureCompareMode {
    	/** Perform no shadow based comparsion */
    	None,
    	/** Perform a comparison between source depth and texture depth */
    	RtoTexture,
    }

    /**
     * The shadowing texture compare function
     */
    public enum DepthTextureCompareFunc {
    	/** Outputs if the source depth is less than the texture depth */
    	LessThanEqual,
    	/** Outputs if the source depth is greater than the texture depth */
    	GreaterThanEqual
    }
    
    /**
     * The type of depth texture translation to output
     */
    public enum DepthTextureMode {
    	/** Output luminance values based on the depth comparison */
    	Luminance,
    	/** Output alpha values based on the depth comparison */
    	Alpha,
    	/** Output intensity values based on the depth comparison */
    	Intensity
    }
    
    

    // Optional String to point to where this texture is located
    private String imageLocation = null;

    // texture attributes.
    private Image image = null;
    private ColorRGBA blendColor = null; // If null, black (gl's default)
    // will be used
    private ColorRGBA borderColor = null; // If null, black (gl's default)
    // will be used

    private Vector3f translation = null;
    private Vector3f scale = null;
    private Quaternion rotation = null;
    private Matrix4f matrix = null;

    private float anisotropicFilterPercent = 0.0f;

    private transient int textureId;
    private ApplyMode apply = ApplyMode.Modulate;
    private MinificationFilter minificationFilter = MinificationFilter.NearestNeighborNoMipMaps;
    private MagnificationFilter magnificationFilter = MagnificationFilter.NearestNeighbor;
    private EnvironmentalMapMode envMapMode = EnvironmentalMapMode.None;
    private RenderToTextureType rttSource = RenderToTextureType.RGBA;
    
    private int memReq = 0;
    private boolean hasBorder = false;

    // The following will only used if apply is set to ApplyMode.Combine
    private CombinerFunctionRGB combineFuncRGB = CombinerFunctionRGB.Modulate;
    private CombinerSource combineSrc0RGB = CombinerSource.CurrentTexture;
    private CombinerSource combineSrc1RGB = CombinerSource.Previous;
    private CombinerSource combineSrc2RGB = CombinerSource.Constant;
    private CombinerOperandRGB combineOp0RGB = CombinerOperandRGB.SourceColor;
    private CombinerOperandRGB combineOp1RGB = CombinerOperandRGB.SourceColor;
    private CombinerOperandRGB combineOp2RGB = CombinerOperandRGB.SourceAlpha;
    private CombinerScale combineScaleRGB = CombinerScale.One;

    private CombinerFunctionAlpha combineFuncAlpha = CombinerFunctionAlpha.Modulate;
    private CombinerSource combineSrc0Alpha = CombinerSource.CurrentTexture;
    private CombinerSource combineSrc1Alpha = CombinerSource.Previous;
    private CombinerSource combineSrc2Alpha = CombinerSource.Constant;
    private CombinerOperandAlpha combineOp0Alpha = CombinerOperandAlpha.SourceAlpha;
    private CombinerOperandAlpha combineOp1Alpha = CombinerOperandAlpha.SourceAlpha;
    private CombinerOperandAlpha combineOp2Alpha = CombinerOperandAlpha.SourceAlpha;
    private CombinerScale combineScaleAlpha = CombinerScale.One;

    private TextureKey key = null;
    private transient boolean storeTexture = DEFAULT_STORE_TEXTURE;

    private DepthTextureCompareMode depthCompareMode = DepthTextureCompareMode.None;
    private DepthTextureCompareFunc depthCompareFunc = DepthTextureCompareFunc.GreaterThanEqual;
    private DepthTextureMode depthMode = DepthTextureMode.Intensity;
    
    /**
     * Constructor instantiates a new <code>Texture</code> object with default
     * attributes.
     */
    public Texture() {
        memReq = 0;
    }
    
    /**
     * <code>setBlendColor</code> sets a color that is used with
     * CombinerSource.Constant
     * 
     * @param color
     *            the new blend color - or null for the default (black)
     */
    public void setBlendColor(ColorRGBA color) {
        this.blendColor = color != null ? color.clone() : null;
    }

    /**
     * <code>setBorderColor</code> sets the color used when texture operations
     * encounter the border of a texture.
     * 
     * @param color
     *            the new border color - or null for the default (black)
     */
    public void setBorderColor(ColorRGBA color) {
        this.borderColor = color != null ? color.clone() : null;
    }

    /**
     * @return the MinificationFilterMode of this texture.
     */
    public MinificationFilter getMinificationFilter() {
        return minificationFilter;
    }

    /**
     * @param minificationFilter
     *            the new MinificationFilterMode for this texture.
     * @throws IllegalArgumentException
     *             if minificationFilter is null
     */
    public void setMinificationFilter(MinificationFilter minificationFilter) {
        if (minificationFilter == null) {
            throw new IllegalArgumentException(
                    "minificationFilter can not be null.");
        }
        this.minificationFilter = minificationFilter;
    }

    /**
     * @return the MagnificationFilterMode of this texture.
     */
    public MagnificationFilter getMagnificationFilter() {
        return magnificationFilter;
    }

    /**
     * @param magnificationFilter
     *            the new MagnificationFilter for this texture.
     * @throws IllegalArgumentException
     *             if magnificationFilter is null
     */
    public void setMagnificationFilter(MagnificationFilter magnificationFilter) {
        if (magnificationFilter == null) {
            throw new IllegalArgumentException(
                    "magnificationFilter can not be null.");
        }
        this.magnificationFilter = magnificationFilter;
    }

    /**
     * <code>setApply</code> sets the apply mode for this texture.
     * 
     * @param apply
     *            the apply mode for this texture.
     * @throws IllegalArgumentException
     *             if apply is null
     */
    public void setApply(ApplyMode apply) {
        if (apply == null) {
            throw new IllegalArgumentException("apply can not be null.");
        }
        this.apply = apply;
    }

    /**
     * <code>setImage</code> sets the image object that defines the texture.
     * 
     * @param image
     *            the image that defines the texture.
     */
    public void setImage(Image image) {
        this.image = image;
        updateMemoryReq();
    }

    /**
     * <code>getTextureId</code> returns the texture id of this texture. This
     * id is required to be unique to any other texture objects running in the
     * same JVM. However, no guarantees are made that it will be unique, and as
     * such, the user is responsible for this.
     * 
     * @return the id of the texture.
     */
    public int getTextureId() {
        return textureId;
    }

    /**
     * <code>setTextureId</code> sets the texture id for this texture. Zero
     * means no id is set.
     * 
     * @param textureId
     *            the texture id of this texture.
     */
    public void setTextureId(int textureId) {
        this.textureId = textureId;
    }

    /**
     * <code>getImage</code> returns the image data that makes up this
     * texture. If no image data has been set, this will return null.
     * 
     * @return the image data that makes up the texture.
     */
    public Image getImage() {
        return image;
    }

    /**
     * <code>getApply</code> returns the apply mode for the texture.
     * 
     * @return the apply mode of the texture.
     */
    public ApplyMode getApply() {
        return apply;
    }

    /**
     * <code>getBlendColor</code> returns the color set to be used with
     * CombinerSource.Constant for this texture (as applicable) If null, black
     * is assumed.
     * 
     * @return the blend color.
     */
    public ColorRGBA getBlendColor() {
        return blendColor;
    }

    /**
     * <code>getBorderColor</code> returns the color to be used for border
     * operations. If null, black is assumed.
     * 
     * @return the border color.
     */
    public ColorRGBA getBorderColor() {
        return borderColor;
    }

    /**
     * <code>setWrap</code> sets the wrap mode of this texture for a
     * particular axis.
     * 
     * @param axis
     *            the texture axis to define a wrapmode on.
     * @param mode
     *            the wrap mode for the given axis of the texture.
     * @throws IllegalArgumentException
     *             if axis or mode are null or invalid for this type of texture
     */
    public abstract void setWrap(WrapAxis axis, WrapMode mode);

    /**
     * <code>setWrap</code> sets the wrap mode of this texture for all axis.
     * 
     * @param mode
     *            the wrap mode for the given axis of the texture.
     * @throws IllegalArgumentException
     *             if mode is null or invalid for this type of texture
     */
    public abstract void setWrap(WrapMode mode);

    /**
     * <code>getWrap</code> returns the wrap mode for a given coordinate axis
     * on this texture.
     * 
     * @param axis
     *            the axis to return for
     * @return the wrap mode of the texture.
     * @throws IllegalArgumentException
     *             if axis is null or invalid for this type of texture
     */
    public abstract WrapMode getWrap(WrapAxis axis);
    
    public abstract Type getType();
    

⌨️ 快捷键说明

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