diff --git a/android/build.gradle b/android/build.gradle index 256ba81..1815877 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -31,52 +31,13 @@ android { } } - -// called every time gradle gets executed, takes the native dependencies of -// the natives configuration, and extracts them to the proper libs/ folders -// so they get packed with the APK. -task copyAndroidNatives { - doFirst { - file("libs/armeabi/").mkdirs() - file("libs/armeabi-v7a/").mkdirs() - file("libs/arm64-v8a/").mkdirs() - file("libs/x86_64/").mkdirs() - file("libs/x86/").mkdirs() - - configurations.natives.files.each { jar -> - def outputDir = null - if (jar.name.endsWith("natives-arm64-v8a.jar")) outputDir = file("libs/arm64-v8a") - if (jar.name.endsWith("natives-armeabi-v7a.jar")) outputDir = file("libs/armeabi-v7a") - if(jar.name.endsWith("natives-armeabi.jar")) outputDir = file("libs/armeabi") - if(jar.name.endsWith("natives-x86_64.jar")) outputDir = file("libs/x86_64") - if(jar.name.endsWith("natives-x86.jar")) outputDir = file("libs/x86") - if(outputDir != null) { - copy { - from zipTree(jar) - into outputDir - include "*.so" - } - } - } - } -} - -tasks.whenTaskAdded { packageTask -> - if (packageTask.name.contains("package")) { - packageTask.dependsOn 'copyAndroidNatives' - } -} - configurations { natives } dependencies { implementation project(":core") - api "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion" - natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi" - natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a" - natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-arm64-v8a" - natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86" - natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64" + + implementation "org.jmonkeyengine:jme3-android:${jme3Version}-stable" + implementation "org.jmonkeyengine:jme3-android-native:${jme3Version}-stable" } task run(type: Exec) { diff --git a/build.gradle b/build.gradle index 0fbcc21..c479bed 100644 --- a/build.gradle +++ b/build.gradle @@ -18,11 +18,9 @@ allprojects { ext { appName = "Cookery" + gdxVersion = '1.9.10' - roboVMVersion = '2.3.8' - box2DLightsVersion = '1.4' - ashleyVersion = '1.7.0' - aiVersion = '1.8.0' + jme3Version = '3.2.3' } repositories { @@ -32,6 +30,7 @@ allprojects { google() maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } maven { url "https://oss.sonatype.org/content/repositories/releases/" } + maven { url "http://dl.bintray.com/jmonkeyengine/org.jmonkeyengine" } } } diff --git a/core/build.gradle b/core/build.gradle index 6320837..ecf8d40 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -1,6 +1,4 @@ -apply plugin: "java" - -sourceCompatibility = 1.8 +sourceCompatibility = '1.8' [compileJava, compileTestJava]*.options*.encoding = 'UTF-8' sourceSets { @@ -14,7 +12,8 @@ sourceSets { } dependencies { - api "com.badlogicgames.gdx:gdx:$gdxVersion" + compile "org.jmonkeyengine:jme3-core:${jme3Version}-stable" + compile "org.jmonkeyengine:jme3-terrain:${jme3Version}-stable" implementation 'se.koc:zutil:1.0.0-SNAPSHOT' diff --git a/core/src/se/cookery/CookeryClient.java b/core/src/se/cookery/CookeryClient.java index 4c61ba5..4a42605 100644 --- a/core/src/se/cookery/CookeryClient.java +++ b/core/src/se/cookery/CookeryClient.java @@ -1,33 +1,50 @@ package se.cookery; -import com.badlogic.gdx.ApplicationAdapter; -import com.badlogic.gdx.Gdx; -import com.badlogic.gdx.graphics.GL20; -import com.badlogic.gdx.graphics.Texture; -import com.badlogic.gdx.graphics.g2d.SpriteBatch; +import com.jme3.app.SimpleApplication; +import com.jme3.material.Material; +import com.jme3.math.ColorRGBA; +import com.jme3.terrain.geomipmap.TerrainLodControl; +import com.jme3.terrain.geomipmap.TerrainQuad; +import com.jme3.terrain.heightmap.AbstractHeightMap; +import se.cookery.core.world.Block; +import se.cookery.core.world.gen.GrassLandWorldGenerator; -public class CookeryClient extends ApplicationAdapter { - SpriteBatch batch; - Texture img; - - @Override - public void create () { - batch = new SpriteBatch(); - img = new Texture("badlogic.jpg"); - } +public class CookeryClient extends SimpleApplication { + private TerrainQuad terrain; - @Override - public void render () { - Gdx.gl.glClearColor(1, 0, 0, 1); - Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); - batch.begin(); - batch.draw(img, 0, 0); - batch.end(); - } - - @Override - public void dispose () { - batch.dispose(); - img.dispose(); - } -} + @Override + public void simpleInitApp() { + flyCam.setMoveSpeed(50); + + /** 3. We have prepared material and heightmap. + * Now we create the actual terrain: + * 3.1) Create a TerrainQuad and name it "my terrain". + * 3.2) A good value for terrain tiles is 64x64 -- so we supply 64+1=65. + * 3.3) We prepared a heightmap of size 512x512 -- so we supply 512+1=513. + * 3.4) As LOD step scale we supply Vector3f(1,1,1). + * 3.5) We supply the prepared heightmap itself. + */ + int patchSize = 65; + Block block = new GrassLandWorldGenerator().generateBlock(0, 0); + float[] heightMap = new float[Block.BLOCK_SIZE*Block.BLOCK_SIZE]; + + for (int x=0; x