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

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

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

Terrain.getHeight介绍

暂无

代码示例

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

@Override
public void update(float interval, MouseInput mouseInput) {
  // Update camera based on mouse            
  if (mouseInput.isRightButtonPressed()) {
    Vector2f rotVec = mouseInput.getDisplVec();
    camera.moveRotation(rotVec.x * MOUSE_SENSITIVITY, rotVec.y * MOUSE_SENSITIVITY, 0);
  }
  // Update camera position
  Vector3f prevPos = new Vector3f(camera.getPosition());
  camera.movePosition(cameraInc.x * CAMERA_POS_STEP, cameraInc.y * CAMERA_POS_STEP, cameraInc.z * CAMERA_POS_STEP);
  // Check if there has been a collision. If true, set the y position to
  // the maximum height
  float height = terrain != null ? terrain.getHeight(camera.getPosition()) : -Float.MAX_VALUE;
  if (camera.getPosition().y <= height) {
    camera.setPosition(prevPos.x, prevPos.y, prevPos.z);
  }
  lightAngle += angleInc;
  if (lightAngle < 0) {
    lightAngle = 0;
  } else if (lightAngle > 180) {
    lightAngle = 180;
  }
  float zValue = (float) Math.cos(Math.toRadians(lightAngle));
  float yValue = (float) Math.sin(Math.toRadians(lightAngle));
  Vector3f lightDirection = this.scene.getSceneLight().getDirectionalLight().getDirection();
  lightDirection.x = 0;
  lightDirection.y = yValue;
  lightDirection.z = zValue;
  lightDirection.normalize();
}

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

