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

📄 alpha.java

📁 JAVA3D矩陈的相关类
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
     *     * <ul>     * <code>startTime += System.currentTimeMillis() - pauseTime</code>     * </ul>     *     * Since the alpha object is no longer paused, this has the effect     * of resuming the interpolator as of the current time.  If the     * alpha object is not paused when this method is called, then this     * method does nothing--the start time is not adjusted in this case.     *     * @since Java 3D 1.3     */    public void resume() {	resume(J3dClock.currentTimeMillis());    }    /**     * Resumes this alpha object as of the specified time.  If the alpha     * object was paused, the difference between the specified     * time and the pause time will be used to adjust the startTime of     * this alpha.  The equation is as follows:     *     * <ul><code>startTime += time - pauseTime</code></ul>     *     * Since the alpha object is no longer paused, this has the effect     * of resuming the interpolator as of the specified time.  If the     * alpha object is not paused when this method is called, then this     * method does nothing--the start time is not adjusted in this case.     *     * @param time the time at which to resume the alpha     *     * @exception IllegalArgumentException if time <= 0     *     * @since Java 3D 1.3     */    public void resume(long time) {	if (time <= 0L) {	    throw new IllegalArgumentException(J3dI18N.getString("Alpha0"));	}	if (paused) {	    long newStartTime = startTime + time - pauseTime;	    paused = false;	    pauseTime = 0L;	    setStartTime(newStartTime);	}    }    /**     * Returns true if this alpha object is paused.     * @return true if this alpha object is paused, false otherwise     *     * @since Java 3D 1.3     */    public boolean isPaused() {	return paused;    }    /**     * Returns the time at which this alpha was paused.     * @return the pause time; returns 0 if this alpha is not paused     *     * @since Java 3D 1.3     */    public long getPauseTime() {	return pauseTime;    }    /**     * This method returns a value between 0.0 and 1.0 inclusive,     * based on the current time and the time-to-alpha parameters     * established for this alpha.  If this alpha object is paused,     * the value will be based on the pause time rather than the     * current time.     * This method will return the starting alpha value if the alpha     * has not yet started (that is, if the current time is less     * than startTime + triggerTime + phaseDelayDuration). This     * method will return the ending alpha value if the alpha has     * finished (that is, if the loop count has expired).     *     * @return a value between 0.0 and 1.0 based on the current time     */    public float value() {	long currentTime = paused ? pauseTime : J3dClock.currentTimeMillis();	return this.value(currentTime);    }    /**     * This method returns a value between 0.0 and 1.0 inclusive,     * based on the specified time and the time-to-alpha parameters     * established for this alpha.     * This method will return the starting alpha value if the alpha     * has not yet started (that is, if the specified time is less     * than startTime + triggerTime + phaseDelayDuration). This     * method will return the ending alpha value if the alpha has     * finished (that is, if the loop count has expired).     *     * @param atTime The time for which we wish to compute alpha     * @return a value between 0.0 and 1.0 based on the specified time     */    public float value(long atTime) {	float interpolatorTime	  = (float)(atTime  - startTime) * .001f; // startTime is in millisec	float alpha, a1, a2, dt, alphaRampDuration;	//	System.err.println("alpha mode: " + mode);	// If non-looping and before start	//	if ((loopCount != -1) &&	//	    interpolatorTime <= ( triggerTime +  phaseDelay)) {	//		//	    if (( mode & INCREASING_ENABLE ) == 0 &&	//		( mode & DECREASING_ENABLE) != 0)	//		alpha = 1.0f;	//	    else	//		alpha = 0.0f;	//	    return alpha;	//	}			//  Case of {constantly} moving forward, snap back, forward again	if (( mode & INCREASING_ENABLE ) != 0 &&	    ( mode & DECREASING_ENABLE) == 0) {               if(interpolatorTime <= (triggerTime + phaseDelay))                      return 0.0f;               if((loopCount != -1) && (interpolatorTime >= stopTime))                      return 1.0f;	    //  Constant velocity case	    if (incAlphaRampInternal == 0.0f) {		alpha = mfmod((interpolatorTime -  triggerTime -  phaseDelay) +			      6.0f*( increasingAlpha +  alphaAtOne),			      (increasingAlpha + alphaAtOne))/ increasingAlpha;		if ( alpha > 1.0f)  alpha = 1.0f;		return alpha;	    }		    //  Ramped velocity case	    alphaRampDuration =  incAlphaRampInternal;	    dt = mfmod((interpolatorTime -  triggerTime -  phaseDelay) +		       6.0f*( increasingAlpha +  alphaAtOne),		       ( increasingAlpha +  alphaAtOne));	    if (dt >=  increasingAlpha) {  alpha = 1.0f; return alpha; }			// Original equation kept to help understand		// computation logic - simplification saves 		// a multiply and an add		// a1 = 1.0f/(alphaRampDuration*alphaRampDuration +		//	   ( increasingAlpha - 2*alphaRampDuration)*		//	   alphaRampDuration);		a1 = 1.0f/(increasingAlpha * alphaRampDuration -			alphaRampDuration * alphaRampDuration);		    if (dt < alphaRampDuration) {		alpha = 0.5f*a1*dt*dt;	    } else if (dt <  increasingAlpha - alphaRampDuration) {		alpha = 0.5f*a1*alphaRampDuration*		    alphaRampDuration +		    (dt - alphaRampDuration)*a1*		    alphaRampDuration;	    } else {		alpha = a1*alphaRampDuration*alphaRampDuration +		    ( increasingAlpha - 2.0f*alphaRampDuration)*a1*		    alphaRampDuration -		    0.5f*a1*( increasingAlpha - dt)*		    ( increasingAlpha - dt);	    }	    return alpha;		} else			    // Case of {constantly} moving backward, snap forward, backward	    // again	    if (( mode & INCREASING_ENABLE ) == 0 &&		( mode & DECREASING_ENABLE) != 0) {			// If non-looping and past end		//		if ((loopCount != -1)		//		    && (interpolatorTime 		//			>= (triggerTime + phaseDelay + decreasingAlpha))) {		//		    alpha = 0.0f;		//		    return alpha;		//		}                if(interpolatorTime <= (triggerTime + phaseDelay))                      return 1.0f;                 if((loopCount != -1) && (interpolatorTime >= stopTime) )                      return 0.0f; 			//  Constant velocity case		if (decAlphaRampInternal == 0.0f) {		    alpha = mfmod((interpolatorTime -  triggerTime -				   phaseDelay) +				  6.0f*( decreasingAlpha + alphaAtZero),				  (decreasingAlpha + alphaAtZero))/ decreasingAlpha;		    if ( alpha > 1.0f) {  alpha = 0.0f; return alpha; }		    alpha = 1.0f -  alpha;		    return alpha;		}			//  Ramped velocity case		alphaRampDuration =  decAlphaRampInternal;			dt = mfmod((interpolatorTime -  triggerTime -  phaseDelay) +			   6.0f*( decreasingAlpha +  alphaAtZero),			   ( decreasingAlpha +  alphaAtZero));		if (dt >=  decreasingAlpha) {  alpha = 0.0f; return alpha; }			// Original equation kept to help understand		// computation logic - simplification saves 		// a multiply and an add		// a1 = 1.0f/(alphaRampDuration*alphaRampDuration +		//	   ( decreasingAlpha - 2*alphaRampDuration)*		//	   alphaRampDuration);		a1 = 1.0f/(decreasingAlpha * alphaRampDuration -			alphaRampDuration * alphaRampDuration);			if (dt < alphaRampDuration) {		    alpha = 0.5f*a1*dt*dt;		} else if (dt <  decreasingAlpha - alphaRampDuration) {		    alpha = 0.5f*a1*alphaRampDuration*			alphaRampDuration +			(dt - alphaRampDuration)*a1*			alphaRampDuration;		} else {		    alpha = a1*alphaRampDuration*alphaRampDuration +			( decreasingAlpha - 2.0f*alphaRampDuration)*a1*			alphaRampDuration -			0.5f*a1*( decreasingAlpha - dt)*			( decreasingAlpha - dt);		}		alpha = 1.0f -  alpha;		return alpha;		    } else				//  Case of {osscilating} increasing and decreasing alpha		if (( mode & INCREASING_ENABLE) != 0 &&		    ( mode & DECREASING_ENABLE) != 0) {			    // If non-looping and past end		  //		    if ((loopCount != -1) &&		  //			(interpolatorTime >= 		  //			 (triggerTime +  phaseDelay +  increasingAlpha +		  //			  alphaAtOne +  decreasingAlpha))) {		  //			alpha = 0.0f;		  //			return alpha;		  //  }		    // If non-looping and past end, we always end up at zero since		    // decreasing alpha has been requested.		    if(interpolatorTime <= (triggerTime + phaseDelay))                         return 0.0f;		    if( (loopCount != -1) && (interpolatorTime >= stopTime))	                         return 0.0f;		    //  Constant velocity case		    if (incAlphaRampInternal == 0.0f			&& decAlphaRampInternal == 0.0f) {			dt = mfmod(interpolatorTime - triggerTime - phaseDelay +				   6.0f*(increasingAlpha + alphaAtOne +					 decreasingAlpha + alphaAtZero),				   increasingAlpha + alphaAtOne +				   decreasingAlpha + alphaAtZero);			alpha = dt / increasingAlpha;			if ( alpha < 1.0f) return alpha;			// sub all increasing alpha time			dt -=  increasingAlpha;			if (dt <  alphaAtOne) {  alpha = 1.0f; return alpha; }			// sub out alpha @ 1 time			dt -=  alphaAtOne;			alpha = dt/ decreasingAlpha;			if ( alpha < 1.0f)  alpha = 1.0f -  alpha;			else  alpha = 0.0f;			return alpha;		    }			    //  Ramped velocity case		    alphaRampDuration =  incAlphaRampInternal;                    // work around for bug 4308308                    if (alphaRampDuration == 0.0f)                        alphaRampDuration = .00001f;		    dt = mfmod(interpolatorTime -  triggerTime -  phaseDelay +			       6.0f*( increasingAlpha +  alphaAtOne +				      decreasingAlpha +  alphaAtZero),			       increasingAlpha +  alphaAtOne +			       decreasingAlpha +  alphaAtZero);		    if (dt <=  increasingAlpha) {			// Original equation kept to help understand			// computation logic - simplification saves 			// a multiply and an add			// a1 = 1.0f/(alphaRampDuration*alphaRampDuration +			//	   ( increasingAlpha - 2*alphaRampDuration)*			//	   alphaRampDuration);			a1 = 1.0f/(increasingAlpha * alphaRampDuration -				alphaRampDuration * alphaRampDuration);				if (dt < alphaRampDuration) {			    alpha = 0.5f*a1*dt*dt;			} else if (dt <  increasingAlpha - alphaRampDuration) {			    alpha = 0.5f*a1*alphaRampDuration*				alphaRampDuration +				(dt - alphaRampDuration)*a1*				alphaRampDuration;			} else {			    alpha = a1*alphaRampDuration*alphaRampDuration+				( increasingAlpha - 2.0f*alphaRampDuration)*a1*				alphaRampDuration -				0.5f*a1*( increasingAlpha - dt)*				( increasingAlpha - dt);			}			return alpha;		    }		    else if (dt <=  increasingAlpha +  alphaAtOne) {			alpha = 1.0f; return alpha;		    }		    else if (dt >=  increasingAlpha +  alphaAtOne +  decreasingAlpha) {			alpha = 0.0f; return alpha;

⌨️ 快捷键说明

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