org.lwjglb.engine.items.Terrain.getWorldHeight()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(21.6k)|赞(0)|评价(0)|浏览(101)

本文整理了Java中org.lwjglb.engine.items.Terrain.getWorldHeight()方法的一些代码示例,展示了Terrain.getWorldHeight()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Terrain.getWorldHeight()方法的具体详情如下:
包路径:org.lwjglb.engine.items.Terrain
类名称:Terrain
方法名:getWorldHeight

Terrain.getWorldHeight介绍

暂无

代码示例

代码示例来源:origin: lwjglgamedev/lwjglbook

protected Vector3f[] getTriangle(Vector3f position, Box2D boundingBox, GameItem terrainBlock) {
  // Get the column and row of the heightmap associated to the current position
  float cellWidth = boundingBox.width / (float) verticesPerCol;
  float cellHeight = boundingBox.height / (float) verticesPerRow;
  int col = (int) ((position.x - boundingBox.x) / cellWidth);
  int row = (int) ((position.z - boundingBox.y) / cellHeight);
  Vector3f[] triangle = new Vector3f[3];
  triangle[1] = new Vector3f(
      boundingBox.x + col * cellWidth,
      getWorldHeight(row + 1, col, terrainBlock),
      boundingBox.y + (row + 1) * cellHeight);
  triangle[2] = new Vector3f(
      boundingBox.x + (col + 1) * cellWidth,
      getWorldHeight(row, col + 1, terrainBlock),
      boundingBox.y + row * cellHeight);
  if (position.z < getDiagonalZCoord(triangle[1].x, triangle[1].z, triangle[2].x, triangle[2].z, position.x)) {
    triangle[0] = new Vector3f(
        boundingBox.x + col * cellWidth,
        getWorldHeight(row, col, terrainBlock),
        boundingBox.y + row * cellHeight);
  } else {
    triangle[0] = new Vector3f(
        boundingBox.x + (col + 1) * cellWidth,
        getWorldHeight(row + 2, col + 1, terrainBlock),
        boundingBox.y + (row + 1) * cellHeight);
  }
  return triangle;
}

代码示例来源:origin: lwjglgamedev/lwjglbook

protected Vector3f[] getTriangle(Vector3f position, Box2D boundingBox, GameItem terrainBlock) {
  // Get the column and row of the heightmap associated to the current position
  float cellWidth = boundingBox.width / (float) verticesPerCol;
  float cellHeight = boundingBox.height / (float) verticesPerRow;
  int col = (int) ((position.x - boundingBox.x) / cellWidth);
  int row = (int) ((position.z - boundingBox.y) / cellHeight);
  Vector3f[] triangle = new Vector3f[3];
  triangle[1] = new Vector3f(
      boundingBox.x + col * cellWidth,
      getWorldHeight(row + 1, col, terrainBlock),
      boundingBox.y + (row + 1) * cellHeight);
  triangle[2] = new Vector3f(
      boundingBox.x + (col + 1) * cellWidth,
      getWorldHeight(row, col + 1, terrainBlock),
      boundingBox.y + row * cellHeight);
  if (position.z < getDiagonalZCoord(triangle[1].x, triangle[1].z, triangle[2].x, triangle[2].z, position.x)) {
    triangle[0] = new Vector3f(
        boundingBox.x + col * cellWidth,
        getWorldHeight(row, col, terrainBlock),
        boundingBox.y + row * cellHeight);
  } else {
    triangle[0] = new Vector3f(
        boundingBox.x + (col + 1) * cellWidth,
        getWorldHeight(row + 2, col + 1, terrainBlock),
        boundingBox.y + (row + 1) * cellHeight);
  }
  return triangle;
}

代码示例来源:origin: lwjglgamedev/lwjglbook

