Package se.llbit.math

Examples of se.llbit.math.Vector3d


  protected void updateCameraPosition() {
    cameraX.removeActionListener(cameraPositionListener);
    cameraY.removeActionListener(cameraPositionListener);
    cameraZ.removeActionListener(cameraPositionListener);

    Vector3d pos = renderMan.scene().camera().getPosition();
    cameraX.setText(decimalFormat.format(pos.x));
    cameraY.setText(decimalFormat.format(pos.y));
    cameraZ.setText(decimalFormat.format(pos.z));

    cameraX.addActionListener(cameraPositionListener);
View Full Code Here


   * Attempt to move the camera to the player position.
   * @param world
   */
  public void moveToPlayer(World world) {
    if (world != null) {
      Vector3d playerPos = world.playerPos();
      if (playerPos != null) {
        pitch = HALF_PI * ( (world.playerPitch() / 90) - 1);
        yaw = HALF_PI * ( -(world.playerYaw() / 90) + 1);
        roll = 0;
        pos.x = playerPos.x;
View Full Code Here

    Random random = state.random;
    Ray reflected = state.rayPool.get();
    Ray transmitted = state.rayPool.get();
    Ray refracted = state.rayPool.get();
    Vector3d ox = state.vectorPool.get(ray.x);
    Vector3d od = state.vectorPool.get(ray.d);
    double s = 0;

    while (true) {

      if (!RayTracer.nextIntersection(scene, ray, state)) {
View Full Code Here

    // TODO Auto-generated method stub
  }

  @Override
  public synchronized void onStrafeLeft() {
    Vector3d d = new Vector3d(1, 0, 0);
    tmpTransform.rotY(yaw);
    tmpTransform.transform(d);
    Vector3d right = new Vector3d();
    right.cross(up, d);
    origin.scaleAdd(-1, right, origin);
    updateOrigin();
    refresh();
  }
View Full Code Here

    refresh();
  }

  @Override
  public synchronized void onStrafeRight() {
    Vector3d d = new Vector3d(1, 0, 0);
    tmpTransform.rotY(yaw);
    tmpTransform.transform(d);
    Vector3d right = new Vector3d();
    right.cross(up, d);
    origin.scaleAdd(1, right, origin);
    updateOrigin();
    refresh();
  }
View Full Code Here

    refresh();
  }

  @Override
  public synchronized void onMoveForward() {
    Vector3d d = new Vector3d(0, -1, 0);
    transform.transform(d);
    origin.scaleAdd(1, d, origin);
    updateOrigin();
    refresh();
  }
View Full Code Here

    refresh();
  }

  @Override
  public synchronized void onMoveBackward() {
    Vector3d d = new Vector3d(0, -1, 0);
    transform.transform(d);
    origin.scaleAdd(-1, d, origin);
    updateOrigin();
    refresh();
  }
View Full Code Here

   * Calculate a camera position centered above all loaded chunks.
   * @return The calculated camera position
   */
  public Vector3d calcCenterCamera() {
    if (chunks.isEmpty())
      return new Vector3d(0, 128, 0);

    int xmin = Integer.MAX_VALUE;
    int xmax = Integer.MIN_VALUE;
    int zmin = Integer.MAX_VALUE;
    int zmax = Integer.MIN_VALUE;
    for (ChunkPosition cp: chunks) {
      if (cp.x < xmin)
        xmin = cp.x;
      if (cp.x > xmax)
        xmax = cp.x;
      if (cp.z < zmin)
        zmin = cp.z;
      if (cp.z > zmax)
        zmax = cp.z;
    }
    xmax += 1;
    zmax += 1;
    xmin *= 16;
    xmax *= 16;
    zmin *= 16;
    zmax *= 16;
    int xcenter = (xmax + xmin)/2;
    int zcenter = (zmax + zmin)/2;
    for (int y = Chunk.Y_MAX-1; y >= 0; --y) {
      int block = octree.get(xcenter - origin.x, y - origin.y,
          zcenter - origin.z);
      if (Block.get(block) != Block.AIR) {
        return new Vector3d(xcenter, y+5, zcenter);
      }
    }
    return new Vector3d(xcenter, 128, zcenter);
  }
View Full Code Here

                ray.currentMaterial,
                block,
                block.description(ray.getBlockData())),
                5, height-5);
          }
          Vector3d pos = camera.getPosition();
          g.drawString(String.format("(%.1f, %.1f, %.1f)",
              pos.x, pos.y, pos.z), 5, 11);
          rayPool.dispose(ray);
        }
      }
View Full Code Here

        || world.spawnPosY() == world.currentLayer());
  }

  public void renderPlayer(World world, Graphics g, ChunkView view, boolean sameLayer) {
    double blockScale = view.scale / 16.;
    Vector3d playerPos = world.playerPos();
    if (playerPos == null) {
      return;
    }
    int px = (int) QuickMath.floor(playerPos.x * blockScale);
    int pz = (int) QuickMath.floor(playerPos.z * blockScale);
 
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.