@Override
 public Vec3f getMax(Vec3f max) {
   if (max == null) {
     max = new Vec3f();
   }
   max.x = maxX;
   max.y = maxY;
   max.z = 0.0f;
   return max;
 }
 @Override
 public Vec3f getMin(Vec3f min) {
   if (min == null) {
     min = new Vec3f();
   }
   min.x = minX;
   min.y = minY;
   min.z = 0.0f;
   return min;
 }
  protected void initParticles() {
    pAndsBuff.clear();
    velBuff.clear();
    lifespanBuff.clear();
    ageBuff.clear();

    float[] velocity = dir.dot(speed);

    for (int i = 0; i < particleCount; i++) {
      pAndsBuff.put(
          new float[] {
            ((float) Math.random() - 0.5f) * 50f, 50f, ((float) Math.random() - 0.5f) * 50f, 0.016f
          });
      velBuff.put(new float[] {velocity[0], velocity[1], velocity[2], 0f});
      ageBuff.put(0f);

      if (i < startCount) {
        lifespanBuff.put(1f);
      } else {
        lifespanBuff.put(0f);
      }
    }

    pAndsBuff.rewind();
    velBuff.rewind();
    lifespanBuff.rewind();
    ageBuff.rewind();

    newParticles = (int) (birthRate * timeBetweenAni);
  }
Exemple #4
0
 /** A view matrix defined by an eye and target position (same as gluLookAt) */
 public static Mat4f lookAt(
     float eyeX,
     float eyeY,
     float eyeZ,
     float centerX,
     float centerY,
     float centerZ,
     float upX,
     float upY,
     float upZ) {
   Vec3f f = new Vec3f(centerX - eyeX, centerY - eyeY, centerZ - eyeZ).normalize();
   Vec3f up = new Vec3f(upX, upY, upZ).normalize();
   Vec3f s = f.cross(up).normalize();
   Vec3f u = s.cross(f).normalize();
   Mat4f m1 =
       new Mat4f(
           new float[] {s.x, u.x, -f.x, 0, s.y, u.y, -f.y, 0, s.z, u.z, -f.z, 0, 0, 0, 0, 1});
   Mat4f m2 = translation(-eyeX, -eyeY, -eyeZ);
   return m1.times(m2);
 }
  public int generateBumpPixel(BufferedImage image, int x, int y, float a) {
    Vec3f S = new Vec3f();
    Vec3f T = new Vec3f();
    Vec3f N = new Vec3f();

    S.x = 1;
    S.y = 0;
    S.z = a * getHeight(image, x + 1, y) - a * getHeight(image, x - 1, y);
    T.x = 0;
    T.y = 1;
    T.z = a * getHeight(image, x, y + 1) - a * getHeight(image, x, y - 1);

    float den = (float) Math.sqrt(S.z * S.z + T.z * T.z + 1);
    N.x = -S.z;
    N.y = -T.z;
    N.z = 1;
    N.divideLocal(den);
    return vectorToColor(N.x, N.y, N.z);
  }