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

📄 fogretained.java

📁 JAVA3D矩陈的相关类
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
  void removeAllScopes() {    Object[] scopeInfo = new Object[3];    ArrayList removeScopeList = new ArrayList();    GroupRetained group;    int n = scopes.size();    tempKey.reset();    for(int index = n-1; index >= 0; index--) {       group  = (GroupRetained)scopes.elementAt(index);       group.removeAllNodesForScopedFog(mirrorFog, removeScopeList, tempKey);       initRemoveScope(index);    }    scopeInfo[0] = null;    scopeInfo[1] = removeScopeList;    scopeInfo[2] = Boolean.FALSE;    sendMessage(SCOPE_CHANGED, scopeInfo);  }      /**     * Removes all scopes from this node     */    void initRemoveAllScopes() {	int n = scopes.size();	for(int index = n-1; index >= 0; index--) 	    initRemoveScope(index);    }    /**     * 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);    }    /**     * This abstract method is used to update the current native     * context fog values.     */    abstract void update(Context ctx, double scale);    void updateImmediateMirrorObject(Object[] objs) {	GroupRetained group;	Vector currentScopes;	int i, nscopes;	Transform3D trans;	int component = ((Integer)objs[1]).intValue();	if ((component & BOUNDS_CHANGED) != 0) {	    mirrorFog.regionOfInfluence = (Bounds) objs[2];	    if (mirrorFog.boundingLeaf == null) {		if (objs[2] != null) {		    mirrorFog.region = ((Bounds)mirrorFog.regionOfInfluence).copy(mirrorFog.region);		    mirrorFog.region.transform(				mirrorFog.regionOfInfluence,				getCurrentLocalToVworld());		}		else {		    mirrorFog.region = null;		}	    }	}	else if  ((component & BOUNDINGLEAF_CHANGED) != 0) {	    mirrorFog.boundingLeaf = (BoundingLeafRetained)objs[2];	    if (objs[2] != null) {		mirrorFog.region = (Bounds)mirrorFog.boundingLeaf.transformedRegion;	    }	    else { 		if (mirrorFog.regionOfInfluence != null) {		    mirrorFog.region = ((Bounds)mirrorFog.regionOfInfluence).copy(mirrorFog.region);		    mirrorFog.region.transform(				mirrorFog.regionOfInfluence,				getCurrentLocalToVworld());		}		else {		    mirrorFog.region = null;		}			    }	}	else if ((component & SCOPE_CHANGED) != 0) {	    Object[] scopeList = (Object[])objs[2];	    ArrayList addList = (ArrayList)scopeList[0];	    ArrayList removeList = (ArrayList)scopeList[1];	    boolean isScoped = ((Boolean)scopeList[2]).booleanValue();	    	    if (addList != null) {		mirrorFog.isScoped = isScoped;		for (i = 0; i < addList.size(); i++) {		    Shape3DRetained obj = ((GeometryAtom)addList.get(i)).source;		    obj.addFog(mirrorFog);		}	    }	    	    if (removeList != null) {		mirrorFog.isScoped = isScoped;		for (i = 0; i < removeList.size(); i++) {		    Shape3DRetained obj = ((GeometryAtom)removeList.get(i)).source;		    obj.removeFog(mirrorFog);		}	    }	}    }    /**     * The update Object function.     */    void updateMirrorObject(Object[] objs) {	int component = ((Integer)objs[1]).intValue();	if ((component & COLOR_CHANGED) != 0) {	    mirrorFog.color.set((Color3f)objs[2]);	}	if ((component & INIT_MIRROR) != 0) {	    mirrorFog.color.set((Color3f)objs[3]);	}    }    /**     * Note: This routine will only be called on     * the mirror object - will update the object's     * cached region and transformed region      */    void updateBoundingLeaf() {        if (boundingLeaf != null && boundingLeaf.switchState.currentSwitchOn) {            region = boundingLeaf.transformedRegion;        } else {            if (regionOfInfluence != null) {		region = regionOfInfluence.copy(region);                region.transform(regionOfInfluence, 				 getCurrentLocalToVworld());            } else {                region = null;            }        }    }    /**     * This setLive routine just calls the superclass's method (after     * checking for use by an immediate context).  It is up to the     * subclasses of fog to add themselves to the list of fogs     */    void setLive(SetLiveState s) {        GroupRetained group;	Vector currentScopes;	int i, nscopes;	TransformGroupRetained[] tlist;        if (inImmCtx) {	    throw new IllegalSharingException(J3dI18N.getString("FogRetained0"));        }        super.doSetLive(s);	if (inSharedGroup) {	    throw new		IllegalSharingException(J3dI18N.getString("FogRetained1"));	}		// Create the mirror object	// Initialization of the mirror object during the INSERT_NODE	// message (in updateMirrorObject)	if (mirrorFog == null) {	    //	    mirrorFog = (FogRetained)this.clone(true);	    mirrorFog = (FogRetained)this.clone();	    // Assign the bounding leaf of this mirror object as null	    // it will later be assigned to be the mirror of the lights	    // bounding leaf object	    mirrorFog.boundingLeaf = null;	    mirrorFog.sgFog = this;	}	//	initMirrorObject();	// If bounding leaf is not null, add the mirror object as a user	// so that any changes to the bounding leaf will be received	if (boundingLeaf != null) {	    boundingLeaf.mirrorBoundingLeaf.addUser(mirrorFog);	}		if ((s.viewScopedNodeList != null) && (s.viewLists != null)) {	    s.viewScopedNodeList.add(mirrorFog);	    s.scopedNodesViewList.add(s.viewLists.get(0));	} else {	    s.nodeList.add(mirrorFog);	}        if (s.transformTargets != null && s.transformTargets[0] != null) {            s.transformTargets[0].addNode(mirrorFog, Targets.ENV_TARGETS);	    s.notifyThreads |= J3dThread.UPDATE_TRANSFORM;        }	// process switch leaf        if (s.switchTargets != null &&                        s.switchTargets[0] != null) {            s.switchTargets[0].addNode(mirrorFog, Targets.ENV_TARGETS);        }        mirrorFog.switchState = (SwitchState)s.switchStates.get(0);	s.notifyThreads |= J3dThread.UPDATE_RENDERING_ENVIRONMENT|	    J3dThread.UPDATE_RENDER;	super.markAsLive();    }    // This is called on the parent object    void initMirrorObject(Object[] args) {	Shape3DRetained shape;	Object[] scopeInfo = (Object[]) args[2];	Boolean scoped = (Boolean)scopeInfo[0];	ArrayList shapeList = (ArrayList)scopeInfo[1];	BoundingLeafRetained bl=(BoundingLeafRetained)((Object[])args[4])[0];	Bounds bnds = (Bounds)((Object[])args[4])[1];	mirrorFog.inBackgroundGroup = ((Boolean)((Object[])args[4])[2]).booleanValue();	mirrorFog.geometryBackground = (BackgroundRetained)((Object[])args[4])[3];	for (int i = 0; i < shapeList.size(); i++) {	    shape = ((GeometryAtom)shapeList.get(i)).source;	    shape.addFog(mirrorFog);	}	mirrorFog.isScoped = scoped.booleanValue();	if (bl != null) {	    mirrorFog.boundingLeaf = bl.mirrorBoundingLeaf;	    mirrorFog.region = boundingLeaf.transformedRegion;	} else {	    mirrorFog.boundingLeaf = null;	    mirrorFog.region = null;	}		if (bnds != null) {	    mirrorFog.regionOfInfluence = bnds;	    if (mirrorFog.region == null) {		mirrorFog.region = (Bounds)regionOfInfluence.clone();		mirrorFog.region.transform(regionOfInfluence, getLastLocalToVworld());	    }	}	else {	    mirrorFog.regionOfInfluence = null;	}    }   // This is called on the parent object    void clearMirrorObject(Object[] args) {	Shape3DRetained shape;	ArrayList shapeList = (ArrayList)args[2];	ArrayList removeScopeList = new ArrayList();		for (int i = 0; i < shapeList.size(); i++) {	    shape = ((GeometryAtom)shapeList.get(i)).source;	    shape.removeFog(mirrorFog);	}			mirrorFog.isScoped = false;	    }        /**     * This clearLive routine first calls the superclass's method, then     * it removes itself to the list of fogs     */    void clearLive(SetLiveState s) {	int i, j;        GroupRetained group;        super.clearLive(s);        if (s.switchTargets != null &&                        s.switchTargets[0] != null) {            s.switchTargets[0].addNode(mirrorFog, Targets.ENV_TARGETS);        }	s.notifyThreads |= J3dThread.UPDATE_RENDERING_ENVIRONMENT|	    J3dThread.UPDATE_RENDER;	// Remove this mirror light as users of the bounding leaf 	if (mirrorFog.boundingLeaf != null)	    mirrorFog.boundingLeaf.removeUser(mirrorFog);		if ((s.viewScopedNodeList != null) && (s.viewLists != null)) {	    s.viewScopedNodeList.add(mirrorFog);	    s.scopedNodesViewList.add(s.viewLists.get(0));	} else {	    s.nodeList.add(mirrorFog);	}	if (s.transformTargets != null && s.transformTargets[0] != null) {            s.transformTargets[0].addNode(mirrorFog, Targets.ENV_TARGETS);	    s.notifyThreads |= J3dThread.UPDATE_TRANSFORM;	}	if (scopes.size() > 0) {	    J3dMessage createMessage = new J3dMessage();	    createMessage.threads = J3dThread.UPDATE_RENDERING_ENVIRONMENT;	    createMessage.universe = universe;	    createMessage.type = J3dMessage.FOG_CHANGED;	    createMessage.args[0] = this;	    createMessage.args[1]= new Integer(CLEAR_MIRROR);	    ArrayList removeScopeList = new ArrayList();	    for (i = 0; i < scopes.size(); i++) {		group = (GroupRetained)scopes.get(i);		tempKey.reset();		group.removeAllNodesForScopedFog(mirrorFog, removeScopeList, tempKey);	    }	    createMessage.args[2] = removeScopeList;	    VirtualUniverse.mc.processMessage(createMessage);	}    }    // Clone the retained side only, internal use only	     protected Object clone() {         FogRetained fr = (FogRetained)super.clone();         fr.color = new Color3f(color);         Bounds b = getInfluencingBounds();         if (b != null) {             fr.initInfluencingBounds(b);         }          fr.scopes = new Vector();         fr.isDirty = 0xffff;         fr.inImmCtx = false;         fr.region = null;         fr.sgFog = null;         fr.mirrorFog = null;	 fr.environmentSets = new UnorderList(1, EnvironmentSet.class);         return fr;     }    void updateTransformChange() {	super.updateTransformChange();        setLocalToVworldScale(sgFog.getLastLocalToVworld().getDistanceScale());    }    // Called on mirror object    void updateImmediateTransformChange() {	// If bounding leaf is null, tranform the bounds object	if (boundingLeaf == null) {	    if (regionOfInfluence != null) {		region = regionOfInfluence.copy(region);		region.transform(regionOfInfluence,				 sgFog.getCurrentLocalToVworld());	    }	    	}    }        final void sendMessage(int attrMask, Object attr) {	J3dMessage createMessage = new J3dMessage();	createMessage.threads = targetThreads;	createMessage.universe = universe;	createMessage.type = J3dMessage.FOG_CHANGED;	createMessage.args[0] = this;	createMessage.args[1]= new Integer(attrMask);	createMessage.args[2] = attr;	VirtualUniverse.mc.processMessage(createMessage);    }        void mergeTransform(TransformGroupRetained xform) {	super.mergeTransform(xform);        if (regionOfInfluence != null) {            regionOfInfluence.transform(xform.transform);        }    }    void getMirrorObjects(ArrayList leafList, HashKey key) {	leafList.add(mirrorFog);    }    /**     * Scale distances from local to eye coordinate     */    protected void validateDistancesInEc(double vworldToCoexistenceScale) {        assert false : "subclasses should override this method";    }    double getLocalToVworldScale() {        return localToVworldScale;    }    void setLocalToVworldScale(double localToVworldScale) {        this.localToVworldScale = localToVworldScale;    }}

⌨️ 快捷键说明

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