Added infinite terrain to main aoo
This commit is contained in:
parent
4d41cbf8c9
commit
68cdc81597
8 changed files with 92 additions and 18 deletions
25
android/android.iml
Normal file
25
android/android.iml
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module version="4">
|
||||||
|
<component name="FacetManager">
|
||||||
|
<facet type="android-gradle" name="Android-Gradle">
|
||||||
|
<configuration>
|
||||||
|
<option name="GRADLE_PROJECT_PATH" value=":android" />
|
||||||
|
<option name="LAST_SUCCESSFUL_SYNC_AGP_VERSION" />
|
||||||
|
<option name="LAST_KNOWN_AGP_VERSION" value="3.5.0" />
|
||||||
|
</configuration>
|
||||||
|
</facet>
|
||||||
|
<facet type="android" name="Android">
|
||||||
|
<configuration>
|
||||||
|
<option name="SELECTED_BUILD_VARIANT" value="debug" />
|
||||||
|
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
|
||||||
|
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
|
||||||
|
<afterSyncTasks>
|
||||||
|
<task>generateDebugSources</task>
|
||||||
|
</afterSyncTasks>
|
||||||
|
<option name="ALLOW_USER_CONFIGURATION" value="false" />
|
||||||
|
<option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/res;file://$MODULE_DIR$/build/generated/res/rs/debug;file://$MODULE_DIR$/build/generated/res/resValues/debug" />
|
||||||
|
<option name="TEST_RES_FOLDERS_RELATIVE_PATH" value="" />
|
||||||
|
</configuration>
|
||||||
|
</facet>
|
||||||
|
</component>
|
||||||
|
</module>
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
package se.cookery;
|
package se.cookery;
|
||||||
|
|
||||||
import com.jme3.app.FlyCamAppState;
|
|
||||||
import com.jme3.app.SimpleApplication;
|
import com.jme3.app.SimpleApplication;
|
||||||
import com.jme3.collision.CollisionResults;
|
import com.jme3.collision.CollisionResults;
|
||||||
import com.jme3.input.ChaseCamera;
|
import com.jme3.input.ChaseCamera;
|
||||||
|
|
@ -15,11 +14,13 @@ import com.jme3.math.Vector2f;
|
||||||
import com.jme3.math.Vector3f;
|
import com.jme3.math.Vector3f;
|
||||||
import com.jme3.post.FilterPostProcessor;
|
import com.jme3.post.FilterPostProcessor;
|
||||||
import com.jme3.scene.Geometry;
|
import com.jme3.scene.Geometry;
|
||||||
import se.cookery.core.world.Block;
|
import se.cookery.core.world.World;
|
||||||
import se.cookery.core.world.gen.GrassLandWorldGenerator;
|
import se.cookery.core.world.gen.BlockGenerator;
|
||||||
|
import se.cookery.core.world.gen.GrassLandBlockGenerator;
|
||||||
import se.cookery.gfx.character.Player;
|
import se.cookery.gfx.character.Player;
|
||||||
import se.cookery.gfx.input.WireFrameToggleAction;
|
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 se.cookery.gfx.util.MaterialUtil;
|
||||||
import com.jme3.post.filters.CartoonEdgeFilter;
|
import com.jme3.post.filters.CartoonEdgeFilter;
|
||||||
|
|
||||||
|
|
@ -33,11 +34,18 @@ public class CookeryClient extends SimpleApplication {
|
||||||
// Setup Terrain
|
// 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));
|
BlockGenerator blockGenerator = new GrassLandBlockGenerator();
|
||||||
terrain.setMaterial(MaterialUtil.createMaterial(assetManager, ColorRGBA.Green));
|
World world = new World(blockGenerator);
|
||||||
rootNode.attachChild(terrain);
|
|
||||||
|
TerrainManager terrain = new TerrainManager(1, 1,
|
||||||
|
new BlockHeightMap(world),
|
||||||
|
MaterialUtil.createMaterial(assetManager, ColorRGBA.Green));
|
||||||
|
|
||||||
|
rootNode.attachChild(terrain.getNode());
|
||||||
|
|
||||||
// -----------------------------------------
|
// -----------------------------------------
|
||||||
// Setup Player
|
// Setup Player
|
||||||
|
|
@ -121,7 +129,7 @@ public class CookeryClient extends SimpleApplication {
|
||||||
// The closest result is the target that the player picked:
|
// The closest result is the target that the player picked:
|
||||||
Geometry target = results.getClosestCollision().getGeometry();
|
Geometry target = results.getClosestCollision().getGeometry();
|
||||||
// Here comes the action:
|
// Here comes the action:
|
||||||
target.setLocalTranslation(target.getLocalTranslation().add(1, 0, 0));
|
// target.setLocalTranslation(target.getLocalTranslation().add(1, 0, 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
package se.cookery.core.world;
|
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.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
@ -10,10 +10,10 @@ public class World {
|
||||||
// Variables
|
// Variables
|
||||||
|
|
||||||
private Map<Long, Map<Long, Block>> worldBlocks = new TreeMap<>();
|
private Map<Long, Map<Long, Block>> worldBlocks = new TreeMap<>();
|
||||||
private WorldGenerator generator;
|
private BlockGenerator generator;
|
||||||
|
|
||||||
|
|
||||||
public World(WorldGenerator generator) {
|
public World(BlockGenerator generator) {
|
||||||
this.generator = generator;
|
this.generator = generator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import se.cookery.core.world.Block;
|
||||||
* A class that implements this interface can be used
|
* A class that implements this interface can be used
|
||||||
* to generate a static or dynamic world.
|
* to generate a static or dynamic world.
|
||||||
*/
|
*/
|
||||||
public interface WorldGenerator {
|
public interface BlockGenerator {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method to generate a block with the provided coordinates,
|
* Method to generate a block with the provided coordinates,
|
||||||
|
|
@ -2,7 +2,7 @@ package se.cookery.core.world.gen;
|
||||||
|
|
||||||
import se.cookery.core.world.Block;
|
import se.cookery.core.world.Block;
|
||||||
|
|
||||||
public class GrassLandWorldGenerator implements WorldGenerator {
|
public class GrassLandBlockGenerator implements BlockGenerator {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Block generateBlock(long x, long y) {
|
public Block generateBlock(long x, long y) {
|
||||||
24
core/src/se/cookery/gfx/terrain/BlockHeightMap.java
Normal file
24
core/src/se/cookery/gfx/terrain/BlockHeightMap.java
Normal file
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
package se.cookery.core.world;
|
package se.cookery.core.world;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import se.cookery.core.world.World;
|
import se.cookery.core.world.gen.GrassLandBlockGenerator;
|
||||||
import se.cookery.core.world.gen.GrassLandWorldGenerator;
|
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
|
|
@ -10,7 +9,7 @@ public class WorldTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void blockExists() {
|
public void blockExists() {
|
||||||
World w = new World(new GrassLandWorldGenerator());
|
World w = new World(new GrassLandBlockGenerator());
|
||||||
assertFalse(w.blockExists(0, 0));
|
assertFalse(w.blockExists(0, 0));
|
||||||
assertFalse(w.blockExists(Long.MAX_VALUE, Long.MAX_VALUE));
|
assertFalse(w.blockExists(Long.MAX_VALUE, Long.MAX_VALUE));
|
||||||
assertFalse(w.blockExists(Long.MIN_VALUE, Long.MAX_VALUE));
|
assertFalse(w.blockExists(Long.MIN_VALUE, Long.MAX_VALUE));
|
||||||
|
|
@ -20,7 +19,7 @@ public class WorldTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getBlock() {
|
public void getBlock() {
|
||||||
World w = new World(new GrassLandWorldGenerator());
|
World w = new World(new GrassLandBlockGenerator());
|
||||||
assertFalse(w.blockExists(0, 0));
|
assertFalse(w.blockExists(0, 0));
|
||||||
assertNotNull(w.getBlock(0,0));
|
assertNotNull(w.getBlock(0,0));
|
||||||
assertTrue(w.blockExists(0, 0));
|
assertTrue(w.blockExists(0, 0));
|
||||||
|
|
|
||||||
18
ios/ios.iml
Normal file
18
ios/ios.iml
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module version="4">
|
||||||
|
<component name="FacetManager">
|
||||||
|
<facet type="android-gradle" name="Android-Gradle">
|
||||||
|
<configuration>
|
||||||
|
<option name="GRADLE_PROJECT_PATH" value=":ios" />
|
||||||
|
<option name="LAST_SUCCESSFUL_SYNC_AGP_VERSION" />
|
||||||
|
<option name="LAST_KNOWN_AGP_VERSION" />
|
||||||
|
</configuration>
|
||||||
|
</facet>
|
||||||
|
<facet type="java-gradle" name="Java-Gradle">
|
||||||
|
<configuration>
|
||||||
|
<option name="BUILD_FOLDER_PATH" value="$MODULE_DIR$/build" />
|
||||||
|
<option name="BUILDABLE" value="true" />
|
||||||
|
</configuration>
|
||||||
|
</facet>
|
||||||
|
</component>
|
||||||
|
</module>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue