Quellcode durchsuchen

added toCellSpace() and toWorldSpace() utility methods to TerrainGrid

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9954 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
bre..om vor 13 Jahren
Ursprung
Commit
c405f09391
1 geänderte Dateien mit 14 neuen und 0 gelöschten Zeilen
  1. 14 0
      engine/src/terrain/com/jme3/terrain/geomipmap/TerrainGrid.java

+ 14 - 0
engine/src/terrain/com/jme3/terrain/geomipmap/TerrainGrid.java

@@ -332,6 +332,20 @@ public class TerrainGrid extends TerrainQuad {
         return cache.get(tileCell);
     }
     
+    /**
+     * Convert the world location into a cell location (integer coordinates)
+     */
+    public Vector3f toCellSpace(Vector3f worldLocation) {
+        return getTileCell(worldLocation);
+    }
+    
+    /**
+     * Convert the cell coordinate (integer coordinates) into world coordinates.
+     */
+    public Vector3f toWorldSpace(Vector3f cellLocation) {
+        return cellLocation.mult(getLocalScale()).multLocal(quadSize - 1);
+    }
+    
     protected void removeQuad(TerrainQuad q) {
         if (q != null && ( (q.getQuadrant() > 0 && q.getQuadrant()<5) || q.getParent() != null) ) {
             for (TerrainGridListener l : listeners) {