Ejemplo n.º 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();
    }
  }
Ejemplo n.º 2
0
 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;
 }
Ejemplo n.º 4
0
  @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();
    }
  }
  public float getHeight(float x, float z, float time) {
    float zval = z * scaleybig * 4f + time * speedbig * 4f;
    float height = FastMath.sin(zval);
    height *= heightbig;

    if (octaves > 0) {
      float height2 =
          (float) ImprovedNoise.noise(x * scaleybig, z * scalexbig, time * speedbig) * heightbig;
      height = height * 0.4f + height2 * 0.6f;
    }
    if (octaves > 1)
      height +=
          ImprovedNoise.noise(x * scaleysmall, z * scalexsmall, time * speedsmall) * heightsmall;
    if (octaves > 2)
      height +=
          ImprovedNoise.noise(
                  x * scaleysmall * 2.0f, z * scalexsmall * 2.0f, time * speedsmall * 1.5f)
              * heightsmall
              * 0.5f;
    if (octaves > 3)
      height +=
          ImprovedNoise.noise(
                  x * scaleysmall * 4.0f, z * scalexsmall * 4.0f, time * speedsmall * 2.0f)
              * heightsmall
              * 0.25f;

    return height; // + waterHeight
  }