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

📄 alpha.java

📁 JAVA3D矩陈的相关类
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
		    }		    else {			dt -=  increasingAlpha + alphaAtOne;			alphaRampDuration =  decAlphaRampInternal;                        // work around for bug 4308308                        if (alphaRampDuration == 0.0f)                            alphaRampDuration = .00001f;			// 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;		    }			}	return 0.0f;    }    float mfmod(float a, float b) {	float fm, ta = (a), tb = (b);	int fmint;	if (tb < 0.0f) tb = -tb;	if (ta < 0.0f) ta = -ta;	fmint =(int)( ta/tb);	fm = ta - (float)fmint * tb;		if ((a) < 0.0f) return ((b) - fm);	else return fm;    }    /**      * Retrieves this alpha's startTime, the base      * for all relative time specifications; the default value      * for startTime is the system start time.      * @return this alpha's startTime.      */    public long getStartTime() {	return this.startTime;    }    /**     * Sets this alpha's startTime to that specified in the argument;      * startTime sets the base (or zero) for all relative time     * computations; the default value for startTime is the system     * start time.     * @param startTime the new startTime value     */    public void setStartTime(long startTime) {	this.startTime = startTime;	// This is used for passive wakeupOnElapsedFrame in	// Interpolator to restart behavior after alpha.finished()	VirtualUniverse.mc.sendRunMessage(J3dThread.RENDER_THREAD);    }    /**      * Retrieves this alpha's loopCount.      * @return this alpha's loopCount.      */    public int getLoopCount() {	return this.loopCount;    }    /**      * Set this alpha's loopCount to that specified in the argument.      * @param loopCount the new loopCount value      */    public void setLoopCount(int loopCount) {	this.loopCount = loopCount;	computeStopTime();	VirtualUniverse.mc.sendRunMessage(J3dThread.RENDER_THREAD);    }    /**      * Retrieves this alpha's mode.      * @return this alpha's mode: any combination of      * INCREASING_ENABLE and DECREASING_ENABLE      */    public int getMode() {	return this.mode;    }    /**      * Set this alpha's mode to that specified in the argument.     * @param mode indicates whether the increasing alpha parameters or     * the decreasing alpha parameters or both are active.  This parameter     * accepts the following values, INCREASING_ENABLE or     * DECREASING_ENABLE, which may be ORed together to specify     * that both are active.     * The increasing alpha parameters are increasingAlphaDuration,     * increasingAlphaRampDuration, and alphaAtOneDuration.     * The decreasing alpha parameters are decreasingAlphaDuration,     * decreasingAlphaRampDuration, and alphaAtZeroDuration.      */    public void setMode(int mode) {	this.mode = mode;	computeStopTime();	VirtualUniverse.mc.sendRunMessage(J3dThread.RENDER_THREAD);    }    /**      * Retrieves this alpha's triggerTime.      * @return this alpha's triggerTime.      */    public long getTriggerTime() {	return (long) (this.triggerTime * 1000f);    }    /**      * Set this alpha's triggerTime to that specified in the argument.      * @param triggerTime  the new triggerTime      */    public void setTriggerTime(long triggerTime) {	this.triggerTime = (float) triggerTime * .001f;	computeStopTime();	VirtualUniverse.mc.sendRunMessage(J3dThread.RENDER_THREAD);    }    /**      * Retrieves this alpha's phaseDelayDuration.      * @return this alpha's phaseDelayDuration.      */    public long getPhaseDelayDuration() {	return (long)(this.phaseDelay * 1000f);    }    /**      * Set this alpha's phaseDelayDuration to that specified in       * the argument.      * @param phaseDelayDuration  the new phaseDelayDuration      */    public void setPhaseDelayDuration(long phaseDelayDuration) {	this.phaseDelay = (float) phaseDelayDuration * .001f;	computeStopTime();	VirtualUniverse.mc.sendRunMessage(J3dThread.RENDER_THREAD);    }    /**      * Retrieves this alpha's increasingAlphaDuration.      * @return this alpha's increasingAlphaDuration.      */    public long getIncreasingAlphaDuration() {	return (long)(this.increasingAlpha * 1000f);    }    /**      * Set this alpha's increasingAlphaDuration to that specified in       * the argument.      * @param increasingAlphaDuration  the new increasingAlphaDuration      */    public void setIncreasingAlphaDuration(long increasingAlphaDuration) {	this.increasingAlpha = (float) increasingAlphaDuration * .001f;	computeStopTime();	VirtualUniverse.mc.sendRunMessage(J3dThread.RENDER_THREAD);    }    /**      * Retrieves this alpha's increasingAlphaRampDuration.      * @return this alpha's increasingAlphaRampDuration.      */    public long getIncreasingAlphaRampDuration() {	return increasingAlphaRamp;    }    /**      * Set this alpha's increasingAlphaRampDuration to that specified       * in the argument.      * @param increasingAlphaRampDuration  the new increasingAlphaRampDuration      */    public void setIncreasingAlphaRampDuration(long increasingAlphaRampDuration) {	increasingAlphaRamp = increasingAlphaRampDuration;	incAlphaRampInternal = (float) increasingAlphaRampDuration * .001f;	if (incAlphaRampInternal > (0.5f * increasingAlpha)) {	    incAlphaRampInternal = 0.5f * increasingAlpha;	}	VirtualUniverse.mc.sendRunMessage(J3dThread.RENDER_THREAD);    }    /**      * Retrieves this alpha's alphaAtOneDuration.      * @return this alpha's alphaAtOneDuration.      */    public long getAlphaAtOneDuration() {	return (long)(this.alphaAtOne * 1000f);    }    /**     * Set this alpha object's alphaAtOneDuration to the specified      * value.     * @param alphaAtOneDuration  the new alphaAtOneDuration     */    public void setAlphaAtOneDuration(long alphaAtOneDuration) {	this.alphaAtOne = (float) alphaAtOneDuration * .001f;	computeStopTime();	VirtualUniverse.mc.sendRunMessage(J3dThread.RENDER_THREAD);    }    /**      * Retrieves this alpha's decreasingAlphaDuration.      * @return this alpha's decreasingAlphaDuration.      */    public long getDecreasingAlphaDuration() {	return (long)(this.decreasingAlpha * 1000f);    }    /**      * Set this alpha's decreasingAlphaDuration to that specified in       * the argument.      * @param decreasingAlphaDuration  the new decreasingAlphaDuration      */    public void setDecreasingAlphaDuration(long decreasingAlphaDuration) {	this.decreasingAlpha = (float) decreasingAlphaDuration * .001f;	computeStopTime();	VirtualUniverse.mc.sendRunMessage(J3dThread.RENDER_THREAD);    }    /**      * Retrieves this alpha's decreasingAlphaRampDuration.      * @return this alpha's decreasingAlphaRampDuration.      */    public long getDecreasingAlphaRampDuration() {	return decreasingAlphaRamp;    }    /**      * Set this alpha's decreasingAlphaRampDuration to that specified       * in the argument.      * @param decreasingAlphaRampDuration  the new decreasingAlphaRampDuration      */    public void setDecreasingAlphaRampDuration(long decreasingAlphaRampDuration) {	decreasingAlphaRamp = decreasingAlphaRampDuration;	decAlphaRampInternal = (float) decreasingAlphaRampDuration * .001f;	if (decAlphaRampInternal > (0.5f * decreasingAlpha)) {	    decAlphaRampInternal = 0.5f * decreasingAlpha;	}	VirtualUniverse.mc.sendRunMessage(J3dThread.RENDER_THREAD);    }    /**      * Retrieves this alpha's alphaAtZeroDuration.      * @return this alpha's alphaAtZeroDuration.      */    public long getAlphaAtZeroDuration() {	return (long)(this.alphaAtZero * 1000f);    }    /**     * Set this alpha object's alphaAtZeroDuration to the specified      * value.     * @param alphaAtZeroDuration  the new alphaAtZeroDuration     */    public void setAlphaAtZeroDuration(long alphaAtZeroDuration) {	this.alphaAtZero = (float) alphaAtZeroDuration * .001f;	computeStopTime();	VirtualUniverse.mc.sendRunMessage(J3dThread.RENDER_THREAD);    }    /**     * Query to test if this alpha object is past its activity window,     * that is, if it has finished looping.     * @return true if no longer looping, false otherwise     */    public boolean finished() {	long currentTime = paused ? pauseTime : J3dClock.currentTimeMillis();	return ((loopCount != -1) && 	        ((float)(currentTime - startTime) * .001f > stopTime));    }    final private void computeStopTime() {        if (loopCount >= 0) {	    float sum = 0;	    if (( mode & INCREASING_ENABLE ) != 0) {		sum = increasingAlpha+alphaAtOne; 	    }	    if ((mode & DECREASING_ENABLE) != 0) {		sum += decreasingAlpha+alphaAtZero;	    }	    stopTime = this.triggerTime + phaseDelay + loopCount*sum;	} else {	    stopTime = 0;	}    }    /**      * This internal method returns a clone of the Alpha     *     * @return a duplicate of this Alpha     */    Alpha cloneAlpha() {      Alpha a = new Alpha();      a.setStartTime(getStartTime());      a.setLoopCount(getLoopCount());      a.setMode(getMode());      a.setTriggerTime(getTriggerTime());      a.setPhaseDelayDuration(getPhaseDelayDuration());      a.setIncreasingAlphaDuration(getIncreasingAlphaDuration());      a.setIncreasingAlphaRampDuration(getIncreasingAlphaRampDuration());      a.setAlphaAtOneDuration(getAlphaAtOneDuration());      a.setDecreasingAlphaDuration(getDecreasingAlphaDuration());      a.setDecreasingAlphaRampDuration(getDecreasingAlphaRampDuration());      a.setAlphaAtZeroDuration(getAlphaAtZeroDuration());      return a;    }    static {        VirtualUniverse.loadLibraries();    }}

⌨️ 快捷键说明

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