diff --git a/core/src/se/cookery/CookeryClient.java b/core/src/se/cookery/CookeryClient.java index 9fec5ea..faecf83 100644 --- a/core/src/se/cookery/CookeryClient.java +++ b/core/src/se/cookery/CookeryClient.java @@ -47,7 +47,6 @@ public class CookeryClient extends SimpleApplication { // cam.lookAt(new Vector3f(0f,0f,0f), Vector3f.UNIT_Z); flyCam.setEnabled(false); -// stateManager.detach(stateManager.getState(FlyCamAppState.class)); ChaseCamera chaseCam = new ChaseCamera(cam, player.getGfxNode(), inputManager); chaseCam.setDefaultDistance(10); chaseCam.setRotationSpeed(2); diff --git a/core/src/se/cookery/gfx/terrain/TerrainHeightMap.java b/core/src/se/cookery/gfx/terrain/TerrainHeightMap.java new file mode 100644 index 0000000..a275bfb --- /dev/null +++ b/core/src/se/cookery/gfx/terrain/TerrainHeightMap.java @@ -0,0 +1,15 @@ +package se.cookery.gfx.terrain; + +public interface TerrainHeightMap { + + + /** + * @return the number of squares on the width that make a single TerrainMesh instance. + */ + int getSquareCountWidth(); + + /** + * @return the number of squares on the height that make a single TerrainMesh instance. + */ + int getSquareCountHeight(); +} diff --git a/core/src/se/cookery/gfx/terrain/TerrainManager.java b/core/src/se/cookery/gfx/terrain/TerrainManager.java new file mode 100644 index 0000000..f1e9fbc --- /dev/null +++ b/core/src/se/cookery/gfx/terrain/TerrainManager.java @@ -0,0 +1,81 @@ +package se.cookery.gfx.terrain; + +import com.jme3.material.Material; +import com.jme3.math.ColorRGBA; +import com.jme3.math.Vector3f; +import com.jme3.scene.Geometry; +import com.jme3.scene.Node; +import se.cookery.gfx.util.MaterialUtil; + +/** + * This class represents a infinite terrain object (using multiple buffered TerrainMesh objects) + */ +public class TerrainManager { + protected static final int BUFFER_SIZE = 3; + + private float squareWidth; + private float squareHeight; + private TerrainHeightMap heightMap; + + private Geometry[][] terrainBuffer; + private Vector3f terrainZero; // The top-left coordinate for the center square + private Node node = new Node("Terrain Node"); + + /** + * Create a new instance of TerrainManager + * + * @param squareWidth is the width of a single square + * @param squareHeight is the height of a single square + * @param heightMap is the height map for the terrain + */ + public TerrainManager(float squareWidth, float squareHeight, TerrainHeightMap heightMap, Material material) { + this.squareWidth = squareWidth; + this.squareHeight = squareHeight; + this.heightMap = heightMap; + this.terrainBuffer = new Geometry[BUFFER_SIZE][BUFFER_SIZE]; + + for (int x=0; x