List of usage examples for com.badlogic.gdx.math Interpolation pow3In
PowIn pow3In
To view the source code for com.badlogic.gdx.math Interpolation pow3In.
Click Source Link
From source file:com.cyphercove.doublehelix.Particle.java
License:Apache License
private void updateCommon(float delta, boolean haveTouchVelocity, Vector3 touchPosition, Vector3 touchVelocity, float cameraDistance) { age += delta;/*from w ww.ja v a 2s. co m*/ if (age < LIFE_FADE_TIME) ageFade = Interpolation.fade.apply(age / LIFE_FADE_TIME); else if (age > LIFE_FADE_OUT_TIME) ageFade = Interpolation.fade.apply((LIFE_TIME - age) / LIFE_FADE_TIME); else ageFade = 1; TMPV.set(center.x, center.y, 0); float distFromAccelerationCenter = TMPV.len() - RADIAL_ACCELERATION_MAX_CENTER; float radialAcceleration = RADIAL_ACCELERATION_MAX * (1F - Math.min(1f, Interpolation.fade .apply(Math.abs(distFromAccelerationCenter) / RADIAL_ACCELERATION_EFFECT_EXTENT))); TMPV.nor().rotate(Vector3.Z, 90f - (distFromAccelerationCenter * DEGREES_ACCLERATION_PER_DIST)); //motion direction TMPV.scl(radialAcceleration); //acceleration baseVelocity.add(TMPV.scl(delta)); //apply acceleration float dampenAmount = DAMPENING * baseVelocity.len() * delta; if (dampenAmount >= 1f) baseVelocity.set(0, 0, 0); else baseVelocity.add(TMPV.set(baseVelocity).scl(-dampenAmount)); velocity.set(baseVelocity); if (haveTouchVelocity && cameraDistance <= TOUCH_CHECK_DISTANCE) { float dst = TMPV.set(center).sub(touchPosition).len(); if (dst < TOUCH_INFLUENCE) { float mag = 1f - Math.min(1f, dst / TOUCH_INFLUENCE); if (mag > touchMagnitude) { touchMagnitude = mag; //float radialDst = distanceToAxis(center, touchPosition, touchVelocity); touchAge = 0; touchRotationVelocity.set(touchVelocity).scl(TOUCH_SPEED_RATIO * mag); touchRotationAxis.set(TMPV).crs(touchVelocity).nor(); } } } if (touchMagnitude > 0) { touchAge += delta; if (touchAge > TOUCH_DAMPEN_TIME) { touchMagnitude = 0; TMPV.set(touchRotationVelocity).scl(0.5f); TMPV.rotate(touchRotationAxis, -45); baseVelocity.add(TMPV); velocity.set(baseVelocity); } else { float lerp = touchAge / TOUCH_DAMPEN_TIME; TMPV.set(touchRotationVelocity).scl(1f - 0.5f * Interpolation.pow2Out.apply(lerp)); TMPV.rotate(touchRotationAxis, -Interpolation.pow3In.apply(lerp) * 45); velocity.add(TMPV); } } if (age >= LIFE_TIME) { center.set(originalCenter); age = 0; } else { center.add(TMPV.set(velocity).scl(delta)); } }