From 8d2e6305dad3af14d48672488c034d91fa480c25 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Wed, 9 Mar 2022 00:22:21 +0100 Subject: [PATCH] update basic ground --- .project | 11 +++++ samples/.project | 11 +++++ samples/resources/lowPoly/data/palette_1.json | 9 ++++ .../atriasoft/ege/mapFactory/ApplScene.java | 1 + .../atriasoft/ege/mapFactory/EgeScene.java | 2 +- .../atriasoft/ege/mapFactory/Ground.java | 43 +++++++++++++++---- 6 files changed, 67 insertions(+), 10 deletions(-) diff --git a/.project b/.project index 045956e..ef28fb1 100644 --- a/.project +++ b/.project @@ -20,4 +20,15 @@ org.eclipse.jdt.core.javanature + + + 1646149232188 + + 30 + + org.eclipse.core.resources.regexFilterMatcher + node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ + + + diff --git a/samples/.project b/samples/.project index 445ad66..6a34b8b 100644 --- a/samples/.project +++ b/samples/.project @@ -14,4 +14,15 @@ org.eclipse.jdt.core.javanature + + + 1646149232189 + + 30 + + org.eclipse.core.resources.regexFilterMatcher + node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ + + + diff --git a/samples/resources/lowPoly/data/palette_1.json b/samples/resources/lowPoly/data/palette_1.json index 02caeaf..13e240c 100644 --- a/samples/resources/lowPoly/data/palette_1.json +++ b/samples/resources/lowPoly/data/palette_1.json @@ -27,6 +27,15 @@ }, "grass_1":{ "Kd":"0.057805 1.0 0.013702" + }, + "grass_2":{ + "Kd":"1.0 0.0 0.013702" + }, + "grass_3":{ + "Kd":"1.0 1.0 0.013702" + }, + "grass_4":{ + "Kd":"0.0 0.0 1.0" } } } \ No newline at end of file diff --git a/samples/src/sample/atriasoft/ege/mapFactory/ApplScene.java b/samples/src/sample/atriasoft/ege/mapFactory/ApplScene.java index ab0898f..5169b9b 100644 --- a/samples/src/sample/atriasoft/ege/mapFactory/ApplScene.java +++ b/samples/src/sample/atriasoft/ege/mapFactory/ApplScene.java @@ -32,6 +32,7 @@ public class ApplScene extends EgeScene { groundEntity .addComponent(new ComponentRenderMeshPalette(new Uri("DATA", "basicPalette.vert"), new Uri("DATA", "basicPalette.frag"), (EngineLight) this.env.getEngine(EngineLight.ENGINE_NAME))); this.env.addEntity(groundEntity); + this.ground.updateMesh(); } } diff --git a/samples/src/sample/atriasoft/ege/mapFactory/EgeScene.java b/samples/src/sample/atriasoft/ege/mapFactory/EgeScene.java index cbc5df0..f06a840 100644 --- a/samples/src/sample/atriasoft/ege/mapFactory/EgeScene.java +++ b/samples/src/sample/atriasoft/ege/mapFactory/EgeScene.java @@ -54,7 +54,7 @@ public class EgeScene extends Widget { final Camera mainView = new Camera(); this.env.addCamera("default", mainView); mainView.setPitch((float) Math.PI * -0.25f); - mainView.setPosition(new Vector3f(0, -5, 5)); + mainView.setPosition(new Vector3f(4, -5, 5)); } diff --git a/samples/src/sample/atriasoft/ege/mapFactory/Ground.java b/samples/src/sample/atriasoft/ege/mapFactory/Ground.java index 1ca70b3..a6d0584 100644 --- a/samples/src/sample/atriasoft/ege/mapFactory/Ground.java +++ b/samples/src/sample/atriasoft/ege/mapFactory/Ground.java @@ -5,17 +5,27 @@ import org.atriasoft.loader3d.model.Material; import org.atriasoft.loader3d.resources.ResourceMeshHeightMap; public class Ground { - int width = 512; - int length = 512; - float[][] heightMap = new float[512][512]; - String[][] colorMap = new String[512][512 * 2]; + int sizeX = 16; + int sizeY = 16; + float[][] heightMap = new float[this.sizeY][this.sizeX]; + String[][] colorMap = new String[this.sizeY][this.sizeX * 2]; ResourceMeshHeightMap mesh = new ResourceMeshHeightMap(); + String baseNamePalette = "palette:grass_1"; + String baseNamePalette2 = "palette:grass_2"; + String baseNamePalette3 = "palette:grass_3"; + String baseNamePalette4 = "palette:grass_4"; public Ground() { - for (int yyy = 0; yyy < this.length; yyy++) { - for (int xxx = 0; xxx < this.width; xxx++) { + for (int yyy = 0; yyy < this.sizeY; yyy++) { + for (int xxx = 0; xxx < this.sizeX; xxx++) { this.heightMap[yyy][xxx] = 0.0f; - this.colorMap[yyy][xxx] = "grass_1"; + if (xxx % 2 == 0) { + this.colorMap[yyy][xxx * 2] = this.baseNamePalette; + this.colorMap[yyy][xxx * 2 + 1] = this.baseNamePalette2; + } else { + this.colorMap[yyy][xxx * 2] = this.baseNamePalette3; + this.colorMap[yyy][xxx * 2 + 1] = this.baseNamePalette4; + } } } } @@ -26,8 +36,23 @@ public class Ground { public void updateMesh() { Material mat = new Material(); - this.mesh.addMaterial("grass_1", mat); - mat.setAmbientFactor(new Vector4f(1.0f, 0, 0, 1.0f)); + this.mesh.addMaterial(this.baseNamePalette, mat); + mat.setAmbientFactor(new Vector4f(1, 0, 0, 1.0f)); + mat = new Material(); + this.mesh.addMaterial(this.baseNamePalette2, mat); + mat.setAmbientFactor(new Vector4f(0, 1, 0, 1.0f)); + mat = new Material(); + this.mesh.addMaterial(this.baseNamePalette3, mat); + mat.setAmbientFactor(new Vector4f(0, 0, 1, 1.0f)); + mat = new Material(); + this.mesh.addMaterial(this.baseNamePalette4, mat); + mat.setAmbientFactor(new Vector4f(1, 1, 0, 1.0f)); + try { + this.mesh.udateData(this.heightMap, this.colorMap, this.sizeX, this.sizeY); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } } }