moved to jme3

This commit is contained in:
Ziver Koc 2020-03-21 19:57:43 +01:00
parent 4dd9985229
commit d563f539a5
20 changed files with 124 additions and 114 deletions

View file

@ -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'

View file

@ -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);
}
}

View file

@ -0,0 +1,4 @@
package se.cookery.core.util.noise;
public class PerlinNoise {
}

View file

@ -0,0 +1,4 @@
package se.cookery.core.util.noise;
public class SimplexNoise {
}

View file

@ -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

View file

@ -1,4 +1,4 @@
package se.cookery.world;
package se.cookery.core.world;
/**
* Class representing a ground material type.

View file

@ -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;

View file

@ -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;

View file

@ -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 {

View file

@ -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.

View 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 {
}

View file

@ -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.*;

View file

@ -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;

View file

@ -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.*;

View file

@ -1,4 +1,4 @@
package se.cookery.world.gen;
package se.cookery.core.world.gen;
import org.junit.jupiter.api.Test;