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

📄 lightretained.java

📁 JAVA3D矩陈的相关类
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
    /**     * 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.addAllNodesForScopedLight((inSharedGroup?numMirrorLights:1), mirrorLights,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();    }    /**     *  Returns the index of the specified scope     *  @return index of the scope in this Light's list of scopes     */  int indexOfScope(Group scope) {    if(scope != null)      return scopes.indexOf((GroupRetained)scope.retained);    else      return scopes.indexOf(null);  }      /**     * Initializes the Light's region of influence.     * @param region a region that contains the Light's new region of influence     */      void initInfluencingBounds(Bounds region) {	if (region != null) {	    regionOfInfluence = (Bounds) region.clone();	    if (staticTransform != null) {		regionOfInfluence.transform(staticTransform.transform);	    }	} else {	    regionOfInfluence = null;	}    }    /**     * Set the Light's region of influence and send a message     * @param region a region that contains the Light's new region of influence     */      void setInfluencingBounds(Bounds region) {	initInfluencingBounds(region);	sendMessage(BOUNDS_CHANGED,  		    (region != null ? region.clone() : null));    }    /**     * Get the Light's region of influence     * @return this Light's region of influence information     */      Bounds getInfluencingBounds() {	Bounds b = null;	if (regionOfInfluence != null) {	    b = (Bounds) regionOfInfluence.clone();            if (staticTransform != null) {                Transform3D invTransform = staticTransform.getInvTransform();                b.transform(invTransform);            }	}	return b;    }    /**     * Initializes the Light'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 Light's region of influence to the specified Leaf node.     */      void setInfluencingBoundingLeaf(BoundingLeaf region) {	int i, numLgts;	numLgts = numMirrorLights;	if (numMirrorLights == 0)  	    numLgts = 1;	if (boundingLeaf != null) {	    // Remove the mirror lights as users of the original bounding leaf	    for (i = 0; i < numLgts; i++) {		boundingLeaf.mirrorBoundingLeaf.removeUser(mirrorLights[i]);	    }	}	if (region != null) {	    boundingLeaf = (BoundingLeafRetained)region.retained;	    // Add all mirror lights as user of this bounding leaf	    for (i = 0; i < numLgts; i++) {		boundingLeaf.mirrorBoundingLeaf.addUser(mirrorLights[i]);	    }	} else {	    boundingLeaf = null;	}	sendMessage(BOUNDINGLEAF_CHANGED, 		     (boundingLeaf != null ?		      boundingLeaf.mirrorBoundingLeaf : null));    }    /**       * Get the Light's region of influence.     */      BoundingLeaf getInfluencingBoundingLeaf() {	return  (boundingLeaf != null ?		 (BoundingLeaf)boundingLeaf.source : null);    }    /**     * This sets the immedate mode context flag     */    void setInImmCtx(boolean inCtx) {	inImmCtx = inCtx;    }    /**     * This gets the immedate mode context flag     */    boolean getInImmCtx() {	return (inImmCtx);    }    // Called on the parent Light object and loops over the mirror object    void initMirrorObject(Object[] args) {	Shape3DRetained shape;	Object[] scopeInfo =  (Object[])((Object[])args[4])[5];	ArrayList gAtomList = (ArrayList)scopeInfo[1];	Boolean scoped = (Boolean)scopeInfo[0];	BoundingLeafRetained bl=(BoundingLeafRetained)((Object[])args[4])[0];	Bounds bnds = (Bounds)((Object[])args[4])[1];	int numLgts = ((Integer)args[2]).intValue();	LightRetained[] mLgts = (LightRetained[]) args[3];	int k;		for ( k = 0; k < numLgts; k++) {	    for (int i = 0; i < gAtomList.size(); i++) {		shape = ((GeometryAtom)gAtomList.get(i)).source;		shape.addLight(mLgts[k]);	    }	    mLgts[k].isScoped = scoped.booleanValue();	}		for (k = 0; k < numLgts; k++) {	    mLgts[k].inBackgroundGroup = ((Boolean)((Object[])args[4])[2]).booleanValue();	    mLgts[k].geometryBackground = (BackgroundRetained)((Object[])args[4])[3];	    if (bl != null) {		mLgts[k].boundingLeaf = bl.mirrorBoundingLeaf;		mLgts[k].region = mLgts[k].boundingLeaf.transformedRegion;	    } else {		mLgts[k].boundingLeaf = null;		mLgts[k].region = null;	    }	    	    if (bnds != null) {		mLgts[k].regionOfInfluence = bnds;		if (mLgts[k].region == null) {		    mLgts[k].region = (Bounds)regionOfInfluence.clone();		    mLgts[k].region.transform(regionOfInfluence, getLastLocalToVworld());		}	    }	    else {		mLgts[k].regionOfInfluence = null;	    }	    mLgts[k].lightOn = ((Boolean)((Object[])args[4])[4]).booleanValue();	}	// if its a ambient light,then do a immediate update of color	if (this instanceof AmbientLightRetained) {	    Color3f clr = (Color3f) ((Object[])args[4])[6];	    for (int i = 0; i < numLgts; i++) {		mLgts[i].color.set(clr);	    }	}	        }        /**      * This method is implemented by each light for rendering     * context updates.  This default one does nothing.     */    abstract void update(Context ctx, int lightSlot, double scale);    // This routine is called when rendering Env structure    // get a message, this routine updates values in the mirror object    // that are not used by the renderer    void updateImmediateMirrorObject(Object[] objs) {	Transform3D trans = null;	int component = ((Integer)objs[1]).intValue();	int numLgts = ((Integer)objs[2]).intValue();	LightRetained[] mLgts = (LightRetained[]) objs[3];	// Color changed called immediately only for ambient lights	if ((component & COLOR_CHANGED) != 0) {	    for (int i = 0; i < numLgts; i++) {		mLgts[i].color.set(((Color3f)objs[4]));	    }	}	else if ((component & ENABLE_CHANGED) != 0) {	    for (int i = 0; i < numLgts; i++) 		mLgts[i].lightOn = ((Boolean)objs[4]).booleanValue();	}	else if ((component & BOUNDS_CHANGED) != 0) {	    for (int i = 0; i < numLgts; i++) {		mLgts[i].regionOfInfluence = (Bounds) objs[4];		if (mLgts[i].boundingLeaf == null) {		    if (objs[4] != null) {			mLgts[i].region = 			    ((Bounds)mLgts[i].regionOfInfluence).copy(mLgts[i].region);			mLgts[i].region.transform(mLgts[i].regionOfInfluence,						  mLgts[i].getCurrentLocalToVworld());		    }		    else {			mLgts[i].region = null;		    }		}	    }	}	else if ((component & BOUNDINGLEAF_CHANGED) != 0) {	    for (int i = 0; i < numLgts; i++) {		mLgts[i].boundingLeaf=((BoundingLeafRetained)objs[4]);		if (objs[4] != null) {		    mLgts[i].region = (Bounds)mLgts[i].boundingLeaf.transformedRegion;		}		else { // evaluate regionOfInfluence if not null 		    if (mLgts[i].regionOfInfluence != null) {			mLgts[i].region = 			    ((Bounds)mLgts[i].regionOfInfluence).copy(mLgts[i].region);			mLgts[i].region.transform(mLgts[i].regionOfInfluence, 						  mLgts[i].getCurrentLocalToVworld());		    }		    else {			mLgts[i].region = null;		    }		}	    }	}	else if ((component & SCOPE_CHANGED) != 0) {	    int nscopes, j, i;	    GroupRetained group;	    Vector currentScopes;	    Object[] scopeList = (Object[])objs[4];	    ArrayList addList = (ArrayList)scopeList[0];	    ArrayList removeList = (ArrayList)scopeList[1];	    boolean isScoped = ((Boolean)scopeList[2]).booleanValue();	    	    if (addList != null) {		for (i = 0; i < numLgts; i++) {		    mLgts[i].isScoped = isScoped;		    for (j = 0; j < addList.size(); j++) {			Shape3DRetained obj = ((GeometryAtom)addList.get(j)).source;			obj.addLight(mLgts[i]);		    }		}	    }	    	    if (removeList != null) {		for (i = 0; i < numLgts; i++) {		    mLgts[i].isScoped = isScoped;		    for (j = 0; j < removeList.size(); j++) {			Shape3DRetained obj = ((GeometryAtom)removeList.get(j)).source;			((Shape3DRetained)obj).removeLight(mLgts[i]);		    }		}	    }	}    }            // The update Object function called during RenderingEnv objUpdate    // Note : if you add any more fields here , you need to update    // updateLight() in RenderingEnvironmentStructure    void updateMirrorObject(Object[] objs) {	Transform3D trans = null;	int component = ((Integer)objs[1]).intValue();	int numLgts = ((Integer)objs[2]).intValue();	LightRetained[] mLgts = (LightRetained[]) objs[3];	if ((component & COLOR_CHANGED) != 0) {	    for (int i = 0; i < numLgts; i++) {		mLgts[i].color.set(((Color3f)objs[4]));	    }	}	if ((component & INIT_MIRROR) != 0) {	    for (int i = 0; i < numLgts; i++) {		Color3f clr = (Color3f) ((Object[])objs[4])[6];		mLgts[i].color.set(clr);	    }	}    }    /** Note: This routine will only be called on     * the mirror object - will update the object's     * cached region and transformed region      */    void updateBoundingLeaf() {	// This is necessary, if for example, the region	// changes from sphere to box.        if (boundingLeaf != null && boundingLeaf.switchState.currentSwitchOn) {            region = boundingLeaf.transformedRegion;        } else { // evaluate regionOfInfluence if not null            if (regionOfInfluence != null) {		region = regionOfInfluence.copy(region);                region.transform(regionOfInfluence, getCurrentLocalToVworld());            } else {                region = null;            }        }    }    void getMirrorObjects(ArrayList leafList, HashKey key) {	if (!inSharedGroup) {	    leafList.add(mirrorLights[0]);	}	else {	    for (int i=0; i<numMirrorLights; i++) {		if (mirrorLights[i].key.equals(key)) {		    leafList.add(mirrorLights[i]);		    break;		}	    }	    	}

⌨️ 快捷键说明

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