@Override public void onRun() { Location location = getLocation(); Vector vector = new Vector(); for (int i = 0; i < particles; i++) { float alpha = ((MathUtils.PI / compilaction) / particles) * i; double phi = Math.pow(Math.abs(MathUtils.sin(2 * compilaction * alpha)) + factorInnerSpike * Math.abs(MathUtils.sin(compilaction * alpha)), 1 / compressYFactorTotal); vector.setY(phi * (MathUtils.sin(alpha) + MathUtils.cos(alpha)) * yFactor); vector.setZ(phi * (MathUtils.cos(alpha) - MathUtils.sin(alpha)) * xFactor); VectorUtils.rotateVector(vector, xRotation, yRotation, zRotation); display(particle, location.add(vector)); location.subtract(vector); } }
/** * Returns true if a random value between 0 and 1 is less than the specified value. */ static public final boolean randomBoolean(float chance) { return MathUtils.random() < chance; }
public static void setVelocity(Entity entity, Vector velocity) { if (!MathUtils.isFinite(velocity.getX()) || !MathUtils.isFinite(velocity.getY()) || !MathUtils.isFinite(velocity.getZ())) { return; } if (Math.abs(velocity.getX()) > MAX_VELOCITY) velocity.setX(MAX_VELOCITY * Math.signum(velocity.getX())); if (Math.abs(velocity.getY()) > MAX_VELOCITY) velocity.setY(MAX_VELOCITY * Math.signum(velocity.getY())); if (Math.abs(velocity.getZ()) > MAX_VELOCITY) velocity.setZ(MAX_VELOCITY * Math.signum(velocity.getZ())); entity.setVelocity(velocity); } }
if (orientToTarget && targetLocation != null && location != null) { Vector direction = targetLocation.toVector().subtract(location.toVector()).normalize(); if (MathUtils.isFinite(direction.getX()) && MathUtils.isFinite(direction.getY()) && MathUtils.isFinite(direction.getZ())) { location.setDirection(direction);
@Override public void onRun() { Vector vector = new Vector(); Location location = getLocation(); for (int i = 0; i < particlesPerIteration; i++) { step++; float t = (MathUtils.PI / particles) * step; float r = MathUtils.sin(t) * size; float s = 2 * MathUtils.PI * t; vector.setX(xFactor * r * MathUtils.cos(s) + xOffset); vector.setZ(zFactor * r * MathUtils.sin(s) + zOffset); vector.setY(yFactor * size * MathUtils.cos(t) + yOffset); VectorUtils.rotateVector(vector, xRotation, yRotation, zRotation); display(particle, location.add(vector)); location.subtract(vector); } }