protected Vector3f[] getTriangle(Vector3f position, Box2D boundingBox, GameItem terrainBlock) {
  // Get the column and row of the heightmap associated to the current position
  float cellWidth = boundingBox.width / (float) verticesPerCol;
  float cellHeight = boundingBox.height / (float) verticesPerRow;
  int col = (int) ((position.x - boundingBox.x) / cellWidth);
  int row = (int) ((position.z - boundingBox.y) / cellHeight);
  Vector3f[] triangle = new Vector3f[3];
  triangle[1] = new Vector3f(
      boundingBox.x + col * cellWidth,
      getWorldHeight(row + 1, col, terrainBlock),
      boundingBox.y + (row + 1) * cellHeight);
  triangle[2] = new Vector3f(
      boundingBox.x + (col + 1) * cellWidth,
      getWorldHeight(row, col + 1, terrainBlock),
      boundingBox.y + row * cellHeight);
  if (position.z < getDiagonalZCoord(triangle[1].x, triangle[1].z, triangle[2].x, triangle[2].z, position.x)) {
    triangle[0] = new Vector3f(
        boundingBox.x + col * cellWidth,
        getWorldHeight(row, col, terrainBlock),
        boundingBox.y + row * cellHeight);
  } else {
    triangle[0] = new Vector3f(
        boundingBox.x + (col + 1) * cellWidth,
        getWorldHeight(row + 2, col + 1, terrainBlock),
        boundingBox.y + (row + 1) * cellHeight);
  }
  return triangle;
}

代码示例来源:origin: lwjglgamedev/lwjglbook

protected Vector3f[] getTriangle(Vector3f position, Box2D boundingBox, GameItem terrainBlock) {
  // Get the column and row of the heightmap associated to the current position
  float cellWidth = boundingBox.width / (float) verticesPerCol;
  float cellHeight = boundingBox.height / (float) verticesPerRow;
  int col = (int) ((position.x - boundingBox.x) / cellWidth);
  int row = (int) ((position.z - boundingBox.y) / cellHeight);
  Vector3f[] triangle = new Vector3f[3];
  triangle[1] = new Vector3f(
      boundingBox.x + col * cellWidth,
      getWorldHeight(row + 1, col, terrainBlock),
      boundingBox.y + (row + 1) * cellHeight);
  triangle[2] = new Vector3f(
      boundingBox.x + (col + 1) * cellWidth,
      getWorldHeight(row, col + 1, terrainBlock),
      boundingBox.y + row * cellHeight);
  if (position.z < getDiagonalZCoord(triangle[1].x, triangle[1].z, triangle[2].x, triangle[2].z, position.x)) {
    triangle[0] = new Vector3f(
        boundingBox.x + col * cellWidth,
        getWorldHeight(row, col, terrainBlock),
        boundingBox.y + row * cellHeight);
  } else {
    triangle[0] = new Vector3f(
        boundingBox.x + (col + 1) * cellWidth,
        getWorldHeight(row + 2, col + 1, terrainBlock),
        boundingBox.y + (row + 1) * cellHeight);
  }
  return triangle;
}

代码示例来源:origin: lwjglgamedev/lwjglbook

protected Vector3f[] getTriangle(Vector3f position, Box2D boundingBox, GameItem terrainBlock) {
  // Get the column and row of the heightmap associated to the current position
  float cellWidth = boundingBox.width / (float) verticesPerCol;
  float cellHeight = boundingBox.height / (float) verticesPerRow;
  int col = (int) ((position.x - boundingBox.x) / cellWidth);
  int row = (int) ((position.z - boundingBox.y) / cellHeight);
  Vector3f[] triangle = new Vector3f[3];
  triangle[1] = new Vector3f(
      boundingBox.x + col * cellWidth,
      getWorldHeight(row + 1, col, terrainBlock),
      boundingBox.y + (row + 1) * cellHeight);
  triangle[2] = new Vector3f(
      boundingBox.x + (col + 1) * cellWidth,
      getWorldHeight(row, col + 1, terrainBlock),
      boundingBox.y + row * cellHeight);
  if (position.z < getDiagonalZCoord(triangle[1].x, triangle[1].z, triangle[2].x, triangle[2].z, position.x)) {
    triangle[0] = new Vector3f(
        boundingBox.x + col * cellWidth,
        getWorldHeight(row, col, terrainBlock),
        boundingBox.y + row * cellHeight);
  } else {
    triangle[0] = new Vector3f(
        boundingBox.x + (col + 1) * cellWidth,
        getWorldHeight(row + 2, col + 1, terrainBlock),
        boundingBox.y + (row + 1) * cellHeight);
  }
  return triangle;
}

