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

📄 texture.java

📁 java 3d game jme 工程开发源代码
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
            if (this.getCombineScaleAlpha() != that.getCombineScaleAlpha())
                return false;
            if (this.getCombineScaleRGB() != that.getCombineScaleRGB())
                return false;
            if (this.getCombineSrc0Alpha() != that.getCombineSrc0Alpha())
                return false;
            if (this.getCombineSrc0RGB() != that.getCombineSrc0RGB())
                return false;
            if (this.getCombineSrc1Alpha() != that.getCombineSrc1Alpha())
                return false;
            if (this.getCombineSrc1RGB() != that.getCombineSrc1RGB())
                return false;
            if (this.getCombineSrc2Alpha() != that.getCombineSrc2Alpha())
                return false;
            if (this.getCombineSrc2RGB() != that.getCombineSrc2RGB())
                return false;
            if (this.getEnvironmentalMapMode() != that
                    .getEnvironmentalMapMode())
                return false;
            if (this.getMagnificationFilter() != that.getMagnificationFilter())
                return false;
            if (this.getMinificationFilter() != that.getMinificationFilter())
                return false;
            if (this.getBlendColor() != null
                    && !this.getBlendColor().equals(that.getBlendColor()))
                return false;
            if (this.getBlendColor() == null && that.getBlendColor() != null)
                return false;
        }
        return true;
    }

    public abstract Texture createSimpleClone();

    /**
     * Retreive a basic clone of this Texture (ie, clone everything but the
     * image data, which is shared)
     * 
     * @return Texture
     */
    public Texture createSimpleClone(Texture rVal) {
        rVal.setApply(apply);
        rVal.setCombineFuncAlpha(combineFuncAlpha);
        rVal.setCombineFuncRGB(combineFuncRGB);
        rVal.setCombineOp0Alpha(combineOp0Alpha);
        rVal.setCombineOp0RGB(combineOp0RGB);
        rVal.setCombineOp1Alpha(combineOp1Alpha);
        rVal.setCombineOp1RGB(combineOp1RGB);
        rVal.setCombineOp2Alpha(combineOp2Alpha);
        rVal.setCombineOp2RGB(combineOp2RGB);
        rVal.setCombineScaleAlpha(combineScaleAlpha);
        rVal.setCombineScaleRGB(combineScaleRGB);
        rVal.setCombineSrc0Alpha(combineSrc0Alpha);
        rVal.setCombineSrc0RGB(combineSrc0RGB);
        rVal.setCombineSrc1Alpha(combineSrc1Alpha);
        rVal.setCombineSrc1RGB(combineSrc1RGB);
        rVal.setCombineSrc2Alpha(combineSrc2Alpha);
        rVal.setCombineSrc2RGB(combineSrc2RGB);
        rVal.setEnvironmentalMapMode(envMapMode);
        rVal.setMinificationFilter(minificationFilter);
        rVal.setMagnificationFilter(magnificationFilter);
        rVal.setHasBorder(hasBorder);
        rVal.setAnisotropicFilterPercent(anisotropicFilterPercent);
        rVal.setImage(image); // NOT CLONED.
        rVal.memReq = memReq;
        rVal.setImageLocation(imageLocation);
        rVal.setTextureId(textureId);
        rVal.setBlendColor(blendColor != null ? blendColor.clone() : null);
        if (scale != null)
            rVal.setScale(scale);
        if (translation != null)
            rVal.setTranslation(translation);
        if (rotation != null)
            rVal.setRotation(rotation);
        if (matrix != null)
            rVal.setMatrix(matrix);
        if (getTextureKey() != null) {
            rVal.setTextureKey(getTextureKey());
        }
        return rVal;
    }

    /**
     * @return Returns the rotation.
     */
    public Quaternion getRotation() {
        return rotation;
    }

    /**
     * @param rotation
     *            The rotation to set.
     */
    public void setRotation(Quaternion rotation) {
        this.rotation = rotation;
    }

    /**
     * @return the texture matrix set on this texture or null if none is set.
     */
    public Matrix4f getMatrix() {
        return matrix;
    }

    /**
     * @param matrix
     *            The matrix to set on this Texture. If null, rotation, scale
     *            and/or translation will be used.
     */
    public void setMatrix(Matrix4f matrix) {
        this.matrix = matrix;
    }

    /**
     * @return Returns the scale.
     */
    public Vector3f getScale() {
        return scale;
    }

    /**
     * @param scale
     *            The scale to set.
     */
    public void setScale(Vector3f scale) {
        this.scale = scale;
    }

    /**
     * @return Returns the translation.
     */
    public Vector3f getTranslation() {
        return translation;
    }

    /**
     * @param translation
     *            The translation to set.
     */
    public void setTranslation(Vector3f translation) {
        this.translation = translation;
    }

    /**
     * @return Returns the rttSource.
     */
    public RenderToTextureType getRTTSource() {
        return rttSource;
    }

    /**
     * @param rttSource
     *            The rttSource to set.
     * @throws IllegalArgumentException
     *             if rttSource is null
     */
    public void setRenderToTextureType(RenderToTextureType rttSource) {
        if (rttSource == null) {
            throw new IllegalArgumentException("invalid RenderToTextureType: null");
        }
        this.rttSource = rttSource;
    }

    /**
     * @return the estimated footprint of this texture in bytes
     */
    public int getMemoryReq() {
        return memReq;
    }

    public void updateMemoryReq() {
        if (image != null) {
            int width = image.getWidth(), height = image.getHeight();
            memReq = width * height;
            int bpp = Image.getEstimatedByteSize(image.getFormat());
            memReq *= bpp;
            if (this.getMinificationFilter().usesMipMapLevels()
                    || image.hasMipmaps()) {
                if (FastMath.isPowerOfTwo(image.getWidth())
                        && FastMath.isPowerOfTwo(image.getHeight()))
                    memReq *= 1.33333f;
                else
                    memReq *= 2.0f; // XXX: Is this right?
            }
        }
    }

    public void write(JMEExporter e) throws IOException {

        OutputCapsule capsule = e.getCapsule(this);
        capsule.write(imageLocation, "imageLocation", null);
        if (storeTexture) {
            capsule.write(image, "image", null);
        }
        capsule.write(blendColor, "blendColor", null);
        capsule.write(borderColor, "borderColor", null);
        capsule.write(translation, "translation", null);
        capsule.write(scale, "scale", null);
        capsule.write(rotation, "rotation", null);
        capsule.write(matrix, "matrix", null);
        capsule.write(hasBorder, "hasBorder", false);
        capsule.write(anisotropicFilterPercent, "anisotropicFilterPercent",
                0.0f);
        capsule.write(minificationFilter, "minificationFilter",
                MinificationFilter.NearestNeighborNoMipMaps);
        capsule.write(magnificationFilter, "magnificationFilter",
                MagnificationFilter.NearestNeighbor);
        capsule.write(apply, "apply", ApplyMode.Modulate);
        capsule.write(envMapMode, "envMapMode", EnvironmentalMapMode.None);
        capsule.write(rttSource, "rttSource", RenderToTextureType.RGBA);
        capsule.write(memReq, "memReq", 0);
        capsule.write(combineFuncRGB, "combineFuncRGB",
                CombinerFunctionRGB.Replace);
        capsule.write(combineFuncAlpha, "combineFuncAlpha",
                CombinerFunctionAlpha.Replace);
        capsule.write(combineSrc0RGB, "combineSrc0RGB",
                CombinerSource.CurrentTexture);
        capsule
                .write(combineSrc1RGB, "combineSrc1RGB",
                        CombinerSource.Previous);
        capsule
                .write(combineSrc2RGB, "combineSrc2RGB",
                        CombinerSource.Constant);
        capsule.write(combineSrc0Alpha, "combineSrc0Alpha",
                CombinerSource.CurrentTexture);
        capsule.write(combineSrc1Alpha, "combineSrc1Alpha",
                CombinerSource.Previous);
        capsule.write(combineSrc2Alpha, "combineSrc2Alpha",
                CombinerSource.Constant);
        capsule.write(combineOp0RGB, "combineOp0RGB",
                CombinerOperandRGB.SourceColor);
        capsule.write(combineOp1RGB, "combineOp1RGB",
                CombinerOperandRGB.SourceColor);
        capsule.write(combineOp2RGB, "combineOp2RGB",
                CombinerOperandRGB.SourceAlpha);
        capsule.write(combineOp0Alpha, "combineOp0Alpha",
                CombinerOperandAlpha.SourceAlpha);
        capsule.write(combineOp1Alpha, "combineOp1Alpha",
                CombinerOperandAlpha.SourceAlpha);
        capsule.write(combineOp2Alpha, "combineOp2Alpha",
                CombinerOperandAlpha.SourceAlpha);
        capsule.write(combineScaleRGB, "combineScaleRGB", CombinerScale.One);
        capsule
                .write(combineScaleAlpha, "combineScaleAlpha",
                        CombinerScale.One);
        if (!storeTexture) {
            capsule.write(key, "textureKey", null);
        }
    }

    public void read(JMEImporter e) throws IOException {
        InputCapsule capsule = e.getCapsule(this);
        imageLocation = capsule.readString("imageLocation", null);
        image = (Image) capsule.readSavable("image", null);
        if (image == null) {
            key = (TextureKey) capsule.readSavable("textureKey", null);
            if (key != null && key.getLocation() != null) {
                TextureManager.loadTexture(this, key);
            }
        }
        blendColor = (ColorRGBA) capsule.readSavable("blendColor", null);
        borderColor = (ColorRGBA) capsule.readSavable("borderColor", null);
        translation = (Vector3f) capsule.readSavable("translation", null);
        scale = (Vector3f) capsule.readSavable("scale", null);
        rotation = (Quaternion) capsule.readSavable("rotation", null);
        matrix = (Matrix4f) capsule.readSavable("matrix", null);
        hasBorder = capsule.readBoolean("hasBorder", false);
        anisotropicFilterPercent = capsule.readFloat(
                "anisotropicFilterPercent", 0.0f);
        minificationFilter = capsule.readEnum("minificationFilter",
                MinificationFilter.class,
                MinificationFilter.NearestNeighborNoMipMaps);
        magnificationFilter = capsule.readEnum("magnificationFilter",
                MagnificationFilter.class, MagnificationFilter.NearestNeighbor);
        apply = capsule.readEnum("apply", ApplyMode.class, ApplyMode.Modulate);
        envMapMode = capsule.readEnum("envMapMode", EnvironmentalMapMode.class,
                EnvironmentalMapMode.None);
        rttSource = capsule.readEnum("rttSource", RenderToTextureType.class,
                RenderToTextureType.RGBA);
        memReq = capsule.readInt("memReq", 0);
        combineFuncRGB = capsule.readEnum("combineFuncRGB",
                CombinerFunctionRGB.class, CombinerFunctionRGB.Replace);
        combineFuncAlpha = capsule.readEnum("combineFuncAlpha",
                CombinerFunctionAlpha.class, CombinerFunctionAlpha.Replace);
        combineSrc0RGB = capsule.readEnum("combineSrc0RGB",
                CombinerSource.class, CombinerSource.CurrentTexture);
        combineSrc1RGB = capsule.readEnum("combineSrc1RGB",
                CombinerSource.class, CombinerSource.Previous);
        combineSrc2RGB = capsule.readEnum("combineSrc2RGB",
                CombinerSource.class, CombinerSource.Constant);
        combineSrc0Alpha = capsule.readEnum("combineSrc0Alpha",
                CombinerSource.class, CombinerSource.CurrentTexture);
        combineSrc1Alpha = capsule.readEnum("combineSrc1Alpha",
                CombinerSource.class, CombinerSource.Previous);
        combineSrc2Alpha = capsule.readEnum("combineSrc2Alpha",
                CombinerSource.class, CombinerSource.Constant);
        combineOp0RGB = capsule.readEnum("combineOp0RGB",
                CombinerOperandRGB.class, CombinerOperandRGB.SourceColor);
        combineOp1RGB = capsule.readEnum("combineOp1RGB",
                CombinerOperandRGB.class, CombinerOperandRGB.SourceColor);
        combineOp2RGB = capsule.readEnum("combineOp2RGB",
                CombinerOperandRGB.class, CombinerOperandRGB.SourceAlpha);
        combineOp0Alpha = capsule.readEnum("combineOp0Alpha",
                CombinerOperandAlpha.class, CombinerOperandAlpha.SourceAlpha);
        combineOp1Alpha = capsule.readEnum("combineOp1Alpha",
                CombinerOperandAlpha.class, CombinerOperandAlpha.SourceAlpha);
        combineOp2Alpha = capsule.readEnum("combineOp2Alpha",
                CombinerOperandAlpha.class, CombinerOperandAlpha.SourceAlpha);
        combineScaleRGB = capsule.readEnum("combineScaleRGB",
                CombinerScale.class, CombinerScale.One);
        combineScaleAlpha = capsule.readEnum("combineScaleAlpha",
                CombinerScale.class, CombinerScale.One);
    }

    public Class<? extends Texture> getClassTag() {
        return this.getClass();
    }

    public void setTextureKey(TextureKey tkey) {
        this.key = tkey;
    }

    public TextureKey getTextureKey() {
        return key;
    }

    public boolean isStoreTexture() {
        return storeTexture;
    }

    public void setStoreTexture(boolean storeTexture) {
        this.storeTexture = storeTexture;
    }

    public boolean hasBorder() {
        return hasBorder;
    }

    public void setHasBorder(boolean hasBorder) {
        this.hasBorder = hasBorder;
    }

    /**
     * Get the depth texture compare function 
     * 
     * @return The depth texture compare function
     */
	public DepthTextureCompareFunc getDepthCompareFunc() {
		return depthCompareFunc;
	}

    /**
     * Set the depth texture compare function 
     * 
     * param depthCompareFunc The depth texture compare function
     */
	public void setDepthCompareFunc(DepthTextureCompareFunc depthCompareFunc) {
		this.depthCompareFunc = depthCompareFunc;
	}

	/**
	 * Get the depth texture apply mode
	 * 
	 * @return The depth texture apply mode
	 */
	public DepthTextureMode getDepthMode() {
		return depthMode;
	}

	/**
	 * Set the depth texture apply mode
	 * 
	 * param depthMode The depth texture apply mode
	 */
	public void setDepthMode(DepthTextureMode depthMode) {
		this.depthMode = depthMode;
	}

	/**
	 * Get the depth texture compare mode
	 * 
	 * @return The depth texture compare mode
	 */
	public DepthTextureCompareMode getDepthCompareMode() {
		return depthCompareMode;
	}

	/**
	 * Set the depth texture compare mode
	 * 
	 * @param depthCompareMode The depth texture compare mode
	 */
	public void setDepthCompareMode(DepthTextureCompareMode depthCompareMode) {
		this.depthCompareMode = depthCompareMode;
	}
}

⌨️ 快捷键说明

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