diff --git a/.classpath b/.classpath
index 5d41398..4bffa9f 100644
--- a/.classpath
+++ b/.classpath
@@ -22,27 +22,27 @@
-
+
-
+
-
+
-
+
-
+
diff --git a/samples/src/module-info.java b/samples/src/module-info.java
new file mode 100644
index 0000000..13a303b
--- /dev/null
+++ b/samples/src/module-info.java
@@ -0,0 +1,13 @@
+/** Basic module interface.
+ *
+ * @author Edouard DUPIN */
+
+open module sample.atriasoft.ege {
+ exports sample.atriasoft.ege.collisiontest;
+ exports sample.atriasoft.ege.lowPoly;
+ exports sample.atriasoft.ege.loxelEngine;
+ exports sample.atriasoft.ege.oldTest;
+ exports sample.atriasoft.ege.s1_texturedCube;
+
+ requires org.atriasoft.ege;
+}
diff --git a/src/org/atriasoft/ege/samples/collisiontest/CollisionTestApplication.java b/samples/src/sample/atriasoft/ege/collisiontest/CollisionTestApplication.java
similarity index 89%
rename from src/org/atriasoft/ege/samples/collisiontest/CollisionTestApplication.java
rename to samples/src/sample/atriasoft/ege/collisiontest/CollisionTestApplication.java
index 0812b89..8d6ebe6 100644
--- a/src/org/atriasoft/ege/samples/collisiontest/CollisionTestApplication.java
+++ b/samples/src/sample/atriasoft/ege/collisiontest/CollisionTestApplication.java
@@ -1,4 +1,4 @@
-package org.atriasoft.ege.samples.collisiontest;
+package sample.atriasoft.ege.collisiontest;
import java.util.ArrayList;
import java.util.List;
@@ -12,7 +12,6 @@ import org.atriasoft.ege.Light;
import org.atriasoft.ege.Material;
import org.atriasoft.ege.camera.Camera;
import org.atriasoft.ege.components.ComponentGravityStatic;
-import org.atriasoft.ege.components.ComponentLight;
import org.atriasoft.ege.components.ComponentLightSun;
import org.atriasoft.ege.components.ComponentMaterial;
import org.atriasoft.ege.components.ComponentPhysics;
@@ -37,7 +36,7 @@ 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.Application;
+import org.atriasoft.gale.GaleApplication;
import org.atriasoft.gale.Gale;
import org.atriasoft.gale.backend3d.OpenGL;
import org.atriasoft.gale.backend3d.OpenGL.Flag;
@@ -48,7 +47,7 @@ import org.atriasoft.gale.key.KeyStatus;
import org.atriasoft.gale.key.KeyType;
import org.atriasoft.gale.resource.ResourceColored3DObject;
-public class CollisionTestApplication extends Application {
+public class CollisionTestApplication extends GaleApplication {
public static Vector3f box1HalfSize;
public static Vector3f box2HalfSize;
// public static ComponentPosition relativeTestPos;
@@ -61,7 +60,6 @@ public class CollisionTestApplication extends Application {
private float angleLight = 0;
private Quaternion basicRotation = Quaternion.IDENTITY;
private Quaternion basicRotation2 = Quaternion.IDENTITY;
- private boolean creationDone;
private ResourceColored3DObject debugDrawProperty;
private Environement env;
private ComponentPosition lightPosition;
@@ -70,9 +68,7 @@ public class CollisionTestApplication extends Application {
private ComponentPosition objectPosition;
private ControlCameraPlayer simpleControl;
- public CollisionTestApplication() {
- this.creationDone = false;
- }
+ public CollisionTestApplication() {}
@Override
public void onCreate(final Context context) {
@@ -80,7 +76,6 @@ public class CollisionTestApplication extends Application {
//ComponentPhysics.globalMaxSpeed = 3;
Gale.getContext().grabPointerEvents(true, new Vector2f(0, 0));
this.env = new Environement();
- this.canDraw = true;
setSize(new Vector2f(1500, 1500));
setTitle("Loxel sample");
this.map = new MapVoxel(this.env);
@@ -117,17 +112,22 @@ public class CollisionTestApplication extends Application {
localBox.addComponent(new ComponentStaticMesh(new Uri("RES", "cube-one.obj")));
localBox.addComponent(new ComponentTexture(new Uri("DATA", "blocks/dirt.png", "loxelEngine")));
localBox.addComponent(new ComponentRenderTexturedStaticMesh(new Uri("DATA", "basic.vert", "loxelEngine"), new Uri("DATA", "basic.frag", "loxelEngine")));
- final ComponentPhysics physics2 = new ComponentPhysics(this.env);
- physics2.setBodyType(PhysicBodyType.BODY_STATIC);
- physics2.setTransform(new Transform3D(Vector3f.ZERO, orientation));
- final Box box2 = new Box();
- box2.setSize(new Vector3f(5.0f, 5.0f, 0.5f));
- box2.setOrigin(Vector3f.ZERO);
- box2.setMass(0);
- physics2.addShape(box2);
- localBox.addComponent(physics2);
+ if (false) {
+ final ComponentPhysics physics2 = new ComponentPhysics(this.env);
+ physics2.setBodyType(PhysicBodyType.BODY_STATIC);
+ physics2.setTransform(new Transform3D(Vector3f.ZERO, orientation));
+ final Box box2 = new Box();
+ box2.setSize(new Vector3f(5.0f, 5.0f, 0.5f));
+ box2.setOrigin(Vector3f.ZERO);
+ box2.setMass(0);
+ physics2.addShape(box2);
+ localBox.addComponent(physics2);
+ } else {
+ localBox.addComponent(new ComponentPosition(new Transform3D(new Vector3f(0, 0, 0))));
+ }
this.env.addEntity(localBox);
}
+ /*
{
// add a cube to test collision ...
final Entity localBox = new Entity(this.env);
@@ -135,18 +135,22 @@ public class CollisionTestApplication extends Application {
localBox.addComponent(new ComponentTexture(new Uri("DATA", "blocks/clay.png", "loxelEngine")));
localBox.addComponent(new ComponentLight(new Light(new Vector3f(0, 1, 0), Vector3f.ZERO, new Vector3f(0.8f, 0.03f, 0.002f))));
localBox.addComponent(new ComponentRenderTexturedStaticMesh(new Uri("DATA", "basic.vert", "loxelEngine"), new Uri("DATA", "basic.frag", "loxelEngine")));
- final ComponentPhysics physics2 = new ComponentPhysics(this.env);
- //physics2.setTransform(new Transform3D(new Vector3f(0, 0, 0.90f)));
- physics2.setTransform(new Transform3D(new Vector3f(0, 0, 1.20f)));
- final Box box2 = new Box();
- box2.setSize(new Vector3f(0.5f, 0.5f, 0.5f));
- box2.setOrigin(Vector3f.ZERO);
- box2.setMass(100);
- physics2.addShape(box2);
- localBox.addComponent(physics2);
+ if (false) {
+ final ComponentPhysics physics2 = new ComponentPhysics(this.env);
+ //physics2.setTransform(new Transform3D(new Vector3f(0, 0, 0.90f)));
+ physics2.setTransform(new Transform3D(new Vector3f(0, 0, 1.20f)));
+ final Box box2 = new Box();
+ box2.setSize(new Vector3f(0.5f, 0.5f, 0.5f));
+ box2.setOrigin(Vector3f.ZERO);
+ box2.setMass(100);
+ physics2.addShape(box2);
+ localBox.addComponent(physics2);
+ } else {
+ localBox.addComponent(new ComponentPosition(new Transform3D(new Vector3f(0, -5, 13))));
+ }
this.env.addEntity(localBox);
}
-
+ */
final Entity gird = new Entity(this.env);
gird.addComponent(new ComponentPosition(new Transform3D(Vector3f.ZERO)));
gird.addComponent(new ComponentStaticMesh(MeshGenerator.createGrid(5)));
@@ -185,8 +189,7 @@ public class CollisionTestApplication extends Application {
//player.addComponent(new ComponentStaticMesh(new Uri("RES", "person.obj")));
player.addComponent(new ComponentStaticMesh(new Uri("RES", "person_-yfw_zup.obj")));
player.addComponent(new ComponentTexture(new Uri("RES", "playerTexture.png")));
- player.addComponent(new ComponentRenderTexturedMaterialsStaticMesh(new Uri("DATA", "basicMaterial.vert", "loxelEngine"), new Uri("DATA", "basicMaterial.frag", "loxelEngine"),
- (EngineLight) this.env.getEngine(EngineLight.ENGINE_NAME)));
+ //player.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(player);
}
final Camera mainView = new Camera();
@@ -213,28 +216,21 @@ public class CollisionTestApplication extends Application {
// ready to let Gale & Ege manage the display
Log.info("==> Init APPL (END)");
- this.creationDone = true;
}
@Override
public void onDraw(final Context context) {
//Log.info("==> appl Draw ...");
final Vector2f size = getSize();
- if (!this.creationDone) {
- OpenGL.setViewPort(new Vector2f(0, 0), size);
- final Color bgColor = new Color(0.8f, 0.5f, 0.5f, 1.0f);
- OpenGL.clearColor(bgColor);
- Log.info("==> appl clear ==> not created ...");
- return;
- }
// Store openGl context.
OpenGL.push();
// set projection matrix:
final Matrix4f tmpProjection = Matrix4f.createMatrixPerspective(3.14f * 0.5f, getAspectRatio(), 0.1f, 50000);
+ //final Matrix4f tmpProjection = Matrix4f.createMatrixOrtho(20, 20, 15, 15, 0, 500000);
OpenGL.setMatrix(tmpProjection);
// set the basic openGL view port: (Draw in all the windows...)
- OpenGL.setViewPort(new Vector2f(0, 0), size);
+ OpenGL.setViewPort(Vector2f.ZERO, size);
// clear background
final Color bgColor = new Color(0.18f, 0.43f, 0.95f, 1.0f);
@@ -305,10 +301,10 @@ public class CollisionTestApplication extends Application {
if (type == KeyKeyboard.f1) {
Gale.getContext().grabPointerEvents(false, new Vector2f(0, 0));
}
- if (type == KeyKeyboard.f2) {
+ if (type == KeyKeyboard.F2) {
Gale.getContext().grabPointerEvents(true, new Vector2f(0, 0));
}
- if (type == KeyKeyboard.f12) {
+ if (type == KeyKeyboard.F12) {
Gale.getContext().setFullScreen(!Gale.getContext().getFullScreen());
}
this.env.onKeyboard(special, type, value, state);
@@ -322,9 +318,6 @@ public class CollisionTestApplication extends Application {
@Override
public void onRegenerateDisplay(final Context context) {
//Log.verbose("Regenerate Gale Application");
- if (!this.creationDone) {
- return;
- }
this.angleLight += 0.01;
final Vector3f posss = this.lightPosition.getTransform().getPosition().add(new Vector3f(5 + (float) Math.cos(this.angleLight) * 7.0f, 5 + (float) Math.sin(this.angleLight) * 7.0f, 0));
this.lightPosition.setTransform(this.lightPosition.getTransform().withPosition(posss));
diff --git a/src/org/atriasoft/ege/samples/collisiontest/Log.java b/samples/src/sample/atriasoft/ege/collisiontest/Log.java
similarity index 50%
rename from src/org/atriasoft/ege/samples/collisiontest/Log.java
rename to samples/src/sample/atriasoft/ege/collisiontest/Log.java
index 3605b31..2c8b868 100644
--- a/src/org/atriasoft/ege/samples/collisiontest/Log.java
+++ b/samples/src/sample/atriasoft/ege/collisiontest/Log.java
@@ -1,30 +1,39 @@
-package org.atriasoft.ege.samples.collisiontest;
+package sample.atriasoft.ege.collisiontest;
public class Log {
- private Log() {}
private static final String LIBNAME = "LoxelEngine";
+
+ 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 critical(String data) {
- System.out.println("[C] " + LIBNAME + " | " + data);
- }
- public static void error(String data) {
- System.out.println("[E] " + LIBNAME + " | " + data);
- }
- public static void warning(String data) {
- System.out.println("[W] " + LIBNAME + " | " + data);
- }
- public static void info(String data) {
- System.out.println("[I] " + LIBNAME + " | " + data);
- }
- public static void debug(String data) {
- System.out.println("[D] " + LIBNAME + " | " + data);
- }
- public static void verbose(String data) {
- System.out.println("[V] " + LIBNAME + " | " + data);
- }
+
public static void todo(String data) {
- System.out.println("[TODO] " + LIBNAME + " | " + 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/src/org/atriasoft/ege/samples/collisiontest/MainCollisionTest.java b/samples/src/sample/atriasoft/ege/collisiontest/MainCollisionTest.java
similarity index 90%
rename from src/org/atriasoft/ege/samples/collisiontest/MainCollisionTest.java
rename to samples/src/sample/atriasoft/ege/collisiontest/MainCollisionTest.java
index adc1028..03bd14b 100644
--- a/src/org/atriasoft/ege/samples/collisiontest/MainCollisionTest.java
+++ b/samples/src/sample/atriasoft/ege/collisiontest/MainCollisionTest.java
@@ -1,4 +1,4 @@
-package org.atriasoft.ege.samples.collisiontest;
+package sample.atriasoft.ege.collisiontest;
import org.atriasoft.ege.Ege;
import org.atriasoft.etk.Uri;
diff --git a/src/org/atriasoft/ege/samples/lowPoly/Log.java b/samples/src/sample/atriasoft/ege/lowPoly/Log.java
similarity index 50%
rename from src/org/atriasoft/ege/samples/lowPoly/Log.java
rename to samples/src/sample/atriasoft/ege/lowPoly/Log.java
index 46ab6f8..c0f4a22 100644
--- a/src/org/atriasoft/ege/samples/lowPoly/Log.java
+++ b/samples/src/sample/atriasoft/ege/lowPoly/Log.java
@@ -1,30 +1,39 @@
-package org.atriasoft.ege.samples.lowPoly;
+package sample.atriasoft.ege.lowPoly;
public class Log {
- private 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 critical(String data) {
- System.out.println("[C] " + LIBNAME + " | " + data);
- }
- public static void error(String data) {
- System.out.println("[E] " + LIBNAME + " | " + data);
- }
- public static void warning(String data) {
- System.out.println("[W] " + LIBNAME + " | " + data);
- }
- public static void info(String data) {
- System.out.println("[I] " + LIBNAME + " | " + data);
- }
- public static void debug(String data) {
- System.out.println("[D] " + LIBNAME + " | " + data);
- }
- public static void verbose(String data) {
- System.out.println("[V] " + LIBNAME + " | " + data);
- }
+
public static void todo(String data) {
- System.out.println("[TODO] " + LIBNAME + " | " + 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/src/org/atriasoft/ege/samples/lowPoly/LowPolyApplication.java b/samples/src/sample/atriasoft/ege/lowPoly/LowPolyApplication.java
similarity index 84%
rename from src/org/atriasoft/ege/samples/lowPoly/LowPolyApplication.java
rename to samples/src/sample/atriasoft/ege/lowPoly/LowPolyApplication.java
index 038c429..347d629 100644
--- a/src/org/atriasoft/ege/samples/lowPoly/LowPolyApplication.java
+++ b/samples/src/sample/atriasoft/ege/lowPoly/LowPolyApplication.java
@@ -1,4 +1,4 @@
-package org.atriasoft.ege.samples.lowPoly;
+package sample.atriasoft.ege.lowPoly;
import org.atriasoft.ege.ControlCameraSimple;
import org.atriasoft.ege.Entity;
@@ -25,7 +25,7 @@ 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.Application;
+import org.atriasoft.gale.GaleApplication;
import org.atriasoft.gale.backend3d.OpenGL;
import org.atriasoft.gale.backend3d.OpenGL.Flag;
import org.atriasoft.gale.context.Context;
@@ -34,75 +34,71 @@ import org.atriasoft.gale.key.KeySpecial;
import org.atriasoft.gale.key.KeyStatus;
import org.atriasoft.gale.key.KeyType;
-public class LowPolyApplication extends Application {
- private Environement env;
- private ComponentPosition objectPosition;
+public class LowPolyApplication extends GaleApplication {
+ private float angleLight = 0;
private Quaternion basicRotation = Quaternion.IDENTITY;
private Quaternion basicRotation2 = Quaternion.IDENTITY;
- private boolean creationDone;
- private ControlCameraSimple simpleControl;
- private Material materialCube;
+ private Environement env;
private ComponentPosition lightPosition;
- private float angleLight = 0;
+ private Material materialCube;
+ private ComponentPosition objectPosition;
+ private ControlCameraSimple simpleControl;
- public LowPolyApplication() {
- this.creationDone = false;
- }
+ public LowPolyApplication() {}
@Override
public void onCreate(final Context context) {
this.env = new Environement();
- this.canDraw = true;
setSize(new Vector2f(800, 600));
setTitle("Low Poly sample");
// simple sun to have a global light ...
- Entity sun = new Entity(this.env);
+ 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 ...
- Entity localLight = new Entity(this.env);
+ final Entity localLight = new Entity(this.env);
this.lightPosition = new ComponentPosition(new Transform3D(new Vector3f(-10, -10, 0)));
localLight.addComponent(this.lightPosition);
localLight.addComponent(new ComponentStaticMesh(new Uri("RES", "cube.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"), new Uri("DATA", "basic.frag")));
+ localLight.addComponent(new ComponentRenderTexturedStaticMesh(new Uri("DATA", "basic.vert", "loxelEngine"), new Uri("DATA", "basic.frag", "loxelEngine")));
this.env.addEntity(localLight);
- Entity gird = new Entity(this.env);
+ 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_EGE", "wireColor.vert"), new Uri("DATA_EGE", "wireColor.frag")));
+ gird.addComponent(new ComponentRenderColoredStaticMesh(new Uri("DATA", "wireColor.vert", "ege"), new Uri("DATA", "wireColor.frag", "ege")));
this.env.addEntity(gird);
- Entity basicTree = new Entity(this.env);
+ 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", "grass.png")));
- basicTree.addComponent(new ComponentRenderTexturedMaterialsStaticMesh(new Uri("DATA", "basicMaterial.vert"), new Uri("DATA", "basicMaterial.frag"),
+ 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++) {
- Entity superGrass = new Entity(this.env);
+ 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"), new Uri("DATA", "basicMaterial.frag"),
+ 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);
}
}
- Camera mainView = new Camera();
+ final Camera mainView = new Camera();
this.env.addCamera("default", mainView);
mainView.setPitch((float) Math.PI * -0.25f);
mainView.setPosition(new Vector3f(0, -5, 5));
@@ -117,30 +113,23 @@ public class LowPolyApplication extends Application {
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)");
- this.creationDone = true;
}
@Override
public void onDraw(final Context context) {
//Log.info("==> appl Draw ...");
- Vector2f size = getSize();
- if (!this.creationDone) {
- OpenGL.setViewPort(new Vector2f(0, 0), size);
- Color bgColor = new Color(0.8f, 0.5f, 0.5f, 1.0f);
- OpenGL.clearColor(bgColor);
- return;
- }
+ final Vector2f size = getSize();
// Store openGl context.
OpenGL.push();
// set projection matrix:
- Matrix4f tmpProjection = Matrix4f.createMatrixPerspective(3.14f * 0.5f, getAspectRatio(), 0.1f, 50000);
+ 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
- Color bgColor = new Color(0.0f, 1.0f, 0.0f, 1.0f);
+ 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);
@@ -166,9 +155,6 @@ public class LowPolyApplication extends Application {
@Override
public void onRegenerateDisplay(final Context context) {
//Log.verbose("Regenerate Gale Application");
- if (!this.creationDone) {
- return;
- }
//materialCube.setAmbientFactor(new Vector3f(1.0f,1.0f,1.0f));
// apply a little rotation to show the element move
//objectPosition.getTransform().applyRotation(basicRotation);
diff --git a/samples/src/sample/atriasoft/ege/lowPoly/MainMowPoly.java b/samples/src/sample/atriasoft/ege/lowPoly/MainMowPoly.java
new file mode 100644
index 0000000..bc556f8
--- /dev/null
+++ b/samples/src/sample/atriasoft/ege/lowPoly/MainMowPoly.java
@@ -0,0 +1,19 @@
+package sample.atriasoft.ege.lowPoly;
+
+import org.atriasoft.ege.Ege;
+import org.atriasoft.etk.Uri;
+import org.atriasoft.gale.Gale;
+
+import sample.atriasoft.ege.collisiontest.MainCollisionTest;
+
+public class MainMowPoly {
+ 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 LowPolyApplication(), args);
+ }
+}
diff --git a/src/org/atriasoft/ege/samples/lowPoly/basic.frag b/samples/src/sample/atriasoft/ege/lowPoly/basic.frag
similarity index 100%
rename from src/org/atriasoft/ege/samples/lowPoly/basic.frag
rename to samples/src/sample/atriasoft/ege/lowPoly/basic.frag
diff --git a/src/org/atriasoft/ege/samples/lowPoly/basic.vert b/samples/src/sample/atriasoft/ege/lowPoly/basic.vert
similarity index 100%
rename from src/org/atriasoft/ege/samples/lowPoly/basic.vert
rename to samples/src/sample/atriasoft/ege/lowPoly/basic.vert
diff --git a/src/org/atriasoft/ege/samples/lowPoly/basicMaterial.frag b/samples/src/sample/atriasoft/ege/lowPoly/basicMaterial.frag
similarity index 100%
rename from src/org/atriasoft/ege/samples/lowPoly/basicMaterial.frag
rename to samples/src/sample/atriasoft/ege/lowPoly/basicMaterial.frag
diff --git a/src/org/atriasoft/ege/samples/lowPoly/basicMaterial.vert b/samples/src/sample/atriasoft/ege/lowPoly/basicMaterial.vert
similarity index 100%
rename from src/org/atriasoft/ege/samples/lowPoly/basicMaterial.vert
rename to samples/src/sample/atriasoft/ege/lowPoly/basicMaterial.vert
diff --git a/src/org/atriasoft/ege/samples/LoxelEngine/Log.java b/samples/src/sample/atriasoft/ege/loxelEngine/Log.java
similarity index 50%
rename from src/org/atriasoft/ege/samples/LoxelEngine/Log.java
rename to samples/src/sample/atriasoft/ege/loxelEngine/Log.java
index b3d6aa4..0078741 100644
--- a/src/org/atriasoft/ege/samples/LoxelEngine/Log.java
+++ b/samples/src/sample/atriasoft/ege/loxelEngine/Log.java
@@ -1,30 +1,39 @@
-package org.atriasoft.ege.samples.LoxelEngine;
+package sample.atriasoft.ege.loxelEngine;
public class Log {
- private Log() {}
private static final String LIBNAME = "LoxelEngine";
+
+ 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 critical(String data) {
- System.out.println("[C] " + LIBNAME + " | " + data);
- }
- public static void error(String data) {
- System.out.println("[E] " + LIBNAME + " | " + data);
- }
- public static void warning(String data) {
- System.out.println("[W] " + LIBNAME + " | " + data);
- }
- public static void info(String data) {
- System.out.println("[I] " + LIBNAME + " | " + data);
- }
- public static void debug(String data) {
- System.out.println("[D] " + LIBNAME + " | " + data);
- }
- public static void verbose(String data) {
- System.out.println("[V] " + LIBNAME + " | " + data);
- }
+
public static void todo(String data) {
- System.out.println("[TODO] " + LIBNAME + " | " + 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/src/org/atriasoft/ege/samples/LoxelEngine/LoxelApplication.java b/samples/src/sample/atriasoft/ege/loxelEngine/LoxelApplication.java
similarity index 90%
rename from src/org/atriasoft/ege/samples/LoxelEngine/LoxelApplication.java
rename to samples/src/sample/atriasoft/ege/loxelEngine/LoxelApplication.java
index 8544179..6ae63bf 100644
--- a/src/org/atriasoft/ege/samples/LoxelEngine/LoxelApplication.java
+++ b/samples/src/sample/atriasoft/ege/loxelEngine/LoxelApplication.java
@@ -1,4 +1,4 @@
-package org.atriasoft.ege.samples.LoxelEngine;
+package sample.atriasoft.ege.loxelEngine;
import java.util.ArrayList;
import java.util.List;
@@ -37,7 +37,7 @@ 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.Application;
+import org.atriasoft.gale.GaleApplication;
import org.atriasoft.gale.Gale;
import org.atriasoft.gale.backend3d.OpenGL;
import org.atriasoft.gale.backend3d.OpenGL.Flag;
@@ -48,30 +48,29 @@ import org.atriasoft.gale.key.KeyStatus;
import org.atriasoft.gale.key.KeyType;
import org.atriasoft.gale.resource.ResourceColored3DObject;
-public class LoxelApplication extends Application {
+public class LoxelApplication extends GaleApplication {
+ public static Vector3f box1HalfSize;
+ public static Vector3f box2HalfSize;
// public static ComponentPosition relativeTestPos;
// public static Box boxTest;
public static List testPoints = new ArrayList<>();
public static List testPointsBox = new ArrayList<>();
public static List testPointsCollide = new ArrayList<>();
- public static Vector3f testRpos;
public static Quaternion testQTransfert;
- public static Vector3f box1HalfSize;
- public static Vector3f box2HalfSize;
- private Environement env;
- private ComponentPosition objectPosition;
+ public static Vector3f testRpos;
+ private float angleLight = 0;
private Quaternion basicRotation = Quaternion.IDENTITY;
private Quaternion basicRotation2 = Quaternion.IDENTITY;
- private boolean creationDone;
- private ControlCameraPlayer simpleControl;
+ private ResourceColored3DObject debugDrawProperty;
+ private Environement env;
private ComponentPosition lightPosition;
- private float angleLight = 0;
private MapVoxel map;
private ComponentPlayer objectPlayer;
- private ResourceColored3DObject debugDrawProperty;
+ private ComponentPosition objectPosition;
+ private ControlCameraPlayer simpleControl;
public LoxelApplication() {
- this.creationDone = false;
+
}
@Override
@@ -80,7 +79,6 @@ public class LoxelApplication extends Application {
//ComponentPhysics.globalMaxSpeed = 3;
Gale.getContext().grabPointerEvents(true, new Vector2f(0, 0));
this.env = new Environement();
- this.canDraw = true;
setSize(new Vector2f(1500, 1500));
setTitle("Loxel sample");
this.map = new MapVoxel(this.env);
@@ -113,9 +111,9 @@ public class LoxelApplication extends Application {
// add a cube to test collision ...
final Entity localBox = new Entity(this.env);
localBox.addComponent(new ComponentStaticMesh(new Uri("RES", "cube-one.obj")));
- localBox.addComponent(new ComponentTexture(new Uri("DATA", "blocks/clay.png")));
+ localBox.addComponent(new ComponentTexture(new Uri("DATA", "blocks/clay.png", "loxelEngine")));
localBox.addComponent(new ComponentLight(new Light(new Vector3f(0, 1, 0), new Vector3f(0, 0, 0), new Vector3f(0.8f, 0.03f, 0.002f))));
- localBox.addComponent(new ComponentRenderTexturedStaticMesh(new Uri("DATA", "basic.vert"), new Uri("DATA", "basic.frag")));
+ localBox.addComponent(new ComponentRenderTexturedStaticMesh(new Uri("DATA", "basic.vert", "loxelEngine"), new Uri("DATA", "basic.frag", "loxelEngine")));
final ComponentPhysics physics2 = new ComponentPhysics(this.env);
physics2.setTransform(new Transform3D(new Vector3f(0, 0, 5)));
final Box box2 = new Box();
@@ -130,9 +128,9 @@ public class LoxelApplication extends Application {
// add a cube to test collision ...
final Entity localBox = new Entity(this.env);
localBox.addComponent(new ComponentStaticMesh(new Uri("RES", "cube-one.obj")));
- localBox.addComponent(new ComponentTexture(new Uri("DATA", "blocks/clay.png")));
+ localBox.addComponent(new ComponentTexture(new Uri("DATA", "blocks/clay.png", "loxelEngine")));
localBox.addComponent(new ComponentLight(new Light(new Vector3f(0, 1, 0), new Vector3f(0, 0, 0), new Vector3f(0.8f, 0.03f, 0.002f))));
- localBox.addComponent(new ComponentRenderTexturedStaticMesh(new Uri("DATA", "basic.vert"), new Uri("DATA", "basic.frag")));
+ localBox.addComponent(new ComponentRenderTexturedStaticMesh(new Uri("DATA", "basic.vert", "loxelEngine"), new Uri("DATA", "basic.frag", "loxelEngine")));
final ComponentPhysics physics2 = new ComponentPhysics(this.env);
physics2.setTransform(new Transform3D(new Vector3f(0, 4, 12.5f)));
final Box box2 = new Box();
@@ -147,8 +145,8 @@ public class LoxelApplication extends Application {
// add a cube to test collision ...
final Entity localBox = new Entity(this.env);
localBox.addComponent(new ComponentStaticMesh(new Uri("RES", "cube-one.obj")));
- localBox.addComponent(new ComponentTexture(new Uri("DATA", "blocks/clay.png")));
- localBox.addComponent(new ComponentRenderTexturedStaticMesh(new Uri("DATA", "basic.vert"), new Uri("DATA", "basic.frag")));
+ localBox.addComponent(new ComponentTexture(new Uri("DATA", "blocks/clay.png", "loxelEngine")));
+ localBox.addComponent(new ComponentRenderTexturedStaticMesh(new Uri("DATA", "basic.vert", "loxelEngine"), new Uri("DATA", "basic.frag", "loxelEngine")));
final ComponentPhysics physics2 = new ComponentPhysics(this.env);
physics2.setTransform(new Transform3D(new Vector3f(-2, 2, 14.5f)));
final Box box2 = new Box();
@@ -164,8 +162,8 @@ public class LoxelApplication extends Application {
// add a cube to test collision ...
final Entity localBox = new Entity(this.env);
localBox.addComponent(new ComponentStaticMesh(new Uri("RES", "cube-one.obj")));
- localBox.addComponent(new ComponentTexture(new Uri("DATA", "blocks/clay.png")));
- localBox.addComponent(new ComponentRenderTexturedStaticMesh(new Uri("DATA", "basic.vert"), new Uri("DATA", "basic.frag")));
+ localBox.addComponent(new ComponentTexture(new Uri("DATA", "blocks/clay.png", "loxelEngine")));
+ localBox.addComponent(new ComponentRenderTexturedStaticMesh(new Uri("DATA", "basic.vert", "loxelEngine"), new Uri("DATA", "basic.frag", "loxelEngine")));
final ComponentPhysics physics2 = new ComponentPhysics(this.env);
physics2.setTransform(new Transform3D(new Vector3f(-5, -5, 14)));
final Box box2 = new Box();
@@ -182,8 +180,8 @@ public class LoxelApplication extends Application {
Quaternion orientation = new Quaternion(0.5f, 0.2f, 0.4f, 1);
orientation = orientation.normalize();
localBox.addComponent(new ComponentStaticMesh(new Uri("RES", "cube-one.obj")));
- localBox.addComponent(new ComponentTexture(new Uri("DATA", "blocks/clay.png")));
- localBox.addComponent(new ComponentRenderTexturedStaticMesh(new Uri("DATA", "basic.vert"), new Uri("DATA", "basic.frag")));
+ localBox.addComponent(new ComponentTexture(new Uri("DATA", "blocks/clay.png", "loxelEngine")));
+ localBox.addComponent(new ComponentRenderTexturedStaticMesh(new Uri("DATA", "basic.vert", "loxelEngine"), new Uri("DATA", "basic.frag", "loxelEngine")));
final ComponentPhysics physics2 = new ComponentPhysics(this.env);
physics2.setTransform(new Transform3D(new Vector3f(15, 15, 14), orientation));
final Box box2 = new Box();
@@ -200,8 +198,8 @@ public class LoxelApplication extends Application {
final Quaternion orientation = new Quaternion(0.3f, 1.3f, 0.4f, 1);
//orientation.normalize();
localBox.addComponent(new ComponentStaticMesh(new Uri("RES", "cube-one.obj")));
- localBox.addComponent(new ComponentTexture(new Uri("DATA", "blocks/clay.png")));
- localBox.addComponent(new ComponentRenderTexturedStaticMesh(new Uri("DATA", "basic.vert"), new Uri("DATA", "basic.frag")));
+ localBox.addComponent(new ComponentTexture(new Uri("DATA", "blocks/clay.png", "loxelEngine")));
+ localBox.addComponent(new ComponentRenderTexturedStaticMesh(new Uri("DATA", "basic.vert", "loxelEngine"), new Uri("DATA", "basic.frag", "loxelEngine")));
final ComponentPhysics physics2 = new ComponentPhysics(this.env);
physics2.setTransform(new Transform3D(new Vector3f(2, -2, 14.2f), orientation));
physics2.setAngularReactionEnable(false);
@@ -219,8 +217,8 @@ public class LoxelApplication extends Application {
Quaternion orientation = new Quaternion(0, 0, 0, 1);
orientation = orientation.normalize();
localBox.addComponent(new ComponentStaticMesh(new Uri("RES", "cube-one.obj")));
- localBox.addComponent(new ComponentTexture(new Uri("DATA", "blocks/dirt.png")));
- localBox.addComponent(new ComponentRenderTexturedStaticMesh(new Uri("DATA", "basic.vert"), new Uri("DATA", "basic.frag")));
+ localBox.addComponent(new ComponentTexture(new Uri("DATA", "blocks/dirt.png", "loxelEngine")));
+ localBox.addComponent(new ComponentRenderTexturedStaticMesh(new Uri("DATA", "basic.vert", "loxelEngine"), new Uri("DATA", "basic.frag", "loxelEngine")));
final ComponentPhysics physics2 = new ComponentPhysics(this.env);
physics2.setBodyType(PhysicBodyType.BODY_STATIC);
physics2.setTransform(new Transform3D(new Vector3f(0, 0, 0.0f), orientation));
@@ -238,7 +236,7 @@ public class LoxelApplication extends Application {
// relativeTestPos = new ComponentPosition(new Transform3D(new Vector3f(0,0,14),new Quaternion(0.5f,0.2f,0.4f,1)));
// localBox.addComponent(relativeTestPos);
//// localBox.addComponent(new ComponentStaticMesh(new Uri("RES", "cube-one.obj")));
- //// localBox.addComponent(new ComponentTexture(new Uri("DATA", "blocks/clay.png")));
+ //// localBox.addComponent(new ComponentTexture(new Uri("DATA", "blocks/clay.png", "loxelEngine")));
//// localBox.addComponent(new ComponentLight(new Light(new Vector3f(0,1,0), new Vector3f(0,0,0), new Vector3f(0.8f,0.03f,0.002f))));
//// localBox.addComponent(new ComponentRenderTexturedStaticMesh(
//// new Uri("DATA", "basic.vert"),
@@ -256,7 +254,7 @@ public class LoxelApplication extends Application {
// Entity localBox = new Entity(this.env);
// localBox.addComponent(new ComponentPosition(new Transform3D(new Vector3f(0,0,14))));
// localBox.addComponent(new ComponentStaticMesh(new Uri("RES", "cube-one.obj")));
- // localBox.addComponent(new ComponentTexture(new Uri("DATA", "blocks/clay.png")));
+ // localBox.addComponent(new ComponentTexture(new Uri("DATA", "blocks/clay.png", "loxelEngine")));
// localBox.addComponent(new ComponentRenderTexturedStaticMesh(
// new Uri("DATA", "basic.vert"),
// new Uri("DATA", "basic.frag")));
@@ -266,11 +264,11 @@ public class LoxelApplication extends Application {
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_EGE", "wireColor.vert"), new Uri("DATA_EGE", "wireColor.frag")));
+ gird.addComponent(new ComponentRenderColoredStaticMesh(new Uri("DATA", "wireColor.vert", "ege"), new Uri("DATA", "wireColor.frag", "ege")));
this.env.addEntity(gird);
final Entity player = new Entity(this.env);
- if (true) {
+ if (false) {
final Transform3D playerTransform = new Transform3D(new Vector3f(0, -5, 1));
//this.objectPosition = new ComponentPositionPlayer();
//player.addComponent(this.objectPosition);
@@ -280,7 +278,7 @@ public class LoxelApplication extends Application {
//player.addComponent(new ComponentStaticMesh(new Uri("RES", "person.obj")));
player.addComponent(new ComponentStaticMesh(new Uri("RES", "person_-yfw_zup.obj")));
player.addComponent(new ComponentTexture(new Uri("RES", "playerTexture.png")));
- player.addComponent(new ComponentRenderTexturedMaterialsStaticMesh(new Uri("DATA", "basicMaterial.vert"), new Uri("DATA", "basicMaterial.frag"),
+ player.addComponent(new ComponentRenderTexturedMaterialsStaticMesh(new Uri("DATA", "basicMaterial.vert", "loxelEngine"), new Uri("DATA", "basicMaterial.frag", "loxelEngine"),
(EngineLight) this.env.getEngine(EngineLight.ENGINE_NAME)));
final ComponentPhysics physics = new ComponentPhysics(this.env, playerTransform);
physics.setBodyType(PhysicBodyType.BODY_DYNAMIC);
@@ -303,7 +301,7 @@ public class LoxelApplication extends Application {
//player.addComponent(new ComponentStaticMesh(new Uri("RES", "person.obj")));
player.addComponent(new ComponentStaticMesh(new Uri("RES", "person_-yfw_zup.obj")));
player.addComponent(new ComponentTexture(new Uri("RES", "playerTexture.png")));
- player.addComponent(new ComponentRenderTexturedMaterialsStaticMesh(new Uri("DATA", "basicMaterial.vert"), new Uri("DATA", "basicMaterial.frag"),
+ player.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(player);
}
@@ -330,20 +328,12 @@ public class LoxelApplication extends Application {
// ready to let Gale & Ege manage the display
Log.info("==> Init APPL (END)");
- this.creationDone = true;
}
@Override
public void onDraw(final Context context) {
//Log.info("==> appl Draw ...");
final Vector2f size = getSize();
- if (!this.creationDone) {
- OpenGL.setViewPort(new Vector2f(0, 0), size);
- final Color bgColor = new Color(0.8f, 0.5f, 0.5f, 1.0f);
- OpenGL.clearColor(bgColor);
- Log.info("==> appl clear ==> not created ...");
- return;
- }
// Store openGl context.
OpenGL.push();
// set projection matrix:
@@ -398,18 +388,18 @@ public class LoxelApplication extends Application {
}
}
- if (testRpos != null) {
+ if (LoxelApplication.testRpos != null) {
//debugDrawProperty.drawSquare(box2HalfSize, testQTransfert.getMatrix4().multiplyNew(Matrix4f.createMatrixTranslate(new Vector3f(testRpos.x,testRpos.y,testRpos.z+14))), new Color(0,1,0,0.5f));
//Matrix4f transformation = Matrix4f.createMatrixTranslate(new Vector3f(testRpos.x,testRpos.y,testRpos.z)).multiply(testQTransfert.getMatrix4()).multiply(Matrix4f.createMatrixTranslate(new Vector3f(0,0,14)));
//Matrix4f transformation = testQTransfert.getMatrix4().multiply(Matrix4f.createMatrixTranslate(new Vector3f(testRpos.x,testRpos.y,testRpos.z))).multiply(Matrix4f.createMatrixTranslate(new Vector3f(0,0,14)));
//Matrix4f transformation = testQTransfert.getMatrix4().multiply(Matrix4f.createMatrixTranslate(new Vector3f(testRpos.x,testRpos.y,testRpos.z))).multiply(Matrix4f.createMatrixTranslate(new Vector3f(0,0,14)));
- final Matrix4f transformation = Matrix4f.createMatrixTranslate(new Vector3f(testRpos.x(), testRpos.y(), testRpos.z())).multiply(Matrix4f.createMatrixTranslate(new Vector3f(0, 0, 14)))
- .multiply(testQTransfert.getMatrix4());
+ final Matrix4f transformation = Matrix4f.createMatrixTranslate(new Vector3f(LoxelApplication.testRpos.x(), LoxelApplication.testRpos.y(), LoxelApplication.testRpos.z()))
+ .multiply(Matrix4f.createMatrixTranslate(new Vector3f(0, 0, 14))).multiply(LoxelApplication.testQTransfert.getMatrix4());
// OK sans la box1 orientation ...
//Matrix4f transformation = Matrix4f.createMatrixTranslate(new Vector3f(testRpos.x,testRpos.y,testRpos.z)).multiply(testQTransfert.getMatrix4()).multiply(Matrix4f.createMatrixTranslate(new Vector3f(0,0,14)));
//Matrix4f transformation = Matrix4f.createMatrixTranslate(new Vector3f(testRpos.x,testRpos.y,testRpos.z)).multiply(testQTransfert.getMatrix4()).multiply(Matrix4f.createMatrixTranslate(new Vector3f(0,0,14)));
- this.debugDrawProperty.drawSquare(box2HalfSize, transformation, new Color(0, 1, 0, 0.5f));
- this.debugDrawProperty.drawSquare(box1HalfSize, Matrix4f.createMatrixTranslate(new Vector3f(0, 0, 14)), new Color(0, 0, 1, 0.5f));
+ this.debugDrawProperty.drawSquare(LoxelApplication.box2HalfSize, transformation, new Color(0, 1, 0, 0.5f));
+ this.debugDrawProperty.drawSquare(LoxelApplication.box1HalfSize, Matrix4f.createMatrixTranslate(new Vector3f(0, 0, 14)), new Color(0, 0, 1, 0.5f));
}
// Restore context of matrix
@@ -421,10 +411,10 @@ public class LoxelApplication extends Application {
if (type == KeyKeyboard.f1) {
Gale.getContext().grabPointerEvents(false, new Vector2f(0, 0));
}
- if (type == KeyKeyboard.f2) {
+ if (type == KeyKeyboard.F2) {
Gale.getContext().grabPointerEvents(true, new Vector2f(0, 0));
}
- if (type == KeyKeyboard.f12) {
+ if (type == KeyKeyboard.F12) {
Gale.getContext().setFullScreen(!Gale.getContext().getFullScreen());
}
this.env.onKeyboard(special, type, value, state);
@@ -438,9 +428,6 @@ public class LoxelApplication extends Application {
@Override
public void onRegenerateDisplay(final Context context) {
//Log.verbose("Regenerate Gale Application");
- if (!this.creationDone) {
- return;
- }
this.angleLight += 0.01;
this.lightPosition.setTransform(this.lightPosition.getTransform()
.withPosition(new Vector3f(5 + (float) Math.cos(this.angleLight) * 7.0f, 5 + (float) Math.sin(this.angleLight) * 7.0f, this.lightPosition.getTransform().getPosition().z())));
diff --git a/samples/src/sample/atriasoft/ege/loxelEngine/MainLoxelEngine.java b/samples/src/sample/atriasoft/ege/loxelEngine/MainLoxelEngine.java
new file mode 100644
index 0000000..77eb2bf
--- /dev/null
+++ b/samples/src/sample/atriasoft/ege/loxelEngine/MainLoxelEngine.java
@@ -0,0 +1,19 @@
+package sample.atriasoft.ege.loxelEngine;
+
+import org.atriasoft.ege.Ege;
+import org.atriasoft.etk.Uri;
+import org.atriasoft.gale.Gale;
+
+import sample.atriasoft.ege.collisiontest.MainCollisionTest;
+
+public class MainLoxelEngine {
+ public static void main(final 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 LoxelApplication(), args);
+ }
+}
diff --git a/src/engineTester/HelloWorld.java b/samples/src/sample/atriasoft/ege/oldTest/HelloWorld.java
similarity index 52%
rename from src/engineTester/HelloWorld.java
rename to samples/src/sample/atriasoft/ege/oldTest/HelloWorld.java
index a4d7b1b..4d63b1e 100644
--- a/src/engineTester/HelloWorld.java
+++ b/samples/src/sample/atriasoft/ege/oldTest/HelloWorld.java
@@ -1,91 +1,73 @@
-package engineTester;
-import org.atriasoft.ege.Environement;
+package sample.atriasoft.ege.oldTest;
+
+import java.nio.IntBuffer;
+
import org.lwjgl.*;
import org.lwjgl.glfw.*;
import org.lwjgl.opengl.*;
import org.lwjgl.system.*;
-import java.nio.*;
-
-import static org.lwjgl.glfw.Callbacks.*;
-import static org.lwjgl.glfw.GLFW.*;
-import static org.lwjgl.opengl.GL11.*;
-import static org.lwjgl.system.MemoryStack.*;
-import static org.lwjgl.system.MemoryUtil.*;
-
public class HelloWorld {
-
+
+ public static void main(final String[] args) {
+ new HelloWorld().run();
+ }
+
// The window handle
private long window;
- private Environement env = new Environement();
- public void run() {
- System.out.println("Hello LWJGL " + Version.getVersion() + "!");
-
- init();
- loop();
-
- // Free the window callbacks and destroy the window
- glfwFreeCallbacks(window);
- glfwDestroyWindow(window);
-
- // Terminate GLFW and free the error callback
- glfwTerminate();
- glfwSetErrorCallback(null).free();
- }
-
+
private void init() {
// Setup an error callback. The default implementation
// will print the error message in System.err.
//GLFWErrorCallback.createPrint(System.err).set();
-
+
// Initialize GLFW. Most GLFW functions will not work before doing this.
- if ( !glfwInit() )
+ if (!GLFW.glfwInit()) {
throw new IllegalStateException("Unable to initialize GLFW");
-
+ }
+
// Configure GLFW
- glfwDefaultWindowHints(); // optional, the current window hints are already the default
- glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); // the window will stay hidden after creation
- glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE); // the window will be resizable
-
+ GLFW.glfwDefaultWindowHints(); // optional, the current window hints are already the default
+ GLFW.glfwWindowHint(GLFW.GLFW_VISIBLE, GLFW.GLFW_FALSE); // the window will stay hidden after creation
+ GLFW.glfwWindowHint(GLFW.GLFW_RESIZABLE, GLFW.GLFW_TRUE); // the window will be resizable
+
// Create the window
- window = glfwCreateWindow(300, 300, "Hello World!", NULL, NULL);
- if ( window == NULL )
+ this.window = GLFW.glfwCreateWindow(300, 300, "Hello World!", MemoryUtil.NULL, MemoryUtil.NULL);
+ if (this.window == MemoryUtil.NULL) {
throw new RuntimeException("Failed to create the GLFW window");
-
+ }
+
// Setup a key callback. It will be called every time a key is pressed, repeated or released.
- glfwSetKeyCallback(window, (window, key, scancode, action, mods) -> {
- if ( key == GLFW_KEY_ESCAPE && action == GLFW_RELEASE )
- glfwSetWindowShouldClose(window, true); // We will detect this in the rendering loop
+ GLFW.glfwSetKeyCallback(this.window, (window, key, scancode, action, mods) -> {
+ if (key == GLFW.GLFW_KEY_ESCAPE && action == GLFW.GLFW_RELEASE) {
+ GLFW.glfwSetWindowShouldClose(window, true); // We will detect this in the rendering loop
+ }
});
-
+
// Get the thread stack and push a new frame
- try ( MemoryStack stack = stackPush() ) {
+ try (MemoryStack stack = MemoryStack.stackPush()) {
IntBuffer pWidth = stack.mallocInt(1); // int*
IntBuffer pHeight = stack.mallocInt(1); // int*
-
+
// Get the window size passed to glfwCreateWindow
- glfwGetWindowSize(window, pWidth, pHeight);
-
+ GLFW.glfwGetWindowSize(this.window, pWidth, pHeight);
+
// Get the resolution of the primary monitor
- GLFWVidMode vidmode = glfwGetVideoMode(glfwGetPrimaryMonitor());
-
+ GLFWVidMode vidmode = GLFW.glfwGetVideoMode(GLFW.glfwGetPrimaryMonitor());
+
// Center the window
- glfwSetWindowPos(
- window,
- (vidmode.width() - pWidth.get(0)) / 2,
- (vidmode.height() - pHeight.get(0)) / 2
- );
+ GLFW.glfwSetWindowPos(this.window, (vidmode.width() - pWidth.get(0)) / 2, (vidmode.height() - pHeight.get(0)) / 2);
} // the stack frame is popped automatically
-
+
// Make the OpenGL context current
- glfwMakeContextCurrent(window);
+ GLFW.glfwMakeContextCurrent(this.window);
// Enable v-sync
- glfwSwapInterval(1);
-
+ GLFW.glfwSwapInterval(1);
+
// Make the window visible
- glfwShowWindow(window);
+ GLFW.glfwShowWindow(this.window);
}
-
+
private void loop() {
// This line is critical for LWJGL's interoperation with GLFW's
// OpenGL context, or any context that is managed externally.
@@ -93,25 +75,36 @@ public class HelloWorld {
// creates the GLCapabilities instance and makes the OpenGL
// bindings available for use.
GL.createCapabilities();
-
+
// Set the clear color
- glClearColor(1.0f, 0.0f, 0.0f, 0.0f);
-
+ GL11.glClearColor(1.0f, 0.0f, 0.0f, 0.0f);
+
// Run the rendering loop until the user has attempted to close
// the window or has pressed the ESCAPE key.
- while ( !glfwWindowShouldClose(window) ) {
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // clear the framebuffer
-
- glfwSwapBuffers(window); // swap the color buffers
-
+ while (!GLFW.glfwWindowShouldClose(this.window)) {
+ GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); // clear the framebuffer
+
+ GLFW.glfwSwapBuffers(this.window); // swap the color buffers
+
// Poll for window events. The key callback above will only be
// invoked during this call.
- glfwPollEvents();
+ GLFW.glfwPollEvents();
}
}
-
- public static void main(String[] args) {
- new HelloWorld().run();
+
+ public void run() {
+ System.out.println("Hello LWJGL " + Version.getVersion() + "!");
+
+ init();
+ loop();
+
+ // Free the window callbacks and destroy the window
+ Callbacks.glfwFreeCallbacks(this.window);
+ GLFW.glfwDestroyWindow(this.window);
+
+ // Terminate GLFW and free the error callback
+ GLFW.glfwTerminate();
+ GLFW.glfwSetErrorCallback(null).free();
}
-
+
}
\ No newline at end of file
diff --git a/src/engineTester/MainGameLoop.java b/samples/src/sample/atriasoft/ege/oldTest/MainGameLoop.java
similarity index 93%
rename from src/engineTester/MainGameLoop.java
rename to samples/src/sample/atriasoft/ege/oldTest/MainGameLoop.java
index 71d8ccd..707718b 100644
--- a/src/engineTester/MainGameLoop.java
+++ b/samples/src/sample/atriasoft/ege/oldTest/MainGameLoop.java
@@ -1,12 +1,14 @@
-package engineTester;
+package sample.atriasoft.ege.oldTest;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
+import org.atriasoft.ege.Ege;
import org.atriasoft.etk.Uri;
import org.atriasoft.etk.math.Vector2f;
import org.atriasoft.etk.math.Vector3f;
+import org.atriasoft.gale.Gale;
import entities.Camera;
import entities.Entity;
@@ -40,6 +42,12 @@ public class MainGameLoop {
* @param args
*/
public static void main(String[] args) {
+ Gale.init();
+ Ege.init();
+ Uri.setGroup("DATA", "data/");
+ Uri.setGroup("RES", "res");
+ Uri.addLibrary("loxelEngine", MainGameLoop.class, "testDataLoxelEngine/");
+ Uri.setApplication(MainGameLoop.class, "");
final DisplayManager manager = new DisplayManager();
final Loader loader = new Loader();
diff --git a/samples/src/sample/atriasoft/ege/s1_texturedCube/Log.java b/samples/src/sample/atriasoft/ege/s1_texturedCube/Log.java
new file mode 100644
index 0000000..571260b
--- /dev/null
+++ b/samples/src/sample/atriasoft/ege/s1_texturedCube/Log.java
@@ -0,0 +1,39 @@
+package sample.atriasoft.ege.s1_texturedCube;
+
+public class Log {
+ private static final String LIBNAME = "Sample1";
+
+ 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/s1_texturedCube/Main.java b/samples/src/sample/atriasoft/ege/s1_texturedCube/Main.java
new file mode 100644
index 0000000..1300f35
--- /dev/null
+++ b/samples/src/sample/atriasoft/ege/s1_texturedCube/Main.java
@@ -0,0 +1,22 @@
+package sample.atriasoft.ege.s1_texturedCube;
+
+import org.atriasoft.ege.Ege;
+import org.atriasoft.etk.Uri;
+import org.atriasoft.gale.Gale;
+
+import sample.atriasoft.ege.collisiontest.MainCollisionTest;
+
+public class Main {
+ public static void main(String[] args) {
+ Gale.init();
+ Ege.init();
+ Uri.setGroup("DATA", "data/");
+ Uri.setGroup("RES", "res");
+ Uri.addLibrary("sample", MainCollisionTest.class, "s1_textured_cube/");
+ Uri.setApplication(MainCollisionTest.class, "");
+ Uri.addLibrary("loxelEngine", MainCollisionTest.class, "testDataLoxelEngine/");
+ Gale.run(new S1Application(), args);
+ }
+
+ public Main() {}
+}
diff --git a/src/org/atriasoft/ege/samples/s1_texturedCube/S1Application.java b/samples/src/sample/atriasoft/ege/s1_texturedCube/S1Application.java
similarity index 62%
rename from src/org/atriasoft/ege/samples/s1_texturedCube/S1Application.java
rename to samples/src/sample/atriasoft/ege/s1_texturedCube/S1Application.java
index 04c5247..a742759 100644
--- a/src/org/atriasoft/ege/samples/s1_texturedCube/S1Application.java
+++ b/samples/src/sample/atriasoft/ege/s1_texturedCube/S1Application.java
@@ -1,4 +1,4 @@
-package org.atriasoft.ege.samples.s1_texturedCube;
+package sample.atriasoft.ege.s1_texturedCube;
import org.atriasoft.ege.ControlCameraSimple;
import org.atriasoft.ege.Entity;
@@ -18,7 +18,7 @@ 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.Application;
+import org.atriasoft.gale.GaleApplication;
import org.atriasoft.gale.backend3d.OpenGL;
import org.atriasoft.gale.backend3d.OpenGL.Flag;
import org.atriasoft.gale.context.Context;
@@ -27,78 +27,73 @@ import org.atriasoft.gale.key.KeySpecial;
import org.atriasoft.gale.key.KeyStatus;
import org.atriasoft.gale.key.KeyType;
-public class S1Application extends Application {
- private Environement env;
- private ComponentPosition objectPosition;
+public class S1Application extends GaleApplication {
private Quaternion basicRotation = Quaternion.IDENTITY;
private Quaternion basicRotation2 = Quaternion.IDENTITY;
- private boolean creationDone;
+ private Environement env;
+ private Camera mainView;
+ private ComponentPosition objectPosition;
+ private boolean signe = false;
private ControlCameraSimple simpleControl;
- public S1Application() {
- this.creationDone = false;
- }
+ public S1Application() {}
@Override
public void onCreate(final Context context) {
+ Log.info("On create .... [BEGIN]");
this.env = new Environement();
- this.canDraw = true;
setSize(new Vector2f(800, 600));
setTitle("Low Poly sample");
- Entity gird = new Entity(this.env);
+ 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_EGE", "wireColor.vert"), new Uri("DATA_EGE", "wireColor.frag")));
+ gird.addComponent(new ComponentRenderColoredStaticMesh(new Uri("DATA", "wireColor.vert", "ege"), new Uri("DATA", "wireColor.frag", "ege")));
this.env.addEntity(gird);
- Entity basicTree = new Entity(this.env);
- this.objectPosition = new ComponentPosition(new Transform3D(new Vector3f(0, 0, 0)));
+ final Entity basicTree = new Entity(this.env);
+ this.objectPosition = new ComponentPosition(new Transform3D(new Vector3f(0, 0, -5)));
basicTree.addComponent(this.objectPosition);
basicTree.addComponent(new ComponentStaticMesh(new Uri("RES", "cube.obj")));
- basicTree.addComponent(new ComponentTexture(new Uri("RES", "dirt.png")));
- basicTree.addComponent(new ComponentRenderTexturedStaticMesh(new Uri("DATA", "basic.vert"), new Uri("DATA", "basic.frag")));
+ basicTree.addComponent(new ComponentTexture(new Uri("DATA", "blocks/dirt.png", "loxelEngine")));
+ basicTree.addComponent(new ComponentRenderTexturedStaticMesh(new Uri("DATA", "basic.vert", "sample"), new Uri("DATA", "basic.frag", "sample")));
this.env.addEntity(basicTree);
- Camera mainView = new Camera();
- this.env.addCamera("default", mainView);
- mainView.setPitch((float) Math.PI * -0.25f);
- mainView.setPosition(new Vector3f(0, -5, 5));
+ this.mainView = new Camera();
+ this.env.addCamera("default", this.mainView);
+ //mainView.setPitch((float) Math.PI * -0.25f);
+ //mainView.setPosition(new Vector3f(0, 0, -5));
- this.simpleControl = new ControlCameraSimple(mainView);
+ this.simpleControl = new ControlCameraSimple(this.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.basicRotation = Quaternion.fromEulerAngles(new Vector3f(0, 0, 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)");
- this.creationDone = true;
+ Log.info("On create .... [ END ]");
}
@Override
public void onDraw(final Context context) {
+ Log.info("On draw .... [BEGIN]");
//Log.info("==> appl Draw ...");
- Vector2f size = getSize();
- if (!this.creationDone) {
- OpenGL.setViewPort(new Vector2f(0, 0), size);
- Color bgColor = new Color(0.8f, 0.5f, 0.5f, 1.0f);
- OpenGL.clearColor(bgColor);
- return;
- }
+ final Vector2f size = getSize();
// Store openGl context.
OpenGL.push();
// set projection matrix:
- Matrix4f tmpProjection = Matrix4f.createMatrixPerspective(3.14f * 0.5f, getAspectRatio(), 0.1f, 50000);
+ final Matrix4f tmpProjection = Matrix4f.createMatrixPerspective(3.14f * 0.5f, getAspectRatio(), 0.1f, 50000);
+ //final Matrix4f tmpProjection = Matrix4f.createMatrixOrtho(300, 300, 400, 400, -50000, 50000);
OpenGL.setMatrix(tmpProjection);
// set the basic openGL view port: (Draw in all the windows...)
OpenGL.setViewPort(new Vector2f(0, 0), size);
// clear background
- Color bgColor = new Color(0.0f, 1.0f, 0.0f, 1.0f);
+ 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);
@@ -106,9 +101,9 @@ public class S1Application extends Application {
OpenGL.enable(Flag.flag_depthTest);
this.env.render(20, "default");
-
// Restore context of matrix
OpenGL.pop();
+ Log.info("On draw .... [ END ]");
}
@Override
@@ -123,14 +118,31 @@ public class S1Application extends Application {
@Override
public void onRegenerateDisplay(final Context context) {
+ Log.info("On Regenerate Display .... [BEGIN]");
//Log.verbose("Regenerate Gale Application");
- if (!this.creationDone) {
- return;
+
+ //this.mainView.setPitch((float) Math.PI * -0.25f);
+ this.mainView.setPitch(-0.7f);
+ this.mainView.setPosition(new Vector3f(0, -10, 10));
+ //this.mainView.setPosition(Vector3f.ZERO);
+
+ //this.objectPosition.setTransform(this.objectPosition.getTransform().withPosition(new Vector3f(2, -1, -5)));
+ if (this.signe == true) {
+ this.objectPosition.setTransform(this.objectPosition.getTransform().withPosition(this.objectPosition.getTransform().getPosition().add(new Vector3f(0, 0, -0.1f))));
+ if (this.objectPosition.getTransform().getPosition().z() < -5) {
+ this.signe = false;
+ }
+ } else {
+ this.objectPosition.setTransform(this.objectPosition.getTransform().withPosition(this.objectPosition.getTransform().getPosition().add(new Vector3f(0, 0, 0.1f))));
+ if (this.objectPosition.getTransform().getPosition().z() > 5) {
+ this.signe = true;
+ }
}
- // apply a litthe rotation to show the element move
+ // apply a little rotation to show the element move
this.objectPosition.setTransform(this.objectPosition.getTransform().rotate(this.basicRotation));
this.objectPosition.setTransform(this.objectPosition.getTransform().rotate(this.basicRotation2));
this.env.periodicCall();
markDrawingIsNeeded();
+ Log.info("On Regenerate Display .... [ END ]");
}
}
diff --git a/src/module-info.java b/src/module-info.java
index 72b57ef..9b387ec 100644
--- a/src/module-info.java
+++ b/src/module-info.java
@@ -11,6 +11,17 @@ open module org.atriasoft.ege {
exports org.atriasoft.ege.map;
exports org.atriasoft.ege.physics.shape;
exports org.atriasoft.ege.resource;
+ exports org.atriasoft.ege.tools;
+ exports entities;
+ exports guis;
+ exports models;
+ exports objConverter;
+ exports renderEngine;
+ exports shaders;
+ exports skybox;
+ exports terrains;
+ exports textures;
+ exports toolbox;
requires transitive org.atriasoft.gale;
requires transitive org.atriasoft.etk;
diff --git a/src/objConverter/OBJFileLoader.java b/src/objConverter/OBJFileLoader.java
index 0c760bb..06bb09b 100644
--- a/src/objConverter/OBJFileLoader.java
+++ b/src/objConverter/OBJFileLoader.java
@@ -8,7 +8,7 @@ import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;
-import org.atriasoft.ege.samples.lowPoly.Log;
+import org.atriasoft.ege.internal.Log;
import org.atriasoft.etk.Uri;
import org.atriasoft.etk.math.Vector2f;
import org.atriasoft.etk.math.Vector3f;
diff --git a/src/org/atriasoft/ege/ControlCameraPlayer.java b/src/org/atriasoft/ege/ControlCameraPlayer.java
index bf529d2..6860272 100644
--- a/src/org/atriasoft/ege/ControlCameraPlayer.java
+++ b/src/org/atriasoft/ege/ControlCameraPlayer.java
@@ -52,22 +52,22 @@ public class ControlCameraPlayer implements ControlInterface {
@Override
public boolean onEventEntry(final EventEntry event) {
- if (event.type() == KeyKeyboard.up || (event.type() == KeyKeyboard.character && (event.getChar() == 'z' || event.getChar() == 'Z'))) {
+ if (event.type() == KeyKeyboard.UP || (event.type() == KeyKeyboard.CHARACTER && (event.getChar() == 'z' || event.getChar() == 'Z'))) {
this.moveUp = getState(event.status(), this.moveUp);
}
- if (event.type() == KeyKeyboard.left || (event.type() == KeyKeyboard.character && (event.getChar() == 'q' || event.getChar() == 'Q'))) {
+ if (event.type() == KeyKeyboard.LEFT || (event.type() == KeyKeyboard.CHARACTER && (event.getChar() == 'q' || event.getChar() == 'Q'))) {
this.moveLeft = getState(event.status(), this.moveLeft);
}
- if (event.type() == KeyKeyboard.right || (event.type() == KeyKeyboard.character && (event.getChar() == 'd' || event.getChar() == 'D'))) {
+ if (event.type() == KeyKeyboard.RIGHT || (event.type() == KeyKeyboard.CHARACTER && (event.getChar() == 'd' || event.getChar() == 'D'))) {
this.moveRight = getState(event.status(), this.moveRight);
}
- if (event.type() == KeyKeyboard.down || (event.type() == KeyKeyboard.character && (event.getChar() == 's' || event.getChar() == 'S'))) {
+ if (event.type() == KeyKeyboard.DOWN || (event.type() == KeyKeyboard.CHARACTER && (event.getChar() == 's' || event.getChar() == 'S'))) {
this.moveDown = getState(event.status(), this.moveDown);
}
- if (event.type() == KeyKeyboard.shiftLeft || event.type() == KeyKeyboard.shiftRight) {
+ if (event.type() == KeyKeyboard.SHIFT_LEFT || event.type() == KeyKeyboard.SHIFT_RIGHT) {
this.walk = event.specialKey().getShift();
}
- if (event.type() == KeyKeyboard.f10) {
+ if (event.type() == KeyKeyboard.F10) {
if (event.status() == KeyStatus.up) {
if (!this.fpsMode) {
this.fpsMode = true;
diff --git a/src/org/atriasoft/ege/ControlCameraPlayerFPS.java b/src/org/atriasoft/ege/ControlCameraPlayerFPS.java
index 0a8addd..1cfc3ec 100644
--- a/src/org/atriasoft/ege/ControlCameraPlayerFPS.java
+++ b/src/org/atriasoft/ege/ControlCameraPlayerFPS.java
@@ -42,16 +42,16 @@ public class ControlCameraPlayerFPS implements ControlInterface {
@Override
public boolean onEventEntry(final EventEntry event) {
- if (event.type() == KeyKeyboard.up || (event.type() == KeyKeyboard.character && (event.getChar() == 'z' || event.getChar() == 'Z'))) {
+ if (event.type() == KeyKeyboard.UP || (event.type() == KeyKeyboard.CHARACTER && (event.getChar() == 'z' || event.getChar() == 'Z'))) {
this.moveUp = getState(event.status(), this.moveUp);
}
- if (event.type() == KeyKeyboard.left || (event.type() == KeyKeyboard.character && (event.getChar() == 'q' || event.getChar() == 'Q'))) {
+ if (event.type() == KeyKeyboard.LEFT || (event.type() == KeyKeyboard.CHARACTER && (event.getChar() == 'q' || event.getChar() == 'Q'))) {
this.moveLeft = getState(event.status(), this.moveLeft);
}
- if (event.type() == KeyKeyboard.right || (event.type() == KeyKeyboard.character && (event.getChar() == 'd' || event.getChar() == 'D'))) {
+ if (event.type() == KeyKeyboard.RIGHT || (event.type() == KeyKeyboard.CHARACTER && (event.getChar() == 'd' || event.getChar() == 'D'))) {
this.moveRight = getState(event.status(), this.moveRight);
}
- if (event.type() == KeyKeyboard.down || (event.type() == KeyKeyboard.character && (event.getChar() == 's' || event.getChar() == 'S'))) {
+ if (event.type() == KeyKeyboard.DOWN || (event.type() == KeyKeyboard.CHARACTER && (event.getChar() == 's' || event.getChar() == 'S'))) {
this.moveDown = getState(event.status(), this.moveDown);
}
return false;
diff --git a/src/org/atriasoft/ege/ControlCameraSimple.java b/src/org/atriasoft/ege/ControlCameraSimple.java
index 4f8c761..5b6aee0 100644
--- a/src/org/atriasoft/ege/ControlCameraSimple.java
+++ b/src/org/atriasoft/ege/ControlCameraSimple.java
@@ -38,16 +38,16 @@ public class ControlCameraSimple implements ControlInterface {
@Override
public boolean onEventEntry(final EventEntry event) {
- if (event.type() == KeyKeyboard.up) {
+ if (event.type() == KeyKeyboard.UP) {
this.moveUp = getState(event.status(), this.moveUp);
}
- if (event.type() == KeyKeyboard.left) {
+ if (event.type() == KeyKeyboard.LEFT) {
this.moveLeft = getState(event.status(), this.moveLeft);
}
- if (!event.specialKey().getCtrl() && event.type() == KeyKeyboard.right) {
+ if (!event.specialKey().getCtrl() && event.type() == KeyKeyboard.RIGHT) {
this.moveRight = getState(event.status(), this.moveRight);
}
- if (!event.specialKey().getCtrl() && event.type() == KeyKeyboard.down) {
+ if (!event.specialKey().getCtrl() && event.type() == KeyKeyboard.DOWN) {
this.moveDown = getState(event.status(), this.moveDown);
}
this.ctrlIsSet = event.specialKey().getCtrl();
diff --git a/src/org/atriasoft/ege/camera/Camera.java b/src/org/atriasoft/ege/camera/Camera.java
index 2c53ba3..502a348 100644
--- a/src/org/atriasoft/ege/camera/Camera.java
+++ b/src/org/atriasoft/ege/camera/Camera.java
@@ -7,10 +7,10 @@ import org.atriasoft.etk.math.Vector3f;
//import renderEngine.DisplayManager;
public class Camera {
- private Vector3f position = new Vector3f(0, 0, 2);
private float pitch = 0;
- private float yaw = 0;
+ private Vector3f position = new Vector3f(0, 0, 2);
private float roll = 0;
+ private float yaw = 0;
public Camera() {
@@ -22,6 +22,12 @@ public class Camera {
matrix = matrix.rotate(new Vector3f(0, 1, 0), getYaw());
matrix = matrix.rotate(new Vector3f(0, 0, 1), getRoll());
matrix = matrix.translate(new Vector3f(-this.position.x(), -this.position.y(), -this.position.z()));
+ /*
+ matrix = matrix.rotate(new Vector3f(1, 0, 0), 0.0f);
+ matrix = matrix.rotate(new Vector3f(0, 1, 0), 0.0f);
+ matrix = matrix.rotate(new Vector3f(0, 0, 1), 0.75f);
+ matrix = matrix.translate(new Vector3f(0, 0, -7));
+ */
return matrix;
}
diff --git a/src/org/atriasoft/ege/components/ComponentRenderColoredStaticMesh.java b/src/org/atriasoft/ege/components/ComponentRenderColoredStaticMesh.java
index 8b3dcda..5432f5a 100644
--- a/src/org/atriasoft/ege/components/ComponentRenderColoredStaticMesh.java
+++ b/src/org/atriasoft/ege/components/ComponentRenderColoredStaticMesh.java
@@ -1,5 +1,4 @@
-
package org.atriasoft.ege.components;
import org.atriasoft.ege.Component;
@@ -10,41 +9,45 @@ import org.atriasoft.gale.resource.ResourceProgram;
public class ComponentRenderColoredStaticMesh extends ComponentRender {
ComponentStaticMesh mesh = null;
+ private int oGLMatrixProjection;
+ private int oGLMatrixTransformation;
+ private int oGLMatrixView;
ComponentPosition position = null;
ResourceProgram program = null;
- private int oGLMatrixTransformation;
- private int oGLMatrixProjection;
- private int oGLMatrixView;
public ComponentRenderColoredStaticMesh(Uri vertexShader, Uri fragmentShader) {
this.program = ResourceProgram.create(vertexShader, fragmentShader);
if (this.program != null) {
this.oGLMatrixTransformation = this.program.getUniform("in_matrixTransformation");
- this.oGLMatrixProjection = this.program.getUniform("in_matrixProjection");
- this.oGLMatrixView = this.program.getUniform("in_matrixView");
+ this.oGLMatrixProjection = this.program.getUniform("in_matrixProjection");
+ this.oGLMatrixView = this.program.getUniform("in_matrixView");
}
}
+
@Override
public void addFriendComponent(Component component) {
if (component.getType().contentEquals("static-mesh")) {
- mesh = (ComponentStaticMesh)component;
+ this.mesh = (ComponentStaticMesh) component;
}
if (component.getType().contentEquals("position")) {
- position = (ComponentPosition)component;
+ this.position = (ComponentPosition) component;
}
}
+
@Override
public void removeFriendComponent(Component component) {
// nothing to do.
}
+
@Override
public void render() {
this.program.use();
-
- Matrix4f projectionMatrix = OpenGL.getMatrix();
- Matrix4f viewMatrix = OpenGL.getCameraMatrix();
- Matrix4f transformationMatrix = position.getTransform().getOpenGLMatrix();
+
+ final Matrix4f projectionMatrix = OpenGL.getMatrix();
+ final Matrix4f viewMatrix = OpenGL.getCameraMatrix();
+ //Log.warning("position 22 " + this.position.getTransform());
+ final Matrix4f transformationMatrix = this.position.getTransform().getOpenGLMatrix();
this.mesh.bindForRendering();
this.program.uniformMatrix(this.oGLMatrixView, viewMatrix);
@@ -57,7 +60,7 @@ public class ComponentRenderColoredStaticMesh extends ComponentRender {
this.mesh.render();
this.mesh.unBindForRendering();
-
+
this.program.unUse();
}
}
diff --git a/src/org/atriasoft/ege/components/ComponentRenderTexturedMaterialsStaticMesh.java b/src/org/atriasoft/ege/components/ComponentRenderTexturedMaterialsStaticMesh.java
index b975a9e..fd08f63 100644
--- a/src/org/atriasoft/ege/components/ComponentRenderTexturedMaterialsStaticMesh.java
+++ b/src/org/atriasoft/ege/components/ComponentRenderTexturedMaterialsStaticMesh.java
@@ -3,30 +3,30 @@ package org.atriasoft.ege.components;
import org.atriasoft.ege.Component;
import org.atriasoft.ege.Light;
import org.atriasoft.ege.Material;
+import org.atriasoft.ege.engines.EngineLight;
import org.atriasoft.etk.Uri;
import org.atriasoft.etk.math.Matrix4f;
import org.atriasoft.etk.math.Vector3f;
import org.atriasoft.gale.backend3d.OpenGL;
import org.atriasoft.gale.resource.ResourceProgram;
-import org.atriasoft.ege.engines.EngineLight;
public class ComponentRenderTexturedMaterialsStaticMesh extends ComponentRender {
private static final int numberOfLight = 8;
- ComponentStaticMesh mesh = null;
- ComponentTexture texture = null;
- ComponentMaterial material = null;
- ComponentPosition position = null;
- private ComponentPhysics playerPhysics = null;
- ResourceProgram program = null;
- EngineLight lightEngine;
- private int GLMatrixTransformation;
- private int GLMatrixProjection;
- private int GLMatrixView;
private int GLambientFactor;
private int GLdiffuseFactor;
- private int GLspecularFactor;
- private int GLshininess;
private GlLightIndex[] GLlights;
+ private int GLMatrixProjection;
+ private int GLMatrixTransformation;
+ private int GLMatrixView;
+ private int GLshininess;
+ private int GLspecularFactor;
+ EngineLight lightEngine;
+ ComponentMaterial material = null;
+ ComponentStaticMesh mesh = null;
+ private ComponentPhysics playerPhysics = null;
+ ComponentPosition position = null;
+ ResourceProgram program = null;
+ ComponentTexture texture = null;
public ComponentRenderTexturedMaterialsStaticMesh(final Uri vertexShader, final Uri fragmentShader, final EngineLight lightEngine) {
this.lightEngine = lightEngine;
@@ -39,8 +39,8 @@ public class ComponentRenderTexturedMaterialsStaticMesh extends ComponentRender
this.GLdiffuseFactor = this.program.getUniform("in_material.diffuseFactor");
this.GLspecularFactor = this.program.getUniform("in_material.specularFactor");
this.GLshininess = this.program.getUniform("in_material.shininess");
- this.GLlights = new GlLightIndex[numberOfLight];
- for (int iii = 0; iii < numberOfLight; iii++) {
+ this.GLlights = new GlLightIndex[ComponentRenderTexturedMaterialsStaticMesh.numberOfLight];
+ for (int iii = 0; iii < ComponentRenderTexturedMaterialsStaticMesh.numberOfLight; iii++) {
final int color = this.program.getUniform("in_lights[" + iii + "].color");
final int position = this.program.getUniform("in_lights[" + iii + "].position");
final int attenuation = this.program.getUniform("in_lights[" + iii + "].attenuation");
@@ -80,9 +80,11 @@ public class ComponentRenderTexturedMaterialsStaticMesh extends ComponentRender
Light[] lights = null;
Matrix4f transformationMatrix = null;
if (this.position != null) {
+ //Log.warning("position " + this.position.getTransform());
lights = this.lightEngine.getNearest(this.position.getTransform().getPosition());
transformationMatrix = this.position.getTransform().getOpenGLMatrix();
} else if (this.playerPhysics != null) {
+ //Log.warning("playerPosition " + this.playerPhysics.getTransform());
lights = this.lightEngine.getNearest(this.playerPhysics.getTransform().getPosition());
transformationMatrix = this.playerPhysics.getTransform().getOpenGLMatrix();
}
@@ -96,7 +98,7 @@ public class ComponentRenderTexturedMaterialsStaticMesh extends ComponentRender
this.program.uniformVector(this.GLdiffuseFactor, mat.getDiffuseFactor());
this.program.uniformVector(this.GLspecularFactor, mat.getSpecularFactor());
this.program.uniformFloat(this.GLshininess, mat.getShininess());
- for (int iii = 0; iii < numberOfLight; iii++) {
+ for (int iii = 0; iii < ComponentRenderTexturedMaterialsStaticMesh.numberOfLight; iii++) {
if (lights[iii] != null) {
this.program.uniformVector(this.GLlights[iii].oGLposition, lights[iii].getPositionDelta());
this.program.uniformVector(this.GLlights[iii].oGLcolor, lights[iii].getColor());
diff --git a/src/org/atriasoft/ege/components/ComponentRenderTexturedStaticMesh.java b/src/org/atriasoft/ege/components/ComponentRenderTexturedStaticMesh.java
index 7559dd5..ef198a0 100644
--- a/src/org/atriasoft/ege/components/ComponentRenderTexturedStaticMesh.java
+++ b/src/org/atriasoft/ege/components/ComponentRenderTexturedStaticMesh.java
@@ -7,14 +7,14 @@ import org.atriasoft.gale.backend3d.OpenGL;
import org.atriasoft.gale.resource.ResourceProgram;
public class ComponentRenderTexturedStaticMesh extends ComponentRender {
- ComponentStaticMesh mesh = null;
- ComponentTexture texture = null;
- ComponentPosition position = null;
- private ComponentPhysics playerPhysics = null;
- ResourceProgram program = null;
- private int GLMatrixTransformation;
private int GLMatrixProjection;
+ private int GLMatrixTransformation;
private int GLMatrixView;
+ ComponentStaticMesh mesh = null;
+ private ComponentPhysics playerPhysics = null;
+ ComponentPosition position = null;
+ ResourceProgram program = null;
+ ComponentTexture texture = null;
public ComponentRenderTexturedStaticMesh(final Uri vertexShader, final Uri fragmentShader) {
this.program = ResourceProgram.create(vertexShader, fragmentShader);
@@ -54,8 +54,10 @@ public class ComponentRenderTexturedStaticMesh extends ComponentRender {
final Matrix4f viewMatrix = OpenGL.getCameraMatrix();
Matrix4f transformationMatrix = null;
if (this.position != null) {
+ //Log.warning("position " + this.position.getTransform());
transformationMatrix = this.position.getTransform().getOpenGLMatrix();
} else if (this.playerPhysics != null) {
+ //Log.warning("playerPosition " + this.playerPhysics.getTransform());
transformationMatrix = this.playerPhysics.getTransform().getOpenGLMatrix();
}
this.mesh.bindForRendering();
diff --git a/src/org/atriasoft/ege/samples/LoxelEngine/MainLoxelEngine.java b/src/org/atriasoft/ege/samples/LoxelEngine/MainLoxelEngine.java
deleted file mode 100644
index c0e1b9f..0000000
--- a/src/org/atriasoft/ege/samples/LoxelEngine/MainLoxelEngine.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package org.atriasoft.ege.samples.LoxelEngine;
-
-import org.atriasoft.etk.Uri;
-import org.atriasoft.gale.Gale;
-
-public class MainLoxelEngine {
- public static void main(final String[] args) {
- Uri.setGroup("DATA", "src/org/atriasoft/ege/samples/LoxelEngine/res/");
- Uri.setGroup("DATA_EGE", "src/org/atriasoft/ege/data/");
- Uri.setGroup("RES", "res");
- Gale.run(new LoxelApplication(), args);
- }
-}
diff --git a/src/org/atriasoft/ege/samples/lowPoly/MainMowPoly.java b/src/org/atriasoft/ege/samples/lowPoly/MainMowPoly.java
deleted file mode 100644
index a934fd2..0000000
--- a/src/org/atriasoft/ege/samples/lowPoly/MainMowPoly.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package org.atriasoft.ege.samples.lowPoly;
-
-import org.atriasoft.etk.Uri;
-import org.atriasoft.gale.Gale;
-
-public class MainMowPoly {
- public static void main(String[] args) {
- Uri.setGroup("DATA", "src/org/atriasoft/ege/samples/lowPoly/");
- Uri.setGroup("DATA_EGE", "src/org/atriasoft/ege/data/");
- Uri.setGroup("RES", "res");
- Gale.run(new LowPolyApplication(), args);
- }
-}
diff --git a/src/org/atriasoft/ege/samples/s1_texturedCube/Log.java b/src/org/atriasoft/ege/samples/s1_texturedCube/Log.java
deleted file mode 100644
index 336f855..0000000
--- a/src/org/atriasoft/ege/samples/s1_texturedCube/Log.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package org.atriasoft.ege.samples.s1_texturedCube;
-
-public class Log {
- private Log() {}
- private static final String LIBNAME = "Sample1";
- public static void print(String data) {
- System.out.println(data);
- }
- public static void critical(String data) {
- System.out.println("[C] " + LIBNAME + " | " + data);
- }
- public static void error(String data) {
- System.out.println("[E] " + LIBNAME + " | " + data);
- }
- public static void warning(String data) {
- System.out.println("[W] " + LIBNAME + " | " + data);
- }
- public static void info(String data) {
- System.out.println("[I] " + LIBNAME + " | " + data);
- }
- public static void debug(String data) {
- System.out.println("[D] " + LIBNAME + " | " + data);
- }
- public static void verbose(String data) {
- System.out.println("[V] " + LIBNAME + " | " + data);
- }
- public static void todo(String data) {
- System.out.println("[TODO] " + LIBNAME + " | " + data);
- }
-}
diff --git a/src/org/atriasoft/ege/samples/s1_texturedCube/Main.java b/src/org/atriasoft/ege/samples/s1_texturedCube/Main.java
deleted file mode 100644
index bbe5760..0000000
--- a/src/org/atriasoft/ege/samples/s1_texturedCube/Main.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package org.atriasoft.ege.samples.s1_texturedCube;
-
-import org.atriasoft.etk.Uri;
-import org.atriasoft.gale.Gale;
-
-public class Main {
- public Main() {}
- public static void main(String[] args) {
- Uri.setGroup("DATA", "src/org/atriasoft/ege/samples/s1_texturedCube/");
- Uri.setGroup("DATA_EGE", "src/org/atriasoft/ege/data/");
- Uri.setGroup("RES", "res");
- Gale.run(new S1Application(), args);
- }
-}
diff --git a/src/org/atriasoft/ege/samples/s1_texturedCube/basic.frag b/src/org/atriasoft/ege/samples/s1_texturedCube/basic.frag
deleted file mode 100644
index 13d2aa8..0000000
--- a/src/org/atriasoft/ege/samples/s1_texturedCube/basic.frag
+++ /dev/null
@@ -1,17 +0,0 @@
-#version 400 core
-
-#ifdef GL_ES
-precision mediump float;
-precision mediump int;
-#endif
-
-in vec2 io_textureCoords;
-
-uniform sampler2D in_textureBase;
-
-// output:
-out vec4 out_Color;
-
-void main(void) {
- out_Color = texture(in_textureBase, io_textureCoords);
-}
diff --git a/src/org/atriasoft/ege/samples/s1_texturedCube/basic.vert b/src/org/atriasoft/ege/samples/s1_texturedCube/basic.vert
deleted file mode 100644
index c0dcaa7..0000000
--- a/src/org/atriasoft/ege/samples/s1_texturedCube/basic.vert
+++ /dev/null
@@ -1,21 +0,0 @@
-#version 400 core
-
-#ifdef GL_ES
-precision mediump float;
-precision mediump int;
-#endif
-
-// Input:
-in vec3 in_position;
-in vec2 in_textureCoords;
-uniform mat4 in_matrixTransformation;
-uniform mat4 in_matrixProjection;
-uniform mat4 in_matrixView;
-
-// output:
-out vec2 io_textureCoords;
-
-void main(void) {
- gl_Position = in_matrixProjection * in_matrixView * in_matrixTransformation * vec4(in_position, 1.0);
- io_textureCoords = in_textureCoords;
-}