代码示例来源:origin: lwjglgamedev/lwjglbook

protected Vector3f[] getTriangle(Vector3f position, Box2D boundingBox, GameItem terrainBlock) {
  // Get the column and row of the heightmap associated to the current position
  float cellWidth = boundingBox.width / (float) verticesPerCol;
  float cellHeight = boundingBox.height / (float) verticesPerRow;
  int col = (int) ((position.x - boundingBox.x) / cellWidth);
  int row = (int) ((position.z - boundingBox.y) / cellHeight);
  Vector3f[] triangle = new Vector3f[3];
  triangle[1] = new Vector3f(
      boundingBox.x + col * cellWidth,
      getWorldHeight(row + 1, col, terrainBlock),
      boundingBox.y + (row + 1) * cellHeight);
  triangle[2] = new Vector3f(
      boundingBox.x + (col + 1) * cellWidth,
      getWorldHeight(row, col + 1, terrainBlock),
      boundingBox.y + row * cellHeight);
  if (position.z < getDiagonalZCoord(triangle[1].x, triangle[1].z, triangle[2].x, triangle[2].z, position.x)) {
    triangle[0] = new Vector3f(
        boundingBox.x + col * cellWidth,
        getWorldHeight(row, col, terrainBlock),
        boundingBox.y + row * cellHeight);
  } else {
    triangle[0] = new Vector3f(
        boundingBox.x + (col + 1) * cellWidth,
        getWorldHeight(row + 2, col + 1, terrainBlock),
        boundingBox.y + (row + 1) * cellHeight);
  }
  return triangle;
}

代码示例来源:origin: lwjglgamedev/lwjglbook

protected Vector3f[] getTriangle(Vector3f position, Box2D boundingBox, GameItem terrainBlock) {
  // Get the column and row of the heightmap associated to the current position
  float cellWidth = boundingBox.width / (float) verticesPerCol;
  float cellHeight = boundingBox.height / (float) verticesPerRow;
  int col = (int) ((position.x - boundingBox.x) / cellWidth);
  int row = (int) ((position.z - boundingBox.y) / cellHeight);
  Vector3f[] triangle = new Vector3f[3];
  triangle[1] = new Vector3f(
      boundingBox.x + col * cellWidth,
      getWorldHeight(row + 1, col, terrainBlock),
      boundingBox.y + (row + 1) * cellHeight);
  triangle[2] = new Vector3f(
      boundingBox.x + (col + 1) * cellWidth,
      getWorldHeight(row, col + 1, terrainBlock),
      boundingBox.y + row * cellHeight);
  if (position.z < getDiagonalZCoord(triangle[1].x, triangle[1].z, triangle[2].x, triangle[2].z, position.x)) {
    triangle[0] = new Vector3f(
        boundingBox.x + col * cellWidth,
        getWorldHeight(row, col, terrainBlock),
        boundingBox.y + row * cellHeight);
  } else {
    triangle[0] = new Vector3f(
        boundingBox.x + (col + 1) * cellWidth,
        getWorldHeight(row + 2, col + 1, terrainBlock),
        boundingBox.y + (row + 1) * cellHeight);
  }
  return triangle;
}

代码示例来源:origin: lwjglgamedev/lwjglbook

