Skip to content

Instantly share code, notes, and snippets.

@homelinen
Created June 11, 2012 13:21
Show Gist options
  • Save homelinen/2910070 to your computer and use it in GitHub Desktop.
Save homelinen/2910070 to your computer and use it in GitHub Desktop.
public Vector3f findStartPoint(Vector3f position, float objHeight) {
Vector3f newPos = position.clone();
int center = Math.round(heightMap.getSize() / 2);
Vector3f trans = new Vector3f(center, 0, center);
position.addLocal(trans);
float yHeight = heightMap.getInterpolatedHeight(position.x, position.z) + objHeight;
Logger.getLogger(WorldTerrain.class.getName()).log(Level.INFO, "Scaled: {0}, Interpolated: {1}, True: {2}",
new Object[] {
heightMap.getScaledHeightAtPoint((int) center, (int) center),
heightMap.getInterpolatedHeight(center, center),
heightMap.getTrueHeightAtPoint((int) center, (int) center)
});
Logger.getLogger(WorldTerrain.class.getName()).log(Level.INFO, "Old Position: {0}\nNew Position: {1}\nTransformed Pos: {2}",
new Object[] { newPos, newPos.add(0, yHeight, 0), position }
);
newPos.setY(yHeight);
Logger.getLogger(WorldTerrain.class.getName()).log(Level.INFO, "Returned Position: {0}", newPos);
return newPos;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment