示例#1
0
  @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();
    }
  }
 /**
  * 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;
 }
 /**
  * generate a random lifespan between the min and max lifespan of the particle system.
  *
  * @return the generated lifespan value
  */
 public float getRandomLifeSpan() {
   return getMinimumLifeTime()
       + ((getMaximumLifeTime() - getMinimumLifeTime()) * FastMath.nextRandomFloat());
 }
 /**
  * Returns a random angle between the min and max angles.
  *
  * @return the random angle.
  */
 public float getRandomAngle() {
   return getMinimumAngle() + FastMath.nextRandomFloat() * (getMaximumAngle() - getMinimumAngle());
 }