protected Vector3f[] getTriangle(Vector3f position, Box2D boundingBox, GameItem terrainBlock) {
  // Get the column and row of the heightmap associated to the current position
  float cellWidth = boundingBox.width / (float) verticesPerCol;
  float cellHeight = boundingBox.height / (float) verticesPerRow;
  int col = (int) ((position.x - boundingBox.x) / cellWidth);
  int row = (int) ((position.z - boundingBox.y) / cellHeight);
  Vector3f[] triangle = new Vector3f[3];
  triangle[1] = new Vector3f(
      boundingBox.x + col * cellWidth,
      getWorldHeight(row + 1, col, terrainBlock),
      boundingBox.y + (row + 1) * cellHeight);
  triangle[2] = new Vector3f(
      boundingBox.x + (col + 1) * cellWidth,
      getWorldHeight(row, col + 1, terrainBlock),
      boundingBox.y + row * cellHeight);
  if (position.z < getDiagonalZCoord(triangle[1].x, triangle[1].z, triangle[2].x, triangle[2].z, position.x)) {
    triangle[0] = new Vector3f(
        boundingBox.x + col * cellWidth,
        getWorldHeight(row, col, terrainBlock),
        boundingBox.y + row * cellHeight);
  } else {
    triangle[0] = new Vector3f(
        boundingBox.x + (col + 1) * cellWidth,
        getWorldHeight(row + 2, col + 1, terrainBlock),
        boundingBox.y + (row + 1) * cellHeight);
  }
  return triangle;
}

代码示例来源:origin: lwjglgamedev/lwjglbook

protected Vector3f[] getTriangle(Vector3f position, Box2D boundingBox, GameItem terrainBlock) {
  // Get the column and row of the heightmap associated to the current position
  float cellWidth = boundingBox.width / (float) verticesPerCol;
  float cellHeight = boundingBox.height / (float) verticesPerRow;
  int col = (int) ((position.x - boundingBox.x) / cellWidth);
  int row = (int) ((position.z - boundingBox.y) / cellHeight);
  Vector3f[] triangle = new Vector3f[3];
  triangle[1] = new Vector3f(
      boundingBox.x + col * cellWidth,
      getWorldHeight(row + 1, col, terrainBlock),
      boundingBox.y + (row + 1) * cellHeight);
  triangle[2] = new Vector3f(
      boundingBox.x + (col + 1) * cellWidth,
      getWorldHeight(row, col + 1, terrainBlock),
      boundingBox.y + row * cellHeight);
  if (position.z < getDiagonalZCoord(triangle[1].x, triangle[1].z, triangle[2].x, triangle[2].z, position.x)) {
    triangle[0] = new Vector3f(
        boundingBox.x + col * cellWidth,
        getWorldHeight(row, col, terrainBlock),
        boundingBox.y + row * cellHeight);
  } else {
    triangle[0] = new Vector3f(
        boundingBox.x + (col + 1) * cellWidth,
        getWorldHeight(row + 2, col + 1, terrainBlock),
        boundingBox.y + (row + 1) * cellHeight);
  }
  return triangle;
}

代码示例来源:origin: lwjglgamedev/lwjglbook

protected Vector3f[] getTriangle(Vector3f position, Box2D boundingBox, GameItem terrainBlock) {
  // Get the column and row of the heightmap associated to the current position
  float cellWidth = boundingBox.width / (float) verticesPerCol;
  float cellHeight = boundingBox.height / (float) verticesPerRow;
  int col = (int) ((position.x - boundingBox.x) / cellWidth);
  int row = (int) ((position.z - boundingBox.y) / cellHeight);
  Vector3f[] triangle = new Vector3f[3];
  triangle[1] = new Vector3f(
      boundingBox.x + col * cellWidth,
      getWorldHeight(row + 1, col, terrainBlock),
      boundingBox.y + (row + 1) * cellHeight);
  triangle[2] = new Vector3f(
      boundingBox.x + (col + 1) * cellWidth,
      getWorldHeight(row, col + 1, terrainBlock),
      boundingBox.y + row * cellHeight);
  if (position.z < getDiagonalZCoord(triangle[1].x, triangle[1].z, triangle[2].x, triangle[2].z, position.x)) {
    triangle[0] = new Vector3f(
        boundingBox.x + col * cellWidth,
        getWorldHeight(row, col, terrainBlock),
        boundingBox.y + row * cellHeight);
  } else {
    triangle[0] = new Vector3f(
        boundingBox.x + (col + 1) * cellWidth,
        getWorldHeight(row + 2, col + 1, terrainBlock),
        boundingBox.y + (row + 1) * cellHeight);
  }
  return triangle;
}

