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

📄 alternateappearanceretained.java

📁 JAVA3D矩陈的相关类
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* * $RCSfile: AlternateAppearanceRetained.java,v $ * * Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved. * * Use is subject to license terms. * * $Revision: 1.6 $ * $Date: 2007/02/09 17:17:49 $ * $State: Exp $ */package javax.media.j3d;import javax.vecmath.*;import java.util.Enumeration;import java.util.Vector;import java.util.ArrayList;class AlternateAppearanceRetained extends LeafRetained {    // Statics used when something in the alternate app changes    static final int APPEARANCE_CHANGED      = 0x0001;    static final int SCOPE_CHANGED           = 0x0002;    static final int BOUNDS_CHANGED          = 0x0004;    static final int BOUNDINGLEAF_CHANGED    = 0x0008;    static final int INIT_MIRROR             = 0x0010; // setLive    static final int CLEAR_MIRROR            = 0x0020; // clearLive    /**     * The Boundary object defining the lights's region of influence.     */      Bounds regionOfInfluence = null;    /**      * The bounding leaf reference     */    BoundingLeafRetained boundingLeaf = null;    /**     * Vector of GroupRetained  nodes that scopes this alternate app .     */    Vector scopes = new Vector();    // This is true when this alternate app  is referenced in an immediate mode context    boolean inImmCtx = false;   // Target threads to be notified when light changes    static final int targetThreads = J3dThread.UPDATE_RENDERING_ENVIRONMENT |                                     J3dThread.UPDATE_RENDER;    // Boolean to indicate if this object is scoped (only used for mirror objects    boolean isScoped = false;    // The object that contains the dynamic HashKey - a string type object    // Used in scoping     HashKey tempKey = new HashKey(250);        /**     * The transformed value of the applicationRegion.     */    Bounds region = null;    /**     * mirror Alternate appearance     */    AlternateAppearanceRetained mirrorAltApp = null;    /**     * Appearance for this object     */    AppearanceRetained appearance;    /**     * A reference to the scene graph alternateApp     */    AlternateAppearanceRetained  sgAltApp = null;    /**     * Is true, if the mirror altapp is viewScoped     */    boolean isViewScoped = false;    AlternateAppearanceRetained() {	this.nodeType = NodeRetained.ALTERNATEAPPEARANCE;	localBounds = new BoundingBox();	((BoundingBox)localBounds).setLower( 1.0, 1.0, 1.0);	((BoundingBox)localBounds).setUpper(-1.0,-1.0,-1.0);    }    /**     * Initializes the appearance     */    void initAppearance(Appearance app) {	if (app != null)	    appearance = (AppearanceRetained) app.retained;	else	    appearance = null;    }        /**     * sets the appearance and send a message     */    void setAppearance(Appearance app) {	if (appearance != null)	    synchronized(appearance.liveStateLock) {		appearance.clearLive(refCount);	    }	initAppearance(app);	if (appearance != null) {	    synchronized(appearance.liveStateLock) {		appearance.setLive(inBackgroundGroup, refCount);	    }	}	// There is no need to clone the appearance's mirror	sendMessage(APPEARANCE_CHANGED, 		    (appearance != null ? appearance.mirror: null));      }       Appearance getAppearance() {        return (appearance == null ? null: (Appearance) appearance.source);    }    /**     * Set the alternate's region of influence.     */      void initInfluencingBounds(Bounds region) {	if (region != null) {            this.regionOfInfluence = (Bounds) region.clone();	} else {	    this.regionOfInfluence = null;	}    }    /**     * Set the alternate's region of influence and send message     */      void setInfluencingBounds(Bounds region) {	initInfluencingBounds(region);	sendMessage(BOUNDS_CHANGED, 		    (region != null ? region.clone() : null));    }    /**       * Get the alternate's region of Influence.     */      Bounds getInfluencingBounds() {	return (regionOfInfluence != null ?		(Bounds) regionOfInfluence.clone() : null);    }    /**     * Set the alternate's region of influence to the specified Leaf node.     */      void initInfluencingBoundingLeaf(BoundingLeaf region) {	if (region != null) {	    boundingLeaf = (BoundingLeafRetained)region.retained;	} else {	    boundingLeaf = null;	}    }    /**     * Set the alternate's region of influence to the specified Leaf node.     */      void setInfluencingBoundingLeaf(BoundingLeaf region) {	if (boundingLeaf != null)	    boundingLeaf.mirrorBoundingLeaf.removeUser(mirrorAltApp);	if (region != null) {	    boundingLeaf = (BoundingLeafRetained)region.retained;	    boundingLeaf.mirrorBoundingLeaf.addUser(mirrorAltApp);	} else {	    boundingLeaf = null;	}	sendMessage(BOUNDINGLEAF_CHANGED, 		    (boundingLeaf != null ? 		     boundingLeaf.mirrorBoundingLeaf : null));    }    /**       * Get the alternate's region of influence.     */      BoundingLeaf getInfluencingBoundingLeaf() {	return (boundingLeaf != null ? 		(BoundingLeaf)boundingLeaf.source : null);    }        /**     * Replaces the specified scope with the scope provided.     * @param scope the new scope     * @param index which scope to replace     */    void initScope(Group scope, int index) {	scopes.setElementAt((GroupRetained)(scope.retained), index);    }    /**     * Replaces the specified scope with the scope provided.     * @param scope the new scope     * @param index which scope to replace     */    void setScope(Group scope, int index) {	ArrayList removeScopeList = new ArrayList();	GroupRetained group;	ArrayList addScopeList = new ArrayList();	Object[] scopeInfo = new Object[3];	group = (GroupRetained) scopes.get(index);	tempKey.reset();	group.removeAllNodesForScopedAltApp(mirrorAltApp, removeScopeList, tempKey);	group = (GroupRetained)scope.retained;	initScope(scope, index);	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.addAllNodesForScopedAltApp(mirrorAltApp,addScopeList, tempKey);	scopeInfo[0] = addScopeList;	scopeInfo[1] = removeScopeList;	scopeInfo[2] = (scopes.size() > 0 ? Boolean.TRUE:Boolean.FALSE);	sendMessage(SCOPE_CHANGED, scopeInfo);    }     Group getScope(int index) {	return (Group)(((GroupRetained)(scopes.elementAt(index))).source);    }    /**     * Inserts the specified scope at specified index.before the     * alt app is live     * @param scope the new scope     * @param index position to insert new scope at     */    void initInsertScope(Node scope, int index) {	GroupRetained group = (GroupRetained)scope.retained;	scopes.insertElementAt((GroupRetained)(scope.retained), index);	group.setAltAppScope();    }    /**     * Inserts the specified scope at specified index and sends     * a message     * @param scope the new scope     * @param index position to insert new scope at     */    void insertScope(Node scope, int index) {	Object[] scopeInfo = new Object[3];	ArrayList addScopeList = new ArrayList();	GroupRetained group = (GroupRetained)scope.retained;	initInsertScope(scope, index);        group = (GroupRetained)scope.retained;	tempKey.reset();	group.addAllNodesForScopedAltApp(mirrorAltApp,addScopeList, tempKey);	scopeInfo[0] = addScopeList;	scopeInfo[1] = null;	scopeInfo[2] = (scopes.size() > 0 ? Boolean.TRUE: Boolean.FALSE);	sendMessage(SCOPE_CHANGED, scopeInfo);    }        void initRemoveScope(int index) {	GroupRetained group  = (GroupRetained)scopes.elementAt(index);	scopes.removeElementAt(index);	group.removeAltAppScope();    }    void removeScope(int index) {	Object[] scopeInfo = new Object[3];	ArrayList removeScopeList = new ArrayList();	GroupRetained group  = (GroupRetained)scopes.elementAt(index);	tempKey.reset();	group.removeAllNodesForScopedAltApp(mirrorAltApp, 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 Group node from this node's list of scopes.   * Method is a no-op if the    * specified node is not found   * @param The Group node 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);    }    void removeAllScopes() {      GroupRetained group;      ArrayList removeScopeList = new ArrayList();      int n = scopes.size();      for(int index = n-1; index >= 0; index--) {	group  = (GroupRetained)scopes.elementAt(index);	tempKey.reset();	group.removeAllNodesForScopedAltApp(mirrorAltApp, removeScopeList, tempKey);	initRemoveScope(index);      }      Object[] scopeInfo = new Object[3];      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 an enumeration object of the scoperen.     * @return an enumeration object of the scoperen     */      Enumeration getAllScopes() {	Enumeration elm = scopes.elements();	Vector v = new Vector(scopes.size());	while (elm.hasMoreElements()) {	    v.add( ((GroupRetained) elm.nextElement()).source);	}	return v.elements();    }  /**    * Returns the index of the specified Group node in this node's list of scopes.   * @param scope the Group node whose index is needed   */  int indexOfScope(Group scope) {    if(scope != null)      return scopes.indexOf((GroupRetained)scope.retained);    else      return scopes.indexOf(null);  }    /**     * Appends the specified scope to this node's list of scopes before     * the alt app is alive     * @param scope the scope to add to this node's list of scopes     */    void initAddScope(Group scope) {        GroupRetained group = (GroupRetained)scope.retained;	scopes.addElement((GroupRetained)(scope.retained));	group.setAltAppScope();    }    /**     * 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 addScope(Group scope) {	Object[] scopeInfo = new Object[3];	ArrayList addScopeList = new ArrayList();        GroupRetained group = (GroupRetained)scope.retained;	initAddScope(scope);	tempKey.reset();	group.addAllNodesForScopedAltApp(mirrorAltApp,addScopeList, tempKey);	scopeInfo[0] = addScopeList;	scopeInfo[1] = null;	scopeInfo[2] = (scopes.size() > 0 ? Boolean.TRUE: Boolean.FALSE);	sendMessage(SCOPE_CHANGED, scopeInfo);    }       /**     * Returns a count of this nodes' scopes.     * @return the number of scopes descendant from this node     */    int numScopes() {	return scopes.size();    }      /**     * This sets the immedate mode context flag     */    void setInImmCtx(boolean inCtx) {        inImmCtx = inCtx;    }     /**     * This gets the immedate mode context flag     */    boolean getInImmCtx() {        return (inImmCtx);    }    boolean isScoped() {	return (scopes != null);    }    void updateImmediateMirrorObject(Object[] objs) {	GroupRetained group;	Vector currentScopes;	int i, nscopes;	Transform3D trans;

⌨️ 快捷键说明

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