@Override public void nextFrame(StageGameState b) { if (phase == 0 && character.play("raiseUp", b.tpf)) { // allow to animate character.animationLock = false; phase++; } else if (phase >= 1 && phase < numFires + 1 && frameCount % delay == 0) { // determine spawn point float a = FastMath.nextRandomFloat() * FastMath.PI * 2; float p = FastMath.nextRandomFloat() * FastMath.PI * 2; Vector3f translation = new Vector3f( radius * FastMath.sin(p) * FastMath.sin(a), radius * FastMath.cos(p), radius * FastMath.sin(p) * FastMath.cos(a)); Fire fire = (Fire) LoadingQueue.quickLoad(new Fire(getUsers()), b); fire.setVelocity(translation.mult(.2f / (float) radius)); fire.model.setLocalTranslation(character.model.getLocalTranslation().add(translation)); b.getRootNode().updateRenderState(); phase++; } else if (phase >= numFires + 1) { finish(); } }
private void readNormal(Vector3f norm) { int zenith = file.readByte(); int azimuth = file.readByte(); float lat = (zenith * 2 * FastMath.PI) / 255; float lng = (azimuth * 2 * FastMath.PI) / 255; norm.x = FastMath.cos(lat) * FastMath.sin(lng); norm.y = FastMath.sin(lat) * FastMath.sin(lng); norm.z = FastMath.cos(lng); }
/** * Generate a random velocity within the parameters of max angle and the rotation matrix. * * @param pSpeed a vector to store the results in. */ protected Vector3f getRandomVelocity(Vector3f pSpeed) { float randDir = FastMath.TWO_PI * FastMath.nextRandomFloat(); float randAngle = getRandomAngle(); if (pSpeed == null) pSpeed = new Vector3f(); pSpeed.x = FastMath.cos(randDir) * FastMath.sin(randAngle); pSpeed.y = FastMath.cos(randAngle); pSpeed.z = FastMath.sin(randDir) * FastMath.sin(randAngle); rotateVectorSpeed(pSpeed); pSpeed.multLocal(getInitialVelocity()); return pSpeed; }
@Override public void nextFrame(StageGameState b) { // if animation is halfway through MeshAnimationController animControl = (MeshAnimationController) character.model.getController(0); if (phase == 0 && animControl.getCurTime() + b.tpf >= animControl.getAnimationLength("cast") / 2) { phase++; // calculate transformations Vector3f rotation = character.rotationVector; float angle = FastMath.atan2(rotation.x, rotation.z); Vector3f translation = new Vector3f(2 * FastMath.sin(angle), 3.7f, 2 * FastMath.cos(angle)); Echo e = (Echo) LoadingQueue.quickLoad(new Echo(getUsers(), target), b); e.rotate(rotation); e.setVelocity(rotation.mult(e.speed)); e.model.setLocalTranslation(character.model.getWorldTranslation().add(translation)); b.getRootNode().updateRenderState(); } else if (character.play("cast", b.tpf)) { finish(); } }