[DEV] update samples
This commit is contained in:
parent
8761cf1264
commit
d5ae92d240
10
.classpath
10
.classpath
@ -22,27 +22,27 @@
|
|||||||
<attribute name="test" value="true"/>
|
<attribute name="test" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry combineaccessrules="false" kind="src" path="/atriasoft-ephysics">
|
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/atriasoft-ephysics">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="module" value="true"/>
|
<attribute name="module" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry combineaccessrules="false" kind="src" path="/scenarium-logger">
|
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/scenarium-logger">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="module" value="true"/>
|
<attribute name="module" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry combineaccessrules="false" kind="src" path="/atriasoft-etk">
|
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/atriasoft-etk">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="module" value="true"/>
|
<attribute name="module" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry combineaccessrules="false" kind="src" path="/atriasoft-gale">
|
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/atriasoft-gale">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="module" value="true"/>
|
<attribute name="module" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry combineaccessrules="false" kind="src" path="/atriasoft-ewol">
|
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/atriasoft-ewol">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="module" value="true"/>
|
<attribute name="module" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
|
13
samples/src/module-info.java
Normal file
13
samples/src/module-info.java
Normal file
@ -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;
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package org.atriasoft.ege.samples.collisiontest;
|
package sample.atriasoft.ege.collisiontest;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -12,7 +12,6 @@ import org.atriasoft.ege.Light;
|
|||||||
import org.atriasoft.ege.Material;
|
import org.atriasoft.ege.Material;
|
||||||
import org.atriasoft.ege.camera.Camera;
|
import org.atriasoft.ege.camera.Camera;
|
||||||
import org.atriasoft.ege.components.ComponentGravityStatic;
|
import org.atriasoft.ege.components.ComponentGravityStatic;
|
||||||
import org.atriasoft.ege.components.ComponentLight;
|
|
||||||
import org.atriasoft.ege.components.ComponentLightSun;
|
import org.atriasoft.ege.components.ComponentLightSun;
|
||||||
import org.atriasoft.ege.components.ComponentMaterial;
|
import org.atriasoft.ege.components.ComponentMaterial;
|
||||||
import org.atriasoft.ege.components.ComponentPhysics;
|
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.Transform3D;
|
||||||
import org.atriasoft.etk.math.Vector2f;
|
import org.atriasoft.etk.math.Vector2f;
|
||||||
import org.atriasoft.etk.math.Vector3f;
|
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.Gale;
|
||||||
import org.atriasoft.gale.backend3d.OpenGL;
|
import org.atriasoft.gale.backend3d.OpenGL;
|
||||||
import org.atriasoft.gale.backend3d.OpenGL.Flag;
|
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.key.KeyType;
|
||||||
import org.atriasoft.gale.resource.ResourceColored3DObject;
|
import org.atriasoft.gale.resource.ResourceColored3DObject;
|
||||||
|
|
||||||
public class CollisionTestApplication extends Application {
|
public class CollisionTestApplication extends GaleApplication {
|
||||||
public static Vector3f box1HalfSize;
|
public static Vector3f box1HalfSize;
|
||||||
public static Vector3f box2HalfSize;
|
public static Vector3f box2HalfSize;
|
||||||
// public static ComponentPosition relativeTestPos;
|
// public static ComponentPosition relativeTestPos;
|
||||||
@ -61,7 +60,6 @@ public class CollisionTestApplication extends Application {
|
|||||||
private float angleLight = 0;
|
private float angleLight = 0;
|
||||||
private Quaternion basicRotation = Quaternion.IDENTITY;
|
private Quaternion basicRotation = Quaternion.IDENTITY;
|
||||||
private Quaternion basicRotation2 = Quaternion.IDENTITY;
|
private Quaternion basicRotation2 = Quaternion.IDENTITY;
|
||||||
private boolean creationDone;
|
|
||||||
private ResourceColored3DObject debugDrawProperty;
|
private ResourceColored3DObject debugDrawProperty;
|
||||||
private Environement env;
|
private Environement env;
|
||||||
private ComponentPosition lightPosition;
|
private ComponentPosition lightPosition;
|
||||||
@ -70,9 +68,7 @@ public class CollisionTestApplication extends Application {
|
|||||||
private ComponentPosition objectPosition;
|
private ComponentPosition objectPosition;
|
||||||
private ControlCameraPlayer simpleControl;
|
private ControlCameraPlayer simpleControl;
|
||||||
|
|
||||||
public CollisionTestApplication() {
|
public CollisionTestApplication() {}
|
||||||
this.creationDone = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(final Context context) {
|
public void onCreate(final Context context) {
|
||||||
@ -80,7 +76,6 @@ public class CollisionTestApplication extends Application {
|
|||||||
//ComponentPhysics.globalMaxSpeed = 3;
|
//ComponentPhysics.globalMaxSpeed = 3;
|
||||||
Gale.getContext().grabPointerEvents(true, new Vector2f(0, 0));
|
Gale.getContext().grabPointerEvents(true, new Vector2f(0, 0));
|
||||||
this.env = new Environement();
|
this.env = new Environement();
|
||||||
this.canDraw = true;
|
|
||||||
setSize(new Vector2f(1500, 1500));
|
setSize(new Vector2f(1500, 1500));
|
||||||
setTitle("Loxel sample");
|
setTitle("Loxel sample");
|
||||||
this.map = new MapVoxel(this.env);
|
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 ComponentStaticMesh(new Uri("RES", "cube-one.obj")));
|
||||||
localBox.addComponent(new ComponentTexture(new Uri("DATA", "blocks/dirt.png", "loxelEngine")));
|
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")));
|
localBox.addComponent(new ComponentRenderTexturedStaticMesh(new Uri("DATA", "basic.vert", "loxelEngine"), new Uri("DATA", "basic.frag", "loxelEngine")));
|
||||||
final ComponentPhysics physics2 = new ComponentPhysics(this.env);
|
if (false) {
|
||||||
physics2.setBodyType(PhysicBodyType.BODY_STATIC);
|
final ComponentPhysics physics2 = new ComponentPhysics(this.env);
|
||||||
physics2.setTransform(new Transform3D(Vector3f.ZERO, orientation));
|
physics2.setBodyType(PhysicBodyType.BODY_STATIC);
|
||||||
final Box box2 = new Box();
|
physics2.setTransform(new Transform3D(Vector3f.ZERO, orientation));
|
||||||
box2.setSize(new Vector3f(5.0f, 5.0f, 0.5f));
|
final Box box2 = new Box();
|
||||||
box2.setOrigin(Vector3f.ZERO);
|
box2.setSize(new Vector3f(5.0f, 5.0f, 0.5f));
|
||||||
box2.setMass(0);
|
box2.setOrigin(Vector3f.ZERO);
|
||||||
physics2.addShape(box2);
|
box2.setMass(0);
|
||||||
localBox.addComponent(physics2);
|
physics2.addShape(box2);
|
||||||
|
localBox.addComponent(physics2);
|
||||||
|
} else {
|
||||||
|
localBox.addComponent(new ComponentPosition(new Transform3D(new Vector3f(0, 0, 0))));
|
||||||
|
}
|
||||||
this.env.addEntity(localBox);
|
this.env.addEntity(localBox);
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
{
|
{
|
||||||
// add a cube to test collision ...
|
// add a cube to test collision ...
|
||||||
final Entity localBox = new Entity(this.env);
|
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 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 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")));
|
localBox.addComponent(new ComponentRenderTexturedStaticMesh(new Uri("DATA", "basic.vert", "loxelEngine"), new Uri("DATA", "basic.frag", "loxelEngine")));
|
||||||
final ComponentPhysics physics2 = new ComponentPhysics(this.env);
|
if (false) {
|
||||||
//physics2.setTransform(new Transform3D(new Vector3f(0, 0, 0.90f)));
|
final ComponentPhysics physics2 = new ComponentPhysics(this.env);
|
||||||
physics2.setTransform(new Transform3D(new Vector3f(0, 0, 1.20f)));
|
//physics2.setTransform(new Transform3D(new Vector3f(0, 0, 0.90f)));
|
||||||
final Box box2 = new Box();
|
physics2.setTransform(new Transform3D(new Vector3f(0, 0, 1.20f)));
|
||||||
box2.setSize(new Vector3f(0.5f, 0.5f, 0.5f));
|
final Box box2 = new Box();
|
||||||
box2.setOrigin(Vector3f.ZERO);
|
box2.setSize(new Vector3f(0.5f, 0.5f, 0.5f));
|
||||||
box2.setMass(100);
|
box2.setOrigin(Vector3f.ZERO);
|
||||||
physics2.addShape(box2);
|
box2.setMass(100);
|
||||||
localBox.addComponent(physics2);
|
physics2.addShape(box2);
|
||||||
|
localBox.addComponent(physics2);
|
||||||
|
} else {
|
||||||
|
localBox.addComponent(new ComponentPosition(new Transform3D(new Vector3f(0, -5, 13))));
|
||||||
|
}
|
||||||
this.env.addEntity(localBox);
|
this.env.addEntity(localBox);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
final Entity gird = new Entity(this.env);
|
final Entity gird = new Entity(this.env);
|
||||||
gird.addComponent(new ComponentPosition(new Transform3D(Vector3f.ZERO)));
|
gird.addComponent(new ComponentPosition(new Transform3D(Vector3f.ZERO)));
|
||||||
gird.addComponent(new ComponentStaticMesh(MeshGenerator.createGrid(5)));
|
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.obj")));
|
||||||
player.addComponent(new ComponentStaticMesh(new Uri("RES", "person_-yfw_zup.obj")));
|
player.addComponent(new ComponentStaticMesh(new Uri("RES", "person_-yfw_zup.obj")));
|
||||||
player.addComponent(new ComponentTexture(new Uri("RES", "playerTexture.png")));
|
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"),
|
//player.addComponent(new ComponentRenderTexturedMaterialsStaticMesh(new Uri("DATA", "basicMaterial.vert", "loxelEngine"), new Uri("DATA", "basicMaterial.frag", "loxelEngine"), (EngineLight) this.env.getEngine(EngineLight.ENGINE_NAME)));
|
||||||
(EngineLight) this.env.getEngine(EngineLight.ENGINE_NAME)));
|
|
||||||
this.env.addEntity(player);
|
this.env.addEntity(player);
|
||||||
}
|
}
|
||||||
final Camera mainView = new Camera();
|
final Camera mainView = new Camera();
|
||||||
@ -213,28 +216,21 @@ public class CollisionTestApplication extends Application {
|
|||||||
|
|
||||||
// ready to let Gale & Ege manage the display
|
// ready to let Gale & Ege manage the display
|
||||||
Log.info("==> Init APPL (END)");
|
Log.info("==> Init APPL (END)");
|
||||||
this.creationDone = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDraw(final Context context) {
|
public void onDraw(final Context context) {
|
||||||
//Log.info("==> appl Draw ...");
|
//Log.info("==> appl Draw ...");
|
||||||
final Vector2f size = getSize();
|
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.
|
// Store openGl context.
|
||||||
OpenGL.push();
|
OpenGL.push();
|
||||||
// set projection matrix:
|
// set projection matrix:
|
||||||
final 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(20, 20, 15, 15, 0, 500000);
|
||||||
OpenGL.setMatrix(tmpProjection);
|
OpenGL.setMatrix(tmpProjection);
|
||||||
|
|
||||||
// set the basic openGL view port: (Draw in all the windows...)
|
// 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
|
// clear background
|
||||||
final Color bgColor = new Color(0.18f, 0.43f, 0.95f, 1.0f);
|
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) {
|
if (type == KeyKeyboard.f1) {
|
||||||
Gale.getContext().grabPointerEvents(false, new Vector2f(0, 0));
|
Gale.getContext().grabPointerEvents(false, new Vector2f(0, 0));
|
||||||
}
|
}
|
||||||
if (type == KeyKeyboard.f2) {
|
if (type == KeyKeyboard.F2) {
|
||||||
Gale.getContext().grabPointerEvents(true, new Vector2f(0, 0));
|
Gale.getContext().grabPointerEvents(true, new Vector2f(0, 0));
|
||||||
}
|
}
|
||||||
if (type == KeyKeyboard.f12) {
|
if (type == KeyKeyboard.F12) {
|
||||||
Gale.getContext().setFullScreen(!Gale.getContext().getFullScreen());
|
Gale.getContext().setFullScreen(!Gale.getContext().getFullScreen());
|
||||||
}
|
}
|
||||||
this.env.onKeyboard(special, type, value, state);
|
this.env.onKeyboard(special, type, value, state);
|
||||||
@ -322,9 +318,6 @@ public class CollisionTestApplication extends Application {
|
|||||||
@Override
|
@Override
|
||||||
public void onRegenerateDisplay(final Context context) {
|
public void onRegenerateDisplay(final Context context) {
|
||||||
//Log.verbose("Regenerate Gale Application");
|
//Log.verbose("Regenerate Gale Application");
|
||||||
if (!this.creationDone) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.angleLight += 0.01;
|
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));
|
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));
|
this.lightPosition.setTransform(this.lightPosition.getTransform().withPosition(posss));
|
@ -1,30 +1,39 @@
|
|||||||
package org.atriasoft.ege.samples.collisiontest;
|
package sample.atriasoft.ege.collisiontest;
|
||||||
|
|
||||||
public class Log {
|
public class Log {
|
||||||
private Log() {}
|
|
||||||
private static final String LIBNAME = "LoxelEngine";
|
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) {
|
public static void print(String data) {
|
||||||
System.out.println(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) {
|
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() {}
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package org.atriasoft.ege.samples.collisiontest;
|
package sample.atriasoft.ege.collisiontest;
|
||||||
|
|
||||||
import org.atriasoft.ege.Ege;
|
import org.atriasoft.ege.Ege;
|
||||||
import org.atriasoft.etk.Uri;
|
import org.atriasoft.etk.Uri;
|
@ -1,30 +1,39 @@
|
|||||||
package org.atriasoft.ege.samples.lowPoly;
|
package sample.atriasoft.ege.lowPoly;
|
||||||
|
|
||||||
public class Log {
|
public class Log {
|
||||||
private Log() {}
|
|
||||||
private static final String LIBNAME = "LowPolySample";
|
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) {
|
public static void print(String data) {
|
||||||
System.out.println(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) {
|
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() {}
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package org.atriasoft.ege.samples.lowPoly;
|
package sample.atriasoft.ege.lowPoly;
|
||||||
|
|
||||||
import org.atriasoft.ege.ControlCameraSimple;
|
import org.atriasoft.ege.ControlCameraSimple;
|
||||||
import org.atriasoft.ege.Entity;
|
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.Transform3D;
|
||||||
import org.atriasoft.etk.math.Vector2f;
|
import org.atriasoft.etk.math.Vector2f;
|
||||||
import org.atriasoft.etk.math.Vector3f;
|
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;
|
||||||
import org.atriasoft.gale.backend3d.OpenGL.Flag;
|
import org.atriasoft.gale.backend3d.OpenGL.Flag;
|
||||||
import org.atriasoft.gale.context.Context;
|
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.KeyStatus;
|
||||||
import org.atriasoft.gale.key.KeyType;
|
import org.atriasoft.gale.key.KeyType;
|
||||||
|
|
||||||
public class LowPolyApplication extends Application {
|
public class LowPolyApplication extends GaleApplication {
|
||||||
private Environement env;
|
private float angleLight = 0;
|
||||||
private ComponentPosition objectPosition;
|
|
||||||
private Quaternion basicRotation = Quaternion.IDENTITY;
|
private Quaternion basicRotation = Quaternion.IDENTITY;
|
||||||
private Quaternion basicRotation2 = Quaternion.IDENTITY;
|
private Quaternion basicRotation2 = Quaternion.IDENTITY;
|
||||||
private boolean creationDone;
|
private Environement env;
|
||||||
private ControlCameraSimple simpleControl;
|
|
||||||
private Material materialCube;
|
|
||||||
private ComponentPosition lightPosition;
|
private ComponentPosition lightPosition;
|
||||||
private float angleLight = 0;
|
private Material materialCube;
|
||||||
|
private ComponentPosition objectPosition;
|
||||||
|
private ControlCameraSimple simpleControl;
|
||||||
|
|
||||||
public LowPolyApplication() {
|
public LowPolyApplication() {}
|
||||||
this.creationDone = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(final Context context) {
|
public void onCreate(final Context context) {
|
||||||
this.env = new Environement();
|
this.env = new Environement();
|
||||||
this.canDraw = true;
|
|
||||||
setSize(new Vector2f(800, 600));
|
setSize(new Vector2f(800, 600));
|
||||||
setTitle("Low Poly sample");
|
setTitle("Low Poly sample");
|
||||||
|
|
||||||
// simple sun to have a global light ...
|
// 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 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))));
|
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);
|
this.env.addEntity(sun);
|
||||||
|
|
||||||
// add a cube to show where in the light ...
|
// 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)));
|
this.lightPosition = new ComponentPosition(new Transform3D(new Vector3f(-10, -10, 0)));
|
||||||
localLight.addComponent(this.lightPosition);
|
localLight.addComponent(this.lightPosition);
|
||||||
localLight.addComponent(new ComponentStaticMesh(new Uri("RES", "cube.obj")));
|
localLight.addComponent(new ComponentStaticMesh(new Uri("RES", "cube.obj")));
|
||||||
localLight.addComponent(new ComponentTexture(new Uri("RES", "grass.png")));
|
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 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);
|
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 ComponentPosition(new Transform3D(new Vector3f(0, 0, 0))));
|
||||||
gird.addComponent(new ComponentStaticMesh(MeshGenerator.createGrid(5)));
|
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);
|
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)));
|
this.objectPosition = new ComponentPosition(new Transform3D(new Vector3f(0, 0, 0)));
|
||||||
basicTree.addComponent(this.objectPosition);
|
basicTree.addComponent(this.objectPosition);
|
||||||
this.materialCube = new Material();
|
this.materialCube = new Material();
|
||||||
basicTree.addComponent(new ComponentMaterial(this.materialCube));
|
basicTree.addComponent(new ComponentMaterial(this.materialCube));
|
||||||
basicTree.addComponent(new ComponentStaticMesh(new Uri("RES", "cube.obj")));
|
basicTree.addComponent(new ComponentStaticMesh(new Uri("RES", "cube.obj")));
|
||||||
basicTree.addComponent(new ComponentTexture(new Uri("RES", "grass.png")));
|
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)));
|
(EngineLight) this.env.getEngine(EngineLight.ENGINE_NAME)));
|
||||||
this.env.addEntity(basicTree);
|
this.env.addEntity(basicTree);
|
||||||
|
|
||||||
for (int xxx = -10; xxx < 10; xxx++) {
|
for (int xxx = -10; xxx < 10; xxx++) {
|
||||||
for (int yyy = -10; yyy < 10; yyy++) {
|
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 ComponentPosition(new Transform3D(new Vector3f(xxx, yyy, -1))));
|
||||||
superGrass.addComponent(new ComponentMaterial(new Material()));
|
superGrass.addComponent(new ComponentMaterial(new Material()));
|
||||||
superGrass.addComponent(new ComponentStaticMesh(new Uri("RES", "cube-one.obj")));
|
superGrass.addComponent(new ComponentStaticMesh(new Uri("RES", "cube-one.obj")));
|
||||||
superGrass.addComponent(new ComponentTexture(new Uri("RES", "dirt.png")));
|
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)));
|
(EngineLight) this.env.getEngine(EngineLight.ENGINE_NAME)));
|
||||||
this.env.addEntity(superGrass);
|
this.env.addEntity(superGrass);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Camera mainView = new Camera();
|
final Camera mainView = new Camera();
|
||||||
this.env.addCamera("default", mainView);
|
this.env.addCamera("default", mainView);
|
||||||
mainView.setPitch((float) Math.PI * -0.25f);
|
mainView.setPitch((float) Math.PI * -0.25f);
|
||||||
mainView.setPosition(new Vector3f(0, -5, 5));
|
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));
|
this.basicRotation2 = Quaternion.fromEulerAngles(new Vector3f(0.003f, 0.01f, 0.001f));
|
||||||
// ready to let Gale & Ege manage the display
|
// ready to let Gale & Ege manage the display
|
||||||
Log.info("==> Init APPL (END)");
|
Log.info("==> Init APPL (END)");
|
||||||
this.creationDone = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDraw(final Context context) {
|
public void onDraw(final Context context) {
|
||||||
//Log.info("==> appl Draw ...");
|
//Log.info("==> appl Draw ...");
|
||||||
Vector2f size = getSize();
|
final 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;
|
|
||||||
}
|
|
||||||
// Store openGl context.
|
// Store openGl context.
|
||||||
OpenGL.push();
|
OpenGL.push();
|
||||||
// set projection matrix:
|
// 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);
|
OpenGL.setMatrix(tmpProjection);
|
||||||
|
|
||||||
// set the basic openGL view port: (Draw in all the windows...)
|
// set the basic openGL view port: (Draw in all the windows...)
|
||||||
OpenGL.setViewPort(new Vector2f(0, 0), size);
|
OpenGL.setViewPort(new Vector2f(0, 0), size);
|
||||||
|
|
||||||
// clear background
|
// 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);
|
OpenGL.clearColor(bgColor);
|
||||||
// real clear request:
|
// real clear request:
|
||||||
OpenGL.clear(OpenGL.ClearFlag.clearFlag_colorBuffer);
|
OpenGL.clear(OpenGL.ClearFlag.clearFlag_colorBuffer);
|
||||||
@ -166,9 +155,6 @@ public class LowPolyApplication extends Application {
|
|||||||
@Override
|
@Override
|
||||||
public void onRegenerateDisplay(final Context context) {
|
public void onRegenerateDisplay(final Context context) {
|
||||||
//Log.verbose("Regenerate Gale Application");
|
//Log.verbose("Regenerate Gale Application");
|
||||||
if (!this.creationDone) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
//materialCube.setAmbientFactor(new Vector3f(1.0f,1.0f,1.0f));
|
//materialCube.setAmbientFactor(new Vector3f(1.0f,1.0f,1.0f));
|
||||||
// apply a little rotation to show the element move
|
// apply a little rotation to show the element move
|
||||||
//objectPosition.getTransform().applyRotation(basicRotation);
|
//objectPosition.getTransform().applyRotation(basicRotation);
|
19
samples/src/sample/atriasoft/ege/lowPoly/MainMowPoly.java
Normal file
19
samples/src/sample/atriasoft/ege/lowPoly/MainMowPoly.java
Normal file
@ -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);
|
||||||
|
}
|
||||||
|
}
|
@ -1,30 +1,39 @@
|
|||||||
package org.atriasoft.ege.samples.LoxelEngine;
|
package sample.atriasoft.ege.loxelEngine;
|
||||||
|
|
||||||
public class Log {
|
public class Log {
|
||||||
private Log() {}
|
|
||||||
private static final String LIBNAME = "LoxelEngine";
|
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) {
|
public static void print(String data) {
|
||||||
System.out.println(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) {
|
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() {}
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package org.atriasoft.ege.samples.LoxelEngine;
|
package sample.atriasoft.ege.loxelEngine;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
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.Transform3D;
|
||||||
import org.atriasoft.etk.math.Vector2f;
|
import org.atriasoft.etk.math.Vector2f;
|
||||||
import org.atriasoft.etk.math.Vector3f;
|
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.Gale;
|
||||||
import org.atriasoft.gale.backend3d.OpenGL;
|
import org.atriasoft.gale.backend3d.OpenGL;
|
||||||
import org.atriasoft.gale.backend3d.OpenGL.Flag;
|
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.key.KeyType;
|
||||||
import org.atriasoft.gale.resource.ResourceColored3DObject;
|
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 ComponentPosition relativeTestPos;
|
||||||
// public static Box boxTest;
|
// public static Box boxTest;
|
||||||
public static List<Vector3f> testPoints = new ArrayList<>();
|
public static List<Vector3f> testPoints = new ArrayList<>();
|
||||||
public static List<Vector3f> testPointsBox = new ArrayList<>();
|
public static List<Vector3f> testPointsBox = new ArrayList<>();
|
||||||
public static List<Boolean> testPointsCollide = new ArrayList<>();
|
public static List<Boolean> testPointsCollide = new ArrayList<>();
|
||||||
public static Vector3f testRpos;
|
|
||||||
public static Quaternion testQTransfert;
|
public static Quaternion testQTransfert;
|
||||||
public static Vector3f box1HalfSize;
|
public static Vector3f testRpos;
|
||||||
public static Vector3f box2HalfSize;
|
private float angleLight = 0;
|
||||||
private Environement env;
|
|
||||||
private ComponentPosition objectPosition;
|
|
||||||
private Quaternion basicRotation = Quaternion.IDENTITY;
|
private Quaternion basicRotation = Quaternion.IDENTITY;
|
||||||
private Quaternion basicRotation2 = Quaternion.IDENTITY;
|
private Quaternion basicRotation2 = Quaternion.IDENTITY;
|
||||||
private boolean creationDone;
|
private ResourceColored3DObject debugDrawProperty;
|
||||||
private ControlCameraPlayer simpleControl;
|
private Environement env;
|
||||||
private ComponentPosition lightPosition;
|
private ComponentPosition lightPosition;
|
||||||
private float angleLight = 0;
|
|
||||||
private MapVoxel map;
|
private MapVoxel map;
|
||||||
private ComponentPlayer objectPlayer;
|
private ComponentPlayer objectPlayer;
|
||||||
private ResourceColored3DObject debugDrawProperty;
|
private ComponentPosition objectPosition;
|
||||||
|
private ControlCameraPlayer simpleControl;
|
||||||
|
|
||||||
public LoxelApplication() {
|
public LoxelApplication() {
|
||||||
this.creationDone = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -80,7 +79,6 @@ public class LoxelApplication extends Application {
|
|||||||
//ComponentPhysics.globalMaxSpeed = 3;
|
//ComponentPhysics.globalMaxSpeed = 3;
|
||||||
Gale.getContext().grabPointerEvents(true, new Vector2f(0, 0));
|
Gale.getContext().grabPointerEvents(true, new Vector2f(0, 0));
|
||||||
this.env = new Environement();
|
this.env = new Environement();
|
||||||
this.canDraw = true;
|
|
||||||
setSize(new Vector2f(1500, 1500));
|
setSize(new Vector2f(1500, 1500));
|
||||||
setTitle("Loxel sample");
|
setTitle("Loxel sample");
|
||||||
this.map = new MapVoxel(this.env);
|
this.map = new MapVoxel(this.env);
|
||||||
@ -113,9 +111,9 @@ public class LoxelApplication extends Application {
|
|||||||
// add a cube to test collision ...
|
// add a cube to test collision ...
|
||||||
final Entity localBox = new Entity(this.env);
|
final Entity localBox = new Entity(this.env);
|
||||||
localBox.addComponent(new ComponentStaticMesh(new Uri("RES", "cube-one.obj")));
|
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 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);
|
final ComponentPhysics physics2 = new ComponentPhysics(this.env);
|
||||||
physics2.setTransform(new Transform3D(new Vector3f(0, 0, 5)));
|
physics2.setTransform(new Transform3D(new Vector3f(0, 0, 5)));
|
||||||
final Box box2 = new Box();
|
final Box box2 = new Box();
|
||||||
@ -130,9 +128,9 @@ public class LoxelApplication extends Application {
|
|||||||
// add a cube to test collision ...
|
// add a cube to test collision ...
|
||||||
final Entity localBox = new Entity(this.env);
|
final Entity localBox = new Entity(this.env);
|
||||||
localBox.addComponent(new ComponentStaticMesh(new Uri("RES", "cube-one.obj")));
|
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 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);
|
final ComponentPhysics physics2 = new ComponentPhysics(this.env);
|
||||||
physics2.setTransform(new Transform3D(new Vector3f(0, 4, 12.5f)));
|
physics2.setTransform(new Transform3D(new Vector3f(0, 4, 12.5f)));
|
||||||
final Box box2 = new Box();
|
final Box box2 = new Box();
|
||||||
@ -147,8 +145,8 @@ public class LoxelApplication extends Application {
|
|||||||
// add a cube to test collision ...
|
// add a cube to test collision ...
|
||||||
final Entity localBox = new Entity(this.env);
|
final Entity localBox = new Entity(this.env);
|
||||||
localBox.addComponent(new ComponentStaticMesh(new Uri("RES", "cube-one.obj")));
|
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")));
|
localBox.addComponent(new ComponentRenderTexturedStaticMesh(new Uri("DATA", "basic.vert", "loxelEngine"), new Uri("DATA", "basic.frag", "loxelEngine")));
|
||||||
final ComponentPhysics physics2 = new ComponentPhysics(this.env);
|
final ComponentPhysics physics2 = new ComponentPhysics(this.env);
|
||||||
physics2.setTransform(new Transform3D(new Vector3f(-2, 2, 14.5f)));
|
physics2.setTransform(new Transform3D(new Vector3f(-2, 2, 14.5f)));
|
||||||
final Box box2 = new Box();
|
final Box box2 = new Box();
|
||||||
@ -164,8 +162,8 @@ public class LoxelApplication extends Application {
|
|||||||
// add a cube to test collision ...
|
// add a cube to test collision ...
|
||||||
final Entity localBox = new Entity(this.env);
|
final Entity localBox = new Entity(this.env);
|
||||||
localBox.addComponent(new ComponentStaticMesh(new Uri("RES", "cube-one.obj")));
|
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")));
|
localBox.addComponent(new ComponentRenderTexturedStaticMesh(new Uri("DATA", "basic.vert", "loxelEngine"), new Uri("DATA", "basic.frag", "loxelEngine")));
|
||||||
final ComponentPhysics physics2 = new ComponentPhysics(this.env);
|
final ComponentPhysics physics2 = new ComponentPhysics(this.env);
|
||||||
physics2.setTransform(new Transform3D(new Vector3f(-5, -5, 14)));
|
physics2.setTransform(new Transform3D(new Vector3f(-5, -5, 14)));
|
||||||
final Box box2 = new Box();
|
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);
|
Quaternion orientation = new Quaternion(0.5f, 0.2f, 0.4f, 1);
|
||||||
orientation = orientation.normalize();
|
orientation = orientation.normalize();
|
||||||
localBox.addComponent(new ComponentStaticMesh(new Uri("RES", "cube-one.obj")));
|
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")));
|
localBox.addComponent(new ComponentRenderTexturedStaticMesh(new Uri("DATA", "basic.vert", "loxelEngine"), new Uri("DATA", "basic.frag", "loxelEngine")));
|
||||||
final ComponentPhysics physics2 = new ComponentPhysics(this.env);
|
final ComponentPhysics physics2 = new ComponentPhysics(this.env);
|
||||||
physics2.setTransform(new Transform3D(new Vector3f(15, 15, 14), orientation));
|
physics2.setTransform(new Transform3D(new Vector3f(15, 15, 14), orientation));
|
||||||
final Box box2 = new Box();
|
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);
|
final Quaternion orientation = new Quaternion(0.3f, 1.3f, 0.4f, 1);
|
||||||
//orientation.normalize();
|
//orientation.normalize();
|
||||||
localBox.addComponent(new ComponentStaticMesh(new Uri("RES", "cube-one.obj")));
|
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")));
|
localBox.addComponent(new ComponentRenderTexturedStaticMesh(new Uri("DATA", "basic.vert", "loxelEngine"), new Uri("DATA", "basic.frag", "loxelEngine")));
|
||||||
final ComponentPhysics physics2 = new ComponentPhysics(this.env);
|
final ComponentPhysics physics2 = new ComponentPhysics(this.env);
|
||||||
physics2.setTransform(new Transform3D(new Vector3f(2, -2, 14.2f), orientation));
|
physics2.setTransform(new Transform3D(new Vector3f(2, -2, 14.2f), orientation));
|
||||||
physics2.setAngularReactionEnable(false);
|
physics2.setAngularReactionEnable(false);
|
||||||
@ -219,8 +217,8 @@ public class LoxelApplication extends Application {
|
|||||||
Quaternion orientation = new Quaternion(0, 0, 0, 1);
|
Quaternion orientation = new Quaternion(0, 0, 0, 1);
|
||||||
orientation = orientation.normalize();
|
orientation = orientation.normalize();
|
||||||
localBox.addComponent(new ComponentStaticMesh(new Uri("RES", "cube-one.obj")));
|
localBox.addComponent(new ComponentStaticMesh(new Uri("RES", "cube-one.obj")));
|
||||||
localBox.addComponent(new ComponentTexture(new Uri("DATA", "blocks/dirt.png")));
|
localBox.addComponent(new ComponentTexture(new Uri("DATA", "blocks/dirt.png", "loxelEngine")));
|
||||||
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);
|
final ComponentPhysics physics2 = new ComponentPhysics(this.env);
|
||||||
physics2.setBodyType(PhysicBodyType.BODY_STATIC);
|
physics2.setBodyType(PhysicBodyType.BODY_STATIC);
|
||||||
physics2.setTransform(new Transform3D(new Vector3f(0, 0, 0.0f), orientation));
|
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)));
|
// relativeTestPos = new ComponentPosition(new Transform3D(new Vector3f(0,0,14),new Quaternion(0.5f,0.2f,0.4f,1)));
|
||||||
// localBox.addComponent(relativeTestPos);
|
// localBox.addComponent(relativeTestPos);
|
||||||
//// localBox.addComponent(new ComponentStaticMesh(new Uri("RES", "cube-one.obj")));
|
//// 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 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(
|
//// localBox.addComponent(new ComponentRenderTexturedStaticMesh(
|
||||||
//// new Uri("DATA", "basic.vert"),
|
//// new Uri("DATA", "basic.vert"),
|
||||||
@ -256,7 +254,7 @@ public class LoxelApplication extends Application {
|
|||||||
// Entity localBox = new Entity(this.env);
|
// Entity localBox = new Entity(this.env);
|
||||||
// localBox.addComponent(new ComponentPosition(new Transform3D(new Vector3f(0,0,14))));
|
// localBox.addComponent(new ComponentPosition(new Transform3D(new Vector3f(0,0,14))));
|
||||||
// localBox.addComponent(new ComponentStaticMesh(new Uri("RES", "cube-one.obj")));
|
// 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(
|
// localBox.addComponent(new ComponentRenderTexturedStaticMesh(
|
||||||
// new Uri("DATA", "basic.vert"),
|
// new Uri("DATA", "basic.vert"),
|
||||||
// new Uri("DATA", "basic.frag")));
|
// new Uri("DATA", "basic.frag")));
|
||||||
@ -266,11 +264,11 @@ public class LoxelApplication extends Application {
|
|||||||
final 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 ComponentPosition(new Transform3D(new Vector3f(0, 0, 0))));
|
||||||
gird.addComponent(new ComponentStaticMesh(MeshGenerator.createGrid(5)));
|
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);
|
this.env.addEntity(gird);
|
||||||
|
|
||||||
final Entity player = new Entity(this.env);
|
final Entity player = new Entity(this.env);
|
||||||
if (true) {
|
if (false) {
|
||||||
final Transform3D playerTransform = new Transform3D(new Vector3f(0, -5, 1));
|
final Transform3D playerTransform = new Transform3D(new Vector3f(0, -5, 1));
|
||||||
//this.objectPosition = new ComponentPositionPlayer();
|
//this.objectPosition = new ComponentPositionPlayer();
|
||||||
//player.addComponent(this.objectPosition);
|
//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.obj")));
|
||||||
player.addComponent(new ComponentStaticMesh(new Uri("RES", "person_-yfw_zup.obj")));
|
player.addComponent(new ComponentStaticMesh(new Uri("RES", "person_-yfw_zup.obj")));
|
||||||
player.addComponent(new ComponentTexture(new Uri("RES", "playerTexture.png")));
|
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)));
|
(EngineLight) this.env.getEngine(EngineLight.ENGINE_NAME)));
|
||||||
final ComponentPhysics physics = new ComponentPhysics(this.env, playerTransform);
|
final ComponentPhysics physics = new ComponentPhysics(this.env, playerTransform);
|
||||||
physics.setBodyType(PhysicBodyType.BODY_DYNAMIC);
|
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.obj")));
|
||||||
player.addComponent(new ComponentStaticMesh(new Uri("RES", "person_-yfw_zup.obj")));
|
player.addComponent(new ComponentStaticMesh(new Uri("RES", "person_-yfw_zup.obj")));
|
||||||
player.addComponent(new ComponentTexture(new Uri("RES", "playerTexture.png")));
|
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)));
|
(EngineLight) this.env.getEngine(EngineLight.ENGINE_NAME)));
|
||||||
this.env.addEntity(player);
|
this.env.addEntity(player);
|
||||||
}
|
}
|
||||||
@ -330,20 +328,12 @@ public class LoxelApplication extends Application {
|
|||||||
|
|
||||||
// ready to let Gale & Ege manage the display
|
// ready to let Gale & Ege manage the display
|
||||||
Log.info("==> Init APPL (END)");
|
Log.info("==> Init APPL (END)");
|
||||||
this.creationDone = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDraw(final Context context) {
|
public void onDraw(final Context context) {
|
||||||
//Log.info("==> appl Draw ...");
|
//Log.info("==> appl Draw ...");
|
||||||
final Vector2f size = getSize();
|
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.
|
// Store openGl context.
|
||||||
OpenGL.push();
|
OpenGL.push();
|
||||||
// set projection matrix:
|
// 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));
|
//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 = 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)));
|
||||||
//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)))
|
final Matrix4f transformation = Matrix4f.createMatrixTranslate(new Vector3f(LoxelApplication.testRpos.x(), LoxelApplication.testRpos.y(), LoxelApplication.testRpos.z()))
|
||||||
.multiply(testQTransfert.getMatrix4());
|
.multiply(Matrix4f.createMatrixTranslate(new Vector3f(0, 0, 14))).multiply(LoxelApplication.testQTransfert.getMatrix4());
|
||||||
// OK sans la box1 orientation ...
|
// 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)));
|
||||||
//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(LoxelApplication.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.box1HalfSize, Matrix4f.createMatrixTranslate(new Vector3f(0, 0, 14)), new Color(0, 0, 1, 0.5f));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restore context of matrix
|
// Restore context of matrix
|
||||||
@ -421,10 +411,10 @@ public class LoxelApplication extends Application {
|
|||||||
if (type == KeyKeyboard.f1) {
|
if (type == KeyKeyboard.f1) {
|
||||||
Gale.getContext().grabPointerEvents(false, new Vector2f(0, 0));
|
Gale.getContext().grabPointerEvents(false, new Vector2f(0, 0));
|
||||||
}
|
}
|
||||||
if (type == KeyKeyboard.f2) {
|
if (type == KeyKeyboard.F2) {
|
||||||
Gale.getContext().grabPointerEvents(true, new Vector2f(0, 0));
|
Gale.getContext().grabPointerEvents(true, new Vector2f(0, 0));
|
||||||
}
|
}
|
||||||
if (type == KeyKeyboard.f12) {
|
if (type == KeyKeyboard.F12) {
|
||||||
Gale.getContext().setFullScreen(!Gale.getContext().getFullScreen());
|
Gale.getContext().setFullScreen(!Gale.getContext().getFullScreen());
|
||||||
}
|
}
|
||||||
this.env.onKeyboard(special, type, value, state);
|
this.env.onKeyboard(special, type, value, state);
|
||||||
@ -438,9 +428,6 @@ public class LoxelApplication extends Application {
|
|||||||
@Override
|
@Override
|
||||||
public void onRegenerateDisplay(final Context context) {
|
public void onRegenerateDisplay(final Context context) {
|
||||||
//Log.verbose("Regenerate Gale Application");
|
//Log.verbose("Regenerate Gale Application");
|
||||||
if (!this.creationDone) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.angleLight += 0.01;
|
this.angleLight += 0.01;
|
||||||
this.lightPosition.setTransform(this.lightPosition.getTransform()
|
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())));
|
.withPosition(new Vector3f(5 + (float) Math.cos(this.angleLight) * 7.0f, 5 + (float) Math.sin(this.angleLight) * 7.0f, this.lightPosition.getTransform().getPosition().z())));
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
@ -1,91 +1,73 @@
|
|||||||
package engineTester;
|
package sample.atriasoft.ege.oldTest;
|
||||||
import org.atriasoft.ege.Environement;
|
|
||||||
|
import java.nio.IntBuffer;
|
||||||
|
|
||||||
import org.lwjgl.*;
|
import org.lwjgl.*;
|
||||||
import org.lwjgl.glfw.*;
|
import org.lwjgl.glfw.*;
|
||||||
import org.lwjgl.opengl.*;
|
import org.lwjgl.opengl.*;
|
||||||
import org.lwjgl.system.*;
|
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 class HelloWorld {
|
||||||
|
|
||||||
|
public static void main(final String[] args) {
|
||||||
|
new HelloWorld().run();
|
||||||
|
}
|
||||||
|
|
||||||
// The window handle
|
// The window handle
|
||||||
private long window;
|
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() {
|
private void init() {
|
||||||
// Setup an error callback. The default implementation
|
// Setup an error callback. The default implementation
|
||||||
// will print the error message in System.err.
|
// will print the error message in System.err.
|
||||||
//GLFWErrorCallback.createPrint(System.err).set();
|
//GLFWErrorCallback.createPrint(System.err).set();
|
||||||
|
|
||||||
// Initialize GLFW. Most GLFW functions will not work before doing this.
|
// Initialize GLFW. Most GLFW functions will not work before doing this.
|
||||||
if ( !glfwInit() )
|
if (!GLFW.glfwInit()) {
|
||||||
throw new IllegalStateException("Unable to initialize GLFW");
|
throw new IllegalStateException("Unable to initialize GLFW");
|
||||||
|
}
|
||||||
|
|
||||||
// Configure GLFW
|
// Configure GLFW
|
||||||
glfwDefaultWindowHints(); // optional, the current window hints are already the default
|
GLFW.glfwDefaultWindowHints(); // optional, the current window hints are already the default
|
||||||
glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); // the window will stay hidden after creation
|
GLFW.glfwWindowHint(GLFW.GLFW_VISIBLE, GLFW.GLFW_FALSE); // the window will stay hidden after creation
|
||||||
glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE); // the window will be resizable
|
GLFW.glfwWindowHint(GLFW.GLFW_RESIZABLE, GLFW.GLFW_TRUE); // the window will be resizable
|
||||||
|
|
||||||
// Create the window
|
// Create the window
|
||||||
window = glfwCreateWindow(300, 300, "Hello World!", NULL, NULL);
|
this.window = GLFW.glfwCreateWindow(300, 300, "Hello World!", MemoryUtil.NULL, MemoryUtil.NULL);
|
||||||
if ( window == NULL )
|
if (this.window == MemoryUtil.NULL) {
|
||||||
throw new RuntimeException("Failed to create the GLFW window");
|
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.
|
// Setup a key callback. It will be called every time a key is pressed, repeated or released.
|
||||||
glfwSetKeyCallback(window, (window, key, scancode, action, mods) -> {
|
GLFW.glfwSetKeyCallback(this.window, (window, key, scancode, action, mods) -> {
|
||||||
if ( key == GLFW_KEY_ESCAPE && action == GLFW_RELEASE )
|
if (key == GLFW.GLFW_KEY_ESCAPE && action == GLFW.GLFW_RELEASE) {
|
||||||
glfwSetWindowShouldClose(window, true); // We will detect this in the rendering loop
|
GLFW.glfwSetWindowShouldClose(window, true); // We will detect this in the rendering loop
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Get the thread stack and push a new frame
|
// 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 pWidth = stack.mallocInt(1); // int*
|
||||||
IntBuffer pHeight = stack.mallocInt(1); // int*
|
IntBuffer pHeight = stack.mallocInt(1); // int*
|
||||||
|
|
||||||
// Get the window size passed to glfwCreateWindow
|
// Get the window size passed to glfwCreateWindow
|
||||||
glfwGetWindowSize(window, pWidth, pHeight);
|
GLFW.glfwGetWindowSize(this.window, pWidth, pHeight);
|
||||||
|
|
||||||
// Get the resolution of the primary monitor
|
// Get the resolution of the primary monitor
|
||||||
GLFWVidMode vidmode = glfwGetVideoMode(glfwGetPrimaryMonitor());
|
GLFWVidMode vidmode = GLFW.glfwGetVideoMode(GLFW.glfwGetPrimaryMonitor());
|
||||||
|
|
||||||
// Center the window
|
// Center the window
|
||||||
glfwSetWindowPos(
|
GLFW.glfwSetWindowPos(this.window, (vidmode.width() - pWidth.get(0)) / 2, (vidmode.height() - pHeight.get(0)) / 2);
|
||||||
window,
|
|
||||||
(vidmode.width() - pWidth.get(0)) / 2,
|
|
||||||
(vidmode.height() - pHeight.get(0)) / 2
|
|
||||||
);
|
|
||||||
} // the stack frame is popped automatically
|
} // the stack frame is popped automatically
|
||||||
|
|
||||||
// Make the OpenGL context current
|
// Make the OpenGL context current
|
||||||
glfwMakeContextCurrent(window);
|
GLFW.glfwMakeContextCurrent(this.window);
|
||||||
// Enable v-sync
|
// Enable v-sync
|
||||||
glfwSwapInterval(1);
|
GLFW.glfwSwapInterval(1);
|
||||||
|
|
||||||
// Make the window visible
|
// Make the window visible
|
||||||
glfwShowWindow(window);
|
GLFW.glfwShowWindow(this.window);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loop() {
|
private void loop() {
|
||||||
// This line is critical for LWJGL's interoperation with GLFW's
|
// This line is critical for LWJGL's interoperation with GLFW's
|
||||||
// OpenGL context, or any context that is managed externally.
|
// OpenGL context, or any context that is managed externally.
|
||||||
@ -93,25 +75,36 @@ public class HelloWorld {
|
|||||||
// creates the GLCapabilities instance and makes the OpenGL
|
// creates the GLCapabilities instance and makes the OpenGL
|
||||||
// bindings available for use.
|
// bindings available for use.
|
||||||
GL.createCapabilities();
|
GL.createCapabilities();
|
||||||
|
|
||||||
// Set the clear color
|
// 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
|
// Run the rendering loop until the user has attempted to close
|
||||||
// the window or has pressed the ESCAPE key.
|
// the window or has pressed the ESCAPE key.
|
||||||
while ( !glfwWindowShouldClose(window) ) {
|
while (!GLFW.glfwWindowShouldClose(this.window)) {
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // clear the framebuffer
|
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); // clear the framebuffer
|
||||||
|
|
||||||
glfwSwapBuffers(window); // swap the color buffers
|
GLFW.glfwSwapBuffers(this.window); // swap the color buffers
|
||||||
|
|
||||||
// Poll for window events. The key callback above will only be
|
// Poll for window events. The key callback above will only be
|
||||||
// invoked during this call.
|
// invoked during this call.
|
||||||
glfwPollEvents();
|
GLFW.glfwPollEvents();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public void run() {
|
||||||
new HelloWorld().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();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,12 +1,14 @@
|
|||||||
package engineTester;
|
package sample.atriasoft.ege.oldTest;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
|
import org.atriasoft.ege.Ege;
|
||||||
import org.atriasoft.etk.Uri;
|
import org.atriasoft.etk.Uri;
|
||||||
import org.atriasoft.etk.math.Vector2f;
|
import org.atriasoft.etk.math.Vector2f;
|
||||||
import org.atriasoft.etk.math.Vector3f;
|
import org.atriasoft.etk.math.Vector3f;
|
||||||
|
import org.atriasoft.gale.Gale;
|
||||||
|
|
||||||
import entities.Camera;
|
import entities.Camera;
|
||||||
import entities.Entity;
|
import entities.Entity;
|
||||||
@ -40,6 +42,12 @@ public class MainGameLoop {
|
|||||||
* @param args
|
* @param args
|
||||||
*/
|
*/
|
||||||
public static void main(String[] 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 DisplayManager manager = new DisplayManager();
|
||||||
final Loader loader = new Loader();
|
final Loader loader = new Loader();
|
39
samples/src/sample/atriasoft/ege/s1_texturedCube/Log.java
Normal file
39
samples/src/sample/atriasoft/ege/s1_texturedCube/Log.java
Normal file
@ -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() {}
|
||||||
|
}
|
22
samples/src/sample/atriasoft/ege/s1_texturedCube/Main.java
Normal file
22
samples/src/sample/atriasoft/ege/s1_texturedCube/Main.java
Normal file
@ -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() {}
|
||||||
|
}
|
@ -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.ControlCameraSimple;
|
||||||
import org.atriasoft.ege.Entity;
|
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.Transform3D;
|
||||||
import org.atriasoft.etk.math.Vector2f;
|
import org.atriasoft.etk.math.Vector2f;
|
||||||
import org.atriasoft.etk.math.Vector3f;
|
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;
|
||||||
import org.atriasoft.gale.backend3d.OpenGL.Flag;
|
import org.atriasoft.gale.backend3d.OpenGL.Flag;
|
||||||
import org.atriasoft.gale.context.Context;
|
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.KeyStatus;
|
||||||
import org.atriasoft.gale.key.KeyType;
|
import org.atriasoft.gale.key.KeyType;
|
||||||
|
|
||||||
public class S1Application extends Application {
|
public class S1Application extends GaleApplication {
|
||||||
private Environement env;
|
|
||||||
private ComponentPosition objectPosition;
|
|
||||||
private Quaternion basicRotation = Quaternion.IDENTITY;
|
private Quaternion basicRotation = Quaternion.IDENTITY;
|
||||||
private Quaternion basicRotation2 = 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;
|
private ControlCameraSimple simpleControl;
|
||||||
|
|
||||||
public S1Application() {
|
public S1Application() {}
|
||||||
this.creationDone = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(final Context context) {
|
public void onCreate(final Context context) {
|
||||||
|
Log.info("On create .... [BEGIN]");
|
||||||
this.env = new Environement();
|
this.env = new Environement();
|
||||||
this.canDraw = true;
|
|
||||||
setSize(new Vector2f(800, 600));
|
setSize(new Vector2f(800, 600));
|
||||||
setTitle("Low Poly sample");
|
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 ComponentPosition(new Transform3D(new Vector3f(0, 0, 0))));
|
||||||
gird.addComponent(new ComponentStaticMesh(MeshGenerator.createGrid(5)));
|
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);
|
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)));
|
this.objectPosition = new ComponentPosition(new Transform3D(new Vector3f(0, 0, -5)));
|
||||||
basicTree.addComponent(this.objectPosition);
|
basicTree.addComponent(this.objectPosition);
|
||||||
basicTree.addComponent(new ComponentStaticMesh(new Uri("RES", "cube.obj")));
|
basicTree.addComponent(new ComponentStaticMesh(new Uri("RES", "cube.obj")));
|
||||||
basicTree.addComponent(new ComponentTexture(new Uri("RES", "dirt.png")));
|
basicTree.addComponent(new ComponentTexture(new Uri("DATA", "blocks/dirt.png", "loxelEngine")));
|
||||||
basicTree.addComponent(new ComponentRenderTexturedStaticMesh(new Uri("DATA", "basic.vert"), new Uri("DATA", "basic.frag")));
|
basicTree.addComponent(new ComponentRenderTexturedStaticMesh(new Uri("DATA", "basic.vert", "sample"), new Uri("DATA", "basic.frag", "sample")));
|
||||||
this.env.addEntity(basicTree);
|
this.env.addEntity(basicTree);
|
||||||
|
|
||||||
Camera mainView = new Camera();
|
this.mainView = new Camera();
|
||||||
this.env.addCamera("default", mainView);
|
this.env.addCamera("default", this.mainView);
|
||||||
mainView.setPitch((float) Math.PI * -0.25f);
|
//mainView.setPitch((float) Math.PI * -0.25f);
|
||||||
mainView.setPosition(new Vector3f(0, -5, 5));
|
//mainView.setPosition(new Vector3f(0, 0, -5));
|
||||||
|
|
||||||
this.simpleControl = new ControlCameraSimple(mainView);
|
this.simpleControl = new ControlCameraSimple(this.mainView);
|
||||||
this.env.addControlInterface(this.simpleControl);
|
this.env.addControlInterface(this.simpleControl);
|
||||||
|
|
||||||
// start the engine.
|
// start the engine.
|
||||||
this.env.setPropertyStatus(GameStatus.gameStart);
|
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));
|
this.basicRotation2 = Quaternion.fromEulerAngles(new Vector3f(0.003f, 0.01f, 0.001f));
|
||||||
// ready to let Gale & Ege manage the display
|
// ready to let Gale & Ege manage the display
|
||||||
Log.info("==> Init APPL (END)");
|
Log.info("==> Init APPL (END)");
|
||||||
this.creationDone = true;
|
Log.info("On create .... [ END ]");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDraw(final Context context) {
|
public void onDraw(final Context context) {
|
||||||
|
Log.info("On draw .... [BEGIN]");
|
||||||
//Log.info("==> appl Draw ...");
|
//Log.info("==> appl Draw ...");
|
||||||
Vector2f size = getSize();
|
final 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;
|
|
||||||
}
|
|
||||||
// Store openGl context.
|
// Store openGl context.
|
||||||
OpenGL.push();
|
OpenGL.push();
|
||||||
// set projection matrix:
|
// 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);
|
OpenGL.setMatrix(tmpProjection);
|
||||||
|
|
||||||
// set the basic openGL view port: (Draw in all the windows...)
|
// set the basic openGL view port: (Draw in all the windows...)
|
||||||
OpenGL.setViewPort(new Vector2f(0, 0), size);
|
OpenGL.setViewPort(new Vector2f(0, 0), size);
|
||||||
|
|
||||||
// clear background
|
// 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);
|
OpenGL.clearColor(bgColor);
|
||||||
// real clear request:
|
// real clear request:
|
||||||
OpenGL.clear(OpenGL.ClearFlag.clearFlag_colorBuffer);
|
OpenGL.clear(OpenGL.ClearFlag.clearFlag_colorBuffer);
|
||||||
@ -106,9 +101,9 @@ public class S1Application extends Application {
|
|||||||
OpenGL.enable(Flag.flag_depthTest);
|
OpenGL.enable(Flag.flag_depthTest);
|
||||||
|
|
||||||
this.env.render(20, "default");
|
this.env.render(20, "default");
|
||||||
|
|
||||||
// Restore context of matrix
|
// Restore context of matrix
|
||||||
OpenGL.pop();
|
OpenGL.pop();
|
||||||
|
Log.info("On draw .... [ END ]");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -123,14 +118,31 @@ public class S1Application extends Application {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRegenerateDisplay(final Context context) {
|
public void onRegenerateDisplay(final Context context) {
|
||||||
|
Log.info("On Regenerate Display .... [BEGIN]");
|
||||||
//Log.verbose("Regenerate Gale Application");
|
//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.basicRotation));
|
||||||
this.objectPosition.setTransform(this.objectPosition.getTransform().rotate(this.basicRotation2));
|
this.objectPosition.setTransform(this.objectPosition.getTransform().rotate(this.basicRotation2));
|
||||||
this.env.periodicCall();
|
this.env.periodicCall();
|
||||||
markDrawingIsNeeded();
|
markDrawingIsNeeded();
|
||||||
|
Log.info("On Regenerate Display .... [ END ]");
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -11,6 +11,17 @@ open module org.atriasoft.ege {
|
|||||||
exports org.atriasoft.ege.map;
|
exports org.atriasoft.ege.map;
|
||||||
exports org.atriasoft.ege.physics.shape;
|
exports org.atriasoft.ege.physics.shape;
|
||||||
exports org.atriasoft.ege.resource;
|
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.gale;
|
||||||
requires transitive org.atriasoft.etk;
|
requires transitive org.atriasoft.etk;
|
||||||
|
@ -8,7 +8,7 @@ import java.io.UnsupportedEncodingException;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
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.Uri;
|
||||||
import org.atriasoft.etk.math.Vector2f;
|
import org.atriasoft.etk.math.Vector2f;
|
||||||
import org.atriasoft.etk.math.Vector3f;
|
import org.atriasoft.etk.math.Vector3f;
|
||||||
|
@ -52,22 +52,22 @@ public class ControlCameraPlayer implements ControlInterface {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onEventEntry(final EventEntry event) {
|
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);
|
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);
|
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);
|
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);
|
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();
|
this.walk = event.specialKey().getShift();
|
||||||
}
|
}
|
||||||
if (event.type() == KeyKeyboard.f10) {
|
if (event.type() == KeyKeyboard.F10) {
|
||||||
if (event.status() == KeyStatus.up) {
|
if (event.status() == KeyStatus.up) {
|
||||||
if (!this.fpsMode) {
|
if (!this.fpsMode) {
|
||||||
this.fpsMode = true;
|
this.fpsMode = true;
|
||||||
|
@ -42,16 +42,16 @@ public class ControlCameraPlayerFPS implements ControlInterface {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onEventEntry(final EventEntry event) {
|
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);
|
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);
|
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);
|
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);
|
this.moveDown = getState(event.status(), this.moveDown);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -38,16 +38,16 @@ public class ControlCameraSimple implements ControlInterface {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onEventEntry(final EventEntry event) {
|
public boolean onEventEntry(final EventEntry event) {
|
||||||
if (event.type() == KeyKeyboard.up) {
|
if (event.type() == KeyKeyboard.UP) {
|
||||||
this.moveUp = getState(event.status(), this.moveUp);
|
this.moveUp = getState(event.status(), this.moveUp);
|
||||||
}
|
}
|
||||||
if (event.type() == KeyKeyboard.left) {
|
if (event.type() == KeyKeyboard.LEFT) {
|
||||||
this.moveLeft = getState(event.status(), this.moveLeft);
|
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);
|
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.moveDown = getState(event.status(), this.moveDown);
|
||||||
}
|
}
|
||||||
this.ctrlIsSet = event.specialKey().getCtrl();
|
this.ctrlIsSet = event.specialKey().getCtrl();
|
||||||
|
@ -7,10 +7,10 @@ import org.atriasoft.etk.math.Vector3f;
|
|||||||
//import renderEngine.DisplayManager;
|
//import renderEngine.DisplayManager;
|
||||||
|
|
||||||
public class Camera {
|
public class Camera {
|
||||||
private Vector3f position = new Vector3f(0, 0, 2);
|
|
||||||
private float pitch = 0;
|
private float pitch = 0;
|
||||||
private float yaw = 0;
|
private Vector3f position = new Vector3f(0, 0, 2);
|
||||||
private float roll = 0;
|
private float roll = 0;
|
||||||
|
private float yaw = 0;
|
||||||
|
|
||||||
public Camera() {
|
public Camera() {
|
||||||
|
|
||||||
@ -22,6 +22,12 @@ public class Camera {
|
|||||||
matrix = matrix.rotate(new Vector3f(0, 1, 0), getYaw());
|
matrix = matrix.rotate(new Vector3f(0, 1, 0), getYaw());
|
||||||
matrix = matrix.rotate(new Vector3f(0, 0, 1), getRoll());
|
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.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;
|
return matrix;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
|
|
||||||
|
|
||||||
package org.atriasoft.ege.components;
|
package org.atriasoft.ege.components;
|
||||||
|
|
||||||
import org.atriasoft.ege.Component;
|
import org.atriasoft.ege.Component;
|
||||||
@ -10,41 +9,45 @@ import org.atriasoft.gale.resource.ResourceProgram;
|
|||||||
|
|
||||||
public class ComponentRenderColoredStaticMesh extends ComponentRender {
|
public class ComponentRenderColoredStaticMesh extends ComponentRender {
|
||||||
ComponentStaticMesh mesh = null;
|
ComponentStaticMesh mesh = null;
|
||||||
|
private int oGLMatrixProjection;
|
||||||
|
private int oGLMatrixTransformation;
|
||||||
|
private int oGLMatrixView;
|
||||||
ComponentPosition position = null;
|
ComponentPosition position = null;
|
||||||
ResourceProgram program = null;
|
ResourceProgram program = null;
|
||||||
private int oGLMatrixTransformation;
|
|
||||||
private int oGLMatrixProjection;
|
|
||||||
private int oGLMatrixView;
|
|
||||||
|
|
||||||
public ComponentRenderColoredStaticMesh(Uri vertexShader, Uri fragmentShader) {
|
public ComponentRenderColoredStaticMesh(Uri vertexShader, Uri fragmentShader) {
|
||||||
this.program = ResourceProgram.create(vertexShader, fragmentShader);
|
this.program = ResourceProgram.create(vertexShader, fragmentShader);
|
||||||
if (this.program != null) {
|
if (this.program != null) {
|
||||||
this.oGLMatrixTransformation = this.program.getUniform("in_matrixTransformation");
|
this.oGLMatrixTransformation = this.program.getUniform("in_matrixTransformation");
|
||||||
this.oGLMatrixProjection = this.program.getUniform("in_matrixProjection");
|
this.oGLMatrixProjection = this.program.getUniform("in_matrixProjection");
|
||||||
this.oGLMatrixView = this.program.getUniform("in_matrixView");
|
this.oGLMatrixView = this.program.getUniform("in_matrixView");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addFriendComponent(Component component) {
|
public void addFriendComponent(Component component) {
|
||||||
if (component.getType().contentEquals("static-mesh")) {
|
if (component.getType().contentEquals("static-mesh")) {
|
||||||
mesh = (ComponentStaticMesh)component;
|
this.mesh = (ComponentStaticMesh) component;
|
||||||
}
|
}
|
||||||
if (component.getType().contentEquals("position")) {
|
if (component.getType().contentEquals("position")) {
|
||||||
position = (ComponentPosition)component;
|
this.position = (ComponentPosition) component;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeFriendComponent(Component component) {
|
public void removeFriendComponent(Component component) {
|
||||||
// nothing to do.
|
// nothing to do.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render() {
|
public void render() {
|
||||||
this.program.use();
|
this.program.use();
|
||||||
|
|
||||||
Matrix4f projectionMatrix = OpenGL.getMatrix();
|
final Matrix4f projectionMatrix = OpenGL.getMatrix();
|
||||||
Matrix4f viewMatrix = OpenGL.getCameraMatrix();
|
final Matrix4f viewMatrix = OpenGL.getCameraMatrix();
|
||||||
Matrix4f transformationMatrix = position.getTransform().getOpenGLMatrix();
|
//Log.warning("position 22 " + this.position.getTransform());
|
||||||
|
final Matrix4f transformationMatrix = this.position.getTransform().getOpenGLMatrix();
|
||||||
this.mesh.bindForRendering();
|
this.mesh.bindForRendering();
|
||||||
|
|
||||||
this.program.uniformMatrix(this.oGLMatrixView, viewMatrix);
|
this.program.uniformMatrix(this.oGLMatrixView, viewMatrix);
|
||||||
@ -57,7 +60,7 @@ public class ComponentRenderColoredStaticMesh extends ComponentRender {
|
|||||||
this.mesh.render();
|
this.mesh.render();
|
||||||
|
|
||||||
this.mesh.unBindForRendering();
|
this.mesh.unBindForRendering();
|
||||||
|
|
||||||
this.program.unUse();
|
this.program.unUse();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,30 +3,30 @@ package org.atriasoft.ege.components;
|
|||||||
import org.atriasoft.ege.Component;
|
import org.atriasoft.ege.Component;
|
||||||
import org.atriasoft.ege.Light;
|
import org.atriasoft.ege.Light;
|
||||||
import org.atriasoft.ege.Material;
|
import org.atriasoft.ege.Material;
|
||||||
|
import org.atriasoft.ege.engines.EngineLight;
|
||||||
import org.atriasoft.etk.Uri;
|
import org.atriasoft.etk.Uri;
|
||||||
import org.atriasoft.etk.math.Matrix4f;
|
import org.atriasoft.etk.math.Matrix4f;
|
||||||
import org.atriasoft.etk.math.Vector3f;
|
import org.atriasoft.etk.math.Vector3f;
|
||||||
import org.atriasoft.gale.backend3d.OpenGL;
|
import org.atriasoft.gale.backend3d.OpenGL;
|
||||||
import org.atriasoft.gale.resource.ResourceProgram;
|
import org.atriasoft.gale.resource.ResourceProgram;
|
||||||
import org.atriasoft.ege.engines.EngineLight;
|
|
||||||
|
|
||||||
public class ComponentRenderTexturedMaterialsStaticMesh extends ComponentRender {
|
public class ComponentRenderTexturedMaterialsStaticMesh extends ComponentRender {
|
||||||
private static final int numberOfLight = 8;
|
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 GLambientFactor;
|
||||||
private int GLdiffuseFactor;
|
private int GLdiffuseFactor;
|
||||||
private int GLspecularFactor;
|
|
||||||
private int GLshininess;
|
|
||||||
private GlLightIndex[] GLlights;
|
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) {
|
public ComponentRenderTexturedMaterialsStaticMesh(final Uri vertexShader, final Uri fragmentShader, final EngineLight lightEngine) {
|
||||||
this.lightEngine = lightEngine;
|
this.lightEngine = lightEngine;
|
||||||
@ -39,8 +39,8 @@ public class ComponentRenderTexturedMaterialsStaticMesh extends ComponentRender
|
|||||||
this.GLdiffuseFactor = this.program.getUniform("in_material.diffuseFactor");
|
this.GLdiffuseFactor = this.program.getUniform("in_material.diffuseFactor");
|
||||||
this.GLspecularFactor = this.program.getUniform("in_material.specularFactor");
|
this.GLspecularFactor = this.program.getUniform("in_material.specularFactor");
|
||||||
this.GLshininess = this.program.getUniform("in_material.shininess");
|
this.GLshininess = this.program.getUniform("in_material.shininess");
|
||||||
this.GLlights = new GlLightIndex[numberOfLight];
|
this.GLlights = new GlLightIndex[ComponentRenderTexturedMaterialsStaticMesh.numberOfLight];
|
||||||
for (int iii = 0; iii < numberOfLight; iii++) {
|
for (int iii = 0; iii < ComponentRenderTexturedMaterialsStaticMesh.numberOfLight; iii++) {
|
||||||
final int color = this.program.getUniform("in_lights[" + iii + "].color");
|
final int color = this.program.getUniform("in_lights[" + iii + "].color");
|
||||||
final int position = this.program.getUniform("in_lights[" + iii + "].position");
|
final int position = this.program.getUniform("in_lights[" + iii + "].position");
|
||||||
final int attenuation = this.program.getUniform("in_lights[" + iii + "].attenuation");
|
final int attenuation = this.program.getUniform("in_lights[" + iii + "].attenuation");
|
||||||
@ -80,9 +80,11 @@ public class ComponentRenderTexturedMaterialsStaticMesh extends ComponentRender
|
|||||||
Light[] lights = null;
|
Light[] lights = null;
|
||||||
Matrix4f transformationMatrix = null;
|
Matrix4f transformationMatrix = null;
|
||||||
if (this.position != null) {
|
if (this.position != null) {
|
||||||
|
//Log.warning("position " + this.position.getTransform());
|
||||||
lights = this.lightEngine.getNearest(this.position.getTransform().getPosition());
|
lights = this.lightEngine.getNearest(this.position.getTransform().getPosition());
|
||||||
transformationMatrix = this.position.getTransform().getOpenGLMatrix();
|
transformationMatrix = this.position.getTransform().getOpenGLMatrix();
|
||||||
} else if (this.playerPhysics != null) {
|
} else if (this.playerPhysics != null) {
|
||||||
|
//Log.warning("playerPosition " + this.playerPhysics.getTransform());
|
||||||
lights = this.lightEngine.getNearest(this.playerPhysics.getTransform().getPosition());
|
lights = this.lightEngine.getNearest(this.playerPhysics.getTransform().getPosition());
|
||||||
transformationMatrix = this.playerPhysics.getTransform().getOpenGLMatrix();
|
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.GLdiffuseFactor, mat.getDiffuseFactor());
|
||||||
this.program.uniformVector(this.GLspecularFactor, mat.getSpecularFactor());
|
this.program.uniformVector(this.GLspecularFactor, mat.getSpecularFactor());
|
||||||
this.program.uniformFloat(this.GLshininess, mat.getShininess());
|
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) {
|
if (lights[iii] != null) {
|
||||||
this.program.uniformVector(this.GLlights[iii].oGLposition, lights[iii].getPositionDelta());
|
this.program.uniformVector(this.GLlights[iii].oGLposition, lights[iii].getPositionDelta());
|
||||||
this.program.uniformVector(this.GLlights[iii].oGLcolor, lights[iii].getColor());
|
this.program.uniformVector(this.GLlights[iii].oGLcolor, lights[iii].getColor());
|
||||||
|
@ -7,14 +7,14 @@ import org.atriasoft.gale.backend3d.OpenGL;
|
|||||||
import org.atriasoft.gale.resource.ResourceProgram;
|
import org.atriasoft.gale.resource.ResourceProgram;
|
||||||
|
|
||||||
public class ComponentRenderTexturedStaticMesh extends ComponentRender {
|
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 GLMatrixProjection;
|
||||||
|
private int GLMatrixTransformation;
|
||||||
private int GLMatrixView;
|
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) {
|
public ComponentRenderTexturedStaticMesh(final Uri vertexShader, final Uri fragmentShader) {
|
||||||
this.program = ResourceProgram.create(vertexShader, fragmentShader);
|
this.program = ResourceProgram.create(vertexShader, fragmentShader);
|
||||||
@ -54,8 +54,10 @@ public class ComponentRenderTexturedStaticMesh extends ComponentRender {
|
|||||||
final Matrix4f viewMatrix = OpenGL.getCameraMatrix();
|
final Matrix4f viewMatrix = OpenGL.getCameraMatrix();
|
||||||
Matrix4f transformationMatrix = null;
|
Matrix4f transformationMatrix = null;
|
||||||
if (this.position != null) {
|
if (this.position != null) {
|
||||||
|
//Log.warning("position " + this.position.getTransform());
|
||||||
transformationMatrix = this.position.getTransform().getOpenGLMatrix();
|
transformationMatrix = this.position.getTransform().getOpenGLMatrix();
|
||||||
} else if (this.playerPhysics != null) {
|
} else if (this.playerPhysics != null) {
|
||||||
|
//Log.warning("playerPosition " + this.playerPhysics.getTransform());
|
||||||
transformationMatrix = this.playerPhysics.getTransform().getOpenGLMatrix();
|
transformationMatrix = this.playerPhysics.getTransform().getOpenGLMatrix();
|
||||||
}
|
}
|
||||||
this.mesh.bindForRendering();
|
this.mesh.bindForRendering();
|
||||||
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
@ -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);
|
|
||||||
}
|
|
@ -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;
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user