blendstate.java
来自「java 3d game jme 工程开发源代码」· Java 代码 · 共 702 行 · 第 1/2 页
JAVA
702 行
* <code>setBlendEnabled</code> sets whether or not blending is enabled.
*
* @param value
* true to enable the blending, false to disable it.
*/
public void setBlendEnabled(boolean value) {
blendEnabled = value;
setNeedsRefresh(true);
}
/**
* <code>setSrcFunction</code> sets the source function for the blending
* equation for both rgb and alpha values.
*
* @param function
* the source function for the blending equation.
* @throws IllegalArgumentException
* if function is null
*/
public void setSourceFunction(SourceFunction function) {
setSourceFunctionRGB(function);
setSourceFunctionAlpha(function);
}
/**
* <code>setSrcFunction</code> sets the source function for the blending
* equation. If supportsSeparateFunc is false, this value will be used for
* RGB and Alpha.
*
* @param function
* the source function for the blending equation.
* @throws IllegalArgumentException
* if function is null
*/
public void setSourceFunctionRGB(SourceFunction function) {
if (function == null) {
throw new IllegalArgumentException("function can not be null.");
}
sourceFunctionRGB = function;
setNeedsRefresh(true);
}
/**
* <code>setSourceFunctionAlpha</code> sets the source function for the blending
* equation used with alpha values.
*
* @param function
* the source function for the blending equation for alpha values.
* @throws IllegalArgumentException
* if function is null
*/
public void setSourceFunctionAlpha(SourceFunction function) {
if (function == null) {
throw new IllegalArgumentException("function can not be null.");
}
sourceFunctionAlpha = function;
setNeedsRefresh(true);
}
/**
* <code>getSourceFunction</code> returns the source function for the
* blending function.
*
* @return the source function for the blending function.
*/
public SourceFunction getSourceFunctionRGB() {
return sourceFunctionRGB;
}
/**
* <code>getSourceFunction</code> returns the source function for the
* blending function.
*
* @return the source function for the blending function.
*/
public SourceFunction getSourceFunctionAlpha() {
return sourceFunctionAlpha;
}
/**
* <code>setDestinationFunction</code> sets the destination function for
* the blending equation for both Alpha and RGB values.
*
* @param function
* the destination function for the blending equation.
* @throws IllegalArgumentException
* if function is null
*/
public void setDestinationFunction(DestinationFunction function) {
setDestinationFunctionRGB(function);
setDestinationFunctionAlpha(function);
}
/**
* <code>setDestinationFunctionRGB</code> sets the destination function
* for the blending equation. If supportsSeparateFunc is false, this value
* will be used for RGB and Alpha.
*
* @param function
* the destination function for the blending equation for RGB
* values.
* @throws IllegalArgumentException
* if function is null
*/
public void setDestinationFunctionRGB(DestinationFunction function) {
if (function == null) {
throw new IllegalArgumentException("function can not be null.");
}
destinationFunctionRGB = function;
setNeedsRefresh(true);
}
/**
* <code>setDestinationFunctionAlpha</code> sets the destination function
* for the blending equation.
*
* @param function
* the destination function for the blending equation for Alpha
* values.
* @throws IllegalArgumentException
* if function is null
*/
public void setDestinationFunctionAlpha(DestinationFunction function) {
if (function == null) {
throw new IllegalArgumentException("function can not be null.");
}
destinationFunctionAlpha = function;
setNeedsRefresh(true);
}
/**
* <code>getDestinationFunction</code> returns the destination function
* for the blending function.
*
* @return the destination function for the blending function.
*/
public DestinationFunction getDestinationFunctionRGB() {
return destinationFunctionRGB;
}
/**
* <code>getDestinationFunction</code> returns the destination function
* for the blending function.
*
* @return the destination function for the blending function.
*/
public DestinationFunction getDestinationFunctionAlpha() {
return destinationFunctionAlpha;
}
public void setBlendEquation(BlendEquation blendEquation) {
setBlendEquationRGB(blendEquation);
setBlendEquationAlpha(blendEquation);
}
public void setBlendEquationRGB(BlendEquation blendEquation) {
if (blendEquation == null) {
throw new IllegalArgumentException("blendEquation can not be null.");
}
this.blendEquationRGB = blendEquation;
}
public void setBlendEquationAlpha(BlendEquation blendEquation) {
if (blendEquation == null) {
throw new IllegalArgumentException("blendEquation can not be null.");
}
this.blendEquationAlpha = blendEquation;
}
public BlendEquation getBlendEquationRGB() {
return blendEquationRGB;
}
public BlendEquation getBlendEquationAlpha() {
return blendEquationAlpha;
}
/**
* <code>isTestEnabled</code> returns true if alpha testing is enabled,
* false otherwise.
*
* @return true if alpha testing is enabled, false otherwise.
*/
public boolean isTestEnabled() {
return testEnabled;
}
/**
* <code>setTestEnabled</code> turns alpha testing on and off. True turns
* on the testing, while false diables it.
*
* @param value
* true to enabled alpha testing, false to disable it.
*/
public void setTestEnabled(boolean value) {
testEnabled = value;
setNeedsRefresh(true);
}
/**
* <code>setTestFunction</code> sets the testing function used for the
* alpha testing. If an invalid value is passed, the default TF_ALWAYS is
* used.
*
* @param function
* the testing function used for the alpha testing.
* @throws IllegalArgumentException
* if function is null
*/
public void setTestFunction(TestFunction function) {
if (function == null) {
throw new IllegalArgumentException("function can not be null.");
}
testFunction = function;
setNeedsRefresh(true);
}
/**
* <code>getTestFunction</code> returns the testing function used for the
* alpha testing.
*
* @return the testing function used for the alpha testing.
*/
public TestFunction getTestFunction() {
return testFunction;
}
/**
* <code>setReference</code> sets the reference value that incoming alpha
* values are compared to when doing alpha testing. This is clamped to [0, 1].
*
* @param reference
* the reference value that alpha values are compared to.
*/
public void setReference(float reference) {
if (reference < 0) {
reference = 0;
}
if (reference > 1) {
reference = 1;
}
this.reference = reference;
setNeedsRefresh(true);
}
/**
* @return true if we support setting a constant color for use with
* *Constant* type BlendFunctions.
*/
public static boolean supportsConstantColor() {
return supportsConstantColor;
}
/**
* @return true if we support setting rgb and alpha functions separately for
* source and destination.
*/
public static boolean supportsSeparateFunctions() {
return supportsSeparateFunc;
}
/**
* @return true if we support setting the blend equation
*/
public static boolean supportsEquation() {
return supportsEq;
}
/**
* @return true if we support setting the blend equation for alpha and rgb
* separately
*/
public static boolean supportsSeparateEquations() {
return supportsSeparateEq;
}
/**
* @return true if we support using min and max blend equations
*/
public static boolean supportsMinMaxEquations() {
return supportsMinMax;
}
/**
* @return true if we support using subtract blend equations
*/
public static boolean supportsSubtractEquations() {
return supportsSubtract;
}
/**
* <code>getReference</code> returns the reference value that incoming
* alpha values are compared to.
*
* @return the reference value that alpha values are compared to.
*/
public float getReference() {
return reference;
}
/**
* @return the color used in constant blending functions. If null and a
* *Constant* function is set, (0,0,0,0) is used.
*/
public ColorRGBA getConstantColor() {
return constantColor;
}
public void setConstantColor(ColorRGBA constantColor) {
this.constantColor = constantColor;
}
public void write(JMEExporter e) throws IOException {
super.write(e);
OutputCapsule capsule = e.getCapsule(this);
capsule.write(blendEnabled, "blendEnabled", false);
capsule.write(sourceFunctionRGB, "sourceFunctionRGB", SourceFunction.SourceAlpha);
capsule.write(destinationFunctionRGB, "destinationFunctionRGB", DestinationFunction.OneMinusSourceAlpha);
capsule.write(blendEquationRGB, "blendEquationRGB", BlendEquation.Add);
capsule.write(sourceFunctionAlpha, "sourceFunctionAlpha", SourceFunction.SourceAlpha);
capsule.write(destinationFunctionAlpha, "destinationFunctionAlpha", DestinationFunction.OneMinusSourceAlpha);
capsule.write(blendEquationAlpha, "blendEquationAlpha", BlendEquation.Add);
capsule.write(testEnabled, "testEnabled", false);
capsule.write(testFunction, "test", TestFunction.Always);
capsule.write(reference, "reference", 0);
capsule.write(constantColor, "constantColor", null);
}
public void read(JMEImporter e) throws IOException {
super.read(e);
InputCapsule capsule = e.getCapsule(this);
blendEnabled = capsule.readBoolean("blendEnabled", false);
sourceFunctionRGB = capsule.readEnum("sourceFunctionRGB", SourceFunction.class, SourceFunction.SourceAlpha);
destinationFunctionRGB = capsule.readEnum("destinationFunctionRGB", DestinationFunction.class, DestinationFunction.OneMinusSourceAlpha);
blendEquationRGB = capsule.readEnum("blendEquationRGB", BlendEquation.class, BlendEquation.Add);
sourceFunctionAlpha = capsule.readEnum("sourceFunctionAlpha", SourceFunction.class, SourceFunction.SourceAlpha);
destinationFunctionAlpha = capsule.readEnum("destinationFunctionAlpha", DestinationFunction.class, DestinationFunction.OneMinusSourceAlpha);
blendEquationAlpha = capsule.readEnum("blendEquationAlpha", BlendEquation.class, BlendEquation.Add);
testEnabled = capsule.readBoolean("testEnabled", false);
testFunction = capsule.readEnum("test", TestFunction.class, TestFunction.Always);
reference = capsule.readFloat("reference", 0);
constantColor = (ColorRGBA) capsule.readSavable("constantColor", null);
}
public Class getClassTag() {
return BlendState.class;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?