From fa29b95c39b531b3e93b74083abf77a526b62fd6 Mon Sep 17 00:00:00 2001 From: "bre..om" Date: Mon, 5 Nov 2012 15:25:14 +0000 Subject: [PATCH] added TerrainGrid.getTerrainAtCell(Vector3f cellCoordinate) to get the terrain tile from cell coordinates git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9953 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../com/jme3/terrain/geomipmap/TerrainGrid.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/engine/src/terrain/com/jme3/terrain/geomipmap/TerrainGrid.java b/engine/src/terrain/com/jme3/terrain/geomipmap/TerrainGrid.java index a8a0ff605..f57a2f9aa 100644 --- a/engine/src/terrain/com/jme3/terrain/geomipmap/TerrainGrid.java +++ b/engine/src/terrain/com/jme3/terrain/geomipmap/TerrainGrid.java @@ -321,6 +321,17 @@ public class TerrainGrid extends TerrainQuad { return cache.get(tileCell); } + /** + * Get the terrain tile at the specified XZ cell coordinate (not world coordinate). + * @param cellCoordinate integer cell coordinates + * @return the terrain tile at that location + */ + public Terrain getTerrainAtCell(Vector3f cellCoordinate) { + Vector3f gridLocation = cellCoordinate.mult(getLocalScale()).multLocal(quadSize - 1); + Vector3f tileCell = getTileCell(gridLocation); + return cache.get(tileCell); + } + protected void removeQuad(TerrainQuad q) { if (q != null && ( (q.getQuadrant() > 0 && q.getQuadrant()<5) || q.getParent() != null) ) { for (TerrainGridListener l : listeners) {