moved to jme3
This commit is contained in:
parent
4dd9985229
commit
d563f539a5
20 changed files with 124 additions and 114 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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" }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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'
|
||||
|
||||
|
|
|
|||
|
|
@ -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<Block.BLOCK_SIZE; x++) {
|
||||
for (int y=0; y<Block.BLOCK_SIZE; y++) {
|
||||
heightMap[Block.BLOCK_SIZE * x + y] = block.getHeight(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
terrain = new TerrainQuad("Ground", patchSize, Block.BLOCK_SIZE+1, heightMap);
|
||||
|
||||
Material mat_terrain = new Material();
|
||||
mat_terrain.setColor("Green", ColorRGBA.Green);
|
||||
|
||||
/** 4. We give the terrain its material, position & scale it, and attach it. */
|
||||
terrain.setMaterial(mat_terrain);
|
||||
rootNode.attachChild(terrain);
|
||||
|
||||
/** 5. The LOD (level of detail) depends on were the camera is: */
|
||||
TerrainLodControl control = new TerrainLodControl(terrain, getCamera());
|
||||
terrain.addControl(control);
|
||||
}
|
||||
}
|
||||
4
core/src/se/cookery/core/util/noise/PerlinNoise.java
Normal file
4
core/src/se/cookery/core/util/noise/PerlinNoise.java
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
package se.cookery.core.util.noise;
|
||||
|
||||
public class PerlinNoise {
|
||||
}
|
||||
4
core/src/se/cookery/core/util/noise/SimplexNoise.java
Normal file
4
core/src/se/cookery/core/util/noise/SimplexNoise.java
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
package se.cookery.core.util.noise;
|
||||
|
||||
public class SimplexNoise {
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package se.cookery.world;
|
||||
package se.cookery.core.world;
|
||||
|
||||
/**
|
||||
* Class representing a block of the world.
|
||||
|
|
@ -11,7 +11,7 @@ public class Block {
|
|||
/**
|
||||
* The size of a block in units of squares. The block is a square with size BLOCK_SIZE x BLOCK_SIZE.
|
||||
**/
|
||||
public static final int BLOCK_SIZE = 20;
|
||||
public static final int BLOCK_SIZE = 64;
|
||||
|
||||
// Variables
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package se.cookery.world;
|
||||
package se.cookery.core.world;
|
||||
|
||||
/**
|
||||
* Class representing a ground material type.
|
||||
|
|
@ -1,12 +1,10 @@
|
|||
package se.cookery.world;
|
||||
package se.cookery.core.world;
|
||||
|
||||
import com.badlogic.gdx.utils.JsonReader;
|
||||
import zutil.io.file.FileUtil;
|
||||
import zutil.log.LogUtil;
|
||||
import zutil.parser.DataNode;
|
||||
import zutil.parser.json.JSONParser;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.security.InvalidParameterException;
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package se.cookery.world;
|
||||
package se.cookery.core.world;
|
||||
|
||||
import se.cookery.world.gen.WorldGenerator;
|
||||
import se.cookery.core.world.gen.WorldGenerator;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package se.cookery.world.gen;
|
||||
package se.cookery.core.world.gen;
|
||||
|
||||
import se.cookery.world.Block;
|
||||
import se.cookery.core.world.Block;
|
||||
|
||||
public class GrassLandWorldGenerator implements WorldGenerator {
|
||||
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package se.cookery.world.gen;
|
||||
package se.cookery.core.world.gen;
|
||||
|
||||
import se.cookery.world.Block;
|
||||
import se.cookery.core.world.Block;
|
||||
|
||||
/**
|
||||
* Interface representing a world generation class.
|
||||
24
core/src/se/cookery/gfx/terrain/TerrainMesh.java
Normal file
24
core/src/se/cookery/gfx/terrain/TerrainMesh.java
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
package se.cookery.gfx.terrain;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
|
||||
/**
|
||||
* This terrain generator generates a simple terrain, similar to the basic
|
||||
* terrain used in my previous tutorials. The difference here is in the shader
|
||||
* programs, with the use of the "flat" type qualifier when passing the colour
|
||||
* from vertex shader to fragment shader. This stops the colour being
|
||||
* interpolated over each triangle, and instead the entire triangle uses the
|
||||
* colour value from just one of the vertices, the "provoking" vertex. This is
|
||||
* by default the last specified vertex of the triangle, but it's possible to
|
||||
* make it use the first vertex instead.
|
||||
*
|
||||
* @author Karl
|
||||
*/
|
||||
public class TerrainMesh {
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
package se.cookery.world;
|
||||
package se.cookery.core.world;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import se.cookery.core.world.Block;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
|
|
@ -1,7 +1,9 @@
|
|||
package se.cookery.world;
|
||||
package se.cookery.core.world;
|
||||
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import se.cookery.core.world.GroundType;
|
||||
import se.cookery.core.world.GroundTypeManager;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.security.InvalidParameterException;
|
||||
|
|
@ -1,7 +1,8 @@
|
|||
package se.cookery.world;
|
||||
package se.cookery.core.world;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import se.cookery.world.gen.GrassLandWorldGenerator;
|
||||
import se.cookery.core.world.World;
|
||||
import se.cookery.core.world.gen.GrassLandWorldGenerator;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package se.cookery.world.gen;
|
||||
package se.cookery.core.world.gen;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
|
@ -2,22 +2,20 @@ apply plugin: "java"
|
|||
|
||||
sourceCompatibility = 1.8
|
||||
sourceSets.main.java.srcDirs = [ "src/" ]
|
||||
sourceSets.main.resources.srcDirs = ["../android/assets"]
|
||||
|
||||
project.ext.mainClassName = "se.cookery.desktop.DesktopLauncher"
|
||||
project.ext.assetsDir = new File("../android/assets")
|
||||
|
||||
dependencies {
|
||||
implementation project(":core")
|
||||
api "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
|
||||
api "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
|
||||
|
||||
runtime "org.jmonkeyengine:jme3-lwjgl3:${jme3Version}-stable"
|
||||
runtime "org.jmonkeyengine:jme3-desktop:${jme3Version}-stable"
|
||||
}
|
||||
|
||||
task run(dependsOn: classes, type: JavaExec) {
|
||||
main = project.mainClassName
|
||||
classpath = sourceSets.main.runtimeClasspath
|
||||
standardInput = System.in
|
||||
workingDir = project.assetsDir
|
||||
ignoreExitValue = true
|
||||
}
|
||||
|
||||
|
|
@ -25,7 +23,6 @@ task debug(dependsOn: classes, type: JavaExec) {
|
|||
main = project.mainClassName
|
||||
classpath = sourceSets.main.runtimeClasspath
|
||||
standardInput = System.in
|
||||
workingDir = project.assetsDir
|
||||
ignoreExitValue = true
|
||||
debug = true
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,10 @@
|
|||
package se.cookery.desktop;
|
||||
|
||||
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
|
||||
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
|
||||
import se.cookery.CookeryClient;
|
||||
|
||||
public class DesktopLauncher {
|
||||
public static void main (String[] arg) {
|
||||
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
|
||||
new LwjglApplication(new CookeryClient(), config);
|
||||
CookeryClient app = new CookeryClient();
|
||||
app.start();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,20 +1,25 @@
|
|||
sourceSets.main.java.srcDirs = [ "src/" ]
|
||||
|
||||
sourceCompatibility = '1.8'
|
||||
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
|
||||
|
||||
dependencies {
|
||||
implementation project(":core")
|
||||
api "com.mobidevelop.robovm:robovm-rt:$roboVMVersion"
|
||||
api "com.mobidevelop.robovm:robovm-cocoatouch:$roboVMVersion"
|
||||
api "com.badlogicgames.gdx:gdx-backend-robovm:$gdxVersion"
|
||||
api "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-ios"
|
||||
}
|
||||
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
|
||||
|
||||
ext {
|
||||
mainClassName = "se.cookery.IOSLauncher"
|
||||
roboVMVersion = '2.3.8'
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation project(":core")
|
||||
|
||||
runtime "org.jmonkeyengine:jme3-ios:${jme3Version}-stable"
|
||||
|
||||
api "com.mobidevelop.robovm:robovm-rt:$roboVMVersion"
|
||||
api "com.mobidevelop.robovm:robovm-cocoatouch:$roboVMVersion"
|
||||
}
|
||||
|
||||
|
||||
|
||||
launchIPhoneSimulator.dependsOn build
|
||||
launchIPadSimulator.dependsOn build
|
||||
launchIOSDevice.dependsOn build
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue