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

📄 renderingattributesretained.java

📁 JAVA3D矩陈的相关类
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* * $RCSfile: RenderingAttributesRetained.java,v $ * * Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved. * * Use is subject to license terms. * * $Revision: 1.8 $ * $Date: 2007/04/12 17:34:06 $ * $State: Exp $ */package javax.media.j3d;import java.util.ArrayList;/** * The RenderingAttributes object defines all rendering state that can be set * as a component object of a Shape3D node. */class RenderingAttributesRetained extends NodeComponentRetained {    // A list of pre-defined bits to indicate which component    // in this RenderingAttributes object changed.    static final int DEPTH_ENABLE      	        = 0x01;    static final int DEPTH_WRITE_ENABLE      	= 0x02;    static final int ALPHA_TEST_VALUE      	= 0x04;    static final int ALPHA_TEST_FUNC      	= 0x08;    static final int VISIBLE               	= 0x10;    static final int IGNORE_VCOLOR             	= 0x20;    static final int RASTER_OP_ENABLE		= 0x40;    static final int RASTER_OP_VALUE		= 0x80;    static final int DEPTH_TEST_FUNC      	= 0x100;    static final int STENCIL_ENABLE      	= 0x200;    static final int STENCIL_OP_VALUES      	= 0x400;    static final int STENCIL_FUNC      	        = 0x800;    static final int STENCIL_WRITE_MASK         = 0x1000;    // depth buffer Enable for hidden surface removal    boolean depthBufferEnable = true;    boolean depthBufferWriteEnable = true;        float alphaTestValue = 0.0f;        int alphaTestFunction = RenderingAttributes.ALWAYS;    int depthTestFunction = RenderingAttributes.LESS_OR_EQUAL;    boolean visible  = true;    boolean ignoreVertexColors = false;    // raster operation    boolean rasterOpEnable = false;    int rasterOp = RenderingAttributes.ROP_COPY;    // stencil operation    boolean stencilEnable = false;    int stencilFailOp = RenderingAttributes.STENCIL_KEEP;    int stencilZFailOp = RenderingAttributes.STENCIL_KEEP;    int stencilZPassOp = RenderingAttributes.STENCIL_KEEP;    int stencilFunction = RenderingAttributes.ALWAYS;    int stencilReferenceValue = 0;    int stencilCompareMask = ~0;    int stencilWriteMask = ~0;    // depth buffer comparison function. Used by multi-texturing only    //[PEPE] NOTE: they are both unused. Candidates for removal.    static final int LESS = 0;    static final int LEQUAL = 1;    /**     * Sets the visibility flag for this RenderingAttributes component object.      * @param visible true or false to enable or disable visibility     * @exception CapabilityNotSetException if appropriate capability is      * not set and this object is part of live or compiled scene graph     *     * @see View#setVisibilityPolicy     */    final void initVisible(boolean state){	visible = state;    }        /**     * Sets the visibility flag for this RenderingAttributes     * component object.  Invisible objects are not rendered (subject to     * the visibility policy for the current view), but they can be picked     * or collided with.     * @param visible true or false to enable or disable visibility     * @exception CapabilityNotSetException if appropriate capability is      * not set and this object is part of live or compiled scene graph     *     * @see View#setVisibilityPolicy     */    final void setVisible(boolean  state){		// Optimize : If new state equal to current state, should I simply return ?	// Is it safe ?	initVisible(state);	// Need to call sendMessage twice. Not an efficient approach, but	// it simplified code logic and speed up the common case; where	// perUniv is false.	sendMessage(VISIBLE, (state ? Boolean.TRUE: Boolean.FALSE));    }        /**     * Retrieves the visibility flag for this RenderingAttributes object.     * @return true if the object is visible; false     * if the object is invisible.     * @exception CapabilityNotSetException if appropriate capability is      * not set and this object is part of live or compiled scene graph     */    final boolean getVisible() {   	return visible;    }     /**     * Enables or disables vertex colors for this RenderAttributes     * component object.     * @param state true or false to enable or disable vertex colors     */   final void initIgnoreVertexColors(boolean state) {	ignoreVertexColors = state;    }    /**     * Enables or disables vertex colors for this RenderAttributes     * component object and sends a      * message notifying the interested structures of the change.     * @param state true or false to enable or disable depth vertex colors     */    final void setIgnoreVertexColors(boolean state) {	initIgnoreVertexColors(state);	sendMessage(IGNORE_VCOLOR,		    (state ? Boolean.TRUE: Boolean.FALSE));    }    /**     * Retrieves the state of vertex color Enable flag     * @return true if vertex colors are enabled, false     * if vertex colors are disabled     */    final boolean getIgnoreVertexColors() {	return ignoreVertexColors;    }    /**     * Enables or disables depth buffer mode for this RenderAttributes     * component object.     * @param state true or false to enable or disable depth buffer mode     */    final void initDepthBufferEnable(boolean state){	depthBufferEnable = state;    }    /**     * Enables or disables depth buffer mode for this RenderAttributes     * component object and sends a      * message notifying the interested structures of the change.     * @param state true or false to enable or disable depth buffer mode     */    final void setDepthBufferEnable(boolean state){	initDepthBufferEnable(state);	sendMessage(DEPTH_ENABLE, (state ? Boolean.TRUE: Boolean.FALSE));    }    /**     * Retrieves the state of zBuffer Enable flag     * @return true if depth buffer mode is enabled, false     * if depth buffer mode is disabled     */    final boolean getDepthBufferEnable(){	return depthBufferEnable;    }    /**     * Enables or disables writing the depth buffer for this object.     * During the transparent rendering pass,     * this attribute can be overridden by     * the depthBufferFreezeTransparent attribute in the View object.     * @param state true or false to enable or disable depth buffer Write mode     * @see View#setDepthBufferFreezeTransparent     */    final void initDepthBufferWriteEnable(boolean state){	depthBufferWriteEnable = state;    }    /**     * Enables or disables writing the depth buffer for this object and sends     * a message notifying the interested structures of the change.     * During the transparent rendering pass,     * this attribute can be overridden by     * the depthBufferFreezeTransparent attribute in the View object.     * @param state true or false to enable or disable depth buffer Write mode     * @see View#setDepthBufferFreezeTransparent     */    final void setDepthBufferWriteEnable(boolean state){	initDepthBufferWriteEnable(state);	sendMessage(DEPTH_WRITE_ENABLE, (state ? Boolean.TRUE: Boolean.FALSE));    }    /**     * Retrieves the state of Depth Buffer Write Enable flag     * @return true if depth buffer is writable, false     * if depth buffer is read-only     */    final boolean getDepthBufferWriteEnable(){	return depthBufferWriteEnable;    }    /**     * Set alpha test value used by alpha test function.  This value is     * compared to the alpha value of each rendered pixel.     * @param value the alpha value     */    final void initAlphaTestValue(float value){	alphaTestValue = value;    }    /**     * Set alpha test value used by alpha test function and sends a      * message notifying the interested structures of the change.     * This value is compared to the alpha value of each rendered pixel.     * @param value the alpha value     */    final void setAlphaTestValue(float value){	initAlphaTestValue(value);	sendMessage(ALPHA_TEST_VALUE,  new Float(value));    }    /**     * Retrieves the alpha test value.     * @return the alpha test value.     */    final float getAlphaTestValue(){	return alphaTestValue;    }    /**     * Set alpha test function.  This function is used to compare the     * alpha test value with each per-pixel alpha value.  If the test     * passes, then the pixel is written otherwise the pixel is not     * written.     * @param function the new alpha test function.  One of:     * ALWAYS, NEVER, EQUAL, NOT_EQUAL, LESS, LESS_OR_EQUAL, GREATER,     * GREATER_OR_EQUAL.     */    final void initAlphaTestFunction(int function){	alphaTestFunction = function;    }    /**     * Set alpha test function and sends a      * message notifying the interested structures of the change.     * This function is used to compare the     * alpha test value with each per-pixel alpha value.  If the test     * passes, then the pixel is written otherwise the pixel is not     * written.     * @param function the new alpha test function.  One of:     * ALWAYS, NEVER, EQUAL, NOT_EQUAL, LESS, LESS_OR_EQUAL, GREATER,     * GREATER_OR_EQUAL.     */    final void setAlphaTestFunction(int function){		initAlphaTestFunction(function);	sendMessage(ALPHA_TEST_FUNC, new Integer(function));    }    /**     * Retrieves current alpha test function.     * @return the current alpha test function     */    final int getAlphaTestFunction(){	return alphaTestFunction;    }    /**     * Set depth test function.  This function is used to compare the     * depth test value with each per-pixel alpha value.  If the test     * passes, then 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,     * GREATER_OR_EQUAL.     * Default value is LESS_OR_EQUAL     */    final void initDepthTestFunction(int function){	depthTestFunction = function;    }    /**     * Set depth test function.  This function is used to compare the     * depth test value with each per-pixel depth value.  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,     * GREATER_OR_EQUAL     * Default value is LESS_OR_EQUAL     */    final void setDepthTestFunction(int function){	initDepthTestFunction(function);	sendMessage(DEPTH_TEST_FUNC, new Integer(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     */    final int getDepthTestFunction(){        return depthTestFunction;    }    /**     * Initialize the raster op enable flag     */    final void initRasterOpEnable(boolean flag) {	rasterOpEnable = flag;    }    /**     * Set the raster op enable flag     */    final void setRasterOpEnable(boolean flag) {	initRasterOpEnable(flag);	sendMessage(RASTER_OP_ENABLE, new Boolean(flag));    }    /**     * Retrieves the current raster op enable flag.     */    final boolean getRasterOpEnable() {	return rasterOpEnable;    }

⌨️ 快捷键说明

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