/** * Sets this transform to the interpolation between the first transform and the second by delta amount. * @param t1 The beginning transform. * @param t2 The ending transform. * @param delta An amount between 0 and 1 representing how far to interpolate from t1 to t2. */ public void interpolateTransforms(Transform t1, Transform t2, float delta) { t1.rot.nlerp(t2.rot, delta); this.rot.set(t1.rot); this.translation.interpolateLocal(t1.translation,t2.translation,delta); this.scale.interpolateLocal(t1.scale,t2.scale,delta); }
/** * Calculates the minimum bounding sphere of 2 points. Used in welzl's * algorithm. * * @param O * The 1st point inside the sphere. * @param A * The 2nd point inside the sphere. * @see #calcWelzl(java.nio.FloatBuffer) */ private void setSphere(Vector3f O, Vector3f A) { radius = FastMath.sqrt(((A.x - O.x) * (A.x - O.x) + (A.y - O.y) * (A.y - O.y) + (A.z - O.z) * (A.z - O.z)) / 4f) + RADIUS_EPSILON - 1f; center.interpolateLocal(O, A, .5f); }
@Override public Vector3f interpolate(float t, int currentIndex, TrackDataReader<Vector3f> data, TrackTimeReader times, Vector3f store) { data.getEntryClamp(currentIndex, store); data.getEntryClamp(currentIndex + 1, next); store.interpolateLocal(next, t); return store; } };
/** * Position the GUI to the given location. * @param pos the position of the GUI. * @param dir the rotation of the GUI. * @param tpf the time per frame. */ private void positionTo(Vector3f pos, Quaternion dir, float tpf) { if (environment != null){ Vector3f guiPos = guiQuadNode.getLocalTranslation(); guiPos.set(0f, 0f, guiDistance); dir.mult(guiPos, guiPos); guiPos.x += pos.x; guiPos.y += pos.y + environment.getVRHeightAdjustment(); guiPos.z += pos.z; if( guiPositioningElastic > 0f && posMode != VRGUIPositioningMode.MANUAL ) { // mix pos & dir with current pos & dir guiPos.interpolateLocal(EoldPos, guiPos, Float.min(1f, tpf * guiPositioningElastic)); EoldPos.set(guiPos); } } else { throw new IllegalStateException("VR GUI manager is not attached to any environment."); } }
/** * This method applies the variation to the particle with already set velocity. * @param particle * the particle to be affected */ protected void applyVelocityVariation(Particle particle) { particle.velocity.set(initialVelocity); temp.set(FastMath.nextRandomFloat(), FastMath.nextRandomFloat(), FastMath.nextRandomFloat()); temp.multLocal(2f); temp.subtractLocal(1f, 1f, 1f); temp.multLocal(initialVelocity.length()); particle.velocity.interpolateLocal(temp, velocityVariation); }
float invWeightSum = 1f - currentWeightSum; localRot.nlerp(bindRot, invWeightSum); localPos.interpolateLocal(bindPos, invWeightSum); localScale.interpolateLocal(bindScale, invWeightSum);
tempV.interpolateLocal(tempV2, blend); tempS.interpolateLocal(tempS2, blend);
localPos.interpolateLocal(tmpV, weight); localScale.interpolateLocal(tmpV2, weight);
tempV.interpolateLocal(tempV2, blend); tempS.interpolateLocal(tempS2, blend);
position2.set(position).interpolateLocal(link.bone.getModelSpacePosition(), blendStart / blendTime); tmpRot1.set(tmpRot2); position.set(position2);
/** * This method applies the variation to the particle with already set velocity. * @param particle * the particle to be affected */ @Override protected void applyVelocityVariation(Particle particle) { particle.velocity.set(initialVelocity); temp.set(particle.position).subtractLocal(origin).normalizeLocal().multLocal(radialVelocity); if (horizontal) { temp.y = 0; } particle.velocity.addLocal(temp); temp.set(FastMath.nextRandomFloat(), FastMath.nextRandomFloat(), FastMath.nextRandomFloat()); temp.multLocal(2f); temp.subtractLocal(1f, 1f, 1f); temp.multLocal(initialVelocity.length()); particle.velocity.interpolateLocal(temp, velocityVariation); }
position2.set(position).interpolateLocal(link.bone.getModelSpacePosition(), blendStart / blendTime); tmpRot1.set(tmpRot2); position.set(position2);
if( camLeft != null && camRight != null ) { temppos.set(camLeft.getLocation()).interpolateLocal(camRight.getLocation(), 0.5f); positionTo(temppos, camLeft.getRotation(), tpf);
p.life -= tpf; if (lastPos != null && isInWorldSpace()) { p.position.interpolateLocal(lastPos, 1 - tpf / originalTpf);
/** * Sets this matrix to the interpolation between the first matrix and the second by delta amount. * @param t1 The beginning transform. * @param t2 The ending transform. * @param delta An amount between 0 and 1 representing how far to interpolate from t1 to t2. */ public void interpolateTransforms(Transform t1, Transform t2, float delta) { this.rot.slerp(t1.rot,t2.rot,delta); this.translation.interpolateLocal(t1.translation,t2.translation,delta); this.scale.interpolateLocal(t1.scale,t2.scale,delta); }
@Override protected void doInterpolate( double t ) { // Interpolate value.interpolateLocal(from, to, (float)t); target.setLocation(value); }
@Override protected void doInterpolate( double t ) { // Interpolate value.interpolateLocal(from, to, (float)t); target.setLocalTranslation(value); }
@Override protected void doInterpolate( double t ) { // Interpolate value.interpolateLocal(from, to, (float)t); target.setLocalScale(value); }
/** * Calculates the minimum bounding sphere of 2 points. Used in welzl's * algorithm. * * @param O * The 1st point inside the sphere. * @param A * The 2nd point inside the sphere. * @see #calcWelzl(java.nio.FloatBuffer) */ private void setSphere(Vector3f O, Vector3f A) { radius = FastMath.sqrt(((A.x - O.x) * (A.x - O.x) + (A.y - O.y) * (A.y - O.y) + (A.z - O.z) * (A.z - O.z)) / 4f) + RADIUS_EPSILON - 1f; center.interpolateLocal(O, A, .5f); }
/** * This method applies the variation to the particle with already set velocity. * @param particle * the particle to be affected */ protected void applyVelocityVariation(Particle particle) { particle.velocity.set(initialVelocity); temp.set(FastMath.nextRandomFloat(), FastMath.nextRandomFloat(), FastMath.nextRandomFloat()); temp.multLocal(2f); temp.subtractLocal(1f, 1f, 1f); temp.multLocal(initialVelocity.length()); particle.velocity.interpolateLocal(temp, velocityVariation); }