代码示例来源:origin: lwjglgamedev/lwjglbook

protected Vector3f[] getTriangle(Vector3f position, Box2D boundingBox, GameItem terrainBlock) {
  // Get the column and row of the heightmap associated to the current position
  float cellWidth = boundingBox.width / (float) verticesPerCol;
  float cellHeight = boundingBox.height / (float) verticesPerRow;
  int col = (int) ((position.x - boundingBox.x) / cellWidth);
  int row = (int) ((position.z - boundingBox.y) / cellHeight);
  Vector3f[] triangle = new Vector3f[3];
  triangle[1] = new Vector3f(
      boundingBox.x + col * cellWidth,
      getWorldHeight(row + 1, col, terrainBlock),
      boundingBox.y + (row + 1) * cellHeight);
  triangle[2] = new Vector3f(
      boundingBox.x + (col + 1) * cellWidth,
      getWorldHeight(row, col + 1, terrainBlock),
      boundingBox.y + row * cellHeight);
  if (position.z < getDiagonalZCoord(triangle[1].x, triangle[1].z, triangle[2].x, triangle[2].z, position.x)) {
    triangle[0] = new Vector3f(
        boundingBox.x + col * cellWidth,
        getWorldHeight(row, col, terrainBlock),
        boundingBox.y + row * cellHeight);
  } else {
    triangle[0] = new Vector3f(
        boundingBox.x + (col + 1) * cellWidth,
        getWorldHeight(row + 2, col + 1, terrainBlock),
        boundingBox.y + (row + 1) * cellHeight);
  }
  return triangle;
}

代码示例来源:origin: lwjglgamedev/lwjglbook

protected Vector3f[] getTriangle(Vector3f position, Box2D boundingBox, GameItem terrainBlock) {
  // Get the column and row of the heightmap associated to the current position
  float cellWidth = boundingBox.width / (float) verticesPerCol;
  float cellHeight = boundingBox.height / (float) verticesPerRow;
  int col = (int) ((position.x - boundingBox.x) / cellWidth);
  int row = (int) ((position.z - boundingBox.y) / cellHeight);
  Vector3f[] triangle = new Vector3f[3];
  triangle[1] = new Vector3f(
      boundingBox.x + col * cellWidth,
      getWorldHeight(row + 1, col, terrainBlock),
      boundingBox.y + (row + 1) * cellHeight);
  triangle[2] = new Vector3f(
      boundingBox.x + (col + 1) * cellWidth,
      getWorldHeight(row, col + 1, terrainBlock),
      boundingBox.y + row * cellHeight);
  if (position.z < getDiagonalZCoord(triangle[1].x, triangle[1].z, triangle[2].x, triangle[2].z, position.x)) {
    triangle[0] = new Vector3f(
        boundingBox.x + col * cellWidth,
        getWorldHeight(row, col, terrainBlock),
        boundingBox.y + row * cellHeight);
  } else {
    triangle[0] = new Vector3f(
        boundingBox.x + (col + 1) * cellWidth,
        getWorldHeight(row + 2, col + 1, terrainBlock),
        boundingBox.y + (row + 1) * cellHeight);
  }
  return triangle;
}

代码示例来源:origin: lwjglgamedev/lwjglbook

