|
|
@ -191,40 +191,19 @@ public class TerrainGrid extends TerrainQuad { |
|
|
|
return 0; // error
|
|
|
|
return 0; // error
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//TODO: unify constructors
|
|
|
|
|
|
|
|
public TerrainGrid(String name, int patchSize, int maxVisibleSize, Vector3f scale, TerrainQuadGrid terrainQuadGrid, |
|
|
|
public TerrainGrid(String name, int patchSize, int maxVisibleSize, Vector3f scale, TerrainQuadGrid terrainQuadGrid, |
|
|
|
Vector2f offset, float offsetAmount) { |
|
|
|
Vector2f offset, float offsetAmount) { |
|
|
|
this.name = name; |
|
|
|
this.name = name; |
|
|
|
this.patchSize = patchSize; |
|
|
|
this.patchSize = patchSize; |
|
|
|
this.size = maxVisibleSize; |
|
|
|
this.size = maxVisibleSize; |
|
|
|
this.quarterSize = maxVisibleSize >> 2; |
|
|
|
|
|
|
|
this.quadSize = (maxVisibleSize + 1) >> 1; |
|
|
|
|
|
|
|
this.stepScale = scale; |
|
|
|
this.stepScale = scale; |
|
|
|
|
|
|
|
this.offset = offset; |
|
|
|
|
|
|
|
this.offsetAmount = offsetAmount; |
|
|
|
|
|
|
|
initData(); |
|
|
|
this.terrainQuadGrid = terrainQuadGrid; |
|
|
|
this.terrainQuadGrid = terrainQuadGrid; |
|
|
|
terrainQuadGrid.setSize(this.size); |
|
|
|
terrainQuadGrid.setSize(this.size); |
|
|
|
terrainQuadGrid.setPatchSize(this.patchSize); |
|
|
|
terrainQuadGrid.setPatchSize(this.patchSize); |
|
|
|
terrainQuadGrid.setQuadSize(this.quadSize); |
|
|
|
terrainQuadGrid.setQuadSize(this.quadSize); |
|
|
|
this.totalSize = maxVisibleSize; |
|
|
|
|
|
|
|
this.offset = offset; |
|
|
|
|
|
|
|
this.offsetAmount = offsetAmount; |
|
|
|
|
|
|
|
this.gridOffset = new int[]{0, 0}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
|
|
|
* -z |
|
|
|
|
|
|
|
* | |
|
|
|
|
|
|
|
* 1|3 |
|
|
|
|
|
|
|
* -x ----+---- x |
|
|
|
|
|
|
|
* 2|4 |
|
|
|
|
|
|
|
* | |
|
|
|
|
|
|
|
* z |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
this.quadIndex = new Vector3f[]{ |
|
|
|
|
|
|
|
new Vector3f(-1, 0, -1), new Vector3f(0, 0, -1), new Vector3f(1, 0, -1), new Vector3f(2, 0, -1), |
|
|
|
|
|
|
|
new Vector3f(-1, 0, 0), new Vector3f(0, 0, 0), new Vector3f(1, 0, 0), new Vector3f(2, 0, 0), |
|
|
|
|
|
|
|
new Vector3f(-1, 0, 1), new Vector3f(0, 0, 1), new Vector3f(1, 0, 1), new Vector3f(2, 0, 1), |
|
|
|
|
|
|
|
new Vector3f(-1, 0, 2), new Vector3f(0, 0, 2), new Vector3f(1, 0, 2), new Vector3f(2, 0, 2)}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
addControl(new UpdateControl()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public TerrainGrid(String name, int patchSize, int maxVisibleSize, Vector3f scale, TerrainQuadGrid terrainQuadGrid) { |
|
|
|
public TerrainGrid(String name, int patchSize, int maxVisibleSize, Vector3f scale, TerrainQuadGrid terrainQuadGrid) { |
|
|
@ -240,14 +219,30 @@ public class TerrainGrid extends TerrainQuad { |
|
|
|
this.name = name; |
|
|
|
this.name = name; |
|
|
|
this.patchSize = patchSize; |
|
|
|
this.patchSize = patchSize; |
|
|
|
this.size = maxVisibleSize; |
|
|
|
this.size = maxVisibleSize; |
|
|
|
this.quarterSize = maxVisibleSize >> 2; |
|
|
|
|
|
|
|
this.quadSize = (maxVisibleSize + 1) >> 1; |
|
|
|
|
|
|
|
this.stepScale = scale; |
|
|
|
this.stepScale = scale; |
|
|
|
|
|
|
|
this.offset = offset; |
|
|
|
|
|
|
|
this.offsetAmount = offsetAmount; |
|
|
|
|
|
|
|
initData(); |
|
|
|
this.heightMapGrid = heightMapGrid; |
|
|
|
this.heightMapGrid = heightMapGrid; |
|
|
|
heightMapGrid.setSize(this.quadSize); |
|
|
|
heightMapGrid.setSize(this.quadSize); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public TerrainGrid(String name, int patchSize, int maxVisibleSize, Vector3f scale, HeightMapGrid heightMapGrid) { |
|
|
|
|
|
|
|
this(name, patchSize, maxVisibleSize, scale, heightMapGrid, new Vector2f(), 0); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public TerrainGrid(String name, int patchSize, int maxVisibleSize, HeightMapGrid heightMapGrid) { |
|
|
|
|
|
|
|
this(name, patchSize, maxVisibleSize, Vector3f.UNIT_XYZ, heightMapGrid); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public TerrainGrid() { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void initData(){ |
|
|
|
|
|
|
|
int maxVisibleSize = size; |
|
|
|
|
|
|
|
this.quarterSize = maxVisibleSize >> 2; |
|
|
|
|
|
|
|
this.quadSize = (maxVisibleSize + 1) >> 1; |
|
|
|
this.totalSize = maxVisibleSize; |
|
|
|
this.totalSize = maxVisibleSize; |
|
|
|
this.offset = offset; |
|
|
|
|
|
|
|
this.offsetAmount = offsetAmount; |
|
|
|
|
|
|
|
this.gridOffset = new int[]{0, 0}; |
|
|
|
this.gridOffset = new int[]{0, 0}; |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
/* |
|
|
@ -268,17 +263,6 @@ public class TerrainGrid extends TerrainQuad { |
|
|
|
addControl(new UpdateControl()); |
|
|
|
addControl(new UpdateControl()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public TerrainGrid(String name, int patchSize, int maxVisibleSize, Vector3f scale, HeightMapGrid heightMapGrid) { |
|
|
|
|
|
|
|
this(name, patchSize, maxVisibleSize, scale, heightMapGrid, new Vector2f(), 0); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public TerrainGrid(String name, int patchSize, int maxVisibleSize, HeightMapGrid heightMapGrid) { |
|
|
|
|
|
|
|
this(name, patchSize, maxVisibleSize, Vector3f.UNIT_XYZ, heightMapGrid); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public TerrainGrid() { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void initialize(Vector3f location) { |
|
|
|
public void initialize(Vector3f location) { |
|
|
|
if (this.material == null) { |
|
|
|
if (this.material == null) { |
|
|
|
throw new RuntimeException("Material must be set prior to call of initialize"); |
|
|
|
throw new RuntimeException("Material must be set prior to call of initialize"); |
|
|
@ -470,30 +454,7 @@ public class TerrainGrid extends TerrainQuad { |
|
|
|
// terrainQuadGrid.setSize(this.size);
|
|
|
|
// terrainQuadGrid.setSize(this.size);
|
|
|
|
// terrainQuadGrid.setPatchSize(this.patchSize);
|
|
|
|
// terrainQuadGrid.setPatchSize(this.patchSize);
|
|
|
|
// terrainQuadGrid.setQuadSize(this.quadSize);
|
|
|
|
// terrainQuadGrid.setQuadSize(this.quadSize);
|
|
|
|
|
|
|
|
initData(); |
|
|
|
int maxVisibleSize = size; |
|
|
|
|
|
|
|
this.quarterSize = maxVisibleSize >> 2; |
|
|
|
|
|
|
|
this.quadSize = (maxVisibleSize + 1) >> 1; |
|
|
|
|
|
|
|
this.totalSize = maxVisibleSize; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.gridOffset = new int[]{0, 0}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
|
|
|
* -z |
|
|
|
|
|
|
|
* | |
|
|
|
|
|
|
|
* 1|3 |
|
|
|
|
|
|
|
* -x ----+---- x |
|
|
|
|
|
|
|
* 2|4 |
|
|
|
|
|
|
|
* | |
|
|
|
|
|
|
|
* z |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
this.quadIndex = new Vector3f[]{ |
|
|
|
|
|
|
|
new Vector3f(-1, 0, -1), new Vector3f(0, 0, -1), new Vector3f(1, 0, -1), new Vector3f(2, 0, -1), |
|
|
|
|
|
|
|
new Vector3f(-1, 0, 0), new Vector3f(0, 0, 0), new Vector3f(1, 0, 0), new Vector3f(2, 0, 0), |
|
|
|
|
|
|
|
new Vector3f(-1, 0, 1), new Vector3f(0, 0, 1), new Vector3f(1, 0, 1), new Vector3f(2, 0, 1), |
|
|
|
|
|
|
|
new Vector3f(-1, 0, 2), new Vector3f(0, 0, 2), new Vector3f(1, 0, 2), new Vector3f(2, 0, 2)}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
addControl(new UpdateControl()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|