diff --git a/android/android.iml b/android/android.iml
new file mode 100644
index 0000000..c15a9c4
--- /dev/null
+++ b/android/android.iml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ generateDebugSources
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/core/src/se/cookery/CookeryClient.java b/core/src/se/cookery/CookeryClient.java
index fa24022..5e5aaaf 100644
--- a/core/src/se/cookery/CookeryClient.java
+++ b/core/src/se/cookery/CookeryClient.java
@@ -1,6 +1,5 @@
package se.cookery;
-import com.jme3.app.FlyCamAppState;
import com.jme3.app.SimpleApplication;
import com.jme3.collision.CollisionResults;
import com.jme3.input.ChaseCamera;
@@ -15,11 +14,13 @@ import com.jme3.math.Vector2f;
import com.jme3.math.Vector3f;
import com.jme3.post.FilterPostProcessor;
import com.jme3.scene.Geometry;
-import se.cookery.core.world.Block;
-import se.cookery.core.world.gen.GrassLandWorldGenerator;
+import se.cookery.core.world.World;
+import se.cookery.core.world.gen.BlockGenerator;
+import se.cookery.core.world.gen.GrassLandBlockGenerator;
import se.cookery.gfx.character.Player;
import se.cookery.gfx.input.WireFrameToggleAction;
-import se.cookery.gfx.terrain.TerrainMesh;
+import se.cookery.gfx.terrain.BlockHeightMap;
+import se.cookery.gfx.terrain.TerrainManager;
import se.cookery.gfx.util.MaterialUtil;
import com.jme3.post.filters.CartoonEdgeFilter;
@@ -33,11 +34,18 @@ public class CookeryClient extends SimpleApplication {
// Setup Terrain
// -----------------------------------------
- Block block = new GrassLandWorldGenerator().generateBlock(0, 0);
+ //Geometry terrain = new Geometry("Terrain", new TerrainMesh(1, 1, Block.BLOCK_SIZE, Block.BLOCK_SIZE));
+ //terrain.setMaterial(MaterialUtil.createMaterial(assetManager, ColorRGBA.Green));
+ //rootNode.attachChild();
- Geometry terrain = new Geometry("Terrain", new TerrainMesh(1, 1, Block.BLOCK_SIZE, Block.BLOCK_SIZE));
- terrain.setMaterial(MaterialUtil.createMaterial(assetManager, ColorRGBA.Green));
- rootNode.attachChild(terrain);
+ BlockGenerator blockGenerator = new GrassLandBlockGenerator();
+ World world = new World(blockGenerator);
+
+ TerrainManager terrain = new TerrainManager(1, 1,
+ new BlockHeightMap(world),
+ MaterialUtil.createMaterial(assetManager, ColorRGBA.Green));
+
+ rootNode.attachChild(terrain.getNode());
// -----------------------------------------
// Setup Player
@@ -121,7 +129,7 @@ public class CookeryClient extends SimpleApplication {
// The closest result is the target that the player picked:
Geometry target = results.getClosestCollision().getGeometry();
// Here comes the action:
- target.setLocalTranslation(target.getLocalTranslation().add(1, 0, 0));
+// target.setLocalTranslation(target.getLocalTranslation().add(1, 0, 0));
}
}
};
diff --git a/core/src/se/cookery/core/world/World.java b/core/src/se/cookery/core/world/World.java
index 418e545..32cd365 100644
--- a/core/src/se/cookery/core/world/World.java
+++ b/core/src/se/cookery/core/world/World.java
@@ -1,6 +1,6 @@
package se.cookery.core.world;
-import se.cookery.core.world.gen.WorldGenerator;
+import se.cookery.core.world.gen.BlockGenerator;
import java.util.HashMap;
import java.util.Map;
@@ -10,10 +10,10 @@ public class World {
// Variables
private Map> worldBlocks = new TreeMap<>();
- private WorldGenerator generator;
+ private BlockGenerator generator;
- public World(WorldGenerator generator) {
+ public World(BlockGenerator generator) {
this.generator = generator;
}
diff --git a/core/src/se/cookery/core/world/gen/WorldGenerator.java b/core/src/se/cookery/core/world/gen/BlockGenerator.java
similarity index 93%
rename from core/src/se/cookery/core/world/gen/WorldGenerator.java
rename to core/src/se/cookery/core/world/gen/BlockGenerator.java
index 9ab9d01..7891e3f 100644
--- a/core/src/se/cookery/core/world/gen/WorldGenerator.java
+++ b/core/src/se/cookery/core/world/gen/BlockGenerator.java
@@ -8,7 +8,7 @@ import se.cookery.core.world.Block;
* A class that implements this interface can be used
* to generate a static or dynamic world.
*/
-public interface WorldGenerator {
+public interface BlockGenerator {
/**
* Method to generate a block with the provided coordinates,
diff --git a/core/src/se/cookery/core/world/gen/GrassLandWorldGenerator.java b/core/src/se/cookery/core/world/gen/GrassLandBlockGenerator.java
similarity index 86%
rename from core/src/se/cookery/core/world/gen/GrassLandWorldGenerator.java
rename to core/src/se/cookery/core/world/gen/GrassLandBlockGenerator.java
index 193d6f3..9aa9040 100644
--- a/core/src/se/cookery/core/world/gen/GrassLandWorldGenerator.java
+++ b/core/src/se/cookery/core/world/gen/GrassLandBlockGenerator.java
@@ -2,7 +2,7 @@ package se.cookery.core.world.gen;
import se.cookery.core.world.Block;
-public class GrassLandWorldGenerator implements WorldGenerator {
+public class GrassLandBlockGenerator implements BlockGenerator {
@Override
public Block generateBlock(long x, long y) {
diff --git a/core/src/se/cookery/gfx/terrain/BlockHeightMap.java b/core/src/se/cookery/gfx/terrain/BlockHeightMap.java
new file mode 100644
index 0000000..add4333
--- /dev/null
+++ b/core/src/se/cookery/gfx/terrain/BlockHeightMap.java
@@ -0,0 +1,24 @@
+package se.cookery.gfx.terrain;
+
+import se.cookery.core.world.Block;
+import se.cookery.core.world.World;
+
+public class BlockHeightMap implements TerrainHeightMap {
+ private World world;
+
+
+ public BlockHeightMap(World world) {
+ this.world = world;
+ }
+
+
+ @Override
+ public int getSquareCountWidth() {
+ return Block.BLOCK_SIZE;
+ }
+
+ @Override
+ public int getSquareCountHeight() {
+ return Block.BLOCK_SIZE;
+ }
+}
diff --git a/core/test/se/cookery/core/world/WorldTest.java b/core/test/se/cookery/core/world/WorldTest.java
index c659d73..6e5e0dc 100644
--- a/core/test/se/cookery/core/world/WorldTest.java
+++ b/core/test/se/cookery/core/world/WorldTest.java
@@ -1,8 +1,7 @@
package se.cookery.core.world;
import org.junit.jupiter.api.Test;
-import se.cookery.core.world.World;
-import se.cookery.core.world.gen.GrassLandWorldGenerator;
+import se.cookery.core.world.gen.GrassLandBlockGenerator;
import static org.junit.jupiter.api.Assertions.*;
@@ -10,7 +9,7 @@ public class WorldTest {
@Test
public void blockExists() {
- World w = new World(new GrassLandWorldGenerator());
+ World w = new World(new GrassLandBlockGenerator());
assertFalse(w.blockExists(0, 0));
assertFalse(w.blockExists(Long.MAX_VALUE, Long.MAX_VALUE));
assertFalse(w.blockExists(Long.MIN_VALUE, Long.MAX_VALUE));
@@ -20,7 +19,7 @@ public class WorldTest {
@Test
public void getBlock() {
- World w = new World(new GrassLandWorldGenerator());
+ World w = new World(new GrassLandBlockGenerator());
assertFalse(w.blockExists(0, 0));
assertNotNull(w.getBlock(0,0));
assertTrue(w.blockExists(0, 0));
diff --git a/ios/ios.iml b/ios/ios.iml
new file mode 100644
index 0000000..d05ff67
--- /dev/null
+++ b/ios/ios.iml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file