protected Vector3f[] getTriangle(Vector3f position, Box2D boundingBox, GameItem terrainBlock) {
  // Get the column and row of the heightmap associated to the current position
  float cellWidth = boundingBox.width / (float) verticesPerCol;
  float cellHeight = boundingBox.height / (float) verticesPerRow;
  int col = (int) ((position.x - boundingBox.x) / cellWidth);
  int row = (int) ((position.z - boundingBox.y) / cellHeight);
  Vector3f[] triangle = new Vector3f[3];
  triangle[1] = new Vector3f(
      boundingBox.x + col * cellWidth,
      getWorldHeight(row + 1, col, terrainBlock),
      boundingBox.y + (row + 1) * cellHeight);
  triangle[2] = new Vector3f(
      boundingBox.x + (col + 1) * cellWidth,
      getWorldHeight(row, col + 1, terrainBlock),
      boundingBox.y + row * cellHeight);
  if (position.z < getDiagonalZCoord(triangle[1].x, triangle[1].z, triangle[2].x, triangle[2].z, position.x)) {
    triangle[0] = new Vector3f(
        boundingBox.x + col * cellWidth,
        getWorldHeight(row, col, terrainBlock),
        boundingBox.y + row * cellHeight);
  } else {
    triangle[0] = new Vector3f(
        boundingBox.x + (col + 1) * cellWidth,
        getWorldHeight(row + 2, col + 1, terrainBlock),
        boundingBox.y + (row + 1) * cellHeight);
  }
  return triangle;
}

代码示例来源:origin: lwjglgamedev/lwjglbook

protected Vector3f[] getTriangle(Vector3f position, Box2D boundingBox, GameItem terrainBlock) {
  // Get the column and row of the heightmap associated to the current position
  float cellWidth = boundingBox.width / (float) verticesPerCol;
  float cellHeight = boundingBox.height / (float) verticesPerRow;
  int col = (int) ((position.x - boundingBox.x) / cellWidth);
  int row = (int) ((position.z - boundingBox.y) / cellHeight);
  Vector3f[] triangle = new Vector3f[3];
  triangle[1] = new Vector3f(
      boundingBox.x + col * cellWidth,
      getWorldHeight(row + 1, col, terrainBlock),
      boundingBox.y + (row + 1) * cellHeight);
  triangle[2] = new Vector3f(
      boundingBox.x + (col + 1) * cellWidth,
      getWorldHeight(row, col + 1, terrainBlock),
      boundingBox.y + row * cellHeight);
  if (position.z < getDiagonalZCoord(triangle[1].x, triangle[1].z, triangle[2].x, triangle[2].z, position.x)) {
    triangle[0] = new Vector3f(
        boundingBox.x + col * cellWidth,
        getWorldHeight(row, col, terrainBlock),
        boundingBox.y + row * cellHeight);
  } else {
    triangle[0] = new Vector3f(
        boundingBox.x + (col + 1) * cellWidth,
        getWorldHeight(row + 2, col + 1, terrainBlock),
        boundingBox.y + (row + 1) * cellHeight);
  }
  return triangle;
}

代码示例来源:origin: lwjglgamedev/lwjglbook

protected Vector3f[] getTriangle(Vector3f position, Box2D boundingBox, GameItem terrainBlock) {
  // Get the column and row of the heightmap associated to the current position
  float cellWidth = boundingBox.width / (float) verticesPerCol;
  float cellHeight = boundingBox.height / (float) verticesPerRow;
  int col = (int) ((position.x - boundingBox.x) / cellWidth);
  int row = (int) ((position.z - boundingBox.y) / cellHeight);
  Vector3f[] triangle = new Vector3f[3];
  triangle[1] = new Vector3f(
      boundingBox.x + col * cellWidth,
      getWorldHeight(row + 1, col, terrainBlock),
      boundingBox.y + (row + 1) * cellHeight);
  triangle[2] = new Vector3f(
      boundingBox.x + (col + 1) * cellWidth,
      getWorldHeight(row, col + 1, terrainBlock),
      boundingBox.y + row * cellHeight);
  if (position.z < getDiagonalZCoord(triangle[1].x, triangle[1].z, triangle[2].x, triangle[2].z, position.x)) {
    triangle[0] = new Vector3f(
        boundingBox.x + col * cellWidth,
        getWorldHeight(row, col, terrainBlock),
        boundingBox.y + row * cellHeight);
  } else {
    triangle[0] = new Vector3f(
        boundingBox.x + (col + 1) * cellWidth,
        getWorldHeight(row + 2, col + 1, terrainBlock),
        boundingBox.y + (row + 1) * cellHeight);
  }
  return triangle;
}