float height = terrain != null ? terrain.getHeight(camera.getPosition()) : -Float.MAX_VALUE;
if (camera.getPosition().y <= height) {
  camera.setPosition(prevPos.x, prevPos.y, prevPos.z);

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

@Override
public void update(float interval, MouseInput mouseInput) {
  // Update camera based on mouse            
  if (mouseInput.isRightButtonPressed()) {
    Vector2f rotVec = mouseInput.getDisplVec();
    camera.moveRotation(rotVec.x * MOUSE_SENSITIVITY, rotVec.y * MOUSE_SENSITIVITY, 0);
  }
  // Update camera position
  Vector3f prevPos = new Vector3f(camera.getPosition());
  camera.movePosition(cameraInc.x * CAMERA_POS_STEP, cameraInc.y * CAMERA_POS_STEP, cameraInc.z * CAMERA_POS_STEP);
  // Check if there has been a collision. If true, set the y position to
  // the maximum height
  float height = terrain != null ? terrain.getHeight(camera.getPosition()) : -Float.MAX_VALUE;
  if (camera.getPosition().y <= height) {
    camera.setPosition(prevPos.x, prevPos.y, prevPos.z);
  }
  lightAngle += angleInc;
  if (lightAngle < 0) {
    lightAngle = 0;
  } else if (lightAngle > 180) {
    lightAngle = 180;
  }
  float zValue = (float) Math.cos(Math.toRadians(lightAngle));
  float yValue = (float) Math.sin(Math.toRadians(lightAngle));
  Vector3f lightDirection = this.scene.getSceneLight().getDirectionalLight().getDirection();
  lightDirection.x = 0;
  lightDirection.y = yValue;
  lightDirection.z = zValue;
  lightDirection.normalize();
}

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

float height = terrain != null ? terrain.getHeight(camera.getPosition()) : -Float.MAX_VALUE;
if (camera.getPosition().y <= height) {
  camera.setPosition(prevPos.x, prevPos.y, prevPos.z);

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

@Override
public void update(float interval, MouseInput mouseInput) {
  // Update camera based on mouse            
  if (mouseInput.isRightButtonPressed()) {
    Vector2f rotVec = mouseInput.getDisplVec();
    camera.moveRotation(rotVec.x * MOUSE_SENSITIVITY, rotVec.y * MOUSE_SENSITIVITY, 0);
  }
  // Update camera position
  Vector3f prevPos = new Vector3f(camera.getPosition());
  camera.movePosition(cameraInc.x * CAMERA_POS_STEP, cameraInc.y * CAMERA_POS_STEP, cameraInc.z * CAMERA_POS_STEP);
  // Check if there has been a collision. If true, set the y position to
  // the maximum height
  float height = terrain != null ? terrain.getHeight(camera.getPosition()) : -Float.MAX_VALUE;
  if (camera.getPosition().y <= height) {
    camera.setPosition(prevPos.x, prevPos.y, prevPos.z);
  }
  lightAngle += angleInc;
  if (lightAngle < 0) {
    lightAngle = 0;
  } else if (lightAngle > 180) {
    lightAngle = 180;
  }
  float zValue = (float) Math.cos(Math.toRadians(lightAngle));
  float yValue = (float) Math.sin(Math.toRadians(lightAngle));
  Vector3f lightDirection = this.scene.getSceneLight().getDirectionalLight().getDirection();
  lightDirection.x = 0;
  lightDirection.y = yValue;
  lightDirection.z = zValue;
  lightDirection.normalize();
}

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

@Override
public void update(float interval, MouseInput mouseInput) {
  // Update camera based on mouse            
  if (mouseInput.isRightButtonPressed()) {
    Vector2f rotVec = mouseInput.getDisplVec();
    camera.moveRotation(rotVec.x * MOUSE_SENSITIVITY, rotVec.y * MOUSE_SENSITIVITY, 0);
  }
  // Update camera position
  Vector3f prevPos = new Vector3f(camera.getPosition());
  camera.movePosition(cameraInc.x * CAMERA_POS_STEP, cameraInc.y * CAMERA_POS_STEP, cameraInc.z * CAMERA_POS_STEP);
  // Check if there has been a collision. If true, set the y position to
  // the maximum height
  float height = terrain != null ? terrain.getHeight(camera.getPosition()) : -Float.MAX_VALUE;
  if (camera.getPosition().y <= height) {
    camera.setPosition(prevPos.x, prevPos.y, prevPos.z);
  }
  // Update directional light direction, intensity and colour
  SceneLight sceneLight = scene.getSceneLight();
  DirectionalLight directionalLight = sceneLight.getDirectionalLight();
  double angRad = Math.toRadians(lightAngle);
  directionalLight.getDirection().x = (float) Math.sin(angRad);
  directionalLight.getDirection().y = (float) Math.cos(angRad);
}

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

@Override
public void update(float interval, MouseInput mouseInput) {
  // Update camera based on mouse            
  if (mouseInput.isRightButtonPressed()) {
    Vector2f rotVec = mouseInput.getDisplVec();
    camera.moveRotation(rotVec.x * MOUSE_SENSITIVITY, rotVec.y * MOUSE_SENSITIVITY, 0);
  }
  // Update camera position
  Vector3f prevPos = new Vector3f(camera.getPosition());
  camera.movePosition(cameraInc.x * CAMERA_POS_STEP, cameraInc.y * CAMERA_POS_STEP, cameraInc.z * CAMERA_POS_STEP);
  // Check if there has been a collision. If true, set the y position to
  // the maximum height
  float height = terrain != null ? terrain.getHeight(camera.getPosition()) : -Float.MAX_VALUE;
  if (camera.getPosition().y <= height) {
    camera.setPosition(prevPos.x, prevPos.y, prevPos.z);
  }
  lightAngle += angleInc;
  if (lightAngle < 0) {
    lightAngle = 0;
  } else if (lightAngle > 180) {
    lightAngle = 180;
  }
  float zValue = (float) Math.cos(Math.toRadians(lightAngle));
  float yValue = (float) Math.sin(Math.toRadians(lightAngle));
  Vector3f lightDirection = this.scene.getSceneLight().getDirectionalLight().getDirection();
  lightDirection.x = 0;
  lightDirection.y = yValue;
  lightDirection.z = zValue;
  lightDirection.normalize();
}

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

float height = terrain != null ? terrain.getHeight(camera.getPosition()) : -Float.MAX_VALUE;
if (camera.getPosition().y <= height) {
  camera.setPosition(prevPos.x, prevPos.y, prevPos.z);

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

float height = terrain != null ? terrain.getHeight(camera.getPosition()) : -Float.MAX_VALUE;
if (camera.getPosition().y <= height) {
  camera.setPosition(prevPos.x, prevPos.y, prevPos.z);

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

float height = terrain != null ? terrain.getHeight(camera.getPosition()) : -Float.MAX_VALUE;
if (camera.getPosition().y <= height) {
  camera.setPosition(prevPos.x, prevPos.y, prevPos.z);

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

float height = terrain != null ? terrain.getHeight(camera.getPosition()) : -Float.MAX_VALUE;
if (camera.getPosition().y <= height) {
  camera.setPosition(prevPos.x, prevPos.y, prevPos.z);

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

float height = terrain != null ? terrain.getHeight(camera.getPosition()) : -Float.MAX_VALUE;
if (camera.getPosition().y <= height) {
  camera.setPosition(prevPos.x, prevPos.y, prevPos.z);

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

float height = terrain != null ? terrain.getHeight(camera.getPosition()) : -Float.MAX_VALUE;
if (camera.getPosition().y <= height) {
  camera.setPosition(prevPos.x, prevPos.y, prevPos.z);

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

float height = terrain != null ? terrain.getHeight(camera.getPosition()) : -Float.MAX_VALUE;
if (camera.getPosition().y <= height) {
  camera.setPosition(prevPos.x, prevPos.y, prevPos.z);

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

float height = terrain != null ? terrain.getHeight(camera.getPosition()) : -Float.MAX_VALUE;
if (camera.getPosition().y <= height) {
  camera.setPosition(prevPos.x, prevPos.y, prevPos.z);

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

float height = terrain != null ? terrain.getHeight(camera.getPosition()) : -Float.MAX_VALUE;
if (camera.getPosition().y <= height) {
  camera.setPosition(prevPos.x, prevPos.y, prevPos.z);

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

float height = terrain != null ? terrain.getHeight(camera.getPosition()) : -Float.MAX_VALUE;
if (camera.getPosition().y <= height) {
  camera.setPosition(prevPos.x, prevPos.y, prevPos.z);

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

float height = terrain.getHeight(camera.getPosition());
if ( camera.getPosition().y <= height )  {
  camera.setPosition(prevPos.x, prevPos.y, prevPos.z);

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

float height = terrain.getHeight(camera.getPosition());
if ( camera.getPosition().y <= height )  {
  camera.setPosition(prevPos.x, prevPos.y, prevPos.z);

相关文章