本文整理匯總了Java中com.jme3.math.FastMath.approximateEquals方法的典型用法代碼示例。如果您正苦於以下問題:Java FastMath.approximateEquals方法的具體用法?Java FastMath.approximateEquals怎麽用?Java FastMath.approximateEquals使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.jme3.math.FastMath
的用法示例。
在下文中一共展示了FastMath.approximateEquals方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: jSpinner1StateChanged
import com.jme3.math.FastMath; //導入方法依賴的package包/類
private void jSpinner1StateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jSpinner1StateChanged
// This is called, when the spinner of the near plane has been changed.
float near = ((float)jSlider1.getValue() / 1000f);
float spin = (Float)jSpinner1.getValue();
// Prevent an endless loop of state changes and don't change the slider when the spinner
// has gone out of range, since this would lead to the slider's StateChanged overwriting the spinner again.
// but we want the spinner to be a free-form field
if (spin <= 2000f && spin >= 100f && !FastMath.approximateEquals((Float)(jSpinner1.getValue()), near)) {
jSlider1.setValue((int)((Float)(jSpinner1.getValue()) * 1000f));
}
final Camera cam = SceneApplication.getApplication().getCamera();
cam.setFrustumPerspective(45f, (float)cam.getWidth() / cam.getHeight(), spin, cam.getFrustumFar());
}
示例2: jSlider1StateChanged
import com.jme3.math.FastMath; //導入方法依賴的package包/類
private void jSlider1StateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jSlider1StateChanged
// This is called, when the slider of the near plane has been dragged.
float near = ((float)jSlider1.getValue() / 1000f);
// Prevent an endless loop of state changes
if (!FastMath.approximateEquals((Float)(jSpinner1.getValue()), near)) {
jSpinner1.setValue(near);
}
}
示例3: jSlider2StateChanged
import com.jme3.math.FastMath; //導入方法依賴的package包/類
private void jSlider2StateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jSlider2StateChanged
// This is called, when the slider of the far plane has been dragged.
float far = jSlider2.getValue();
// Prevent an endless loop of state changes
if (!FastMath.approximateEquals((Float)(jSpinner2.getValue()), far)) {
jSpinner2.setValue(far);
}
}
示例4: jSpinner2StateChanged
import com.jme3.math.FastMath; //導入方法依賴的package包/類
private void jSpinner2StateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jSpinner2StateChanged
// Prevent an endless loop of state changes and don't change the slider when the spinner
// has gone out of range, since this would lead to the slider's StateChanged overwriting the spinner again.
// but we want the spinner to be a free-form field
float spin = (Float)jSpinner2.getValue();
if (spin <= 3000f && spin >= 5f && !FastMath.approximateEquals(spin, (float)jSlider2.getValue())) {
jSlider2.setValue((int)spin);
}
final Camera cam = SceneApplication.getApplication().getCamera();
cam.setFrustumPerspective(45f, (float)cam.getWidth() / cam.getHeight(), cam.getFrustumNear(), spin);
}
示例5: tryParseShadowMapSize
import com.jme3.math.FastMath; //導入方法依賴的package包/類
void tryParseShadowMapSize(PLSFVisualPanel1 comp) throws WizardValidationException {
try {
shadowMapSize = Integer.parseInt(comp.getjShadowMapField().getText());
} catch (NumberFormatException nfe) {
throw new WizardValidationException(comp, "NumberFormatException when trying to parse the ShadowMapSize!", null);
}
double log2 = Math.log(shadowMapSize) / Math.log(2);
if (!FastMath.approximateEquals((float)(Math.floor(log2) - log2), 0f)) {
LOG.warning("The Shadow Map Size is not power of two!");
}
}
示例6: tryParseShadowMapSize
import com.jme3.math.FastMath; //導入方法依賴的package包/類
void tryParseShadowMapSize(SLSFVisualPanel1 comp) throws WizardValidationException {
try {
shadowMapSize = Integer.parseInt(comp.getjShadowMapField().getText());
} catch (NumberFormatException nfe) {
throw new WizardValidationException(comp, "NumberFormatException when trying to parse the ShadowMapSize!", null);
}
double log2 = Math.log(shadowMapSize) / Math.log(2);
if (!FastMath.approximateEquals((float)(Math.floor(log2) - log2), 0f)) {
LOG.warning("The Shadow Map Size is not power of two!");
}
}
示例7: tryParseShadowMapSize
import com.jme3.math.FastMath; //導入方法依賴的package包/類
void tryParseShadowMapSize(DLSFVisualPanel1 comp) throws WizardValidationException {
try {
shadowMapSize = Integer.parseInt(comp.getjShadowMapField().getText());
} catch (NumberFormatException nfe) {
throw new WizardValidationException(comp, "NumberFormatException when trying to parse the ShadowMapSize!", null);
}
double log2 = Math.log(shadowMapSize) / Math.log(2);
if (!FastMath.approximateEquals((float)(Math.floor(log2) - log2), 0f)) {
LOG.warning("The Shadow Map Size is not power of two!");
}
}
示例8: update
import com.jme3.math.FastMath; //導入方法依賴的package包/類
@Override
public void update() {
//update the character state based on the needed components
//first collect some necessary information
PhysicsCharacter character = get(PhysicsCharacter.class);
Vector2f move = get(PhysicsCharacterMovement.class).getDirection();
set(new PhysicsCharacterMovementForce(new Vector3f(
move.x*character.getMass()*character.getAcceleration(), 0,
move.y*character.getMass()*character.getAcceleration())));
float capsuleHeight = character.getHeight()-2*character.getRadius()-character.getStepHeight();
float bodyHeight = capsuleHeight+2*character.getRadius();
float jumpSpeed = FastMath.sqrt(2*9.81f*character.getJumpHeight());
boolean jumping = get(PhysicsCharacterState.class).isJumping();
boolean ducking = get(PhysicsCharacterState.class).isDucking();
set(new PhysicsCharacterState(false, false)); //TODO remove
int jumpCount = get(PhysicsCharacterJumpCount.class).getCount();
boolean onGround = false;
Vector3f velocity = get(LinearVelocity.class).getVelocity();
PhysicsPosition pos = get(PhysicsPosition.class);
//the most important part is the ray system which keeps the capsule floating
//in the air over the ground
List<PhysicsRayTestResult> rayTestResultList = bulletSystem.getPhysicsSpace()
.rayTest(pos.getLocation(), pos.getLocation().add(0,-50,0));
if(rayTestResultList.size() > 0){
float len = 60;
for (PhysicsRayTestResult physicsRayTestResult : rayTestResultList) {
if(physicsRayTestResult.getHitFraction()*50 < len){
len = physicsRayTestResult.getHitFraction()*50;
}
}
//if the character is near the ground or below it push it to the min step height.
if(len <= character.getStepHeight() + bodyHeight/2){
float diff = character.getStepHeight() + bodyHeight/2-len;
set(new WarpPosition(pos.getLocation().add(0, diff, 0), pos.getRotation()));
if(velocity.y < 0) {
set(new WarpVelocity(velocity.clone().setY(0), Vector3f.ZERO));
}
onGround = true;
set(new PhysicsCharacterJumpCount(0));
jumpCount = 0;
}
}
Vector3f impulse = new Vector3f();
//apply jump
if(jumping && (onGround || jumpCount < character.getMaxJumpNumber())){
set(new PhysicsCharacterJumpCount(jumpCount+1));
impulse.addLocal(new Vector3f(0, character.getMass()*jumpSpeed, 0));
}
//slow the character down if no movement is applied
if(onGround){
Vector3f slowDownImpulse = new Vector3f();
if(FastMath.approximateEquals(move.x, 0)){
slowDownImpulse.setX(-velocity.x*character.getMass()*0.05f);
}
if(FastMath.approximateEquals(move.y, 0)){
slowDownImpulse.setZ(-velocity.z*character.getMass()*0.05f);
}
impulse.addLocal(slowDownImpulse);
}
//TODO use combined impulse
set(new Impulse(impulse, new Vector3f()));
}