代码示例来源:origin: lwjglgamedev/lwjglbook

protected Vector3f[] getTriangle(Vector3f position, Box2D boundingBox, GameItem terrainBlock) {
  // Get the column and row of the heightmap associated to the current position
  float cellWidth = boundingBox.width / (float) verticesPerCol;
  float cellHeight = boundingBox.height / (float) verticesPerRow;
  int col = (int) ((position.x - boundingBox.x) / cellWidth);
  int row = (int) ((position.z - boundingBox.y) / cellHeight);
  Vector3f[] triangle = new Vector3f[3];
  triangle[1] = new Vector3f(
      boundingBox.x + col * cellWidth,
      getWorldHeight(row + 1, col, terrainBlock),
      boundingBox.y + (row + 1) * cellHeight);
  triangle[2] = new Vector3f(
      boundingBox.x + (col + 1) * cellWidth,
      getWorldHeight(row, col + 1, terrainBlock),
      boundingBox.y + row * cellHeight);
  if (position.z < getDiagonalZCoord(triangle[1].x, triangle[1].z, triangle[2].x, triangle[2].z, position.x)) {
    triangle[0] = new Vector3f(
        boundingBox.x + col * cellWidth,
        getWorldHeight(row, col, terrainBlock),
        boundingBox.y + row * cellHeight);
  } else {
    triangle[0] = new Vector3f(
        boundingBox.x + (col + 1) * cellWidth,
        getWorldHeight(row + 2, col + 1, terrainBlock),
        boundingBox.y + (row + 1) * cellHeight);
  }
  return triangle;
}

代码示例来源:origin: lwjglgamedev/lwjglbook

protected Vector3f[] getTriangle(Vector3f position, Box2D boundingBox, GameItem terrainBlock) {
  // Get the column and row of the heightmap associated to the current position
  float cellWidth = boundingBox.width / (float) verticesPerCol;
  float cellHeight = boundingBox.height / (float) verticesPerRow;
  int col = (int) ((position.x - boundingBox.x) / cellWidth);
  int row = (int) ((position.z - boundingBox.y) / cellHeight);
  Vector3f[] triangle = new Vector3f[3];
  triangle[1] = new Vector3f(
      boundingBox.x + col * cellWidth,
      getWorldHeight(row + 1, col, terrainBlock),
      boundingBox.y + (row + 1) * cellHeight);
  triangle[2] = new Vector3f(
      boundingBox.x + (col + 1) * cellWidth,
      getWorldHeight(row, col + 1, terrainBlock),
      boundingBox.y + row * cellHeight);
  if (position.z < getDiagonalZCoord(triangle[1].x, triangle[1].z, triangle[2].x, triangle[2].z, position.x)) {
    triangle[0] = new Vector3f(
        boundingBox.x + col * cellWidth,
        getWorldHeight(row, col, terrainBlock),
        boundingBox.y + row * cellHeight);
  } else {
    triangle[0] = new Vector3f(
        boundingBox.x + (col + 1) * cellWidth,
        getWorldHeight(row + 2, col + 1, terrainBlock),
        boundingBox.y + (row + 1) * cellHeight);
  }
  return triangle;
}

代码示例来源:origin: lwjglgamedev/lwjglbook

