diff --git a/.classpath b/.classpath
index 3e8b9c7..dbcec19 100644
--- a/.classpath
+++ b/.classpath
@@ -22,22 +22,7 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
@@ -47,7 +32,27 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/samples/resources/emf/Entry.emf b/samples/resources/lowPoly/data/Entry.emf
similarity index 100%
rename from samples/resources/emf/Entry.emf
rename to samples/resources/lowPoly/data/Entry.emf
diff --git a/samples/src/sample/atriasoft/ege/lowPoly/kkk_basic.frag b/samples/resources/lowPoly/data/basicPalette.frag
similarity index 89%
rename from samples/src/sample/atriasoft/ege/lowPoly/kkk_basic.frag
rename to samples/resources/lowPoly/data/basicPalette.frag
index 13d2aa8..a5fe9f5 100644
--- a/samples/src/sample/atriasoft/ege/lowPoly/kkk_basic.frag
+++ b/samples/resources/lowPoly/data/basicPalette.frag
@@ -14,4 +14,5 @@ out vec4 out_Color;
void main(void) {
out_Color = texture(in_textureBase, io_textureCoords);
+ //out_Color = vec4(1,0,0,1);
}
diff --git a/samples/src/sample/atriasoft/ege/lowPoly/kkk_basic.vert b/samples/resources/lowPoly/data/basicPalette.vert
similarity index 100%
rename from samples/src/sample/atriasoft/ege/lowPoly/kkk_basic.vert
rename to samples/resources/lowPoly/data/basicPalette.vert
diff --git a/samples/resources/lowPoly/data/cube-one.obj b/samples/resources/lowPoly/data/cube-one.obj
new file mode 100644
index 0000000..6a4210b
--- /dev/null
+++ b/samples/resources/lowPoly/data/cube-one.obj
@@ -0,0 +1,46 @@
+# Blender v2.82 (sub 7) OBJ File: 'cube.blend'
+# www.blender.org
+mtllib cube.mtl
+o Cube
+v 0.5 0.5 -0.5
+v 0.5 -0.5 -0.5
+v 0.5 0.5 0.5
+v 0.5 -0.5 0.5
+v -0.5 0.5 -0.5
+v -0.5 -0.5 -0.5
+v -0.5 0.5 0.5
+v -0.5 -0.5 0.5
+vt 0.875000 0.500000
+vt 0.625000 0.750000
+vt 0.625000 0.500000
+vt 0.375000 1.000000
+vt 0.375000 0.750000
+vt 0.625000 0.000000
+vt 0.375000 0.250000
+vt 0.375000 0.000000
+vt 0.375000 0.500000
+vt 0.125000 0.750000
+vt 0.125000 0.500000
+vt 0.625000 0.250000
+vt 0.875000 0.750000
+vt 0.625000 1.000000
+vn 0.0000 1.0000 0.0000
+vn 0.0000 0.0000 1.0000
+vn -1.0000 0.0000 0.0000
+vn 0.0000 -1.0000 0.0000
+vn 1.0000 0.0000 0.0000
+vn 0.0000 0.0000 -1.0000
+usemtl Material
+s off
+f 5/1/1 3/2/1 1/3/1
+f 3/2/2 8/4/2 4/5/2
+f 7/6/3 6/7/3 8/8/3
+f 2/9/4 8/10/4 6/11/4
+f 1/3/5 4/5/5 2/9/5
+f 5/12/6 2/9/6 6/7/6
+f 5/1/1 7/13/1 3/2/1
+f 3/2/2 7/14/2 8/4/2
+f 7/6/3 5/12/3 6/7/3
+f 2/9/4 4/5/4 8/10/4
+f 1/3/5 3/2/5 4/5/5
+f 5/12/6 1/3/6 2/9/6
diff --git a/samples/resources/lowPoly/data/grass.png b/samples/resources/lowPoly/data/grass.png
new file mode 100644
index 0000000..9296601
Binary files /dev/null and b/samples/resources/lowPoly/data/grass.png differ
diff --git a/samples/resources/emf/palette_1.json b/samples/resources/lowPoly/data/palette_1.json
similarity index 92%
rename from samples/resources/emf/palette_1.json
rename to samples/resources/lowPoly/data/palette_1.json
index 9e90373..28f5754 100644
--- a/samples/resources/emf/palette_1.json
+++ b/samples/resources/lowPoly/data/palette_1.json
@@ -5,20 +5,20 @@
"Kd":"0.346704 0.558341 0.090842",
"Ks":"0.500000 0.500000 0.500000",
"Ke":"0.000000 0.000000 0.000000",
- "vNi":"1.000000,
+ "vNi":1.000000,
"d":1.000000,
"illum":2
},
"palette": {
"leaf_1":{
"Kd":"0.346704 0.558341 0.090842"
- }
+ },
"leaf_2":{
"Kd":"0.278894 0.278894 0.023153"
- }
+ },
"leaf_3":{
"Kd":"0.800000 0.800000 0.800000"
- }
+ },
"trunk_1":{
"Kd":"0.057805 0.039546 0.013702"
}
diff --git a/samples/resources/lowPoly/data/simple3D.emf b/samples/resources/lowPoly/data/simple3D.emf
new file mode 100644
index 0000000..c9a7dab
--- /dev/null
+++ b/samples/resources/lowPoly/data/simple3D.emf
@@ -0,0 +1,67 @@
+EMF(STRING)
+# Blender v2.92.0 EMF File: 'simple3D.blend'
+Mesh:Arbre_Normal_Mesh
+ Vertex:17
+ 3.051021 3.620651 -2.087459|5.582213 1.032425 -2.087459|4.922988 -2.135247 -2.087459|1.459509 -4.026786 -2.087459|-2.779363 -3.534152 -2.087459|-5.310555 -0.945922 -2.087459|-4.651330 2.221750 -2.087459|-1.187852 4.113286 -2.087459|1.442891 1.647222 2.690865|2.577781 0.486759 2.690865|2.282209 -0.933506 2.690865|0.729316 -1.781600 2.690865|-1.171233 -1.560721 2.690865|-2.306123 -0.400256 2.690865|-2.010551 1.020007 2.690865|-0.457659 1.868100 2.690865|13.475907 -19.707346 33.057674|
+ Normal(face):28
+ 0.000000 0.000000 -1.000000|0.842352 -0.175302 0.509620|-0.105309 -0.906134 0.409672|-0.842352 0.175302 0.509620|0.105309 0.906134 0.409672|0.842351 -0.175302 0.509621|-0.105310 -0.906134 0.409672|-0.842351 0.175302 0.509621|0.000000 0.000000 1.000000|0.631866 0.617942 0.467860|0.431163 -0.789476 0.436837|0.431163 -0.789476 0.436838|-0.631866 -0.617941 0.467860|-0.431162 0.789476 0.436838|
+ Face:28
+ palette:trunk_1
+ 7/0 4/0 6/0| 9/1 2/1 1/1| 3/2 12/2 4/2| 13/3 6/3 5/3| 7/4 8/4 0/4| 7/0 0/0 3/0| 0/0 1/0 2/0| 3/0 0/0 2/0| 3/0 4/0 7/0| 4/0 5/0 6/0| 9/5 10/5 2/5| 3/6 11/6 12/6| 13/7 14/7 6/7| 7/4 15/4 8/4|
+ palette:leaf_1
+ 11/8 10/8 8/8| 9/8 8/8 10/8| 8/8 15/8 11/8| 15/8 14/8 12/8| 14/8 13/8 12/8| 12/8 11/8 15/8|
+ palette:leaf_2
+ 0/9 9/9 1/9| 10/10 3/10 2/10| 0/9 8/9 9/9| 10/11 11/11 3/11|
+ palette:leaf_3
+ 4/12 13/12 5/12| 14/13 7/13 6/13| 4/12 12/12 13/12| 14/13 15/13 7/13|
+Physics:
+ Cylinder
+ radius:0.25
+ size:2.0
+ origin:0.0117903 0.0311268 0.962411
+ mass:6.25
+ Sphere
+ radius:1.3350000381469727
+ origin:-0.093534 -0.0233787 2.81849
+ mass:237.92705789594712
+
+# Just for information:
+Palettes:leaf_1
+ Ns 225.000000
+ Ka 1.000000 1.000000 1.000000
+ Kd 0.346704 0.558341 0.090842
+ Ks 0.500000 0.500000 0.500000
+ Ke 0.000000 0.000000 0.000000
+ vNi 1.000000
+ d 1.000000
+ illum 2
+# Just for information:
+Palettes:leaf_2
+ Ns 225.000000
+ Ka 1.000000 1.000000 1.000000
+ Kd 0.278894 0.278894 0.023153
+ Ks 0.500000 0.500000 0.500000
+ Ke 0.000000 0.000000 0.000000
+ vNi 1.000000
+ d 1.000000
+ illum 2
+# Just for information:
+Palettes:leaf_3
+ Ns 225.000000
+ Ka 1.000000 1.000000 1.000000
+ Kd 0.800000 0.800000 0.800000
+ Ks 0.500000 0.500000 0.500000
+ Ke 0.000000 0.000000 0.000000
+ vNi 1.000000
+ d 1.000000
+ illum 2
+# Just for information:
+Palettes:trunk_1
+ Ns 225.000000
+ Ka 1.000000 1.000000 1.000000
+ Kd 0.057805 0.039546 0.013702
+ Ks 0.500000 0.500000 0.500000
+ Ke 0.000000 0.000000 0.000000
+ vNi 1.000000
+ d 1.000000
+ illum 2
diff --git a/samples/resources/emf/tower.emf b/samples/resources/lowPoly/data/tower.emf
similarity index 100%
rename from samples/resources/emf/tower.emf
rename to samples/resources/lowPoly/data/tower.emf
diff --git a/samples/resources/emf/tree1.emf b/samples/resources/lowPoly/data/tree1.emf
similarity index 100%
rename from samples/resources/emf/tree1.emf
rename to samples/resources/lowPoly/data/tree1.emf
diff --git a/samples/resources/lowPoly/simple3D.blend b/samples/resources/lowPoly/simple3D.blend
new file mode 100644
index 0000000..8f24edb
Binary files /dev/null and b/samples/resources/lowPoly/simple3D.blend differ
diff --git a/samples/resources/emf/tree1.blend1 b/samples/resources/lowPoly/simple3D.blend1
similarity index 76%
rename from samples/resources/emf/tree1.blend1
rename to samples/resources/lowPoly/simple3D.blend1
index 37c4797..a09984f 100644
Binary files a/samples/resources/emf/tree1.blend1 and b/samples/resources/lowPoly/simple3D.blend1 differ
diff --git a/samples/resources/emf/tree1.blend b/samples/resources/lowPoly/tree1.blend
similarity index 100%
rename from samples/resources/emf/tree1.blend
rename to samples/resources/lowPoly/tree1.blend
diff --git a/samples/resources/emf/tree1.mtl b/samples/resources/lowPoly/tree1.mtl
similarity index 100%
rename from samples/resources/emf/tree1.mtl
rename to samples/resources/lowPoly/tree1.mtl
diff --git a/samples/resources/emf/tree1.obj b/samples/resources/lowPoly/tree1.obj
similarity index 100%
rename from samples/resources/emf/tree1.obj
rename to samples/resources/lowPoly/tree1.obj
diff --git a/samples/resources/emf/tree1_base.emf b/samples/resources/lowPoly/tree1_base.emf
similarity index 100%
rename from samples/resources/emf/tree1_base.emf
rename to samples/resources/lowPoly/tree1_base.emf
diff --git a/samples/src/sample/atriasoft/ege/lightTest/LightTestApplication.java b/samples/src/sample/atriasoft/ege/lightTest/LightTestApplication.java
new file mode 100644
index 0000000..03506ec
--- /dev/null
+++ b/samples/src/sample/atriasoft/ege/lightTest/LightTestApplication.java
@@ -0,0 +1,175 @@
+package sample.atriasoft.ege.lightTest;
+
+import org.atriasoft.ege.ControlCameraSimple;
+import org.atriasoft.ege.Entity;
+import org.atriasoft.ege.Environement;
+import org.atriasoft.ege.GameStatus;
+import org.atriasoft.ege.Light;
+import org.atriasoft.ege.Material;
+import org.atriasoft.ege.camera.Camera;
+import org.atriasoft.ege.components.ComponentLight;
+import org.atriasoft.ege.components.ComponentLightSun;
+import org.atriasoft.ege.components.ComponentMaterial;
+import org.atriasoft.ege.components.ComponentPosition;
+import org.atriasoft.ege.components.ComponentRenderColoredStaticMesh;
+import org.atriasoft.ege.components.ComponentRenderTexturedMaterialsStaticMesh;
+import org.atriasoft.ege.components.ComponentRenderTexturedStaticMesh;
+import org.atriasoft.ege.components.ComponentStaticMesh;
+import org.atriasoft.ege.components.ComponentTexture;
+import org.atriasoft.ege.engines.EngineLight;
+import org.atriasoft.ege.tools.MeshGenerator;
+import org.atriasoft.etk.Color;
+import org.atriasoft.etk.Uri;
+import org.atriasoft.etk.math.Matrix4f;
+import org.atriasoft.etk.math.Quaternion;
+import org.atriasoft.etk.math.Transform3D;
+import org.atriasoft.etk.math.Vector2f;
+import org.atriasoft.etk.math.Vector3f;
+import org.atriasoft.gale.GaleApplication;
+import org.atriasoft.gale.backend3d.OpenGL;
+import org.atriasoft.gale.backend3d.OpenGL.Flag;
+import org.atriasoft.gale.context.GaleContext;
+import org.atriasoft.gale.key.KeyKeyboard;
+import org.atriasoft.gale.key.KeySpecial;
+import org.atriasoft.gale.key.KeyStatus;
+import org.atriasoft.gale.key.KeyType;
+
+public class LightTestApplication extends GaleApplication {
+ private float angleLight = 0;
+ private Quaternion basicRotation = Quaternion.IDENTITY;
+ private Quaternion basicRotation2 = Quaternion.IDENTITY;
+ private Environement env;
+ private ComponentPosition lightPosition;
+ private Material materialCube;
+ private ComponentPosition objectPosition;
+ private ControlCameraSimple simpleControl;
+
+ public LightTestApplication() {}
+
+ @Override
+ public void onCreate(final GaleContext context) {
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ this.env = new Environement();
+ setSize(new Vector2f(800, 600));
+ setTitle("Low Poly sample");
+
+ // simple sun to have a global light ...
+ final Entity sun = new Entity(this.env);
+ sun.addComponent(new ComponentPosition(new Transform3D(new Vector3f(1000, 1000, 1000))));
+ sun.addComponent(new ComponentLightSun(new Light(new Vector3f(0.4f, 0.4f, 0.4f), new Vector3f(0, 0, 0), new Vector3f(0.8f, 0, 0))));
+ this.env.addEntity(sun);
+
+ // add a cube to show where in the light ...
+ final Entity localLight = new Entity(this.env);
+ this.lightPosition = new ComponentPosition(new Transform3D(new Vector3f(-10, -10, 1)));
+ localLight.addComponent(this.lightPosition);
+ localLight.addComponent(new ComponentStaticMesh(new Uri("RES", "cube-one.obj")));
+ localLight.addComponent(new ComponentTexture(new Uri("RES", "grass.png")));
+ localLight.addComponent(new ComponentLight(new Light(new Vector3f(0, 2, 0), new Vector3f(0, 0, 0), new Vector3f(0.8f, 0.01f, 0.002f))));
+ localLight.addComponent(new ComponentRenderTexturedStaticMesh(new Uri("DATA", "basic.vert", "loxelEngine"), new Uri("DATA", "basic.frag", "loxelEngine")));
+ this.env.addEntity(localLight);
+
+ final Entity gird = new Entity(this.env);
+ gird.addComponent(new ComponentPosition(new Transform3D(new Vector3f(0, 0, 0))));
+ gird.addComponent(new ComponentStaticMesh(MeshGenerator.createGrid(5)));
+ gird.addComponent(new ComponentRenderColoredStaticMesh(new Uri("DATA", "wireColor.vert", "ege"), new Uri("DATA", "wireColor.frag", "ege")));
+ this.env.addEntity(gird);
+
+ final Entity basicTree = new Entity(this.env);
+ this.objectPosition = new ComponentPosition(new Transform3D(new Vector3f(0, 0, 0)));
+ basicTree.addComponent(this.objectPosition);
+ this.materialCube = new Material();
+ basicTree.addComponent(new ComponentMaterial(this.materialCube));
+ basicTree.addComponent(new ComponentStaticMesh(new Uri("RES", "cube.obj")));
+ basicTree.addComponent(new ComponentTexture(new Uri("RES", "mud.png")));
+ //basicTree.addComponent(new ComponentRenderTexturedStaticMesh(new Uri("DATA", "basic.vert", "loxelEngine"), new Uri("DATA", "basic.frag", "loxelEngine")));
+ basicTree.addComponent(new ComponentRenderTexturedMaterialsStaticMesh(new Uri("DATA", "basicMaterial.vert", "loxelEngine"), new Uri("DATA", "basicMaterial.frag", "loxelEngine"),
+ (EngineLight) this.env.getEngine(EngineLight.ENGINE_NAME)));
+ this.env.addEntity(basicTree);
+
+ for (int xxx = -10; xxx < 10; xxx++) {
+ for (int yyy = -10; yyy < 10; yyy++) {
+ final Entity superGrass = new Entity(this.env);
+ superGrass.addComponent(new ComponentPosition(new Transform3D(new Vector3f(xxx, yyy, -1))));
+ superGrass.addComponent(new ComponentMaterial(new Material()));
+ superGrass.addComponent(new ComponentStaticMesh(new Uri("RES", "cube-one.obj")));
+ superGrass.addComponent(new ComponentTexture(new Uri("RES", "dirt.png")));
+ superGrass.addComponent(new ComponentRenderTexturedMaterialsStaticMesh(new Uri("DATA", "basicMaterial.vert", "loxelEngine"), new Uri("DATA", "basicMaterial.frag", "loxelEngine"),
+ (EngineLight) this.env.getEngine(EngineLight.ENGINE_NAME)));
+ this.env.addEntity(superGrass);
+ }
+ }
+
+ final Camera mainView = new Camera();
+ this.env.addCamera("default", mainView);
+ mainView.setPitch((float) Math.PI * -0.25f);
+ mainView.setPosition(new Vector3f(0, -5, 5));
+
+ this.simpleControl = new ControlCameraSimple(mainView);
+ this.env.addControlInterface(this.simpleControl);
+
+ // start the engine.
+ this.env.setPropertyStatus(GameStatus.gameStart);
+
+ this.basicRotation = Quaternion.fromEulerAngles(new Vector3f(0.005f, 0.005f, 0.01f));
+ this.basicRotation2 = Quaternion.fromEulerAngles(new Vector3f(0.003f, 0.01f, 0.001f));
+ // ready to let Gale & Ege manage the display
+ Log.info("==> Init APPL (END)");
+ }
+
+ @Override
+ public void onDraw(final GaleContext context) {
+ //Log.info("==> appl Draw ...");
+ final Vector2f size = getSize();
+ // Store openGl context.
+ OpenGL.push();
+ // set projection matrix:
+ final Matrix4f tmpProjection = Matrix4f.createMatrixPerspective(3.14f * 0.5f, getAspectRatio(), 0.1f, 50000);
+ OpenGL.setMatrix(tmpProjection);
+
+ // set the basic openGL view port: (Draw in all the windows...)
+ OpenGL.setViewPort(new Vector2f(0, 0), size);
+
+ // clear background
+ final Color bgColor = new Color(0.0f, 1.0f, 0.0f, 1.0f);
+ OpenGL.clearColor(bgColor);
+ // real clear request:
+ OpenGL.clear(OpenGL.ClearFlag.clearFlag_colorBuffer);
+ OpenGL.clear(OpenGL.ClearFlag.clearFlag_depthBuffer);
+ OpenGL.enable(Flag.flag_depthTest);
+
+ this.env.render(20, "default");
+
+ // Restore context of matrix
+ OpenGL.pop();
+ }
+
+ @Override
+ public void onKeyboard(final KeySpecial special, final KeyKeyboard type, final Character value, final KeyStatus state) {
+ this.env.onKeyboard(special, type, value, state);
+ }
+
+ @Override
+ public void onPointer(final KeySpecial special, final KeyType type, final int pointerID, final Vector2f pos, final KeyStatus state) {
+ this.env.onPointer(special, type, pointerID, pos, state);
+ }
+
+ @Override
+ public void onRegenerateDisplay(final GaleContext context) {
+ //Log.verbose("Regenerate Gale Application");
+ //materialCube.setAmbientFactor(new Vector3f(1.0f,1.0f,1.0f));
+ // apply a little rotation to show the element move
+ //objectPosition.getTransform().applyRotation(basicRotation);
+ //objectPosition.getTransform().applyRotation(basicRotation2);
+ this.angleLight += 0.01;
+ this.lightPosition.setTransform(this.lightPosition.getTransform()
+ .withPosition(new Vector3f((float) Math.cos(this.angleLight) * 7.0f, (float) Math.sin(this.angleLight) * 7.0f, this.lightPosition.getTransform().getPosition().z())));
+ this.env.periodicCall();
+ markDrawingIsNeeded();
+ }
+}
diff --git a/samples/src/sample/atriasoft/ege/lightTest/Log.java b/samples/src/sample/atriasoft/ege/lightTest/Log.java
new file mode 100644
index 0000000..8ef48f1
--- /dev/null
+++ b/samples/src/sample/atriasoft/ege/lightTest/Log.java
@@ -0,0 +1,39 @@
+package sample.atriasoft.ege.lightTest;
+
+public class Log {
+ private static final String LIBNAME = "LowPolySample";
+
+ public static void critical(String data) {
+ System.out.println("[C] " + Log.LIBNAME + " | " + data);
+ }
+
+ public static void debug(String data) {
+ System.out.println("[D] " + Log.LIBNAME + " | " + data);
+ }
+
+ public static void error(String data) {
+ System.out.println("[E] " + Log.LIBNAME + " | " + data);
+ }
+
+ public static void info(String data) {
+ System.out.println("[I] " + Log.LIBNAME + " | " + data);
+ }
+
+ public static void print(String data) {
+ System.out.println(data);
+ }
+
+ public static void todo(String data) {
+ System.out.println("[TODO] " + Log.LIBNAME + " | " + data);
+ }
+
+ public static void verbose(String data) {
+ System.out.println("[V] " + Log.LIBNAME + " | " + data);
+ }
+
+ public static void warning(String data) {
+ System.out.println("[W] " + Log.LIBNAME + " | " + data);
+ }
+
+ private Log() {}
+}
diff --git a/samples/src/sample/atriasoft/ege/lightTest/MainLightTest.java b/samples/src/sample/atriasoft/ege/lightTest/MainLightTest.java
new file mode 100644
index 0000000..c247658
--- /dev/null
+++ b/samples/src/sample/atriasoft/ege/lightTest/MainLightTest.java
@@ -0,0 +1,19 @@
+package sample.atriasoft.ege.lightTest;
+
+import org.atriasoft.ege.Ege;
+import org.atriasoft.etk.Uri;
+import org.atriasoft.gale.Gale;
+
+import sample.atriasoft.ege.collisiontest.MainCollisionTest;
+
+public class MainLightTest {
+ public static void main(String[] args) {
+ Gale.init();
+ Ege.init();
+ Uri.setGroup("DATA", "data/");
+ Uri.setGroup("RES", "res");
+ Uri.addLibrary("loxelEngine", MainCollisionTest.class, "testDataLoxelEngine/");
+ Uri.setApplication(MainCollisionTest.class, "");
+ Gale.run(new LightTestApplication(), args);
+ }
+}
diff --git a/samples/src/sample/atriasoft/ege/lowPoly/LowPolyApplication.java b/samples/src/sample/atriasoft/ege/lowPoly/LowPolyApplication.java
index dfab758..6a1f3d0 100644
--- a/samples/src/sample/atriasoft/ege/lowPoly/LowPolyApplication.java
+++ b/samples/src/sample/atriasoft/ege/lowPoly/LowPolyApplication.java
@@ -10,12 +10,15 @@ import org.atriasoft.ege.camera.Camera;
import org.atriasoft.ege.components.ComponentLight;
import org.atriasoft.ege.components.ComponentLightSun;
import org.atriasoft.ege.components.ComponentMaterial;
+import org.atriasoft.ege.components.ComponentMesh;
import org.atriasoft.ege.components.ComponentPosition;
import org.atriasoft.ege.components.ComponentRenderColoredStaticMesh;
+import org.atriasoft.ege.components.ComponentRenderMeshPalette;
import org.atriasoft.ege.components.ComponentRenderTexturedMaterialsStaticMesh;
import org.atriasoft.ege.components.ComponentRenderTexturedStaticMesh;
import org.atriasoft.ege.components.ComponentStaticMesh;
import org.atriasoft.ege.components.ComponentTexture;
+import org.atriasoft.ege.components.ComponentTexturePalette;
import org.atriasoft.ege.engines.EngineLight;
import org.atriasoft.ege.tools.MeshGenerator;
import org.atriasoft.etk.Color;
@@ -68,42 +71,45 @@ public class LowPolyApplication extends GaleApplication {
final Entity localLight = new Entity(this.env);
this.lightPosition = new ComponentPosition(new Transform3D(new Vector3f(-10, -10, 1)));
localLight.addComponent(this.lightPosition);
- localLight.addComponent(new ComponentStaticMesh(new Uri("RES", "cube-one.obj")));
- localLight.addComponent(new ComponentTexture(new Uri("RES", "grass.png")));
+ localLight.addComponent(new ComponentStaticMesh(new Uri("DATA", "cube-one.obj")));
+ localLight.addComponent(new ComponentTexture(new Uri("DATA", "grass.png")));
localLight.addComponent(new ComponentLight(new Light(new Vector3f(0, 2, 0), new Vector3f(0, 0, 0), new Vector3f(0.8f, 0.01f, 0.002f))));
localLight.addComponent(new ComponentRenderTexturedStaticMesh(new Uri("DATA", "basic.vert", "loxelEngine"), new Uri("DATA", "basic.frag", "loxelEngine")));
this.env.addEntity(localLight);
+ // Simple Gird
final Entity gird = new Entity(this.env);
gird.addComponent(new ComponentPosition(new Transform3D(new Vector3f(0, 0, 0))));
gird.addComponent(new ComponentStaticMesh(MeshGenerator.createGrid(5)));
gird.addComponent(new ComponentRenderColoredStaticMesh(new Uri("DATA", "wireColor.vert", "ege"), new Uri("DATA", "wireColor.frag", "ege")));
this.env.addEntity(gird);
+ // test entity
final Entity basicTree = new Entity(this.env);
this.objectPosition = new ComponentPosition(new Transform3D(new Vector3f(0, 0, 0)));
basicTree.addComponent(this.objectPosition);
- this.materialCube = new Material();
- basicTree.addComponent(new ComponentMaterial(this.materialCube));
- basicTree.addComponent(new ComponentStaticMesh(new Uri("RES", "cube.obj")));
- basicTree.addComponent(new ComponentTexture(new Uri("RES", "mud.png")));
+ //this.materialCube = new Material();
+ //basicTree.addComponent(new ComponentMaterial(this.materialCube));
+ basicTree.addComponent(new ComponentMesh(new Uri("DATA", "tree1.emf")));
+ //basicTree.addComponent(new ComponentMesh(new Uri("DATA", "simple3D.emf")));
+ //basicTree.addComponent(new ComponentTexture(new Uri("RES", "mud.png")));
+ basicTree.addComponent(new ComponentTexturePalette(new Uri("DATA", "palette_1.json")));
//basicTree.addComponent(new ComponentRenderTexturedStaticMesh(new Uri("DATA", "basic.vert", "loxelEngine"), new Uri("DATA", "basic.frag", "loxelEngine")));
- basicTree.addComponent(new ComponentRenderTexturedMaterialsStaticMesh(new Uri("DATA", "basicMaterial.vert", "loxelEngine"), new Uri("DATA", "basicMaterial.frag", "loxelEngine"),
- (EngineLight) this.env.getEngine(EngineLight.ENGINE_NAME)));
+ basicTree.addComponent(new ComponentRenderMeshPalette(new Uri("DATA", "basicPalette.vert"), new Uri("DATA", "basicPalette.frag")));
this.env.addEntity(basicTree);
- for (int xxx = -10; xxx < 10; xxx++) {
- for (int yyy = -10; yyy < 10; yyy++) {
- final Entity superGrass = new Entity(this.env);
- superGrass.addComponent(new ComponentPosition(new Transform3D(new Vector3f(xxx, yyy, -1))));
- superGrass.addComponent(new ComponentMaterial(new Material()));
- superGrass.addComponent(new ComponentStaticMesh(new Uri("RES", "cube-one.obj")));
- superGrass.addComponent(new ComponentTexture(new Uri("RES", "dirt.png")));
- superGrass.addComponent(new ComponentRenderTexturedMaterialsStaticMesh(new Uri("DATA", "basicMaterial.vert", "loxelEngine"), new Uri("DATA", "basicMaterial.frag", "loxelEngine"),
- (EngineLight) this.env.getEngine(EngineLight.ENGINE_NAME)));
- this.env.addEntity(superGrass);
- }
- }
+// for (int xxx = -10; xxx < 10; xxx++) {
+// for (int yyy = -10; yyy < 10; yyy++) {
+// final Entity superGrass = new Entity(this.env);
+// superGrass.addComponent(new ComponentPosition(new Transform3D(new Vector3f(xxx, yyy, -1))));
+// superGrass.addComponent(new ComponentMaterial(new Material()));
+// superGrass.addComponent(new ComponentStaticMesh(new Uri("RES", "cube-one.obj")));
+// superGrass.addComponent(new ComponentTexture(new Uri("RES", "dirt.png")));
+// superGrass.addComponent(new ComponentRenderTexturedMaterialsStaticMesh(new Uri("DATA", "basicMaterial.vert", "loxelEngine"), new Uri("DATA", "basicMaterial.frag", "loxelEngine"),
+// (EngineLight) this.env.getEngine(EngineLight.ENGINE_NAME)));
+// this.env.addEntity(superGrass);
+// }
+// }
final Camera mainView = new Camera();
this.env.addCamera("default", mainView);
diff --git a/samples/src/sample/atriasoft/ege/lowPoly/MainMowPoly.java b/samples/src/sample/atriasoft/ege/lowPoly/MainLowPoly.java
similarity index 84%
rename from samples/src/sample/atriasoft/ege/lowPoly/MainMowPoly.java
rename to samples/src/sample/atriasoft/ege/lowPoly/MainLowPoly.java
index bc556f8..9bb655f 100644
--- a/samples/src/sample/atriasoft/ege/lowPoly/MainMowPoly.java
+++ b/samples/src/sample/atriasoft/ege/lowPoly/MainLowPoly.java
@@ -6,14 +6,14 @@ import org.atriasoft.gale.Gale;
import sample.atriasoft.ege.collisiontest.MainCollisionTest;
-public class MainMowPoly {
+public class MainLowPoly {
public static void main(String[] args) {
Gale.init();
Ege.init();
Uri.setGroup("DATA", "data/");
Uri.setGroup("RES", "res");
Uri.addLibrary("loxelEngine", MainCollisionTest.class, "testDataLoxelEngine/");
- Uri.setApplication(MainCollisionTest.class, "");
+ Uri.setApplication(MainCollisionTest.class, "lowPoly");
Gale.run(new LowPolyApplication(), args);
}
}
diff --git a/samples/src/sample/atriasoft/ege/lowPoly/kkk_basicMaterial.frag b/samples/src/sample/atriasoft/ege/lowPoly/kkk_basicMaterial.frag
deleted file mode 100644
index 3c8e7d7..0000000
--- a/samples/src/sample/atriasoft/ege/lowPoly/kkk_basicMaterial.frag
+++ /dev/null
@@ -1,80 +0,0 @@
-#version 400 core
-
-#ifdef GL_ES
-precision mediump float;
-precision mediump int;
-#endif
-
-struct Light {
- vec3 color;
- vec3 position;
- vec3 attenuation;
-};
-
-struct Material {
- vec3 ambientFactor;
- vec3 diffuseFactor;
- vec3 specularFactor;
- float shininess;
-};
-const int MAX_LIGHT_NUMBER = 8;
-
-
-in vec2 io_textureCoords;
-in vec3 io_surfaceNormal;
-in vec3 io_toCameraVector;
-in vec3 io_toLightVector[MAX_LIGHT_NUMBER];
-// FOW: Fog Of War result calculation
-in float io_fowVisibility;
-
-// texture properties
-uniform sampler2D in_textureBase;
-// Material
-uniform Material in_material;
-// 2 light for suns and other for locals ...
-uniform Light in_lights[MAX_LIGHT_NUMBER];
-// global color of the sky ... needed to have a better color for the FOW
-//uniform vec3 in_sky_color;
-const vec3 in_sky_color = vec3(1.0,1.0,1.0);
-
-// output:
-out vec4 out_Color;
-
-void main(void) {
- // disable transparency elements in the texture ...
- // Can be set at the start of the shader ...
- vec4 textureColour = texture(in_textureBase, io_textureCoords);
- if (textureColour.a < 0.5) {
- discard;
- }
-
- vec3 unitNormal = normalize(io_surfaceNormal);
- vec3 unitVectorToCamera = normalize(io_toCameraVector);
- vec3 totalDiffuse = vec3(0.0);
- vec3 totalSpecular = vec3(0.0);
- for(int iii=0; iii maybe set an uniform for this
- totalDiffuse = max(totalDiffuse, 0.2);
-
- out_Color = vec4(totalDiffuse,1.0) * textureColour + vec4(totalSpecular, 1.0);
- out_Color = mix(vec4(in_sky_color,1.0), out_Color, io_fowVisibility);
-}
-
-
-
-
diff --git a/samples/src/sample/atriasoft/ege/lowPoly/kkk_basicMaterial.vert b/samples/src/sample/atriasoft/ege/lowPoly/kkk_basicMaterial.vert
deleted file mode 100644
index a707aa7..0000000
--- a/samples/src/sample/atriasoft/ege/lowPoly/kkk_basicMaterial.vert
+++ /dev/null
@@ -1,59 +0,0 @@
-#version 400 core
-
-#ifdef GL_ES
-precision mediump float;
-precision mediump int;
-#endif
-
-struct Light {
- vec3 color;
- vec3 position;
- vec3 attenuation;
-};
-const int MAX_LIGHT_NUMBER = 8;
-
-// Input:
-layout (location = 0) in vec3 in_position;
-layout (location = 1) in vec2 in_textureCoords;
-layout (location = 2) in vec3 in_normal;
-// 2 light for suns and other for locals ...
-uniform Light in_lights[MAX_LIGHT_NUMBER];
-
-uniform mat4 in_matrixTransformation;
-uniform mat4 in_matrixProjection;
-uniform mat4 in_matrixView;
-
-//uniform float in_numberOfRows;
-//uniform vec2 in_offset;
-const float in_numberOfRows = 1;
-const vec2 in_offset = vec2(0.0,0.0);
-
-// Configuration of the FOV ==> TODO: Set it in parameter uniform ...
-const float c_density = 0.007;
-const float c_gradient = 1.5;
-
-// output:
-out vec2 io_textureCoords;
-out vec3 io_surfaceNormal;
-out vec3 io_toCameraVector;
-out vec3 io_toLightVector[MAX_LIGHT_NUMBER];
-// FOW: Fog Of War result calculation
-out float io_fowVisibility;
-
-void main(void) {
- vec4 worldPosition = in_matrixTransformation * vec4(in_position, 1.0);
- vec4 positionRelativeToCam = in_matrixView * worldPosition;
- gl_Position = in_matrixProjection * positionRelativeToCam;
- io_textureCoords = (in_textureCoords/in_numberOfRows) + in_offset;
-
- io_surfaceNormal = (in_matrixTransformation * vec4(in_normal, 0.0)).xyz;
- for(int iii=0;iii need update before drawing...
OpenGL.updateAllFlags();
// Request the draw all the elements:
- this.mesh.render();
+ this.mesh.renderArrays();
+
this.texture.unBindForRendering();
this.mesh.unBindForRendering();
this.program.unUse();
diff --git a/src/org/atriasoft/ege/components/ComponentTexturePalette.java b/src/org/atriasoft/ege/components/ComponentTexturePalette.java
index 1039233..a1294b7 100644
--- a/src/org/atriasoft/ege/components/ComponentTexturePalette.java
+++ b/src/org/atriasoft/ege/components/ComponentTexturePalette.java
@@ -1,10 +1,14 @@
package org.atriasoft.ege.components;
+import java.awt.Image;
+
import org.atriasoft.egami.ImageByte;
+import org.atriasoft.egami.ToolImage;
import org.atriasoft.ege.Component;
import org.atriasoft.ege.internal.Log;
import org.atriasoft.etk.Uri;
import org.atriasoft.gale.resource.ResourceTexture2;
+import org.atriasoft.iogami.IOgami;
import org.atriasoft.loader3d.resources.ResourcePaletteFile;
public class ComponentTexturePalette extends Component {
@@ -18,13 +22,21 @@ public class ComponentTexturePalette extends Component {
if (this.texture == null) {
Log.error("can not instanciate Texture ...");
}
+ // element already called
+ updateFromPalette();
+ // for next update (realTime reload)
this.palette.onUpdate(() -> {
- Log.warning("update palet environnement");
- final ImageByte img = this.palette.getImageByte();
- this.texture.set(img);
+ updateFromPalette();
});
}
+ public void updateFromPalette() {
+ Log.warning("update palet environnement");
+ final ImageByte img = this.palette.getImageByte();
+ IOgami.storePNG(new Uri("/home/heero/000000000aaaaplopppp.png"), img);
+ this.texture.set(img);
+ }
+
public void bindForRendering() {
this.texture.bindForRendering(0);