summaryrefslogtreecommitdiffstats
path: root/src/de/gamezock/metacraft/data/Map.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/de/gamezock/metacraft/data/Map.java')
-rw-r--r--src/de/gamezock/metacraft/data/Map.java70
1 files changed, 9 insertions, 61 deletions
diff --git a/src/de/gamezock/metacraft/data/Map.java b/src/de/gamezock/metacraft/data/Map.java
index 770ffe7..c6d306b 100644
--- a/src/de/gamezock/metacraft/data/Map.java
+++ b/src/de/gamezock/metacraft/data/Map.java
@@ -1,12 +1,8 @@
package de.gamezock.metacraft.data;
-import java.util.List;
-import java.util.Vector;
-
-import javax.vecmath.Point3f;
public class Map {
- private List<Triangle> triangleData;
+ Tile[][] tiles;
private float[][] heightmap;
@@ -14,69 +10,25 @@ public class Map {
int width = 5;
int height = 5;
- float[][] tileHeightmap = new float[width][height];
- Tile[][] tiles = new Tile[width][height];
+ heightmap = new float[width][height];
+ tiles = new Tile[width][height];
for(int i = 0; i < width; ++i) {
for(int j = 0; j < height; ++j) {
- tileHeightmap[i][j] = ((i-2)*(i-2)+(j-2)*(j-2))*0.5f;
+ //heightmap[i][j] = ((i-2)*(i-2)+(j-2)*(j-2))*0.5f;
+ heightmap[i][j] = 0;
tiles[i][j] = new Tile(new TestTile());
}
}
-
- createMapData(tiles, tileHeightmap);
}
- private void createMapData(Tile[][] tiles, float[][] tileHeightmap) {
- int tileSize = tiles[0][0].getData().getSize();
-
- heightmap = new float[tiles.length * tileSize][tiles[0].length * tileSize];
-
- for(int i = 0; i < tiles.length; ++i) {
- for(int j = 0; j < tiles[i].length; ++j) {
- float[][] localHeightmap = tiles[i][j].getData().getHeightmap();
-
- for(int x = 0; x < tileSize; ++x) {
- for(int y = 0; y < tileSize; ++y) {
- heightmap[i*tileSize + x][j*tileSize + y] = tileHeightmap[i][j] + localHeightmap[x][y];
- }
- }
- }
- }
-
- triangleData = new Vector<Triangle>();
-
- for(int x = 0; x < heightmap.length-1; ++x) {
- for(int y = 0; y < heightmap[x].length-1; ++y) {
- float[] h = new float[4];
- h[0] = heightmap[x][y];
- h[1] = heightmap[x+1][y];
- h[2] = heightmap[x+1][y+1];
- h[3] = heightmap[x][y+1];
-
- float center = (h[0] + h[1] + h[2] + h[3]) / 4;
-
- for(int i = 0; i < 4; ++i) {
- int i_1 = (i+1)%4;
- int i_2 = (i+2)%4;
-
- Point3f v1 = new Point3f(x + i_1/2, y + i/2, h[i]);
- Point3f v2 = new Point3f(x+0.5f, y+0.5f, center);
- Point3f v3 = new Point3f(x + i_2/2, y + i_1/2, h[i_1]);
-
- triangleData.add(new Triangle(v1, v2, v3));
- }
- }
- }
- }
-
- /*public Tile getTile(int x, int y) {
+ public Tile getTile(int x, int y) {
return tiles[x][y];
}
public float getTileHeight(int x, int y) {
return heightmap[x][y];
- }*/
+ }
public int getWidth() {
return heightmap.length;
@@ -86,11 +38,7 @@ public class Map {
return heightmap[0].length;
}
- /*public int getTileSize() {
- return tileSize;
- }*/
-
- public List<Triangle> getTriangleData() {
- return triangleData;
+ public int getTileSize() {
+ return tiles[0][0].getData().getSize();
}
}