protected Vector3f[] getTriangle(Vector3f position, Box2D boundingBox, GameItem terrainBlock) {
  // Get the column and row of the heightmap associated to the current position
  float cellWidth = boundingBox.width / (float) verticesPerCol;
  float cellHeight = boundingBox.height / (float) verticesPerRow;
  int col = (int) ((position.x - boundingBox.x) / cellWidth);
  int row = (int) ((position.z - boundingBox.y) / cellHeight);
  Vector3f[] triangle = new Vector3f[3];
  triangle[1] = new Vector3f(
      boundingBox.x + col * cellWidth,
      getWorldHeight(row + 1, col, terrainBlock),
      boundingBox.y + (row + 1) * cellHeight);
  triangle[2] = new Vector3f(
      boundingBox.x + (col + 1) * cellWidth,
      getWorldHeight(row, col + 1, terrainBlock),
      boundingBox.y + row * cellHeight);
  if (position.z < getDiagonalZCoord(triangle[1].x, triangle[1].z, triangle[2].x, triangle[2].z, position.x)) {
    triangle[0] = new Vector3f(
        boundingBox.x + col * cellWidth,
        getWorldHeight(row, col, terrainBlock),
        boundingBox.y + row * cellHeight);
  } else {
    triangle[0] = new Vector3f(
        boundingBox.x + (col + 1) * cellWidth,
        getWorldHeight(row + 2, col + 1, terrainBlock),
        boundingBox.y + (row + 1) * cellHeight);
  }
  return triangle;
}

代码示例来源:origin: lwjglgamedev/lwjglbook

protected Vector3f[] getTriangle(Vector3f position, Box2D boundingBox, GameItem terrainBlock) {
  // Get the column and row of the heightmap associated to the current position
  float cellWidth = boundingBox.width / (float) verticesPerCol;
  float cellHeight = boundingBox.height / (float) verticesPerRow;
  int col = (int) ((position.x - boundingBox.x) / cellWidth);
  int row = (int) ((position.z - boundingBox.y) / cellHeight);
  Vector3f[] triangle = new Vector3f[3];
  triangle[1] = new Vector3f(
      boundingBox.x + col * cellWidth,
      getWorldHeight(row + 1, col, terrainBlock),
      boundingBox.y + (row + 1) * cellHeight);
  triangle[2] = new Vector3f(
      boundingBox.x + (col + 1) * cellWidth,
      getWorldHeight(row, col + 1, terrainBlock),
      boundingBox.y + row * cellHeight);
  if (position.z < getDiagonalZCoord(triangle[1].x, triangle[1].z, triangle[2].x, triangle[2].z, position.x)) {
    triangle[0] = new Vector3f(
        boundingBox.x + col * cellWidth,
        getWorldHeight(row, col, terrainBlock),
        boundingBox.y + row * cellHeight);
  } else {
    triangle[0] = new Vector3f(
        boundingBox.x + (col + 1) * cellWidth,
        getWorldHeight(row + 2, col + 1, terrainBlock),
        boundingBox.y + (row + 1) * cellHeight);
  }
  return triangle;
}

代码示例来源:origin: lwjglgamedev/lwjglbook

protected Vector3f[] getTriangle(Vector3f position, Box2D boundingBox, GameItem terrainBlock) {
  // Get the column and row of the heightmap associated to the current position
  float cellWidth = boundingBox.width / (float) verticesPerCol;
  float cellHeight = boundingBox.height / (float) verticesPerRow;
  int col = (int) ((position.x - boundingBox.x) / cellWidth);
  int row = (int) ((position.z - boundingBox.y) / cellHeight);
  Vector3f[] triangle = new Vector3f[3];
  triangle[1] = new Vector3f(
      boundingBox.x + col * cellWidth,
      getWorldHeight(row + 1, col, terrainBlock),
      boundingBox.y + (row + 1) * cellHeight);
  triangle[2] = new Vector3f(
      boundingBox.x + (col + 1) * cellWidth,
      getWorldHeight(row, col + 1, terrainBlock),
      boundingBox.y + row * cellHeight);
  if (position.z < getDiagonalZCoord(triangle[1].x, triangle[1].z, triangle[2].x, triangle[2].z, position.x)) {
    triangle[0] = new Vector3f(
        boundingBox.x + col * cellWidth,
        getWorldHeight(row, col, terrainBlock),
        boundingBox.y + row * cellHeight);
  } else {
    triangle[0] = new Vector3f(
        boundingBox.x + (col + 1) * cellWidth,
        getWorldHeight(row + 2, col + 1, terrainBlock),
        boundingBox.y + (row + 1) * cellHeight);
  }
  return triangle;
}

相关文章