OSDN Git Service

* javadoc
authorbrentowens <brentowens@75d07b2b-3a1a-0410-a2c5-0572b91ccdca>
Tue, 5 Jul 2011 19:42:37 +0000 (19:42 +0000)
committerbrentowens <brentowens@75d07b2b-3a1a-0410-a2c5-0572b91ccdca>
Tue, 5 Jul 2011 19:42:37 +0000 (19:42 +0000)
git-svn-id: http://jmonkeyengine.googlecode.com/svn/trunk@7826 75d07b2b-3a1a-0410-a2c5-0572b91ccdca

engine/src/terrain/com/jme3/terrain/geomipmap/TerrainPatch.java
engine/src/terrain/com/jme3/terrain/geomipmap/TerrainQuad.java

index 5497928..650d8b8 100644 (file)
@@ -70,7 +70,7 @@ import java.util.List;
 /**\r
  * A terrain patch is a leaf in the terrain quad tree. It has a mesh that can change levels of detail (LOD)\r
  * whenever the view point, or camera, changes. The actual terrain mesh is created by the LODGeomap class.\r
- * That uses a geo mip mapping algorithm to change the index buffer of the mesh.\r
+ * That uses a geo-mipmapping algorithm to change the index buffer of the mesh.\r
  * The mesh is a triangle strip. In wireframe mode you might notice some strange lines, these are degenerate\r
  * triangles generated by the geoMipMap algorithm and can be ignored. The video card removes them at almost no cost.\r
  * \r
@@ -104,10 +104,10 @@ public class TerrainPatch extends Geometry {
     // x/z step\r
     protected Vector3f stepScale;\r
 \r
-    // center of the block in relation to (0,0,0)\r
+    // center of the patch in relation to (0,0,0)\r
     protected Vector2f offset;\r
 \r
-    // amount the block has been shifted.\r
+    // amount the patch has been shifted.\r
     protected float offsetAmount;\r
 \r
     protected LodCalculator lodCalculator;\r
@@ -137,7 +137,7 @@ public class TerrainPatch extends Geometry {
      * <code>TriMesh</code> object for rendering.\r
      *\r
      * @param name\r
-     *                 the name of the terrain block.\r
+     *                 the name of the terrain patch.\r
      * @param size\r
      *                 the size of the heightmap.\r
      * @param stepScale\r
@@ -145,7 +145,7 @@ public class TerrainPatch extends Geometry {
      * @param heightMap\r
      *                 the height data.\r
      * @param origin\r
-     *                 the origin offset of the block.\r
+     *                 the origin offset of the patch.\r
      */\r
     public TerrainPatch(String name, int size, Vector3f stepScale,\r
                     float[] heightMap, Vector3f origin) {\r
@@ -158,18 +158,18 @@ public class TerrainPatch extends Geometry {
      * <code>TriMesh</code> object for renderering.\r
      *\r
      * @param name\r
-     *                 the name of the terrain block.\r
+     *                 the name of the terrain patch.\r
      * @param size\r
-     *                 the size of the block.\r
+     *                 the size of the patch.\r
      * @param stepScale\r
      *                 the scale for the axes.\r
      * @param heightMap\r
      *                 the height data.\r
      * @param origin\r
-     *                 the origin offset of the block.\r
+     *                 the origin offset of the patch.\r
      * @param totalSize\r
-     *                 the total size of the terrain. (Higher if the block is part of\r
-     *                 a <code>TerrainPage</code> tree.\r
+     *                 the total size of the terrain. (Higher if the patch is part of\r
+     *                 a <code>TerrainQuad</code> tree.\r
      * @param offset\r
      *                 the offset for texture coordinates.\r
      * @param offsetAmount\r
@@ -765,7 +765,7 @@ public class TerrainPatch extends Geometry {
     }\r
        \r
     /**\r
-     * Returns the offset amount this terrain block uses for textures.\r
+     * Returns the offset amount this terrain patch uses for textures.\r
      *\r
      * @return The current offset amount.\r
      */\r
@@ -792,9 +792,9 @@ public class TerrainPatch extends Geometry {
     }\r
 \r
     /**\r
-     * Returns the size of this terrain block.\r
+     * Returns the size of this terrain patch.\r
      *\r
-     * @return The current block size.\r
+     * @return The current patch size.\r
      */\r
     public int getSize() {\r
         return size;\r
@@ -813,7 +813,7 @@ public class TerrainPatch extends Geometry {
     /**\r
      * Sets the value for the current offset amount to use when building texture\r
      * coordinates. Note that this does <b>NOT </b> rebuild the terrain at all.\r
-     * This is mostly used for outside constructors of terrain blocks.\r
+     * This is mostly used for outside constructors of terrain patches.\r
      *\r
      * @param offset\r
      *                 The new texture offset.\r
@@ -823,9 +823,9 @@ public class TerrainPatch extends Geometry {
     }\r
 \r
     /**\r
-     * Sets the size of this terrain block. Note that this does <b>NOT </b>\r
+     * Sets the size of this terrain patch. Note that this does <b>NOT </b>\r
      * rebuild the terrain at all. This is mostly used for outside constructors\r
-     * of terrain blocks.\r
+     * of terrain patches.\r
      *\r
      * @param size\r
      *                 The new size.\r
@@ -839,7 +839,7 @@ public class TerrainPatch extends Geometry {
     /**\r
      * Sets the total size of the terrain . Note that this does <b>NOT </b>\r
      * rebuild the terrain at all. This is mostly used for outside constructors\r
-     * of terrain blocks.\r
+     * of terrain patches.\r
      *\r
      * @param totalSize\r
      *                 The new total size.\r
@@ -849,9 +849,9 @@ public class TerrainPatch extends Geometry {
     }\r
 \r
     /**\r
-     * Sets the step scale of this terrain block's height map. Note that this\r
+     * Sets the step scale of this terrain patch's height map. Note that this\r
      * does <b>NOT </b> rebuild the terrain at all. This is mostly used for\r
-     * outside constructors of terrain blocks.\r
+     * outside constructors of terrain patches.\r
      *\r
      * @param stepScale\r
      *                 The new step scale.\r
@@ -863,7 +863,7 @@ public class TerrainPatch extends Geometry {
     /**\r
      * Sets the offset of this terrain texture map. Note that this does <b>NOT\r
      * </b> rebuild the terrain at all. This is mostly used for outside\r
-     * constructors of terrain blocks.\r
+     * constructors of terrain patches.\r
      *\r
      * @param offsetAmount\r
      *                 The new texture offset.\r
index f8c5206..caa1bb5 100644 (file)
@@ -138,7 +138,7 @@ public class TerrainQuad extends Node implements Terrain {
     }\r
 \r
     protected TerrainQuad(String name, int patchSize, int size,\r
-                            Vector3f stepScale, float[] heightMap, int totalSize,\r
+                            Vector3f scale, float[] heightMap, int totalSize,\r
                             Vector2f offset, float offsetAmount,\r
                             LodCalculatorFactory lodCalculatorFactory)\r
     {\r
@@ -155,7 +155,7 @@ public class TerrainQuad extends Node implements Terrain {
         this.totalSize = totalSize;\r
         this.size = size;\r
         this.patchSize = patchSize;\r
-        this.stepScale = stepScale;\r
+        this.stepScale = scale;\r
         this.lodCalculatorFactory = lodCalculatorFactory;\r
         split(patchSize, heightMap);\r
     }\r
@@ -549,9 +549,9 @@ public class TerrainQuad extends Node implements Terrain {
 \r
     /**\r
      * <code>split</code> divides the heightmap data for four children. The\r
-     * children are either pages or blocks. This is dependent on the size of the\r
+     * children are either quads or patches. This is dependent on the size of the\r
      * children. If the child's size is less than or equal to the set block\r
-     * size, then blocks are created, otherwise, pages are created.\r
+     * size, then patches are created, otherwise, quads are created.\r
      *\r
      * @param blockSize\r
      *                 the blocks size to test against.\r
@@ -568,10 +568,20 @@ public class TerrainQuad extends Node implements Terrain {
     }\r
 \r
     /**\r
-     * <code>createQuadPage</code> generates four new pages from this page.\r
+     * Quadrants, world coordinates, and heightmap coordinates (Y-up):\r
+     *         x\r
+     *         | u\r
+     *        2|4 v\r
+     *  -z ----+---- z\r
+     *     -v 1|3\r
+     *      -u |\r
+     *        -x\r
+     * <code>createQuad</code> generates four new quads from this quad.\r
+     * The heightmap's top left (0,0) coordinate is at the bottom, -x,-z\r
+     * coordinate of the terrain, so it grows in the positive x.z direction.\r
      */\r
     protected void createQuad(int blockSize, float[] heightMap) {\r
-        // create 4 terrain pages\r
+        // create 4 terrain quads\r
         int quarterSize = size >> 2;\r
 \r
         int split = (size + 1) >> 1;\r
@@ -582,7 +592,7 @@ public class TerrainQuad extends Node implements Terrain {
         if (lodCalculatorFactory == null)\r
             lodCalculatorFactory = new LodDistanceCalculatorFactory(); // set a default one\r
 \r
-        // 1 upper left\r
+        // 1 upper left of heightmap, lower left quad\r
         float[] heightBlock1 = createHeightSubBlock(heightMap, 0, 0, split);\r
 \r
         Vector3f origin1 = new Vector3f(-quarterSize * stepScale.x, 0,\r
@@ -593,14 +603,14 @@ public class TerrainQuad extends Node implements Terrain {
         tempOffset.x += origin1.x;\r
         tempOffset.y += origin1.z;\r
 \r
-        TerrainQuad page1 = new TerrainQuad(getName() + "Quad1", blockSize,\r
+        TerrainQuad quad1 = new TerrainQuad(getName() + "Quad1", blockSize,\r
                         split, stepScale, heightBlock1, totalSize, tempOffset,\r
                         offsetAmount, lodCalculatorFactory);\r
-        page1.setLocalTranslation(origin1);\r
-        page1.quadrant = 1;\r
-        this.attachChild(page1);\r
+        quad1.setLocalTranslation(origin1);\r
+        quad1.quadrant = 1;\r
+        this.attachChild(quad1);\r
 \r
-        // 2 lower left\r
+        // 2 lower left of heightmap, upper left quad\r
         float[] heightBlock2 = createHeightSubBlock(heightMap, 0, split - 1,\r
                         split);\r
 \r
@@ -613,14 +623,14 @@ public class TerrainQuad extends Node implements Terrain {
         tempOffset.x += origin2.x;\r
         tempOffset.y += origin2.z;\r
 \r
-        TerrainQuad page2 = new TerrainQuad(getName() + "Quad2", blockSize,\r
+        TerrainQuad quad2 = new TerrainQuad(getName() + "Quad2", blockSize,\r
                         split, stepScale, heightBlock2, totalSize, tempOffset,\r
                         offsetAmount, lodCalculatorFactory);\r
-        page2.setLocalTranslation(origin2);\r
-        page2.quadrant = 2;\r
-        this.attachChild(page2);\r
+        quad2.setLocalTranslation(origin2);\r
+        quad2.quadrant = 2;\r
+        this.attachChild(quad2);\r
 \r
-        // 3 upper right\r
+        // 3 upper right of heightmap, lower right quad\r
         float[] heightBlock3 = createHeightSubBlock(heightMap, split - 1, 0,\r
                         split);\r
 \r
@@ -633,14 +643,14 @@ public class TerrainQuad extends Node implements Terrain {
         tempOffset.x += origin3.x;\r
         tempOffset.y += origin3.z;\r
 \r
-        TerrainQuad page3 = new TerrainQuad(getName() + "Quad3", blockSize,\r
+        TerrainQuad quad3 = new TerrainQuad(getName() + "Quad3", blockSize,\r
                         split, stepScale, heightBlock3, totalSize, tempOffset,\r
                         offsetAmount, lodCalculatorFactory);\r
-        page3.setLocalTranslation(origin3);\r
-        page3.quadrant = 3;\r
-        this.attachChild(page3);\r
-        // //\r
-        // 4 lower right\r
+        quad3.setLocalTranslation(origin3);\r
+        quad3.quadrant = 3;\r
+        this.attachChild(quad3);\r
+        \r
+        // 4 lower right of heightmap, upper right quad\r
         float[] heightBlock4 = createHeightSubBlock(heightMap, split - 1,\r
                         split - 1, split);\r
 \r
@@ -653,12 +663,12 @@ public class TerrainQuad extends Node implements Terrain {
         tempOffset.x += origin4.x;\r
         tempOffset.y += origin4.z;\r
 \r
-        TerrainQuad page4 = new TerrainQuad(getName() + "Quad4", blockSize,\r
+        TerrainQuad quad4 = new TerrainQuad(getName() + "Quad4", blockSize,\r
                         split, stepScale, heightBlock4, totalSize, tempOffset,\r
                         offsetAmount, lodCalculatorFactory);\r
-        page4.setLocalTranslation(origin4);\r
-        page4.quadrant = 4;\r
-        this.attachChild(page4);\r
+        quad4.setLocalTranslation(origin4);\r
+        quad4.quadrant = 4;\r
+        this.attachChild(quad4);\r
 \r
     }\r
 \r
@@ -679,10 +689,10 @@ public class TerrainQuad extends Node implements Terrain {
     }\r
 \r
     /**\r
-     * <code>createQuadBlock</code> creates four child blocks from this page.\r
+     * <code>createQuadPatch</code> creates four child patches from this quad.\r
      */\r
     protected void createQuadPatch(float[] heightMap) {\r
-        // create 4 terrain blocks\r
+        // create 4 terrain patches\r
         int quarterSize = size >> 2;\r
         int halfSize = size >> 1;\r
         int split = (size + 1) >> 1;\r
@@ -1183,12 +1193,12 @@ public class TerrainQuad extends Node implements Terrain {
         else if (tp.getQuadrant() == 2)\r
             return getPatch(4);\r
         else if (tp.getQuadrant() == 3) {\r
-            // find the page to the right and ask it for child 1.\r
+            // find the patch to the right and ask it for child 1.\r
             TerrainQuad quad = findRightQuad();\r
             if (quad != null)\r
                 return quad.getPatch(1);\r
         } else if (tp.getQuadrant() == 4) {\r
-            // find the page to the right and ask it for child 2.\r
+            // find the patch to the right and ask it for child 2.\r
             TerrainQuad quad = findRightQuad();\r
             if (quad != null)\r
                 return quad.getPatch(2);\r
@@ -1203,7 +1213,7 @@ public class TerrainQuad extends Node implements Terrain {
         else if (tp.getQuadrant() == 3)\r
             return getPatch(4);\r
         else if (tp.getQuadrant() == 2) {\r
-            // find the page below and ask it for child 1.\r
+            // find the patch below and ask it for child 1.\r
             TerrainQuad quad = findDownQuad();\r
             if (quad != null)\r
                 return quad.getPatch(1);\r
@@ -1223,7 +1233,7 @@ public class TerrainQuad extends Node implements Terrain {
         else if (tp.getQuadrant() == 4)\r
             return getPatch(3);\r
         else if (tp.getQuadrant() == 1) {\r
-            // find the page above and ask it for child 2.\r
+            // find the patch above and ask it for child 2.\r
             TerrainQuad quad = findTopQuad();\r
             if (quad != null)\r
                 return quad.getPatch(2);\r
@@ -1242,7 +1252,7 @@ public class TerrainQuad extends Node implements Terrain {
         else if (tp.getQuadrant() == 4)\r
             return getPatch(2);\r
         else if (tp.getQuadrant() == 1) {\r
-            // find the page above and ask it for child 2.\r
+            // find the patch above and ask it for child 2.\r
             TerrainQuad quad = findLeftQuad();\r
             if (quad != null)\r
                 return quad.getPatch(3);\r
@@ -1303,7 +1313,7 @@ public class TerrainQuad extends Node implements Terrain {
 \r
     protected TerrainQuad findTopQuad() {\r
         if (getParent() == null || !(getParent() instanceof TerrainQuad))\r
-                return null;\r
+            return null;\r
 \r
         TerrainQuad pQuad = (TerrainQuad) getParent();\r
 \r
@@ -1326,7 +1336,7 @@ public class TerrainQuad extends Node implements Terrain {
 \r
     protected TerrainQuad findLeftQuad() {\r
         if (getParent() == null || !(getParent() instanceof TerrainQuad))\r
-                return null;\r
+            return null;\r
 \r
         TerrainQuad pQuad = (TerrainQuad) getParent();\r
 \r