protected float getHeight(int x, int z, float xm, float zm) { QuadrantChild match = findMatchingChild(x,z); if (match != null) { if (match.child instanceof TerrainQuad) { return ((TerrainQuad) match.child).getHeight(match.col, match.row, xm, zm); } else if (match.child instanceof TerrainPatch) { return ((TerrainPatch) match.child).getHeight(match.col, match.row, xm, zm); } } return Float.NaN; }
/** * Get the interpolated height of the terrain at the specified point. * @param xz the location to get the height for * @return Float.NAN if the value does not exist, or the coordinates are outside of the terrain */ public float getHeight(Vector2f xz) { // offset float x = (float)(((xz.x - getWorldTranslation().x) / getWorldScale().x) + (float)(totalSize-1) / 2f); float z = (float)(((xz.y - getWorldTranslation().z) / getWorldScale().z) + (float)(totalSize-1) / 2f); if (!isInside((int)x, (int)z)) return Float.NaN; float height = getHeight((int)x, (int)z, (x%1f), (z%1f)); height *= getWorldScale().y; return height; }
float height = terrain.getHeight(loc); System.out.println("collide " + hit.getContactPoint() + ", height: " + height + ", distance: " + hit.getDistance()); collisionMarker.setLocalTranslation(new Vector3f(hit.getContactPoint().x, height, hit.getContactPoint().z));
@Override public void simpleUpdate(float tpf){ Vector3f intersection = getWorldIntersection(); updateHintText(intersection); if (raiseTerrain){ if (intersection != null) { adjustHeight(intersection, 64, tpf * 60); } }else if (lowerTerrain){ if (intersection != null) { adjustHeight(intersection, 64, -tpf * 60); } } if (terrain != null && intersection != null) { float h = terrain.getHeight(new Vector2f(intersection.x, intersection.z)); Vector3f tl = terrain.getWorldTranslation(); marker.setLocalTranslation(tl.add(new Vector3f(intersection.x, h, intersection.z)) ); markerNormal.setLocalTranslation(tl.add(new Vector3f(intersection.x, h, intersection.z)) ); Vector3f normal = terrain.getNormal(new Vector2f(intersection.x, intersection.z)); ((Arrow)markerNormal.getMesh()).setArrowExtent(normal); } }
public float getHeightAt(Vector2f vec) { float height = 0; if(terrain != null) { vec = vec.mult(appScaled / spaceSize); height = terrain.getHeight(vec) / appScaled * spaceSize; } return height; }
private float getHeightForCam(float x, float z) { Float height = 0f; if(terrain != null) { Vector2f vec = new Vector2f(x, z); height = terrain.getHeight(vec) + 3; } return (height.isNaN() ? 3 : height); }
protected float getHeight(int x, int z, float xm, float zm) { QuadrantChild match = findMatchingChild(x,z); if (match != null) { if (match.child instanceof TerrainQuad) { return ((TerrainQuad) match.child).getHeight(match.col, match.row, xm, zm); } else if (match.child instanceof TerrainPatch) { return ((TerrainPatch) match.child).getHeight(match.col, match.row, xm, zm); } } return Float.NaN; }
/** * Get the interpolated height of the terrain at the specified point. * @param xz the location to get the height for * @return Float.NAN if the value does not exist, or the coordinates are outside of the terrain */ public float getHeight(Vector2f xz) { // offset float x = (float)(((xz.x - getWorldTranslation().x) / getWorldScale().x) + (float)(totalSize-1) / 2f); float z = (float)(((xz.y - getWorldTranslation().z) / getWorldScale().z) + (float)(totalSize-1) / 2f); if (!isInside((int)x, (int)z)) return Float.NaN; float height = getHeight((int)x, (int)z, (x%1f), (z%1f)); height *= getWorldScale().y; return height; }