📄 fog.java
字号:
/* * $RCSfile: Fog.java,v $ * * Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved. * * Use is subject to license terms. * * $Revision: 1.5 $ * $Date: 2007/02/09 17:17:58 $ * $State: Exp $ */package javax.media.j3d;import java.util.Enumeration;import javax.vecmath.Color3f;/** * The Fog leaf node defines a set of fog parameters common to all * types of fog. These parameters include the fog color and a region * of influence in which this Fog node is active. * A Fog node also contains a list of Group nodes that specifies the * hierarchical scope of this Fog. If the scope list is empty, then * the Fog node has universe scope: all nodes within the region of * influence are affected by this Fog node. If the scope list is * non-empty, then only those Leaf nodes under the Group nodes in the * scope list are affected by this Fog node (subject to the * influencing bounds). * <p> * If the regions of influence of multiple Fog nodes overlap, the * Java 3D system will choose a single set of fog parameters for those * objects that lie in the intersection. This is done in an * implementation-dependent manner, but in general, the Fog node that * is "closest" to the object is chosen. */public abstract class Fog extends Leaf { /** * Specifies that this Fog node allows read access to its * influencing bounds and bounds leaf information. */ public static final int ALLOW_INFLUENCING_BOUNDS_READ = CapabilityBits.FOG_ALLOW_INFLUENCING_BOUNDS_READ; /** * Specifies that this Fog node allows write access to its * influencing bounds and bounds leaf information. */ public static final int ALLOW_INFLUENCING_BOUNDS_WRITE = CapabilityBits.FOG_ALLOW_INFLUENCING_BOUNDS_WRITE; /** * Specifies that this Fog node allows read access to its color * information. */ public static final int ALLOW_COLOR_READ = CapabilityBits.FOG_ALLOW_COLOR_READ; /** * Specifies that this Fog node allows write access to its color * information. */ public static final int ALLOW_COLOR_WRITE = CapabilityBits.FOG_ALLOW_COLOR_WRITE; /** * Specifies that this Fog node allows read access to its scope * information at runtime. */ public static final int ALLOW_SCOPE_READ = CapabilityBits.FOG_ALLOW_SCOPE_READ; /** * Specifies that this Fog node allows write access to its scope * information at runtime. */ public static final int ALLOW_SCOPE_WRITE = CapabilityBits.FOG_ALLOW_SCOPE_WRITE; // Array for setting default read capabilities private static final int[] readCapabilities = { ALLOW_INFLUENCING_BOUNDS_READ, ALLOW_COLOR_READ, ALLOW_SCOPE_READ }; /** * Constructs a Fog node with default parameters. The default * values are as follows: * <ul> * color : black (0,0,0)<br> * scope : empty (universe scope)<br> * influencing bounds : null<br> * influencing bounding leaf : null<br> * </ul> */ public Fog() { // Just use the defaults // set default read capabilities setDefaultReadCapabilities(readCapabilities); } /** * Constructs a Fog node with the specified fog color. * @param color the fog color */ public Fog(Color3f color) { // set default read capabilities setDefaultReadCapabilities(readCapabilities); ((FogRetained)this.retained).initColor(color); } /** * Constructs a Fog node with the specified fog color. * @param r the red component of the fog color * @param g the green component of the fog color * @param b the blue component of the fog color */ public Fog(float r, float g, float b) { // set default read capabilities setDefaultReadCapabilities(readCapabilities); ((FogRetained)this.retained).initColor(r, g, b); } /** * Sets the fog color to the specified color. * @param color the new fog color * @exception CapabilityNotSetException if appropriate capability is * not set and this object is part of live or compiled scene graph */ public void setColor(Color3f color) { if (isLiveOrCompiled()) if(!this.getCapability(ALLOW_COLOR_WRITE)) throw new CapabilityNotSetException(J3dI18N.getString("Fog0")); if (isLive()) ((FogRetained)this.retained).setColor(color); else ((FogRetained)this.retained).initColor(color); } /** * Sets the fog color to the specified color. * @param r the red component of the fog color * @param g the green component of the fog color * @param b the blue component of the fog color * @exception CapabilityNotSetException if appropriate capability is * not set and this object is part of live or compiled scene graph */ public void setColor(float r, float g, float b) { if (isLiveOrCompiled()) if(!this.getCapability(ALLOW_COLOR_WRITE)) throw new CapabilityNotSetException(J3dI18N.getString("Fog0")); if (isLive()) ((FogRetained)this.retained).setColor(r, g, b); else ((FogRetained)this.retained).initColor(r, g, b); } /** * Retrieves the fog color. * @param color the vector that will receive the current fog color * @exception CapabilityNotSetException if appropriate capability is * not set and this object is part of live or compiled scene graph */ public void getColor(Color3f color) { if (isLiveOrCompiled()) if(!this.getCapability(ALLOW_COLOR_READ)) throw new CapabilityNotSetException(J3dI18N.getString("Fog2")); ((FogRetained)this.retained).getColor(color); } /** * Sets the Fog's influencing region to the specified bounds. * This is used when the influencing bounding leaf is set to null. * @param region the bounds that contains the Fog's new influencing region. * @exception CapabilityNotSetException if appropriate capability is * not set and this object is part of live or compiled scene graph */ public void setInfluencingBounds(Bounds region) { if (isLiveOrCompiled()) if(!this.getCapability(ALLOW_INFLUENCING_BOUNDS_WRITE)) throw new CapabilityNotSetException(J3dI18N.getString("Fog3")); if (isLive()) ((FogRetained)this.retained).setInfluencingBounds(region); else ((FogRetained)this.retained).initInfluencingBounds(region); } /** * Retrieves the Fog node's influencing bounds. * @return this Fog's influencing bounds information * @exception CapabilityNotSetException if appropriate capability is * not set and this object is part of live or compiled scene graph */ public Bounds getInfluencingBounds() { if (isLiveOrCompiled()) if(!this.getCapability(ALLOW_INFLUENCING_BOUNDS_READ)) throw new CapabilityNotSetException(J3dI18N.getString("Fog4")); return ((FogRetained)this.retained).getInfluencingBounds(); } /** * Sets the Fog's influencing region to the specified bounding leaf. * When set to a value other than null, this overrides the influencing * bounds object. * @param region the bounding leaf node used to specify the Fog * node's new influencing region. * @exception CapabilityNotSetException if appropriate capability is * not set and this object is part of live or compiled scene graph */ public void setInfluencingBoundingLeaf(BoundingLeaf region) { if (isLiveOrCompiled()) if(!this.getCapability(ALLOW_INFLUENCING_BOUNDS_WRITE)) throw new CapabilityNotSetException(J3dI18N.getString("Fog3")); if (isLive()) ((FogRetained)this.retained).setInfluencingBoundingLeaf(region); else ((FogRetained)this.retained).initInfluencingBoundingLeaf(region); } /** * Retrieves the Fog node's influencing bounding leaf. * @return this Fog's influencing bounding leaf information * @exception CapabilityNotSetException if appropriate capability is * not set and this object is part of live or compiled scene graph */ public BoundingLeaf getInfluencingBoundingLeaf() { if (isLiveOrCompiled()) if(!this.getCapability(ALLOW_INFLUENCING_BOUNDS_READ)) throw new CapabilityNotSetException(J3dI18N.getString("Fog4")); return ((FogRetained)this.retained).getInfluencingBoundingLeaf(); } /** * Replaces the node at the specified index in this Fog node's * list of scopes with the specified Group node. * By default, Fog nodes are scoped only by their influencing * bounds. This allows them to be further scoped by a list of * nodes in the hierarchy. * @param scope the Group node to be stored at the specified index. * @param index the index of the Group node to be replaced. * @exception CapabilityNotSetException if appropriate capability is * not set and this object is part of live or compiled scene graph * @exception RestrictedAccessException if the specified group node * is part of a compiled scene graph */ public void setScope(Group scope, int index) { if (isLiveOrCompiled()) if(!this.getCapability(ALLOW_SCOPE_WRITE)) throw new CapabilityNotSetException(J3dI18N.getString("Fog7")); if (isLive()) ((FogRetained)this.retained).setScope(scope, index); else ((FogRetained)this.retained).initScope(scope, index); } /** * Retrieves the Group node at the specified index from this Fog node's * list of scopes. * @param index the index of the Group node to be returned. * @return the Group node at the specified index. * @exception CapabilityNotSetException if appropriate capability is
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -