當前位置: 首頁>>代碼示例>>Java>>正文


Java FastMath.clamp方法代碼示例

本文整理匯總了Java中com.jme3.math.FastMath.clamp方法的典型用法代碼示例。如果您正苦於以下問題:Java FastMath.clamp方法的具體用法?Java FastMath.clamp怎麽用?Java FastMath.clamp使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.jme3.math.FastMath的用法示例。


在下文中一共展示了FastMath.clamp方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setScrollAreaPositionTo

import com.jme3.math.FastMath; //導入方法依賴的package包/類
private void setScrollAreaPositionTo(float relativeScrollAmount, Orientation orientation) {
	relativeScrollAmount = FastMath.clamp(relativeScrollAmount, 0, 1);
	if (orientation == Orientation.VERTICAL) {
		float lastY = scrollableArea.getY();
		float newY = Math.round(-(getVerticalScrollDistance() * relativeScrollAmount));
		if (lastY != newY) {
			scrollableArea.setY(newY);
			if (lastY > -(getVerticalScrollDistance() * relativeScrollAmount))
				onScrollContent(ScrollDirection.Up);
			else
				onScrollContent(ScrollDirection.Down);
		}
	} else {
		float lastX = scrollableArea.getX();
		float newX = Math.min(0, Math.round(-(getHorizontalScrollDistance() * relativeScrollAmount)));
		if (lastX != newX) {
			scrollableArea.setX(newX);
			if (lastX < -(getHorizontalScrollDistance() * relativeScrollAmount))
				onScrollContent(ScrollDirection.Left);
			else
				onScrollContent(ScrollDirection.Right);
		}
	}
}
 
開發者ID:rockfireredmoon,項目名稱:icetone,代碼行數:25,代碼來源:ScrollPanel.java

示例2: onMouseMotionEvent

import com.jme3.math.FastMath; //導入方法依賴的package包/類
public void onMouseMotionEvent(MouseMotionEvent evt) {
    x += evt.getDX();
    y += evt.getDY();

    // Prevent mouse from leaving screen
    AppSettings settings = TestSoftwareMouse.this.settings;
    x = FastMath.clamp(x, 0, settings.getWidth());
    y = FastMath.clamp(y, 0, settings.getHeight());

    // adjust for hotspot
    cursor.setPosition(x, y - 64);
}
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:13,代碼來源:TestSoftwareMouse.java

示例3: computeAnalogValue

import com.jme3.math.FastMath; //導入方法依賴的package包/類
private float computeAnalogValue(long timeDelta) {
    if (safeMode || frameDelta == 0) {
        return 1f;
    } else {
        return FastMath.clamp((float) timeDelta / (float) frameDelta, 0, 1);
    }
}
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:8,代碼來源:InputManager.java

示例4: getColor

import com.jme3.math.FastMath; //導入方法依賴的package包/類
private Color getColor(String r, String g, String b, String a) {
    try {
        float fr = FastMath.clamp(Float.parseFloat(r), 0, 1);
        float fg = FastMath.clamp(Float.parseFloat(g), 0, 1);
        float fb = FastMath.clamp(Float.parseFloat(b), 0, 1);
        float fa = FastMath.clamp(Float.parseFloat(a), 0, 1);
        return new Color(fr, fg, fb, fa);
    } catch (NumberFormatException e) {
        return null;
    }
}
 
開發者ID:jMonkeyEngine,項目名稱:sdk,代碼行數:12,代碼來源:ColorPanel.java

示例5: fixTimePointByCutTime

import com.jme3.math.FastMath; //導入方法依賴的package包/類
/**
     * 重新計算受cutTime影響的時間插值點。
     * @param interpolation 原始的時間插值點(未受cutTime影響的時間插值)
     * @return 經過cutTime計算後的實際的時間插值點
     */
    protected float fixTimePointByCutTime(float interpolation) {
//        float cutTimeStart = data.getCutTimeStart();
//        float cutTimeEnd = data.getCutTimeEnd();
        float cutTimeStart = 0;
        float cutTimeEnd = 0;
        float result = FastMath.clamp((interpolation - cutTimeStart) / (1.0f - cutTimeStart - cutTimeEnd)
                , 0f, 1.0f);
        return result;
    }
 
開發者ID:huliqing,項目名稱:LuoYing,代碼行數:15,代碼來源:SimpleAnimationSkill.java

示例6: toJfxColor

