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

📄 lightretained.java

📁 JAVA3D矩陈的相关类
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/* * $RCSfile: LightRetained.java,v $ * * Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved. * * Use is subject to license terms. * * $Revision: 1.6 $ * $Date: 2007/04/12 17:34:05 $ * $State: Exp $ */package javax.media.j3d;import javax.vecmath.*;import java.util.Enumeration;import java.util.Vector;import java.util.ArrayList;/** * LightRetained is an abstract class that contains instance variable common to * all lights. */abstract class LightRetained extends LeafRetained {    // Statics used when something in the light changes    static final int ENABLE_CHANGED          = 0x0001;    static final int SCOPE_CHANGED           = 0x0002;    static final int BOUNDS_CHANGED          = 0x0004;    static final int COLOR_CHANGED           = 0x0008;    static final int BOUNDINGLEAF_CHANGED    = 0x0010;    static final int INIT_MIRROR             = 0x0020;    static final int CLEAR_MIRROR            = 0x0040;    static final int LAST_DEFINED_BIT        = 0x0040;    // Indicates whether the light is turned on.    boolean	lightOn = true;    // The color of the light (white by default).    Color3f	color = new Color3f(1.0f, 1.0f, 1.0f);    // This node which specifies the hierarchical scope of the    // light.  A null reference means that this light has universal    // scope.    Vector scopes = new Vector();    /**     * The Boundary object defining the lights's region of influence.     */      Bounds regionOfInfluence = null;     /**      * The bounding leaf reference     */    BoundingLeafRetained boundingLeaf = null;    /**     * The transformed value of the applicationRegion.     */    Bounds region = null;    /**      * This bitmask is set when something changes in the light     */    int lightDirty = 0xffff;    // This is a copy of the sgLight's dirty bits    int sgLightDirty = 0xffff;    // The type of light    int lightType = -1;    // This is true when this light is needed in the current light set    boolean isNeeded = false;    // This is true when this light is referenced in an immediate mode context    boolean inImmCtx = false;    // A back reference to the scene graph light, when this is a mirror light    LightRetained sgLight = null;    // A HashKey for lights in a shared group    HashKey key = null;    // An array of mirror lights, one for each instance of this light in a    // shared group.  Entry 0 is the only one valid if we are not in a shared    // group.    LightRetained[] mirrorLights = new LightRetained[1];    // The number of valid lights in mirrorLights    int numMirrorLights = 0;    // Indicated whether the light is a scoped light    boolean isScoped = false;   // The object that contains the dynamic HashKey - a string type object    // Used in scoping     HashKey tempKey = new HashKey(250);    /**     * A list of all the EnvironmentSets that reference this light.     * Note that multiple RenderBin update thread may access     * this shared environmentSets simultaneously.     * So we use UnorderList when sync. all the operations.     */    UnorderList environmentSets = new UnorderList(1, EnvironmentSet.class);    // Is true, if the mirror light is viewScoped    boolean isViewScoped = false;    /**     * Temporary list of newly added mirror lights, during any setlive     */    ArrayList newlyAddedMirrorLights = new ArrayList();    // Target threads to be notified when light changes    static final int targetThreads = J3dThread.UPDATE_RENDERING_ENVIRONMENT |	J3dThread.UPDATE_RENDER;    /**     * Initialize the light on or off.     * @param state true or false to enable or disable the light     */    void initEnable(boolean state) {        this.lightOn = state;    }    /**     * Turns the light on or off and send a message     * @param state true or false to enable or disable the light     */    void setEnable(boolean state) {	initEnable(state);	sendMessage(ENABLE_CHANGED, 		    (state ? Boolean.TRUE: Boolean.FALSE));    }    /**     * Returns the state of the light (on/off).     * @return true if the light is on, false if the light is off.     */     boolean getEnable() {	return this.lightOn;    }    /**     * Initialize the color of this light node.     * @param color the value of this new light color     */    void initColor(Color3f color) {	this.color.set(color);    }    /**     * Sets the color of this light node and send a message     * @param color the value of this new light color     */    void setColor(Color3f color) {	initColor(color);	sendMessage(COLOR_CHANGED, new Color3f(color));     }    /**     * Retrieves the color of this light.     * @param color the vector that will receive the color of this light     */     void getColor(Color3f color) {	color.set(this.color);    }    /**     * Initializes the specified scope with the scope provided.     * @param scope the new scope     * @param index which scope to replace     */    void initScope(Group scope, int index) {        GroupRetained group = (GroupRetained)scope.retained;        scopes.setElementAt(group, index);    }    /**     * Replaces the specified scope with the scope provided and     * send a message     * @param scope the new scope      * @param index which scope to replace     */    void setScope(Group scope, int index) {	ArrayList addScopeList = new ArrayList();	ArrayList removeScopeList = new ArrayList();	GroupRetained group;	Object[] scopeInfo = new Object[3];	group = (GroupRetained) scopes.get(index);	tempKey.reset();	group.removeAllNodesForScopedLight((inSharedGroup?numMirrorLights:1), mirrorLights, removeScopeList, tempKey);	        group = (GroupRetained)scope.retained;	tempKey.reset();	// If its a group, then add the scope to the group, if	// its a shape, then keep a list to be added during	// updateMirrorObject	group.addAllNodesForScopedLight((inSharedGroup?numMirrorLights:1), mirrorLights,addScopeList, tempKey);		initScope(scope, index);	J3dMessage createMessage = new J3dMessage();	scopeInfo[0] = addScopeList;	scopeInfo[1] = removeScopeList;	scopeInfo[2] = (scopes.size() > 0 ? Boolean.TRUE: Boolean.FALSE);	sendMessage(SCOPE_CHANGED, scopeInfo);    }        /**     * Inserts the specified scope at specified index.     * @param scope the new scope     * @param index position to insert new scope at     */    void initInsertScope(Group scope, int index) {        GroupRetained group = (GroupRetained)scope.retained;        scopes.insertElementAt(group, index);	group.setLightScope();    }    /**     * Inserts the specified scope at specified index.     * @param scope the new scope     * @param index position to insert new scope at     */    void insertScope(Group scope, int index) {	Object[] scopeInfo = new Object[3];	ArrayList addScopeList = new ArrayList();        GroupRetained group = (GroupRetained)scope.retained;	tempKey.reset();	group.addAllNodesForScopedLight((inSharedGroup?numMirrorLights:1), mirrorLights,addScopeList, tempKey);		initInsertScope(scope, index);	scopeInfo[0] = addScopeList;	scopeInfo[1] = null;	scopeInfo[2] = (scopes.size() > 0 ? Boolean.TRUE: Boolean.FALSE);	sendMessage(SCOPE_CHANGED, scopeInfo);    }        /**     * Removes the scope at specified index.     * @param index which scope to remove     */    void initRemoveScope(int index) {        GroupRetained group = (GroupRetained)scopes.elementAt(index);        scopes.removeElementAt(index);	group.removeLightScope();    }        /**     * Removes the scope at specified index.     * @param index which scope to remove     */    void removeScope(int index) {	Object[] scopeInfo = new Object[3];	ArrayList removeScopeList = new ArrayList();              GroupRetained group = (GroupRetained)scopes.elementAt(index);	tempKey.reset();	group.removeAllNodesForScopedLight((inSharedGroup?numMirrorLights:1), mirrorLights, removeScopeList, tempKey);	initRemoveScope(index);	scopeInfo[0] = null;	scopeInfo[1] = removeScopeList;	scopeInfo[2] = (scopes.size() > 0 ? Boolean.TRUE: Boolean.FALSE);	sendMessage(SCOPE_CHANGED, scopeInfo);    }          /**     * Removes the specified scope     * @param scope to be removed     */    void removeScope(Group scope) {      int ind = indexOfScope(scope);      if(ind >= 0)	removeScope(ind);    }  void initRemoveScope(Group scope) {      int ind = indexOfScope(scope);      if(ind >= 0)	initRemoveScope(ind);  }    /**     *  Removes all the scopes from this Light's list of scopes     */    void removeAllScopes() {      int n = scopes.size();      Object[] scopeInfo = new Object[3];      ArrayList removeScopeList = new ArrayList();      GroupRetained group;      for(int index = n-1; index >= 0; index--) {	group = (GroupRetained)scopes.elementAt(index);	tempKey.reset();	group.removeAllNodesForScopedLight((inSharedGroup?numMirrorLights:1), mirrorLights, removeScopeList, tempKey);	initRemoveScope(index);      }      scopeInfo[0] = null;      scopeInfo[1] = removeScopeList;      scopeInfo[2] = (Boolean.FALSE);      sendMessage(SCOPE_CHANGED, scopeInfo);    }    void initRemoveAllScopes() {      int n = scopes.size();      for(int i = n-1; i >= 0; i--) 	initRemoveScope(i);  }         /**     * Returns the scope specified by the index.     * @param index of the scope to be returned     * @return the scope at location index     */    Group getScope(int index) {      return (Group)(((GroupRetained)(scopes.elementAt(index))).source);    }      /**     * Returns an enumeration object of the scope     * @return an enumeration object of the scope     */      Enumeration getAllScopes() {	Enumeration elm = scopes.elements();	Vector v = new Vector(scopes.size());	while (elm.hasMoreElements()) {	    v.add( ((GroupRetained) elm.nextElement()).source);	}	return v.elements();    }    /**     * Appends the specified scope to this node's list of scopes.     * @param scope the scope to add to this node's list of scopes     */    void initAddScope(Group scope) {        GroupRetained group = (GroupRetained)scope.retained;        scopes.addElement(group);	group.setLightScope();    }

⌨️ 快捷键说明

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