Package se.llbit.math

Examples of se.llbit.math.Vector3d


  }

  protected Vector3d getCurrentColor() {
    int index = gradientUI.getSelctedIndex();
    Vector4d stop = gradientUI.getStop(index);
    return new Vector3d(stop.x, stop.y, stop.z);
  }
View Full Code Here


    huePicker = new HuePicker(this);
    lightnessPicker = new LightnessPicker(this);
    saturationPicker = new SaturationPicker(this);

    for (int i = 0; i < NUM_SWATCHES; ++i) {
      swatchColors[i] = new Vector3d();
      swatches[i] = new JPanel();
      swatches[i].setPreferredSize(new Dimension(25, 25));
      final int index = i;
      swatches[i].addMouseListener(new MouseListener() {
        @Override
        public void mouseClicked(MouseEvent e) {
        }
        @Override
        public void mousePressed(MouseEvent e) {
          setColor(swatchColors[index]);
        }
        @Override
        public void mouseReleased(MouseEvent e) {
        }
        @Override
        public void mouseEntered(MouseEvent e) {
        }
        @Override
        public void mouseExited(MouseEvent e) {
        }

      });
    }

    for (int i = 0; i < NUM_SWATCHES; ++i) {
      historyColors[i] = new Vector3d();
      history[i] = new JPanel();
      history[i].setPreferredSize(new Dimension(25, 25));
      final int index = i;
      history[i].addMouseListener(new MouseListener() {
        @Override
View Full Code Here

    setVisible(true);
  }

  protected void onColorPicked() {
    updateHistory();
    Vector3d color = new Vector3d();
    se.llbit.math.Color.RGBfromHSL(color, hue, saturation, lightness);
    for (ColorListener listener: listeners) {
      listener.onColorPicked(color);
    }
  }
View Full Code Here

   */
  public static List<Vector4d> gradientFromJson(JsonArray array) {
    List<Vector4d> gradient = new ArrayList<Vector4d>(array.getNumElement());
    for (int i = 0; i < array.getNumElement(); ++i) {
      JsonObject obj = array.getElement(i).object();
      Vector3d color = new Vector3d();
      try {
        Color.fromString(obj.get("rgb").stringValue(""), 16, color);
        Vector4d stop = new Vector4d(color.x, color.y, color.z, obj.get("pos").doubleValue(Double.NaN));
        if (!Double.isNaN(stop.w)) {
          gradient.add(stop);
View Full Code Here

    double x2 = random.nextDouble();
    double cos_a = 1-x1 + x1*RADIUS_COS;
    double sin_a = FastMath.sqrt(1 - cos_a*cos_a);
    double phi = 2 * Math.PI * x2;

    Vector3d u = vectorPool.get(su);
    Vector3d v = vectorPool.get(sv);
    Vector3d w = vectorPool.get(sw);

    u.scale(FastMath.cos(phi)*sin_a);
    v.scale(FastMath.sin(phi)*sin_a);
    w.scale(cos_a);

    reflected.d.add(u, v);
    reflected.d.add(w);
    reflected.d.normalize();

View Full Code Here

  /**
   * @return sun color
   */
  public Vector3d getColor() {
    return new Vector3d(color);
  }
View Full Code Here

  private void enterBlock(Ray ray, double[] nearfar) {
    int level = 0;
    double t1, t2;
    double tNear = Double.NEGATIVE_INFINITY;
    double tFar = Double.POSITIVE_INFINITY;
    Vector3d d = ray.d;
    Vector3d o = ray.x;

    if (d.x != 0) {
      t1 = -o.x / d.x;
      t2 = ((1<<level) - o.x) / d.x;
View Full Code Here

        new AABB(0, 1, 0, 0.5, 0, 1),
        new AABB(0, 1, 0.5, 1, 0, 0.5),
        new AABB(0, 0.5, 0.5, 1, 0.5, 1),
    };
    quads = new Quad[] {
      new Quad(new Vector3d(14/16., 16/16., 2/16.), new Vector3d(2/16., 16/16., 2/16.),
          new Vector3d(14/16., 16/16., 14/16.), new Vector4d(2/16., 14/16., 2/16., 14/16.)),
    };
  }
View Full Code Here

  private void setUpTorch() {
    quads = new Quad[4];

    // west
    quads[0] = new Quad(new Vector3d(15/16., 3/16., 0),
        new Vector3d(15/16., 3/16., 1),
        new Vector3d((11-12/10.)/16., 1, 0),
        new Vector4d(0, 1, 0, 13/16.));

    // east
    quads[1] = new Quad(new Vector3d((13-12/10.)/16., 1, 0),
        new Vector3d((13-12/10.)/16., 1, 1),
        new Vector3d(17/16., 3/16., 0),
        new Vector4d(1, 0, 13/16., 0));

    // top
    quads[2] = new Quad(
        new Vector3d(13/16., 13/16., 9/16.),
        new Vector3d(13/16., 13/16., 7/16.),
        new Vector3d(11/16., 13/16., 9/16.),
        new Vector4d(9/16., 7/16., 10/16., 8/16.));

    // bottom
    quads[3] = new Quad(
        new Vector3d(15/16., 3/16., 7/16.),
        new Vector3d(17/16., 3/16., 7/16.),
        new Vector3d(15/16., 3/16., 9/16.),
        new Vector4d(7/16., 9/16., 0/16., 2/16.));

    uvtriangles = new UVTriangle[4];

    // facing south
    uvtriangles[0] = new UVTriangle(
        new Vector3d(8/16., 3/16., 9/16.),
        new Vector3d(24/16., 3/16., 9/16.),
        new Vector3d((4-12/10.)/16., 1, 9/16.),
        new Vector2d(0, 0),
        new Vector2d(1, 0),
        new Vector2d(0., 13/16.));
    uvtriangles[1] = new UVTriangle(
        new Vector3d((20-12/10.)/16., 1, 9/16.),
        new Vector3d((4-12/10.)/16., 1, 9/16.),
        new Vector3d(24/16., 3/16., 9/16.),
        new Vector2d(1, 13/16.),
        new Vector2d(0, 13/16.),
        new Vector2d(1, 0));

    // facing north
    uvtriangles[2] = new UVTriangle(
        new Vector3d(24/16., 3/16., 7/16.),
        new Vector3d(8/16., 3/16., 7/16.),
        new Vector3d((4-12/10.)/16., 1, 7/16.),
        new Vector2d(1, 0),
        new Vector2d(0, 0),
        new Vector2d(0, 13/16.));
    uvtriangles[3] = new UVTriangle(
        new Vector3d((4-12/10.)/16., 1, 7/16.),
        new Vector3d((20-12/10.)/16., 1, 7/16.),
        new Vector3d(24/16., 3/16., 7/16.),
        new Vector2d(0, 13/16.),
        new Vector2d(1, 13/16.),
        new Vector2d(1, 0));

    light = new Vector3d(.1, 1, -.1);
    light.normalize();
  }
View Full Code Here

  /**
   * @return vector with player position, nor {@code null} if not available
   */
  public synchronized Vector3d playerPos() {
    if (havePlayerPos && playerDimension == dimension) {
      return new Vector3d(playerX, playerY, playerZ);
    } else {
      return null;
    }
  }
View Full Code Here

TOP

Related Classes of se.llbit.math.Vector3d

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.