import com.jme3.math.FastMath; //導入方法依賴的package包/類
private Color toJfxColor(ColorRGBA jmeColor) {
    if (jmeColor == null) {
        return new Color(1,1,1,1);
    }
    
    return new Color(FastMath.clamp(jmeColor.r, 0, 1)
            , FastMath.clamp(jmeColor.g, 0, 1)
            , FastMath.clamp(jmeColor.b, 0, 1)
            , FastMath.clamp(jmeColor.a, 0, 1));
}
 
開發者ID:huliqing,項目名稱:LuoYing,代碼行數:11,代碼來源:ColorConverter.java

示例7: apply

import com.jme3.math.FastMath; //導入方法依賴的package包/類
@Override
public float apply (float a) {
	return FastMath.clamp(a * a * a * (a * (a * 6 - 15) + 10), 0, 1);
}
 
開發者ID:rockfireredmoon,項目名稱:icetone,代碼行數:5,代碼來源:Interpolation.java

示例8: setAngle

import com.jme3.math.FastMath; //導入方法依賴的package包/類
public void setAngle(float ang) {
    angles[1] = ang;
    angles[1] = FastMath.clamp(angles[1], minAngle, maxAngle);
    quat.fromAngles(angles);
    node.setLocalRotation(quat);
}
 
開發者ID:dwhuang,項目名稱:SMILE,代碼行數:7,代碼來源:RobotJointState.java

示例9: update

import com.jme3.math.FastMath; //導入方法依賴的package包/類
@Override
public void update(float tpf) {
	if (!enabled) {
		return;
	}
    super.update(tpf);
    if (velocity > 0 && holding.size() > 0) {
        release();
    }
    
    if (holding.size() > 0) {
        velocity = 0;
        return;
    }
    
    // check holding objects
    float maxDiff = opening * FastMath.tan(FastMath.QUARTER_PI / 4);
    for (Entry<Float, Spatial> e1 : leftContacts.entrySet()) {
        for (Entry<Float, Spatial> e2 : rightContacts.entrySet()) {
            if (e1.getValue() != e2.getValue()) {
                continue;
            }
            if (FastMath.abs(e1.getKey() - e2.getKey()) > maxDiff) {
                continue;
            }
        	
            Spatial s = e1.getValue();
            if (holding.contains(s)) {
                continue;
            }
            MyRigidBodyControl rbc = s.getControl(MyRigidBodyControl.class);
            if (rbc == null || rbc.getMass() == 0 || rbc.isKinematic()) {
                continue;
            }
            hold(s);
            logger.log(Level.INFO, "hold");
        }
    }
    
    if ((leftContacts.size() > 0 || rightContacts.size() > 0) && holding.size() <= 0) {
        logger.log(Level.INFO, "cannot hold: {0}", maxDiff);
    }
                
    leftContacts.clear();
    rightContacts.clear();

    
    if (velocity != 0) {
        if (velocity < 0) {
            float impulse = -velocity * tpf * FINGER_MASS * 2;
            impulse -= fingerPressure;
            float offset = impulse / (FINGER_MASS * 2);
            offset = FastMath.clamp(offset, 0, offset);
            opening -= offset;
            checkDigitCollision = true;
        } else {
            opening += velocity * tpf;
            checkDigitCollision = false;
        }
        opening = FastMath.clamp(opening, 0, Gripper.MAX_OPENING);

        // update finger opeining
        Vector3f v = leftFinger.getLocalTranslation();
        v.x = -opening / 2 - Gripper.FINGER_SIZE.x / 2;
        leftFinger.setLocalTranslation(v);
        v = rightFinger.getLocalTranslation();
        v.x = opening / 2 + Gripper.FINGER_SIZE.x / 2;
        rightFinger.setLocalTranslation(v);
        
        fingerPressure = 0;
        velocity = 0;
    } else {
        checkDigitCollision = false;
    }
}
 
開發者ID:dwhuang,項目名稱:SMILE,代碼行數:76,代碼來源:Gripper.java

示例10: setData

import com.jme3.math.FastMath; //導入方法依賴的package包/類
@Override
public void setData(SkillData data) {
    super.setData(data); 
    timePoint = FastMath.clamp(data.getAsFloat("timePoint", timePoint), 0, 1.0f);
}
 
開發者ID:huliqing,項目名稱:LuoYing,代碼行數:6,代碼來源:ResetSkill.java

示例11: setTime

import com.jme3.math.FastMath; //導入方法依賴的package包/類
/**
 * @param time Set the time of the currently playing animation, the time
 * is clamped from 0 to getAnimMaxTime().
 */
public void setTime(float time) {
    this.time = FastMath.clamp(time, 0, getAnimMaxTime());
}
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:8,代碼來源:AnimChannel.java


注:本文中的com.jme3.math.FastMath.clamp方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。