📄 renderingattributes.java
字号:
rt.initDepthBufferEnable(attr.getDepthBufferEnable()); rt.initDepthBufferWriteEnable(attr.getDepthBufferWriteEnable()); rt.initDepthTestFunction(attr.getDepthTestFunction()); rt.initAlphaTestValue(attr.getAlphaTestValue()); rt.initAlphaTestFunction(attr.getAlphaTestFunction()); rt.initVisible(attr.getVisible()); rt.initIgnoreVertexColors(attr.getIgnoreVertexColors()); rt.initRasterOpEnable(attr.getRasterOpEnable()); rt.initRasterOp(attr.getRasterOp()); rt.initStencilEnable(attr.getStencilEnable()); int[] ops = new int[3]; attr.getStencilOp(ops); rt.initStencilOp(ops[0], ops[1], ops[2]); attr.getStencilFunction(ops); rt.initStencilFunction(ops[0], ops[1], ops[2]); rt.initStencilWriteMask(attr.getStencilWriteMask()); } /** * Set depth test function. This function is used to compare each * incoming (source) per-pixel depth test value with the stored per-pixel * depth value in the frame buffer. If the test * passes, the pixel is written, otherwise the pixel is not * written. * @param function the new depth test function. One of * ALWAYS, NEVER, EQUAL, NOT_EQUAL, LESS, LESS_OR_EQUAL, GREATER, * or GREATER_OR_EQUAL. * The default value is LESS_OR_EQUAL. * @exception CapabilityNotSetException if appropriate capability is * not set and this object is part of live or compiled scene graph * * @since Java 3D 1.4 */ public void setDepthTestFunction(int function){ if (isLiveOrCompiled()) if (!this.getCapability(ALLOW_DEPTH_TEST_FUNCTION_WRITE)) throw new CapabilityNotSetException(J3dI18N.getString("RenderingAttributes14")); if (isLive()) ((RenderingAttributesRetained)this.retained).setDepthTestFunction(function); else ((RenderingAttributesRetained)this.retained).initDepthTestFunction(function); } /** * Retrieves current depth test function. * @return the current depth test function * @exception CapabilityNotSetException if appropriate capability is * not set and this object is part of live or compiled scene graph * * @since Java 3D 1.4 */ public int getDepthTestFunction(){ if (isLiveOrCompiled()) if (!this.getCapability(ALLOW_DEPTH_TEST_FUNCTION_READ)) throw new CapabilityNotSetException(J3dI18N.getString("RenderingAttributes15")); return ((RenderingAttributesRetained)this.retained).getDepthTestFunction(); } /** * Enables or disables the stencil buffer for this RenderingAttributes * component object. If the stencil buffer is disabled, the * stencil operation and function are ignored. If a scene graph * is rendered on a Canvas3D that does not have a stencil buffer, * the stencil buffer will be implicitly disabled for that canvas. * * @param state true or false to enable or disable stencil buffer * operations. * If this is set to false, the stencilOp and stencilFunction parameters * are not used. * * @exception CapabilityNotSetException if appropriate capability is * not set and this object is part of live or compiled scene graph * * @see GraphicsConfigTemplate3D#setStencilSize * * @since Java 3D 1.4 */ public void setStencilEnable(boolean state) { if (isLiveOrCompiled()) { if (!this.getCapability(ALLOW_STENCIL_ATTRIBUTES_WRITE)) { throw new CapabilityNotSetException(J3dI18N.getString("RenderingAttributes16")); } } if (isLive()) ((RenderingAttributesRetained)this.retained).setStencilEnable(state); else ((RenderingAttributesRetained)this.retained).initStencilEnable(state); } /** * Retrieves the stencil buffer enable flag for this RenderingAttributes * object. * * @return true if stencil buffer operations are enabled; false * if stencil buffer operations are disabled. * * @exception CapabilityNotSetException if appropriate capability is * not set and this object is part of live or compiled scene graph * * @since Java 3D 1.4 */ public boolean getStencilEnable() { if (isLiveOrCompiled()) { if (!this.getCapability(ALLOW_STENCIL_ATTRIBUTES_READ)) { throw new CapabilityNotSetException(J3dI18N.getString("RenderingAttributes17")); } } return ((RenderingAttributesRetained)this.retained).getStencilEnable(); } /** * Sets the stencil operations for this RenderingAttributes object to the * specified parameters. * * @param failOp operation performed when the stencil test fails, one of: * STENCIL_KEEP, STENCIL_ZERO, STENCIL_REPLACE, STENCIL_INCR, STENCIL_DECR, * or STENCIL_INVERT. * * @param zFailOp operation performed when the stencil test passes and the * depth test fails, one of: * STENCIL_KEEP, STENCIL_ZERO, STENCIL_REPLACE, STENCIL_INCR, STENCIL_DECR, * or STENCIL_INVERT. * * @param zPassOp operation performed when both the stencil test and the * depth test pass, one of: * STENCIL_KEEP, STENCIL_ZERO, STENCIL_REPLACE, STENCIL_INCR, STENCIL_DECR, * or STENCIL_INVERT. * * @exception CapabilityNotSetException if appropriate capability is * not set and this object is part of live or compiled scene graph * * @since Java 3D 1.4 */ public void setStencilOp(int failOp, int zFailOp, int zPassOp) { if (isLiveOrCompiled()) { if (!this.getCapability(ALLOW_STENCIL_ATTRIBUTES_WRITE)) { throw new CapabilityNotSetException(J3dI18N.getString("RenderingAttributes16")); } } if (isLive()) ((RenderingAttributesRetained)this.retained).setStencilOp(failOp, zFailOp, zPassOp); else ((RenderingAttributesRetained)this.retained).initStencilOp(failOp, zFailOp, zPassOp); } /** * Sets the stencil operations for this RenderingAttributes object to the * specified parameters. * * @param stencilOps an array of three integers that specifies the new * set of stencil operations. Element 0 of the array specifies the * <code>failOp</code> parameter, element 1 specifies the * <code>zFailOp</code> parameter, and element 2 specifies the * <code>zPassOp</code> parameter. * * @exception CapabilityNotSetException if appropriate capability is * not set and this object is part of live or compiled scene graph * * @see #setStencilOp(int,int,int) * * @since Java 3D 1.4 */ public void setStencilOp(int[] stencilOps) { if (isLiveOrCompiled()) { if (!this.getCapability(ALLOW_STENCIL_ATTRIBUTES_WRITE)) { throw new CapabilityNotSetException(J3dI18N.getString("RenderingAttributes16")); } } if (isLive()) ((RenderingAttributesRetained)this.retained).setStencilOp(stencilOps[0], stencilOps[1], stencilOps[2]); else ((RenderingAttributesRetained)this.retained).initStencilOp(stencilOps[0], stencilOps[1], stencilOps[2]); } /** * Retrieves the current set of stencil operations, and copies them * into the specified array. The caller must ensure that this array * has been allocated with enough space to hold the results. * * @param stencilOps array that will receive the current set of * three stencil operations. The <code>failOp</code> parameter is copied * into element 0 of the array, the <code>zFailOp</code> parameter is copied * into element 1, and the <code>zPassOp</code> parameter is copied * into element 2. * * @exception CapabilityNotSetException if appropriate capability is * not set and this object is part of live or compiled scene graph * * @since Java 3D 1.4 */ public void getStencilOp(int[] stencilOps) { if (isLiveOrCompiled()) { if (!this.getCapability(ALLOW_STENCIL_ATTRIBUTES_READ)) { throw new CapabilityNotSetException(J3dI18N.getString("RenderingAttributes17")); } } ((RenderingAttributesRetained)this.retained).getStencilOp(stencilOps); } /** * Sets the stencil function, reference value, and comparison mask * for this RenderingAttributes object to the specified parameters. * * @param function the stencil test function, used to compare the * stencil reference value with the stored per-pixel * stencil value in the frame buffer. If the test * passes, the pixel is written, otherwise the pixel is not * written. The stencil function is one of: * ALWAYS, NEVER, EQUAL, NOT_EQUAL, LESS, LESS_OR_EQUAL, GREATER, * or GREATER_OR_EQUAL. * * @param refValue the stencil reference value that is tested against * the stored per-pixel stencil value * * @param compareMask a mask that limits which bits are compared; it is * bitwise-ANDed with both the stencil reference value and the stored * per-pixel stencil value before doing the comparison. * * @exception CapabilityNotSetException if appropriate capability is * not set and this object is part of live or compiled scene graph * * @since Java 3D 1.4 */ public void setStencilFunction(int function, int refValue, int compareMask) { if (isLiveOrCompiled()) { if (!this.getCapability(ALLOW_STENCIL_ATTRIBUTES_WRITE)) { throw new CapabilityNotSetException(J3dI18N.getString("RenderingAttributes16")); } } if (isLive()) ((RenderingAttributesRetained)this.retained).setStencilFunction(function, refValue, compareMask); else ((RenderingAttributesRetained)this.retained).initStencilFunction(function, refValue, compareMask); } /** * Sets the stencil function, reference value, and comparison mask * for this RenderingAttributes object to the specified parameters. * * @param params an array of three integers that specifies the new * stencil function, reference value, and comparison mask. * Element 0 of the array specifies the * stencil function, element 1 specifies the * reference value, and element 2 specifies the * comparison mask. * * @exception CapabilityNotSetException if appropriate capability is * not set and this object is part of live or compiled scene graph * * @see #setStencilFunction(int,int,int) * * @since Java 3D 1.4 */ public void setStencilFunction(int[] params) { if (isLiveOrCompiled()) { if (!this.getCapability(ALLOW_STENCIL_ATTRIBUTES_WRITE)) { throw new CapabilityNotSetException(J3dI18N.getString("RenderingAttributes16")); } } if (isLive()) ((RenderingAttributesRetained)this.retained).setStencilFunction(params[0], params[1], params[2]); else ((RenderingAttributesRetained)this.retained).initStencilFunction(params[0], params[1], params[2]); } /** * Retrieves the stencil function, reference value, and comparison mask, * and copies them into the specified array. The caller must ensure * that this array has been allocated with enough space to hold the results. * * @param params array that will receive the current stencil function, * reference value, and comparison mask. The stencil function is copied * into element 0 of the array, the reference value is copied * into element 1, and the comparison mask is copied * into element 2. * * @exception CapabilityNotSetException if appropriate capability is * not set and this object is part of live or compiled scene graph * * @since Java 3D 1.4 */ public void getStencilFunction(int[] params) { if (isLiveOrCompiled()) { if (!this.getCapability(ALLOW_STENCIL_ATTRIBUTES_READ)) { throw new CapabilityNotSetException(J3dI18N.getString("RenderingAttributes17")); } } ((RenderingAttributesRetained)this.retained).getStencilFunction(params); } /** * Sets the stencil write mask for this RenderingAttributes * object. This mask controls which bits of the * stencil buffer are written. * The default value is <code>~0</code> (all ones). * * @param mask the new stencil write mask. * * @exception CapabilityNotSetException if appropriate capability is * not set and this object is part of live or compiled scene graph * * @since Java 3D 1.4 */ public void setStencilWriteMask(int mask) { if (isLiveOrCompiled()) { if (!this.getCapability(ALLOW_STENCIL_ATTRIBUTES_WRITE)) { throw new CapabilityNotSetException(J3dI18N.getString("RenderingAttributes16")); } } if (isLive()) ((RenderingAttributesRetained)this.retained).setStencilWriteMask(mask); else ((RenderingAttributesRetained)this.retained).initStencilWriteMask(mask); } /** * Retrieves the current stencil write mask for this RenderingAttributes * object. * * @return the stencil write mask. * * @exception CapabilityNotSetException if appropriate capability is * not set and this object is part of live or compiled scene graph * * @since Java 3D 1.4 */ public int getStencilWriteMask() { if (isLiveOrCompiled()) { if (!this.getCapability(ALLOW_STENCIL_ATTRIBUTES_READ)) { throw new CapabilityNotSetException(J3dI18N.getString("RenderingAttributes17")); } } return ((RenderingAttributesRetained)this.retained).getStencilWriteMask(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -