[FIX] arbo
This commit is contained in:
parent
2f8051b97e
commit
cc5e4f1ee9
47
pom.xml
47
pom.xml
@ -1,14 +1,26 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>org.atriasoft</groupId>
|
<groupId>org.atriasoft</groupId>
|
||||||
<artifactId>ege</artifactId>
|
<artifactId>ege</artifactId>
|
||||||
<version>0.1.0</version>
|
<version>0.1.0</version>
|
||||||
<properties>
|
<licenses>
|
||||||
<maven.compiler.version>3.13.0</maven.compiler.version>
|
<license>
|
||||||
<maven.compiler.source>21</maven.compiler.source>
|
<name>Mozilla Public License 2.0</name>
|
||||||
<maven.compiler.target>21</maven.compiler.target>
|
<url>https://opensource.org/licenses/MPL-2.0</url>
|
||||||
<maven.dependency.version>3.1.1</maven.dependency.version>
|
<distribution>repo</distribution>
|
||||||
</properties>
|
</license>
|
||||||
|
</licenses>
|
||||||
|
<developers>
|
||||||
|
<developer>
|
||||||
|
<id>dev1</id>
|
||||||
|
<name>Edouard DUPIN</name>
|
||||||
|
<email>edouard.dupin@proton.me</email>
|
||||||
|
<roles>
|
||||||
|
<role>Lead Developer</role>
|
||||||
|
</roles>
|
||||||
|
</developer>
|
||||||
|
</developers>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
@ -46,13 +58,13 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.junit.jupiter</groupId>
|
<groupId>org.junit.jupiter</groupId>
|
||||||
<artifactId>junit-jupiter-api</artifactId>
|
<artifactId>junit-jupiter-api</artifactId>
|
||||||
<version>5.11.0-M2</version>
|
<version>5.11.0</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.junit.jupiter</groupId>
|
<groupId>org.junit.jupiter</groupId>
|
||||||
<artifactId>junit-jupiter-engine</artifactId>
|
<artifactId>junit-jupiter-engine</artifactId>
|
||||||
<version>5.11.0-M2</version>
|
<version>5.11.0</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -64,27 +76,26 @@
|
|||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<sourceDirectory>src</sourceDirectory>
|
<sourceDirectory>src/main</sourceDirectory>
|
||||||
<resources>
|
<resources>
|
||||||
<resource>
|
<resource>
|
||||||
<directory>${basedir}/src/resources</directory>
|
<directory>${basedir}/src/resources</directory>
|
||||||
</resource>
|
</resource>
|
||||||
</resources>
|
</resources>
|
||||||
<testSourceDirectory>test/src</testSourceDirectory>
|
<testSourceDirectory>src/test</testSourceDirectory>
|
||||||
<testResources>
|
<testResources>
|
||||||
<testResource>
|
<testResource>
|
||||||
<directory>${basedir}/test/resources</directory>
|
<directory>${basedir}/src/testResources</directory>
|
||||||
</testResource>
|
</testResource>
|
||||||
</testResources>
|
</testResources>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>${maven.compiler.version}</version>
|
<version>3.14.0</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>${maven.compiler.source}</source>
|
<source>21</source>
|
||||||
<target>${maven.compiler.target}</target>
|
<target>21</target>
|
||||||
<!--<encoding>${project.build.sourceEncoding}</encoding>-->
|
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<!-- Create the source bundle -->
|
<!-- Create the source bundle -->
|
||||||
@ -105,7 +116,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
<version>3.0.0-M5</version>
|
<version>3.2.5</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-assembly-plugin</artifactId>
|
<artifactId>maven-assembly-plugin</artifactId>
|
||||||
@ -124,7 +135,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-javadoc-plugin</artifactId>
|
<artifactId>maven-javadoc-plugin</artifactId>
|
||||||
<version>3.2.0</version>
|
<version>3.3.0</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<show>private</show>
|
<show>private</show>
|
||||||
<nohelp>true</nohelp>
|
<nohelp>true</nohelp>
|
||||||
@ -138,7 +149,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-javadoc-plugin</artifactId>
|
<artifactId>maven-javadoc-plugin</artifactId>
|
||||||
<version>3.2.0</version>
|
<version>3.3.0</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<show>public</show>
|
<show>public</show>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
@ -41,7 +41,7 @@
|
|||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<sourceDirectory>src</sourceDirectory>
|
<sourceDirectory>src/main</sourceDirectory>
|
||||||
<resources>
|
<resources>
|
||||||
<resource>
|
<resource>
|
||||||
<directory>${basedir}/src/resources</directory>
|
<directory>${basedir}/src/resources</directory>
|
||||||
|
@ -1,19 +0,0 @@
|
|||||||
/** Basic module interface.
|
|
||||||
*
|
|
||||||
* @author Edouard DUPIN */
|
|
||||||
|
|
||||||
open module sample.atriasoft.ege {
|
|
||||||
exports sample.atriasoft.ege.mapFactory;
|
|
||||||
exports sample.atriasoft.ege.mapFactory.model;
|
|
||||||
exports sample.atriasoft.ege.mapFactory.tools;
|
|
||||||
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 transitive org.atriasoft.ege;
|
|
||||||
requires transitive org.atriasoft.ewol;
|
|
||||||
requires transitive org.atriasoft.etk;
|
|
||||||
requires transitive org.atriasoft.gale; // for map factory
|
|
||||||
}
|
|
@ -1,332 +0,0 @@
|
|||||||
package sample.atriasoft.ege.collisiontest;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.atriasoft.ege.ControlCameraPlayer;
|
|
||||||
import org.atriasoft.ege.Engine;
|
|
||||||
import org.atriasoft.ege.Entity;
|
|
||||||
import org.atriasoft.ege.Environement;
|
|
||||||
import org.atriasoft.ege.GameStatus;
|
|
||||||
import org.atriasoft.ege.Light;
|
|
||||||
import org.atriasoft.ege.Material;
|
|
||||||
import org.atriasoft.ege.camera.Camera;
|
|
||||||
import org.atriasoft.ege.components.ComponentGravityStatic;
|
|
||||||
import org.atriasoft.ege.components.ComponentLightSun;
|
|
||||||
import org.atriasoft.ege.components.ComponentMaterial;
|
|
||||||
import org.atriasoft.ege.components.ComponentPhysics;
|
|
||||||
import org.atriasoft.ege.components.ComponentPlayer;
|
|
||||||
import org.atriasoft.ege.components.ComponentPosition;
|
|
||||||
import org.atriasoft.ege.components.ComponentPositionPlayer;
|
|
||||||
import org.atriasoft.ege.components.ComponentRenderColoredStaticMesh;
|
|
||||||
import org.atriasoft.ege.components.ComponentRenderTexturedStaticMesh;
|
|
||||||
import org.atriasoft.ege.components.ComponentStaticMesh;
|
|
||||||
import org.atriasoft.ege.components.ComponentTexture;
|
|
||||||
import org.atriasoft.ege.components.PhysicBodyType;
|
|
||||||
import org.atriasoft.ege.engines.EnginePhysics;
|
|
||||||
import org.atriasoft.ege.map.MapVoxel;
|
|
||||||
import org.atriasoft.ege.tools.MeshGenerator;
|
|
||||||
import org.atriasoft.etk.Color;
|
|
||||||
import org.atriasoft.etk.Uri;
|
|
||||||
import org.atriasoft.etk.math.Matrix4f;
|
|
||||||
import org.atriasoft.etk.math.Quaternion;
|
|
||||||
import org.atriasoft.etk.math.Transform3D;
|
|
||||||
import org.atriasoft.etk.math.Vector2f;
|
|
||||||
import org.atriasoft.etk.math.Vector3f;
|
|
||||||
import org.atriasoft.gale.Gale;
|
|
||||||
import org.atriasoft.gale.GaleApplication;
|
|
||||||
import org.atriasoft.gale.backend3d.OpenGL;
|
|
||||||
import org.atriasoft.gale.backend3d.OpenGL.Flag;
|
|
||||||
import org.atriasoft.gale.context.GaleContext;
|
|
||||||
import org.atriasoft.gale.key.KeyKeyboard;
|
|
||||||
import org.atriasoft.gale.key.KeySpecial;
|
|
||||||
import org.atriasoft.gale.key.KeyStatus;
|
|
||||||
import org.atriasoft.gale.key.KeyType;
|
|
||||||
import org.atriasoft.gale.resource.ResourceColored3DObject;
|
|
||||||
import org.atriasoft.phyligram.PhysicBox;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
public class CollisionTestApplication extends GaleApplication {
|
|
||||||
final static private Logger LOGGER = LoggerFactory.getLogger(CollisionTestApplication.class);
|
|
||||||
public static Vector3f box1HalfSize;
|
|
||||||
public static Vector3f box2HalfSize;
|
|
||||||
// public static ComponentPosition relativeTestPos;
|
|
||||||
// public static Box boxTest;
|
|
||||||
public static List<Vector3f> testPoints = new ArrayList<>();
|
|
||||||
public static List<Vector3f> testPointsBox = new ArrayList<>();
|
|
||||||
public static List<Boolean> testPointsCollide = new ArrayList<>();
|
|
||||||
public static Quaternion testQTransfert;
|
|
||||||
public static Vector3f testRpos;
|
|
||||||
private float angleLight = 0;
|
|
||||||
private Quaternion basicRotation = Quaternion.IDENTITY;
|
|
||||||
private Quaternion basicRotation2 = Quaternion.IDENTITY;
|
|
||||||
private ResourceColored3DObject debugDrawProperty;
|
|
||||||
private Environement env;
|
|
||||||
private ComponentPosition lightPosition;
|
|
||||||
private MapVoxel map;
|
|
||||||
private ComponentPlayer objectPlayer;
|
|
||||||
private ComponentPosition objectPosition;
|
|
||||||
private ControlCameraPlayer simpleControl;
|
|
||||||
|
|
||||||
public CollisionTestApplication() {}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreate(final GaleContext context) {
|
|
||||||
// set the system global max speed
|
|
||||||
//ComponentPhysics.globalMaxSpeed = 3;
|
|
||||||
Gale.getContext().grabPointerEvents(true, new Vector2f(0, 0));
|
|
||||||
this.env = new Environement();
|
|
||||||
setSize(new Vector2f(1500, 1500));
|
|
||||||
setTitle("Loxel sample");
|
|
||||||
this.map = new MapVoxel(this.env);
|
|
||||||
// this.env.addEngine(map);
|
|
||||||
// map.init();
|
|
||||||
|
|
||||||
// simple sun to have a global light ...
|
|
||||||
final Entity globalGravity = new Entity(this.env);
|
|
||||||
globalGravity.addComponent(new ComponentGravityStatic(new Vector3f(0, 0, -1)));
|
|
||||||
this.env.addEntity(globalGravity);
|
|
||||||
|
|
||||||
// simple sun to have a global light ...
|
|
||||||
final Entity sun = new Entity(this.env);
|
|
||||||
sun.addComponent(new ComponentPosition(new Transform3D(new Vector3f(1000, 1000, 1000))));
|
|
||||||
sun.addComponent(
|
|
||||||
new ComponentLightSun(new Light(new Color(0.4f, 0.4f, 0.4f), Vector3f.ZERO, new Vector3f(0.8f, 0, 0))));
|
|
||||||
this.env.addEntity(sun);
|
|
||||||
|
|
||||||
// add a cube to show where in the light ...
|
|
||||||
final Entity localLight = new Entity(this.env);
|
|
||||||
this.lightPosition = new ComponentPosition(new Transform3D(new Vector3f(-10, -10, 17)));
|
|
||||||
// localLight.addComponent(lightPosition);
|
|
||||||
// localLight.addComponent(new ComponentStaticMesh(new Uri("RES", "cube.obj")));
|
|
||||||
// localLight.addComponent(new ComponentTexture(new Uri("RES", "grass.png")));
|
|
||||||
// localLight.addComponent(new ComponentLight(new Light(new Vector3f(0,1,0), new Vector3f(0,0,0), new Vector3f(0.8f,0.03f,0.002f))));
|
|
||||||
// localLight.addComponent(new ComponentRenderTexturedStaticMesh(
|
|
||||||
// new Uri("DATA", "basic.vert"),
|
|
||||||
// new Uri("DATA", "basic.frag")));
|
|
||||||
// env.addEntity(localLight);
|
|
||||||
{
|
|
||||||
// this is the floor
|
|
||||||
final Entity localBox = new Entity(this.env);
|
|
||||||
Quaternion orientation = new Quaternion(0, 0, 0, 1);
|
|
||||||
orientation = orientation.normalize();
|
|
||||||
localBox.addComponent(new ComponentStaticMesh(new Uri("RES", "cube-one.obj")));
|
|
||||||
localBox.addComponent(new ComponentTexture(new Uri("DATA", "blocks/dirt.png", "loxelEngine")));
|
|
||||||
localBox.addComponent(new ComponentRenderTexturedStaticMesh(new Uri("DATA", "basic.vert", "loxelEngine"),
|
|
||||||
new Uri("DATA", "basic.frag", "loxelEngine")));
|
|
||||||
localBox.addComponent(new ComponentPosition(new Transform3D(Vector3f.ZERO, orientation)));
|
|
||||||
final ComponentPhysics physics2 = new ComponentPhysics(this.env);
|
|
||||||
physics2.setBodyType(PhysicBodyType.BODY_STATIC);
|
|
||||||
final PhysicBox box2 = new PhysicBox();
|
|
||||||
box2.setSize(new Vector3f(5.0f, 5.0f, 0.5f));
|
|
||||||
box2.setOrigin(Vector3f.ZERO);
|
|
||||||
box2.setMass(0);
|
|
||||||
physics2.addShape(box2);
|
|
||||||
localBox.addComponent(physics2);
|
|
||||||
this.env.addEntity(localBox);
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
{
|
|
||||||
// add a cube to test collision ...
|
|
||||||
final Entity localBox = new Entity(this.env);
|
|
||||||
localBox.addComponent(new ComponentStaticMesh(new Uri("RES", "cube-one.obj")));
|
|
||||||
localBox.addComponent(new ComponentTexture(new Uri("DATA", "blocks/clay.png", "loxelEngine")));
|
|
||||||
localBox.addComponent(new ComponentLight(new Light(new Vector3f(0, 1, 0), Vector3f.ZERO, new Vector3f(0.8f, 0.03f, 0.002f))));
|
|
||||||
localBox.addComponent(new ComponentRenderTexturedStaticMesh(new Uri("DATA", "basic.vert", "loxelEngine"), new Uri("DATA", "basic.frag", "loxelEngine")));
|
|
||||||
if (false) {
|
|
||||||
final ComponentPhysics physics2 = new ComponentPhysics(this.env);
|
|
||||||
//physics2.setTransform(new Transform3D(new Vector3f(0, 0, 0.90f)));
|
|
||||||
physics2.setTransform(new Transform3D(new Vector3f(0, 0, 1.20f)));
|
|
||||||
final Box box2 = new Box();
|
|
||||||
box2.setSize(new Vector3f(0.5f, 0.5f, 0.5f));
|
|
||||||
box2.setOrigin(Vector3f.ZERO);
|
|
||||||
box2.setMass(100);
|
|
||||||
physics2.addShape(box2);
|
|
||||||
localBox.addComponent(physics2);
|
|
||||||
} else {
|
|
||||||
localBox.addComponent(new ComponentPosition(new Transform3D(new Vector3f(0, -5, 13))));
|
|
||||||
}
|
|
||||||
this.env.addEntity(localBox);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
final Entity gird = new Entity(this.env);
|
|
||||||
gird.addComponent(new ComponentPosition(new Transform3D(Vector3f.ZERO)));
|
|
||||||
gird.addComponent(new ComponentStaticMesh(MeshGenerator.createGrid(5)));
|
|
||||||
gird.addComponent(new ComponentRenderColoredStaticMesh(new Uri("DATA", "wireColor.vert", "ege"),
|
|
||||||
new Uri("DATA", "wireColor.frag", "ege")));
|
|
||||||
this.env.addEntity(gird);
|
|
||||||
|
|
||||||
final Entity player = new Entity(this.env);
|
|
||||||
final Transform3D playerTransform = new Transform3D(new Vector3f(0, -5, 0));
|
|
||||||
this.objectPosition = new ComponentPositionPlayer();
|
|
||||||
player.addComponent(this.objectPosition);
|
|
||||||
this.objectPlayer = new ComponentPlayer();
|
|
||||||
player.addComponent(this.objectPlayer);
|
|
||||||
player.addComponent(new ComponentMaterial(new Material()));
|
|
||||||
//player.addComponent(new ComponentStaticMesh(new Uri("RES", "person.obj")));
|
|
||||||
player.addComponent(new ComponentStaticMesh(new Uri("RES", "person_-yfw_zup.obj")));
|
|
||||||
player.addComponent(new ComponentTexture(new Uri("RES", "playerTexture.png")));
|
|
||||||
//player.addComponent(new ComponentRenderTexturedMaterialsStaticMesh(new Uri("DATA", "basicMaterial.vert", "loxelEngine"), new Uri("DATA", "basicMaterial.frag", "loxelEngine"), (EngineLight) this.env.getEngine(EngineLight.ENGINE_NAME)));
|
|
||||||
this.env.addEntity(player);
|
|
||||||
final Camera mainView = new Camera();
|
|
||||||
this.env.addCamera("default", mainView);
|
|
||||||
mainView.setPitch((float) Math.PI * -0.25f);
|
|
||||||
mainView.setPosition(new Vector3f(0, -5, 5));
|
|
||||||
|
|
||||||
this.simpleControl = new ControlCameraPlayer(mainView, player);
|
|
||||||
this.env.addControlInterface(this.simpleControl);
|
|
||||||
|
|
||||||
// start the engine.
|
|
||||||
this.env.setPropertyStatus(GameStatus.gameStart);
|
|
||||||
|
|
||||||
this.basicRotation = Quaternion.fromEulerAngles(new Vector3f(0.005f, 0.005f, 0.01f));
|
|
||||||
this.basicRotation2 = Quaternion.fromEulerAngles(new Vector3f(0.003f, 0.01f, 0.001f));
|
|
||||||
|
|
||||||
final Engine tmpEngine = this.env.getEngine("physics");
|
|
||||||
if (tmpEngine != null) {
|
|
||||||
final EnginePhysics physicsEngine = (EnginePhysics) tmpEngine;
|
|
||||||
//Disable gravity for test ...
|
|
||||||
//physicsEngine.setGravity(new Vector3f(0.0f, 0.0f, -1.0f));
|
|
||||||
//physicsEngine.setGravity(new Vector3f(0.0f, 0.0f, -10.0f));
|
|
||||||
}
|
|
||||||
|
|
||||||
// ready to let Gale & Ege manage the display
|
|
||||||
LOGGER.info("==> Init APPL (END)");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDraw(final GaleContext context) {
|
|
||||||
//LOGGER.info("==> appl Draw ...");
|
|
||||||
final Vector2f size = getSize();
|
|
||||||
// Store openGl context.
|
|
||||||
OpenGL.push();
|
|
||||||
// set projection matrix:
|
|
||||||
final Matrix4f tmpProjection = Matrix4f.createMatrixPerspective(3.14f * 0.5f, getAspectRatio(), 0.1f, 50000);
|
|
||||||
//final Matrix4f tmpProjection = Matrix4f.createMatrixOrtho(20, 20, 15, 15, 0, 500000);
|
|
||||||
OpenGL.setMatrix(tmpProjection);
|
|
||||||
|
|
||||||
// set the basic openGL view port: (Draw in all the windows...)
|
|
||||||
OpenGL.setViewPort(Vector2f.ZERO, size);
|
|
||||||
|
|
||||||
// clear background
|
|
||||||
final Color bgColor = new Color(0.18f, 0.43f, 0.95f, 1.0f);
|
|
||||||
OpenGL.clearColor(bgColor);
|
|
||||||
// real clear request:
|
|
||||||
OpenGL.clear(OpenGL.ClearFlag.clearFlag_colorBuffer);
|
|
||||||
OpenGL.clear(OpenGL.ClearFlag.clearFlag_depthBuffer);
|
|
||||||
OpenGL.enable(Flag.flag_depthTest);
|
|
||||||
|
|
||||||
//LOGGER.info("==> appl Draw ...");
|
|
||||||
this.env.render(20, "default");
|
|
||||||
if (this.debugDrawProperty == null) {
|
|
||||||
this.debugDrawProperty = ResourceColored3DObject.create();
|
|
||||||
}
|
|
||||||
// now render the point test collision ...
|
|
||||||
for (int iii = 0; iii < CollisionTestApplication.testPoints.size(); iii++) {
|
|
||||||
final Vector3f elem = CollisionTestApplication.testPoints.get(iii);
|
|
||||||
final boolean collide = CollisionTestApplication.testPointsCollide.get(iii);
|
|
||||||
if (collide) {
|
|
||||||
this.debugDrawProperty.drawSquare(new Vector3f(0.1f, 0.1f, 0.1f),
|
|
||||||
Matrix4f.IDENTITY.multiply(
|
|
||||||
Matrix4f.createMatrixTranslate(new Vector3f(elem.x(), elem.y(), elem.z() + 14))),
|
|
||||||
new Color(1, 0, 0, 1));
|
|
||||||
} else if (iii == 0) {
|
|
||||||
this.debugDrawProperty.drawSquare(new Vector3f(0.05f, 0.05f, 0.05f),
|
|
||||||
Matrix4f.IDENTITY.multiply(
|
|
||||||
Matrix4f.createMatrixTranslate(new Vector3f(elem.x(), elem.y(), elem.z() + 14))),
|
|
||||||
new Color(0, 1, 0, 1));
|
|
||||||
} else if (iii == 7) {
|
|
||||||
this.debugDrawProperty.drawSquare(new Vector3f(0.05f, 0.05f, 0.05f),
|
|
||||||
Matrix4f.IDENTITY.multiply(
|
|
||||||
Matrix4f.createMatrixTranslate(new Vector3f(elem.x(), elem.y(), elem.z() + 14))),
|
|
||||||
new Color(1, 1, 0, 1));
|
|
||||||
} else {
|
|
||||||
this.debugDrawProperty.drawSquare(new Vector3f(0.1f, 0.1f, 0.1f),
|
|
||||||
Matrix4f.IDENTITY.multiply(
|
|
||||||
Matrix4f.createMatrixTranslate(new Vector3f(elem.x(), elem.y(), elem.z() + 14))),
|
|
||||||
new Color(1, 1, 1, 1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (int iii = 0; iii < CollisionTestApplication.testPointsBox.size(); iii++) {
|
|
||||||
final Vector3f elem = CollisionTestApplication.testPointsBox.get(iii);
|
|
||||||
if (iii == 0) {
|
|
||||||
this.debugDrawProperty.drawSquare(new Vector3f(0.05f, 0.05f, 0.05f),
|
|
||||||
Matrix4f.IDENTITY.multiply(
|
|
||||||
Matrix4f.createMatrixTranslate(new Vector3f(elem.x(), elem.y(), elem.z() + 14))),
|
|
||||||
new Color(0, 1, 0, 1));
|
|
||||||
} else if (iii == 7) {
|
|
||||||
this.debugDrawProperty.drawSquare(new Vector3f(0.05f, 0.05f, 0.05f),
|
|
||||||
Matrix4f.IDENTITY.multiply(
|
|
||||||
Matrix4f.createMatrixTranslate(new Vector3f(elem.x(), elem.y(), elem.z() + 14))),
|
|
||||||
new Color(1, 1, 0, 1));
|
|
||||||
} else {
|
|
||||||
this.debugDrawProperty.drawSquare(new Vector3f(0.1f, 0.1f, 0.1f),
|
|
||||||
Matrix4f.IDENTITY.multiply(
|
|
||||||
Matrix4f.createMatrixTranslate(new Vector3f(elem.x(), elem.y(), elem.z() + 14))),
|
|
||||||
new Color(0, 0, 1, 1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (CollisionTestApplication.testRpos != null) {
|
|
||||||
//debugDrawProperty.drawSquare(box2HalfSize, testQTransfert.getMatrix4().multiplyNew(Matrix4f.createMatrixTranslate(new Vector3f(testRpos.x,testRpos.y,testRpos.z+14))), new Color(0,1,0,0.5f));
|
|
||||||
//Matrix4f transformation = Matrix4f.createMatrixTranslate(new Vector3f(testRpos.x,testRpos.y,testRpos.z)).multiply(testQTransfert.getMatrix4()).multiply(Matrix4f.createMatrixTranslate(new Vector3f(0,0,14)));
|
|
||||||
//Matrix4f transformation = testQTransfert.getMatrix4().multiply(Matrix4f.createMatrixTranslate(new Vector3f(testRpos.x,testRpos.y,testRpos.z))).multiply(Matrix4f.createMatrixTranslate(new Vector3f(0,0,14)));
|
|
||||||
//Matrix4f transformation = testQTransfert.getMatrix4().multiply(Matrix4f.createMatrixTranslate(new Vector3f(testRpos.x,testRpos.y,testRpos.z))).multiply(Matrix4f.createMatrixTranslate(new Vector3f(0,0,14)));
|
|
||||||
final Matrix4f transformation = Matrix4f
|
|
||||||
.createMatrixTranslate(new Vector3f(CollisionTestApplication.testRpos.x(),
|
|
||||||
CollisionTestApplication.testRpos.y(), CollisionTestApplication.testRpos.z()))
|
|
||||||
.multiply(Matrix4f.createMatrixTranslate(new Vector3f(0, 0, 14)))
|
|
||||||
.multiply(CollisionTestApplication.testQTransfert.getMatrix4());
|
|
||||||
// OK sans la box1 orientation ...
|
|
||||||
//Matrix4f transformation = Matrix4f.createMatrixTranslate(new Vector3f(testRpos.x,testRpos.y,testRpos.z)).multiply(testQTransfert.getMatrix4()).multiply(Matrix4f.createMatrixTranslate(new Vector3f(0,0,14)));
|
|
||||||
//Matrix4f transformation = Matrix4f.createMatrixTranslate(new Vector3f(testRpos.x,testRpos.y,testRpos.z)).multiply(testQTransfert.getMatrix4()).multiply(Matrix4f.createMatrixTranslate(new Vector3f(0,0,14)));
|
|
||||||
this.debugDrawProperty.drawSquare(CollisionTestApplication.box2HalfSize, transformation,
|
|
||||||
new Color(0, 1, 0, 0.5f));
|
|
||||||
this.debugDrawProperty.drawSquare(CollisionTestApplication.box1HalfSize,
|
|
||||||
Matrix4f.createMatrixTranslate(new Vector3f(0, 0, 14)), new Color(0, 0, 1, 0.5f));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Restore context of matrix
|
|
||||||
OpenGL.pop();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onKeyboard(
|
|
||||||
final KeySpecial special,
|
|
||||||
final KeyKeyboard type,
|
|
||||||
final Character value,
|
|
||||||
final KeyStatus state) {
|
|
||||||
if (type == KeyKeyboard.F1) {
|
|
||||||
Gale.getContext().grabPointerEvents(false, new Vector2f(0, 0));
|
|
||||||
}
|
|
||||||
if (type == KeyKeyboard.F2) {
|
|
||||||
Gale.getContext().grabPointerEvents(true, new Vector2f(0, 0));
|
|
||||||
}
|
|
||||||
if (type == KeyKeyboard.F12) {
|
|
||||||
Gale.getContext().setFullScreen(!Gale.getContext().getFullScreen());
|
|
||||||
}
|
|
||||||
this.env.onKeyboard(special, type, value, state);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPointer(
|
|
||||||
final KeySpecial special,
|
|
||||||
final KeyType type,
|
|
||||||
final int pointerID,
|
|
||||||
final Vector2f pos,
|
|
||||||
final KeyStatus state) {
|
|
||||||
this.env.onPointer(special, type, pointerID, new Vector3f(pos.x(), pos.y(), 0), state);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onRegenerateDisplay(final GaleContext context) {
|
|
||||||
//LOGGER.trace("Regenerate Gale Application");
|
|
||||||
this.angleLight += 0.01;
|
|
||||||
final Vector3f posss = this.lightPosition.getTransform().getPosition().add(new Vector3f(
|
|
||||||
5 + (float) Math.cos(this.angleLight) * 7.0f, 5 + (float) Math.sin(this.angleLight) * 7.0f, 0));
|
|
||||||
this.lightPosition.setTransform(this.lightPosition.getTransform().withPosition(posss));
|
|
||||||
this.env.periodicCall();
|
|
||||||
markDrawingIsNeeded();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
package sample.atriasoft.ege.collisiontest;
|
|
||||||
|
|
||||||
import org.atriasoft.ege.Ege;
|
|
||||||
import org.atriasoft.etk.Uri;
|
|
||||||
import org.atriasoft.gale.Gale;
|
|
||||||
|
|
||||||
public class MainCollisionTest {
|
|
||||||
public static void main(final String[] args) {
|
|
||||||
Gale.init();
|
|
||||||
Ege.init();
|
|
||||||
Uri.setGroup("DATA", "data/");
|
|
||||||
Uri.setGroup("RES", "res");
|
|
||||||
Uri.addLibrary("loxelEngine", MainCollisionTest.class, "resources/testDataLoxelEngine");
|
|
||||||
Uri.setApplication(MainCollisionTest.class, "resources");
|
|
||||||
Gale.run(new CollisionTestApplication(), args);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,196 +0,0 @@
|
|||||||
package sample.atriasoft.ege.lightTest;
|
|
||||||
|
|
||||||
import org.atriasoft.ege.ControlCameraSimple;
|
|
||||||
import org.atriasoft.ege.Entity;
|
|
||||||
import org.atriasoft.ege.Environement;
|
|
||||||
import org.atriasoft.ege.GameStatus;
|
|
||||||
import org.atriasoft.ege.Light;
|
|
||||||
import org.atriasoft.ege.Material;
|
|
||||||
import org.atriasoft.ege.camera.Camera;
|
|
||||||
import org.atriasoft.ege.components.ComponentLight;
|
|
||||||
import org.atriasoft.ege.components.ComponentLightSun;
|
|
||||||
import org.atriasoft.ege.components.ComponentMaterial;
|
|
||||||
import org.atriasoft.ege.components.ComponentPosition;
|
|
||||||
import org.atriasoft.ege.components.ComponentRenderColoredStaticMesh;
|
|
||||||
import org.atriasoft.ege.components.ComponentRenderTexturedMaterialsStaticMesh;
|
|
||||||
import org.atriasoft.ege.components.ComponentRenderTexturedStaticMesh;
|
|
||||||
import org.atriasoft.ege.components.ComponentStaticMesh;
|
|
||||||
import org.atriasoft.ege.components.ComponentTexture;
|
|
||||||
import org.atriasoft.ege.engines.EngineLight;
|
|
||||||
import org.atriasoft.ege.tools.MeshGenerator;
|
|
||||||
import org.atriasoft.etk.Color;
|
|
||||||
import org.atriasoft.etk.Uri;
|
|
||||||
import org.atriasoft.etk.math.Matrix4f;
|
|
||||||
import org.atriasoft.etk.math.Quaternion;
|
|
||||||
import org.atriasoft.etk.math.Transform3D;
|
|
||||||
import org.atriasoft.etk.math.Vector2f;
|
|
||||||
import org.atriasoft.etk.math.Vector3f;
|
|
||||||
import org.atriasoft.gale.GaleApplication;
|
|
||||||
import org.atriasoft.gale.backend3d.OpenGL;
|
|
||||||
import org.atriasoft.gale.backend3d.OpenGL.Flag;
|
|
||||||
import org.atriasoft.gale.context.GaleContext;
|
|
||||||
import org.atriasoft.gale.key.KeyKeyboard;
|
|
||||||
import org.atriasoft.gale.key.KeySpecial;
|
|
||||||
import org.atriasoft.gale.key.KeyStatus;
|
|
||||||
import org.atriasoft.gale.key.KeyType;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
public class LightTestApplication extends GaleApplication {
|
|
||||||
final static private Logger LOGGER = LoggerFactory.getLogger(LightTestApplication.class);
|
|
||||||
private float angleLight = 0;
|
|
||||||
private Quaternion basicRotation = Quaternion.IDENTITY;
|
|
||||||
private Quaternion basicRotation2 = Quaternion.IDENTITY;
|
|
||||||
private Environement env;
|
|
||||||
private ComponentPosition lightPosition;
|
|
||||||
private Material materialCube;
|
|
||||||
private ComponentPosition objectPosition;
|
|
||||||
private ControlCameraSimple simpleControl;
|
|
||||||
|
|
||||||
public LightTestApplication() {}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreate(final GaleContext context) {
|
|
||||||
try {
|
|
||||||
Thread.sleep(1000);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
this.env = new Environement();
|
|
||||||
setSize(new Vector2f(800, 600));
|
|
||||||
setTitle("Low Poly sample");
|
|
||||||
|
|
||||||
// simple sun to have a global light ...
|
|
||||||
final Entity sun = new Entity(this.env);
|
|
||||||
sun.addComponent(new ComponentPosition(new Transform3D(new Vector3f(1000, 1000, 1000))));
|
|
||||||
sun.addComponent(new ComponentLightSun(
|
|
||||||
new Light(new Color(0.4f, 0.4f, 0.4f), new Vector3f(0, 0, 0), new Vector3f(0.8f, 0, 0))));
|
|
||||||
this.env.addEntity(sun);
|
|
||||||
|
|
||||||
// add a cube to show where in the light ...
|
|
||||||
final Entity localLight = new Entity(this.env);
|
|
||||||
this.lightPosition = new ComponentPosition(new Transform3D(new Vector3f(-10, -10, 1)));
|
|
||||||
localLight.addComponent(this.lightPosition);
|
|
||||||
localLight.addComponent(new ComponentStaticMesh(new Uri("RES", "cube-one.obj")));
|
|
||||||
localLight.addComponent(new ComponentTexture(new Uri("RES", "grass.png")));
|
|
||||||
localLight.addComponent(new ComponentLight(
|
|
||||||
new Light(new Color(0.0f, 2.0f, 0.0f), new Vector3f(0, 0, 0), new Vector3f(0.8f, 0.01f, 0.002f))));
|
|
||||||
localLight.addComponent(new ComponentRenderTexturedStaticMesh(new Uri("DATA", "basic.vert", "loxelEngine"),
|
|
||||||
new Uri("DATA", "basic.frag", "loxelEngine")));
|
|
||||||
this.env.addEntity(localLight);
|
|
||||||
|
|
||||||
final Entity gird = new Entity(this.env);
|
|
||||||
gird.addComponent(new ComponentPosition(new Transform3D(new Vector3f(0, 0, 0))));
|
|
||||||
gird.addComponent(new ComponentStaticMesh(MeshGenerator.createGrid(5)));
|
|
||||||
gird.addComponent(new ComponentRenderColoredStaticMesh(new Uri("DATA", "wireColor.vert", "ege"),
|
|
||||||
new Uri("DATA", "wireColor.frag", "ege")));
|
|
||||||
this.env.addEntity(gird);
|
|
||||||
|
|
||||||
final Entity basicTree = new Entity(this.env);
|
|
||||||
this.objectPosition = new ComponentPosition(new Transform3D(new Vector3f(0, 0, 0)));
|
|
||||||
basicTree.addComponent(this.objectPosition);
|
|
||||||
this.materialCube = new Material();
|
|
||||||
basicTree.addComponent(new ComponentMaterial(this.materialCube));
|
|
||||||
basicTree.addComponent(new ComponentStaticMesh(new Uri("RES", "cube.obj")));
|
|
||||||
basicTree.addComponent(new ComponentTexture(new Uri("RES", "mud.png")));
|
|
||||||
//basicTree.addComponent(new ComponentRenderTexturedStaticMesh(new Uri("DATA", "basic.vert", "loxelEngine"), new Uri("DATA", "basic.frag", "loxelEngine")));
|
|
||||||
basicTree.addComponent(
|
|
||||||
new ComponentRenderTexturedMaterialsStaticMesh(new Uri("DATA", "basicMaterial.vert", "loxelEngine"),
|
|
||||||
new Uri("DATA", "basicMaterial.frag", "loxelEngine"),
|
|
||||||
(EngineLight) this.env.getEngine(EngineLight.ENGINE_NAME)));
|
|
||||||
this.env.addEntity(basicTree);
|
|
||||||
|
|
||||||
for (int xxx = -10; xxx < 10; xxx++) {
|
|
||||||
for (int yyy = -10; yyy < 10; yyy++) {
|
|
||||||
final Entity superGrass = new Entity(this.env);
|
|
||||||
superGrass.addComponent(new ComponentPosition(new Transform3D(new Vector3f(xxx, yyy, -1))));
|
|
||||||
superGrass.addComponent(new ComponentMaterial(new Material()));
|
|
||||||
superGrass.addComponent(new ComponentStaticMesh(new Uri("RES", "cube-one.obj")));
|
|
||||||
superGrass.addComponent(new ComponentTexture(new Uri("RES", "dirt.png")));
|
|
||||||
superGrass.addComponent(new ComponentRenderTexturedMaterialsStaticMesh(
|
|
||||||
new Uri("DATA", "basicMaterial.vert", "loxelEngine"),
|
|
||||||
new Uri("DATA", "basicMaterial.frag", "loxelEngine"),
|
|
||||||
(EngineLight) this.env.getEngine(EngineLight.ENGINE_NAME)));
|
|
||||||
this.env.addEntity(superGrass);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final Camera mainView = new Camera();
|
|
||||||
this.env.addCamera("default", mainView);
|
|
||||||
mainView.setPitch((float) Math.PI * -0.25f);
|
|
||||||
mainView.setPosition(new Vector3f(0, -5, 5));
|
|
||||||
|
|
||||||
this.simpleControl = new ControlCameraSimple(mainView);
|
|
||||||
this.env.addControlInterface(this.simpleControl);
|
|
||||||
|
|
||||||
// start the engine.
|
|
||||||
this.env.setPropertyStatus(GameStatus.gameStart);
|
|
||||||
|
|
||||||
this.basicRotation = Quaternion.fromEulerAngles(new Vector3f(0.005f, 0.005f, 0.01f));
|
|
||||||
this.basicRotation2 = Quaternion.fromEulerAngles(new Vector3f(0.003f, 0.01f, 0.001f));
|
|
||||||
// ready to let Gale & Ege manage the display
|
|
||||||
LOGGER.info("==> Init APPL (END)");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDraw(final GaleContext context) {
|
|
||||||
//LOGGER.info("==> appl Draw ...");
|
|
||||||
final Vector2f size = getSize();
|
|
||||||
// Store openGl context.
|
|
||||||
OpenGL.push();
|
|
||||||
// set projection matrix:
|
|
||||||
final Matrix4f tmpProjection = Matrix4f.createMatrixPerspective(3.14f * 0.5f, getAspectRatio(), 0.1f, 50000);
|
|
||||||
OpenGL.setMatrix(tmpProjection);
|
|
||||||
|
|
||||||
// set the basic openGL view port: (Draw in all the windows...)
|
|
||||||
OpenGL.setViewPort(new Vector2f(0, 0), size);
|
|
||||||
|
|
||||||
// clear background
|
|
||||||
final Color bgColor = new Color(0.0f, 1.0f, 0.0f, 1.0f);
|
|
||||||
OpenGL.clearColor(bgColor);
|
|
||||||
// real clear request:
|
|
||||||
OpenGL.clear(OpenGL.ClearFlag.clearFlag_colorBuffer);
|
|
||||||
OpenGL.clear(OpenGL.ClearFlag.clearFlag_depthBuffer);
|
|
||||||
OpenGL.enable(Flag.flag_depthTest);
|
|
||||||
|
|
||||||
this.env.render(20, "default");
|
|
||||||
|
|
||||||
// Restore context of matrix
|
|
||||||
OpenGL.pop();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onKeyboard(
|
|
||||||
final KeySpecial special,
|
|
||||||
final KeyKeyboard type,
|
|
||||||
final Character value,
|
|
||||||
final KeyStatus state) {
|
|
||||||
this.env.onKeyboard(special, type, value, state);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPointer(
|
|
||||||
final KeySpecial special,
|
|
||||||
final KeyType type,
|
|
||||||
final int pointerID,
|
|
||||||
final Vector2f pos,
|
|
||||||
final KeyStatus state) {
|
|
||||||
this.env.onPointer(special, type, pointerID, new Vector3f(pos.x(), pos.y(), 0), state);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onRegenerateDisplay(final GaleContext context) {
|
|
||||||
//LOGGER.trace("Regenerate Gale Application");
|
|
||||||
//materialCube.setAmbientFactor(new Vector3f(1.0f,1.0f,1.0f));
|
|
||||||
// apply a little rotation to show the element move
|
|
||||||
//objectPosition.getTransform().applyRotation(basicRotation);
|
|
||||||
//objectPosition.getTransform().applyRotation(basicRotation2);
|
|
||||||
this.angleLight += 0.01;
|
|
||||||
this.lightPosition.setTransform(this.lightPosition.getTransform().withPosition(
|
|
||||||
new Vector3f((float) Math.cos(this.angleLight) * 7.0f, (float) Math.sin(this.angleLight) * 7.0f,
|
|
||||||
this.lightPosition.getTransform().getPosition().z())));
|
|
||||||
this.env.periodicCall();
|
|
||||||
markDrawingIsNeeded();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,19 +0,0 @@
|
|||||||
package sample.atriasoft.ege.lightTest;
|
|
||||||
|
|
||||||
import org.atriasoft.ege.Ege;
|
|
||||||
import org.atriasoft.etk.Uri;
|
|
||||||
import org.atriasoft.gale.Gale;
|
|
||||||
|
|
||||||
import sample.atriasoft.ege.collisiontest.MainCollisionTest;
|
|
||||||
|
|
||||||
public class MainLightTest {
|
|
||||||
public static void main(final String[] args) {
|
|
||||||
Gale.init();
|
|
||||||
Ege.init();
|
|
||||||
Uri.setGroup("DATA", "data");
|
|
||||||
Uri.setGroup("RES", "res");
|
|
||||||
Uri.addLibrary("loxelEngine", MainCollisionTest.class, "resources/testDataLoxelEngine");
|
|
||||||
Uri.setApplication(MainCollisionTest.class, "resources");
|
|
||||||
Gale.run(new LightTestApplication(), args);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,207 +0,0 @@
|
|||||||
package sample.atriasoft.ege.lowPoly;
|
|
||||||
|
|
||||||
import org.atriasoft.ege.ControlCameraSimple;
|
|
||||||
import org.atriasoft.ege.Entity;
|
|
||||||
import org.atriasoft.ege.Environement;
|
|
||||||
import org.atriasoft.ege.GameStatus;
|
|
||||||
import org.atriasoft.ege.Light;
|
|
||||||
import org.atriasoft.ege.Material;
|
|
||||||
import org.atriasoft.ege.camera.Camera;
|
|
||||||
import org.atriasoft.ege.components.ComponentLight;
|
|
||||||
import org.atriasoft.ege.components.ComponentLightSun;
|
|
||||||
import org.atriasoft.ege.components.ComponentMesh;
|
|
||||||
import org.atriasoft.ege.components.ComponentPosition;
|
|
||||||
import org.atriasoft.ege.components.ComponentRenderColoredStaticMesh;
|
|
||||||
import org.atriasoft.ege.components.ComponentRenderMeshPalette;
|
|
||||||
import org.atriasoft.ege.components.ComponentRenderTexturedStaticMesh;
|
|
||||||
import org.atriasoft.ege.components.ComponentStaticMesh;
|
|
||||||
import org.atriasoft.ege.components.ComponentTexture;
|
|
||||||
import org.atriasoft.ege.components.ComponentTexturePalette;
|
|
||||||
import org.atriasoft.ege.engines.EngineLight;
|
|
||||||
import org.atriasoft.ege.tools.MeshGenerator;
|
|
||||||
import org.atriasoft.etk.Color;
|
|
||||||
import org.atriasoft.etk.Uri;
|
|
||||||
import org.atriasoft.etk.math.Matrix4f;
|
|
||||||
import org.atriasoft.etk.math.Quaternion;
|
|
||||||
import org.atriasoft.etk.math.Transform3D;
|
|
||||||
import org.atriasoft.etk.math.Vector2f;
|
|
||||||
import org.atriasoft.etk.math.Vector3f;
|
|
||||||
import org.atriasoft.gale.GaleApplication;
|
|
||||||
import org.atriasoft.gale.backend3d.OpenGL;
|
|
||||||
import org.atriasoft.gale.backend3d.OpenGL.Flag;
|
|
||||||
import org.atriasoft.gale.context.GaleContext;
|
|
||||||
import org.atriasoft.gale.key.KeyKeyboard;
|
|
||||||
import org.atriasoft.gale.key.KeySpecial;
|
|
||||||
import org.atriasoft.gale.key.KeyStatus;
|
|
||||||
import org.atriasoft.gale.key.KeyType;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
public class LowPolyApplication extends GaleApplication {
|
|
||||||
final static private Logger LOGGER = LoggerFactory.getLogger(LowPolyApplication.class);
|
|
||||||
private float angleLight = 0;
|
|
||||||
private Quaternion basicRotation = Quaternion.IDENTITY;
|
|
||||||
private Quaternion basicRotation2 = Quaternion.IDENTITY;
|
|
||||||
private Environement env;
|
|
||||||
private ComponentPosition lightPosition;
|
|
||||||
private Material materialCube;
|
|
||||||
private ComponentPosition objectPosition;
|
|
||||||
private ControlCameraSimple simpleControl;
|
|
||||||
|
|
||||||
public LowPolyApplication() {}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreate(final GaleContext context) {
|
|
||||||
try {
|
|
||||||
Thread.sleep(1000);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
this.env = new Environement();
|
|
||||||
setSize(new Vector2f(800, 600));
|
|
||||||
setTitle("Low Poly sample");
|
|
||||||
|
|
||||||
// simple sun to have a global light ...
|
|
||||||
final Entity sun = new Entity(this.env);
|
|
||||||
sun.addComponent(new ComponentPosition(new Transform3D(new Vector3f(1000, 1000, 1000))));
|
|
||||||
sun.addComponent(new ComponentLightSun(
|
|
||||||
new Light(new Color(1.0f, 1.0f, 1.0f), new Vector3f(0, 0, 0), new Vector3f(1.0f, 0, 0))));
|
|
||||||
this.env.addEntity(sun);
|
|
||||||
|
|
||||||
// add a cube to show where in the light ...
|
|
||||||
final Entity localLight = new Entity(this.env);
|
|
||||||
this.lightPosition = new ComponentPosition(new Transform3D(new Vector3f(-10, -10, 1)));
|
|
||||||
localLight.addComponent(this.lightPosition);
|
|
||||||
localLight.addComponent(new ComponentStaticMesh(new Uri("DATA", "cube-one.obj")));
|
|
||||||
localLight.addComponent(new ComponentTexture(new Uri("DATA", "grass.png")));
|
|
||||||
localLight.addComponent(new ComponentLight(
|
|
||||||
new Light(new Color(0.0f, 0.0f, 2.0f), new Vector3f(0, 0, 0), new Vector3f(0.8f, 0.01f, 0.002f))));
|
|
||||||
localLight.addComponent(new ComponentRenderTexturedStaticMesh(new Uri("DATA", "basic.vert", "loxelEngine"),
|
|
||||||
new Uri("DATA", "basic.frag", "loxelEngine")));
|
|
||||||
this.env.addEntity(localLight);
|
|
||||||
|
|
||||||
// Simple Gird
|
|
||||||
final Entity gird = new Entity(this.env);
|
|
||||||
gird.addComponent(new ComponentPosition(new Transform3D(new Vector3f(0, 0, 0))));
|
|
||||||
gird.addComponent(new ComponentStaticMesh(MeshGenerator.createGrid(5)));
|
|
||||||
gird.addComponent(new ComponentRenderColoredStaticMesh(new Uri("DATA", "wireColor.vert", "ege"),
|
|
||||||
new Uri("DATA", "wireColor.frag", "ege")));
|
|
||||||
this.env.addEntity(gird);
|
|
||||||
|
|
||||||
// test entity
|
|
||||||
Entity basicTree = new Entity(this.env);
|
|
||||||
this.objectPosition = new ComponentPosition(new Transform3D(new Vector3f(0, 0, 0)));
|
|
||||||
basicTree.addComponent(this.objectPosition);
|
|
||||||
//this.materialCube = new Material();
|
|
||||||
//basicTree.addComponent(new ComponentMaterial(this.materialCube));
|
|
||||||
basicTree.addComponent(new ComponentMesh(new Uri("DATA", "tree1.emf")));
|
|
||||||
basicTree.addComponent(new ComponentTexturePalette(new Uri("DATA", "palette_1.json")));
|
|
||||||
//basicTree.addComponent(new ComponentRenderTexturedStaticMesh(new Uri("DATA", "basic.vert", "loxelEngine"), new Uri("DATA", "basic.frag", "loxelEngine")));
|
|
||||||
basicTree.addComponent(new ComponentRenderMeshPalette(new Uri("DATA", "basicPalette.vert"),
|
|
||||||
new Uri("DATA", "basicPalette.frag"), (EngineLight) this.env.getEngine(EngineLight.ENGINE_NAME)));
|
|
||||||
this.env.addEntity(basicTree);
|
|
||||||
|
|
||||||
basicTree = new Entity(this.env);
|
|
||||||
this.objectPosition = new ComponentPosition(new Transform3D(new Vector3f(3, 2, 0)));
|
|
||||||
basicTree.addComponent(this.objectPosition);
|
|
||||||
//this.materialCube = new Material();
|
|
||||||
//basicTree.addComponent(new ComponentMaterial(this.materialCube));
|
|
||||||
basicTree.addComponent(new ComponentMesh(new Uri("DATA", "tree2.emf")));
|
|
||||||
basicTree.addComponent(new ComponentTexturePalette(new Uri("DATA", "palette_1.json")));
|
|
||||||
//basicTree.addComponent(new ComponentRenderTexturedStaticMesh(new Uri("DATA", "basic.vert", "loxelEngine"), new Uri("DATA", "basic.frag", "loxelEngine")));
|
|
||||||
basicTree.addComponent(new ComponentRenderMeshPalette(new Uri("DATA", "basicPalette.vert"),
|
|
||||||
new Uri("DATA", "basicPalette.frag"), (EngineLight) this.env.getEngine(EngineLight.ENGINE_NAME)));
|
|
||||||
this.env.addEntity(basicTree);
|
|
||||||
|
|
||||||
// for (int xxx = -10; xxx < 10; xxx++) {
|
|
||||||
// for (int yyy = -10; yyy < 10; yyy++) {
|
|
||||||
// final Entity superGrass = new Entity(this.env);
|
|
||||||
// superGrass.addComponent(new ComponentPosition(new Transform3D(new Vector3f(xxx, yyy, -1))));
|
|
||||||
// superGrass.addComponent(new ComponentMaterial(new Material()));
|
|
||||||
// superGrass.addComponent(new ComponentStaticMesh(new Uri("RES", "cube-one.obj")));
|
|
||||||
// superGrass.addComponent(new ComponentTexture(new Uri("RES", "dirt.png")));
|
|
||||||
// superGrass.addComponent(new ComponentRenderTexturedMaterialsStaticMesh(new Uri("DATA", "basicMaterial.vert", "loxelEngine"), new Uri("DATA", "basicMaterial.frag", "loxelEngine"),
|
|
||||||
// (EngineLight) this.env.getEngine(EngineLight.ENGINE_NAME)));
|
|
||||||
// this.env.addEntity(superGrass);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
final Camera mainView = new Camera();
|
|
||||||
this.env.addCamera("default", mainView);
|
|
||||||
mainView.setPitch((float) Math.PI * -0.25f);
|
|
||||||
mainView.setPosition(new Vector3f(0, -5, 5));
|
|
||||||
|
|
||||||
this.simpleControl = new ControlCameraSimple(mainView);
|
|
||||||
this.env.addControlInterface(this.simpleControl);
|
|
||||||
|
|
||||||
// start the engine.
|
|
||||||
this.env.setPropertyStatus(GameStatus.gameStart);
|
|
||||||
|
|
||||||
this.basicRotation = Quaternion.fromEulerAngles(new Vector3f(0.005f, 0.005f, 0.01f));
|
|
||||||
this.basicRotation2 = Quaternion.fromEulerAngles(new Vector3f(0.003f, 0.01f, 0.001f));
|
|
||||||
// ready to let Gale & Ege manage the display
|
|
||||||
LOGGER.info("==> Init APPL (END)");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDraw(final GaleContext context) {
|
|
||||||
//LOGGER.info("==> appl Draw ...");
|
|
||||||
final Vector2f size = getSize();
|
|
||||||
// Store openGl context.
|
|
||||||
OpenGL.push();
|
|
||||||
// set projection matrix:
|
|
||||||
final Matrix4f tmpProjection = Matrix4f.createMatrixPerspective(3.14f * 0.5f, getAspectRatio(), 0.1f, 50000);
|
|
||||||
OpenGL.setMatrix(tmpProjection);
|
|
||||||
|
|
||||||
// set the basic openGL view port: (Draw in all the windows...)
|
|
||||||
OpenGL.setViewPort(new Vector2f(0, 0), size);
|
|
||||||
|
|
||||||
// clear background
|
|
||||||
final Color bgColor = new Color(0.0f, 1.0f, 0.0f, 1.0f);
|
|
||||||
OpenGL.clearColor(bgColor);
|
|
||||||
// real clear request:
|
|
||||||
OpenGL.clear(OpenGL.ClearFlag.clearFlag_colorBuffer);
|
|
||||||
OpenGL.clear(OpenGL.ClearFlag.clearFlag_depthBuffer);
|
|
||||||
OpenGL.enable(Flag.flag_depthTest);
|
|
||||||
|
|
||||||
this.env.render(20, "default");
|
|
||||||
|
|
||||||
// Restore context of matrix
|
|
||||||
OpenGL.pop();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onKeyboard(
|
|
||||||
final KeySpecial special,
|
|
||||||
final KeyKeyboard type,
|
|
||||||
final Character value,
|
|
||||||
final KeyStatus state) {
|
|
||||||
this.env.onKeyboard(special, type, value, state);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPointer(
|
|
||||||
final KeySpecial special,
|
|
||||||
final KeyType type,
|
|
||||||
final int pointerID,
|
|
||||||
final Vector2f pos,
|
|
||||||
final KeyStatus state) {
|
|
||||||
this.env.onPointer(special, type, pointerID, new Vector3f(pos.x(), pos.y(), 0), state);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onRegenerateDisplay(final GaleContext context) {
|
|
||||||
//LOGGER.trace("Regenerate Gale Application");
|
|
||||||
//materialCube.setAmbientFactor(new Vector3f(1.0f,1.0f,1.0f));
|
|
||||||
// apply a little rotation to show the element move
|
|
||||||
//objectPosition.getTransform().applyRotation(basicRotation);
|
|
||||||
//objectPosition.getTransform().applyRotation(basicRotation2);
|
|
||||||
this.angleLight += 0.01;
|
|
||||||
this.lightPosition.setTransform(this.lightPosition.getTransform().withPosition(
|
|
||||||
new Vector3f((float) Math.cos(this.angleLight) * 7.0f, (float) Math.sin(this.angleLight) * 7.0f,
|
|
||||||
this.lightPosition.getTransform().getPosition().z())));
|
|
||||||
this.env.periodicCall();
|
|
||||||
markDrawingIsNeeded();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,19 +0,0 @@
|
|||||||
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 MainLowPoly {
|
|
||||||
public static void main(final String[] args) {
|
|
||||||
Gale.init();
|
|
||||||
Ege.init();
|
|
||||||
Uri.setGroup("DATA", "data/");
|
|
||||||
Uri.setGroup("RES", "res");
|
|
||||||
Uri.addLibrary("loxelEngine", MainCollisionTest.class, "resources/testDataLoxelEngine");
|
|
||||||
Uri.setApplication(MainCollisionTest.class, "resources/lowPoly");
|
|
||||||
Gale.run(new LowPolyApplication(), args);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,566 +0,0 @@
|
|||||||
package sample.atriasoft.ege.loxelEngine;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.atriasoft.ege.ControlCameraPlayer;
|
|
||||||
import org.atriasoft.ege.Entity;
|
|
||||||
import org.atriasoft.ege.Environement;
|
|
||||||
import org.atriasoft.ege.GameStatus;
|
|
||||||
import org.atriasoft.ege.Light;
|
|
||||||
import org.atriasoft.ege.Material;
|
|
||||||
import org.atriasoft.ege.camera.Camera;
|
|
||||||
import org.atriasoft.ege.components.ComponentGravityStatic;
|
|
||||||
import org.atriasoft.ege.components.ComponentLight;
|
|
||||||
import org.atriasoft.ege.components.ComponentLightSun;
|
|
||||||
import org.atriasoft.ege.components.ComponentMaterial;
|
|
||||||
import org.atriasoft.ege.components.ComponentPhysics;
|
|
||||||
import org.atriasoft.ege.components.ComponentPlayer;
|
|
||||||
import org.atriasoft.ege.components.ComponentPosition;
|
|
||||||
import org.atriasoft.ege.components.ComponentPositionPlayer;
|
|
||||||
import org.atriasoft.ege.components.ComponentRenderColoredStaticMesh;
|
|
||||||
import org.atriasoft.ege.components.ComponentRenderTexturedMaterialsStaticMesh;
|
|
||||||
import org.atriasoft.ege.components.ComponentRenderTexturedStaticMesh;
|
|
||||||
import org.atriasoft.ege.components.ComponentStaticMesh;
|
|
||||||
import org.atriasoft.ege.components.ComponentTexture;
|
|
||||||
import org.atriasoft.ege.components.PhysicBodyType;
|
|
||||||
import org.atriasoft.ege.engines.EngineLight;
|
|
||||||
import org.atriasoft.ege.map.MapVoxel;
|
|
||||||
import org.atriasoft.ege.tools.MeshGenerator;
|
|
||||||
import org.atriasoft.etk.Color;
|
|
||||||
import org.atriasoft.etk.Uri;
|
|
||||||
import org.atriasoft.etk.math.Matrix4f;
|
|
||||||
import org.atriasoft.etk.math.Quaternion;
|
|
||||||
import org.atriasoft.etk.math.Transform3D;
|
|
||||||
import org.atriasoft.etk.math.Vector2f;
|
|
||||||
import org.atriasoft.etk.math.Vector3f;
|
|
||||||
import org.atriasoft.gale.Gale;
|
|
||||||
import org.atriasoft.gale.GaleApplication;
|
|
||||||
import org.atriasoft.gale.backend3d.OpenGL;
|
|
||||||
import org.atriasoft.gale.backend3d.OpenGL.Flag;
|
|
||||||
import org.atriasoft.gale.context.GaleContext;
|
|
||||||
import org.atriasoft.gale.key.KeyKeyboard;
|
|
||||||
import org.atriasoft.gale.key.KeySpecial;
|
|
||||||
import org.atriasoft.gale.key.KeyStatus;
|
|
||||||
import org.atriasoft.gale.key.KeyType;
|
|
||||||
import org.atriasoft.gale.resource.ResourceColored3DObject;
|
|
||||||
import org.atriasoft.phyligram.PhysicBox;
|
|
||||||
import org.atriasoft.phyligram.PhysicSphere;
|
|
||||||
import org.atriasoft.phyligram.PhysicTriangle;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
public class LoxelApplicationPerso extends GaleApplication {
|
|
||||||
final static private Logger LOGGER = LoggerFactory.getLogger(LoxelApplicationPerso.class);
|
|
||||||
public static Vector3f box1HalfSize;
|
|
||||||
public static Vector3f box2HalfSize;
|
|
||||||
// public static ComponentPosition relativeTestPos;
|
|
||||||
// public static Box boxTest;
|
|
||||||
public static List<Vector3f> testPoints = new ArrayList<>();
|
|
||||||
public static List<Vector3f> testPointsBox = new ArrayList<>();
|
|
||||||
public static List<Boolean> testPointsCollide = new ArrayList<>();
|
|
||||||
public static Quaternion testQTransfert;
|
|
||||||
public static Vector3f testRpos;
|
|
||||||
public boolean disable = false;
|
|
||||||
private float angleLight = 0;
|
|
||||||
private Quaternion basicRotation = Quaternion.IDENTITY;
|
|
||||||
private Quaternion basicRotation2 = Quaternion.IDENTITY;
|
|
||||||
private ResourceColored3DObject debugDrawProperty;
|
|
||||||
private Environement env;
|
|
||||||
private ComponentPosition lightPosition;
|
|
||||||
private MapVoxel map;
|
|
||||||
private ComponentPlayer objectPlayer;
|
|
||||||
private ComponentPosition objectPosition;
|
|
||||||
private ControlCameraPlayer simpleControl;
|
|
||||||
|
|
||||||
public LoxelApplicationPerso() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreate(final GaleContext context) {
|
|
||||||
// set the system global max speed
|
|
||||||
//ComponentPhysicsPerso.globalMaxSpeed = 3;
|
|
||||||
Gale.getContext().grabPointerEvents(true, new Vector2f(0, 0));
|
|
||||||
this.env = new Environement();
|
|
||||||
setSize(new Vector2f(1500, 1500));
|
|
||||||
setTitle("Loxel sample");
|
|
||||||
this.map = new MapVoxel(this.env);
|
|
||||||
// this.env.addEngine(map);
|
|
||||||
// map.init();
|
|
||||||
|
|
||||||
// simple sun to have a global light ...
|
|
||||||
final Entity globalGravity = new Entity(this.env);
|
|
||||||
globalGravity.addComponent(new ComponentGravityStatic(new Vector3f(0, 0, -1)));
|
|
||||||
this.env.addEntity(globalGravity);
|
|
||||||
|
|
||||||
// simple sun to have a global light ...
|
|
||||||
final Entity sun = new Entity(this.env);
|
|
||||||
sun.addComponent(new ComponentPosition(new Transform3D(new Vector3f(1000, 1000, 1000))));
|
|
||||||
sun.addComponent(new ComponentLightSun(
|
|
||||||
new Light(new Color(0.4f, 0.4f, 0.4f), new Vector3f(0, 0, 0), new Vector3f(0.8f, 0, 0))));
|
|
||||||
this.env.addEntity(sun);
|
|
||||||
|
|
||||||
// add a cube to show where in the light ...
|
|
||||||
final Entity localLight = new Entity(this.env);
|
|
||||||
this.lightPosition = new ComponentPosition(new Transform3D(new Vector3f(-10, -10, 17)));
|
|
||||||
// localLight.addComponent(lightPosition);
|
|
||||||
// localLight.addComponent(new ComponentStaticMesh(new Uri("RES", "cube.obj")));
|
|
||||||
// localLight.addComponent(new ComponentTexture(new Uri("RES", "grass.png")));
|
|
||||||
// localLight.addComponent(new ComponentLight(new Light(new Vector3f(0,1,0), new Vector3f(0,0,0), new Vector3f(0.8f,0.03f,0.002f))));
|
|
||||||
// localLight.addComponent(new ComponentRenderTexturedStaticMesh(
|
|
||||||
// new Uri("DATA", "basic.vert"),
|
|
||||||
// new Uri("DATA", "basic.frag")));
|
|
||||||
// env.addEntity(localLight);
|
|
||||||
if (this.disable) {
|
|
||||||
// add a cube to test collision ...
|
|
||||||
final Entity localBox = new Entity(this.env);
|
|
||||||
localBox.addComponent(new ComponentStaticMesh(new Uri("RES", "cube-one.obj")));
|
|
||||||
localBox.addComponent(new ComponentTexture(new Uri("DATA", "blocks/clay.png", "loxelEngine")));
|
|
||||||
localBox.addComponent(new ComponentLight(
|
|
||||||
new Light(new Color(0.0f, 1.0f, 0.0f), new Vector3f(0, 0, 0), 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 ComponentPosition(new Transform3D(new Vector3f(0, 0, 5))));
|
|
||||||
final ComponentPhysics physics2 = new ComponentPhysics(this.env);
|
|
||||||
final PhysicBox box2 = new PhysicBox();
|
|
||||||
box2.setSize(new Vector3f(1.001f, 1.001f, 1.001f));
|
|
||||||
box2.setOrigin(new Vector3f(0, 0, 0));
|
|
||||||
box2.setMass(1);
|
|
||||||
physics2.addShape(box2);
|
|
||||||
localBox.addComponent(physics2);
|
|
||||||
this.env.addEntity(localBox);
|
|
||||||
}
|
|
||||||
if (this.disable) {
|
|
||||||
// add a cube to test collision ...
|
|
||||||
final Entity localBox = new Entity(this.env);
|
|
||||||
localBox.addComponent(new ComponentStaticMesh(new Uri("RES", "cube-one.obj")));
|
|
||||||
localBox.addComponent(new ComponentTexture(new Uri("DATA", "blocks/clay.png", "loxelEngine")));
|
|
||||||
localBox.addComponent(new ComponentLight(
|
|
||||||
new Light(new Color(0.0f, 1.0f, 0.0f), new Vector3f(0, 0, 0), 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 ComponentPosition(new Transform3D(new Vector3f(0, 4, 2.5f))));
|
|
||||||
final ComponentPhysics physics2 = new ComponentPhysics(this.env);
|
|
||||||
final PhysicBox box2 = new PhysicBox();
|
|
||||||
box2.setSize(new Vector3f(2.0f, 2.0f, 2.0f));
|
|
||||||
box2.setOrigin(new Vector3f(0, 0, 0));
|
|
||||||
box2.setMass(1);
|
|
||||||
physics2.addShape(box2);
|
|
||||||
localBox.addComponent(physics2);
|
|
||||||
this.env.addEntity(localBox);
|
|
||||||
}
|
|
||||||
if (this.disable) {
|
|
||||||
// add a cube to test collision ...
|
|
||||||
final Entity localBox = new Entity(this.env);
|
|
||||||
localBox.addComponent(new ComponentStaticMesh(new Uri("RES", "cube-one.obj")));
|
|
||||||
localBox.addComponent(new ComponentTexture(new Uri("DATA", "blocks/clay.png", "loxelEngine")));
|
|
||||||
localBox.addComponent(new ComponentRenderTexturedStaticMesh(new Uri("DATA", "basic.vert", "loxelEngine"),
|
|
||||||
new Uri("DATA", "basic.frag", "loxelEngine")));
|
|
||||||
localBox.addComponent(new ComponentPosition(new Transform3D(new Vector3f(-2, 2, 1.5f))));
|
|
||||||
final ComponentPhysics physics2 = new ComponentPhysics(this.env);
|
|
||||||
final PhysicBox box2 = new PhysicBox();
|
|
||||||
box2.setSize(new Vector3f(3.0f, 3.0f, 3.0f));
|
|
||||||
box2.setOrigin(new Vector3f(0, 0, 0));
|
|
||||||
box2.setMass(1);
|
|
||||||
physics2.addShape(box2);
|
|
||||||
localBox.addComponent(physics2);
|
|
||||||
this.env.addEntity(localBox);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.disable) {
|
|
||||||
// add a cube to test collision ...
|
|
||||||
final Entity localBox = new Entity(this.env);
|
|
||||||
localBox.addComponent(new ComponentStaticMesh(new Uri("RES", "cube-one.obj")));
|
|
||||||
localBox.addComponent(new ComponentTexture(new Uri("DATA", "blocks/clay.png", "loxelEngine")));
|
|
||||||
localBox.addComponent(new ComponentRenderTexturedStaticMesh(new Uri("DATA", "basic.vert", "loxelEngine"),
|
|
||||||
new Uri("DATA", "basic.frag", "loxelEngine")));
|
|
||||||
localBox.addComponent(new ComponentPosition(new Transform3D(new Vector3f(-5, -5, 0))));
|
|
||||||
final ComponentPhysics physics2 = new ComponentPhysics(this.env);
|
|
||||||
final PhysicBox box2 = new PhysicBox();
|
|
||||||
box2.setSize(new Vector3f(2, 2, 2));
|
|
||||||
box2.setOrigin(new Vector3f(0, 0, 0));
|
|
||||||
box2.setMass(1);
|
|
||||||
physics2.addShape(box2);
|
|
||||||
localBox.addComponent(physics2);
|
|
||||||
this.env.addEntity(localBox);
|
|
||||||
}
|
|
||||||
if (this.disable) {
|
|
||||||
// add a cube to test collision ...
|
|
||||||
final Entity localBox = new Entity(this.env);
|
|
||||||
Quaternion orientation = new Quaternion(0.5f, 0.2f, 0.4f, 1);
|
|
||||||
orientation = orientation.normalize();
|
|
||||||
localBox.addComponent(new ComponentStaticMesh(new Uri("RES", "cube-one.obj")));
|
|
||||||
localBox.addComponent(new ComponentTexture(new Uri("DATA", "blocks/clay.png", "loxelEngine")));
|
|
||||||
localBox.addComponent(new ComponentRenderTexturedStaticMesh(new Uri("DATA", "basic.vert", "loxelEngine"),
|
|
||||||
new Uri("DATA", "basic.frag", "loxelEngine")));
|
|
||||||
localBox.addComponent(new ComponentPosition(new Transform3D(new Vector3f(15, 15, 0), orientation)));
|
|
||||||
final ComponentPhysics physics2 = new ComponentPhysics(this.env);
|
|
||||||
final PhysicBox box2 = new PhysicBox();
|
|
||||||
box2.setSize(new Vector3f(4, 4, 4));
|
|
||||||
box2.setOrigin(new Vector3f(0, 0, 0));
|
|
||||||
box2.setMass(1);
|
|
||||||
physics2.addShape(box2);
|
|
||||||
localBox.addComponent(physics2);
|
|
||||||
this.env.addEntity(localBox);
|
|
||||||
}
|
|
||||||
if (this.disable) {
|
|
||||||
// add a cube to test collision ...
|
|
||||||
final Entity localBox = new Entity(this.env);
|
|
||||||
final Quaternion orientation = new Quaternion(0.3f, 1.3f, 0.4f, 1);
|
|
||||||
//orientation.normalize();
|
|
||||||
localBox.addComponent(new ComponentStaticMesh(new Uri("RES", "cube-one.obj")));
|
|
||||||
localBox.addComponent(new ComponentTexture(new Uri("DATA", "blocks/clay.png", "loxelEngine")));
|
|
||||||
localBox.addComponent(new ComponentRenderTexturedStaticMesh(new Uri("DATA", "basic.vert", "loxelEngine"),
|
|
||||||
new Uri("DATA", "basic.frag", "loxelEngine")));
|
|
||||||
localBox.addComponent(new ComponentPosition(new Transform3D(new Vector3f(2, -2, 0.2f), orientation)));
|
|
||||||
final ComponentPhysics physics2 = new ComponentPhysics(this.env);
|
|
||||||
// TODO: physics2.setAngularReactionEnable(false);
|
|
||||||
final PhysicBox box2 = new PhysicBox();
|
|
||||||
box2.setSize(new Vector3f(0.5f, 0.5f, 0.5f));
|
|
||||||
box2.setOrigin(new Vector3f(0, 0, 0));
|
|
||||||
box2.setMass(1);
|
|
||||||
physics2.addShape(box2);
|
|
||||||
localBox.addComponent(physics2);
|
|
||||||
this.env.addEntity(localBox);
|
|
||||||
}
|
|
||||||
if (this.disable) {
|
|
||||||
// this is the floor
|
|
||||||
final Entity localBox = new Entity(this.env);
|
|
||||||
Quaternion orientation = new Quaternion(0, 0, 0, 1);
|
|
||||||
orientation = orientation.normalize();
|
|
||||||
localBox.addComponent(new ComponentStaticMesh(new Uri("RES", "cube-one.obj")));
|
|
||||||
localBox.addComponent(new ComponentTexture(new Uri("DATA", "blocks/dirt.png", "loxelEngine")));
|
|
||||||
localBox.addComponent(new ComponentRenderTexturedStaticMesh(new Uri("DATA", "basic.vert", "loxelEngine"),
|
|
||||||
new Uri("DATA", "basic.frag", "loxelEngine")));
|
|
||||||
localBox.addComponent(new ComponentPosition(new Transform3D(new Vector3f(0, 0, 0.0f), orientation)));
|
|
||||||
final ComponentPhysics physics2 = new ComponentPhysics(this.env);
|
|
||||||
physics2.setBodyType(PhysicBodyType.BODY_STATIC);
|
|
||||||
final PhysicBox box2 = new PhysicBox();
|
|
||||||
box2.setSize(new Vector3f(20.0f, 20.0f, 0.5f));
|
|
||||||
box2.setOrigin(new Vector3f(0, 0, 0));
|
|
||||||
box2.setMass(0);
|
|
||||||
physics2.addShape(box2);
|
|
||||||
localBox.addComponent(physics2);
|
|
||||||
this.env.addEntity(localBox);
|
|
||||||
}
|
|
||||||
// {
|
|
||||||
// // add a cube to test collision ...
|
|
||||||
// Entity localBox = new Entity(this.env);
|
|
||||||
// relativeTestPos = new ComponentPosition(new Transform3D(new Vector3f(0,0,14),new Quaternion(0.5f,0.2f,0.4f,1)));
|
|
||||||
// localBox.addComponent(relativeTestPos);
|
|
||||||
//// localBox.addComponent(new ComponentStaticMesh(new Uri("RES", "cube-one.obj")));
|
|
||||||
//// localBox.addComponent(new ComponentTexture(new Uri("DATA", "blocks/clay.png", "loxelEngine")));
|
|
||||||
//// localBox.addComponent(new ComponentLight(new Light(new Vector3f(0,1,0), new Vector3f(0,0,0), new Vector3f(0.8f,0.03f,0.002f))));
|
|
||||||
//// localBox.addComponent(new ComponentRenderTexturedStaticMesh(
|
|
||||||
//// new Uri("DATA", "basic.vert"),
|
|
||||||
//// new Uri("DATA", "basic.frag")));
|
|
||||||
// ComponentPhysicsPerso physics2 = new ComponentPhysicsPerso(true);
|
|
||||||
// boxTest = new Box();
|
|
||||||
// boxTest.setSize(new Vector3f(1,1,1));
|
|
||||||
// boxTest.setOrigin(new Vector3f(0,0,0));
|
|
||||||
// boxTest.setMass(1);
|
|
||||||
// physics2.addShape(boxTest);
|
|
||||||
// localBox.addComponent(physics2);
|
|
||||||
// env.addEntity(localBox);
|
|
||||||
// }
|
|
||||||
// {
|
|
||||||
// Entity localBox = new Entity(this.env);
|
|
||||||
// localBox.addComponent(new ComponentPosition(new Transform3D(new Vector3f(0,0,14))));
|
|
||||||
// localBox.addComponent(new ComponentStaticMesh(new Uri("RES", "cube-one.obj")));
|
|
||||||
// localBox.addComponent(new ComponentTexture(new Uri("DATA", "blocks/clay.png", "loxelEngine")));
|
|
||||||
// localBox.addComponent(new ComponentRenderTexturedStaticMesh(
|
|
||||||
// new Uri("DATA", "basic.vert"),
|
|
||||||
// new Uri("DATA", "basic.frag")));
|
|
||||||
// env.addEntity(localBox);
|
|
||||||
// }
|
|
||||||
boolean selectCase1 = true;
|
|
||||||
if (!this.disable) {
|
|
||||||
// add a cube to test collision ...
|
|
||||||
final Entity localBox = new Entity(this.env);
|
|
||||||
localBox.addComponent(new ComponentStaticMesh(new Uri("RES", "cube-one.obj")));
|
|
||||||
localBox.addComponent(new ComponentTexture(new Uri("DATA", "blocks/clay.png", "loxelEngine")));
|
|
||||||
localBox.addComponent(new ComponentLight(
|
|
||||||
new Light(new Color(0.0f, 1.0f, 0.0f), new Vector3f(0, 0, 0), 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 ComponentPosition(new Transform3D(new Vector3f(0, 3, 0))));
|
|
||||||
final ComponentPhysics physics2 = new ComponentPhysics(this.env);
|
|
||||||
physics2.setBodyType(PhysicBodyType.BODY_STATIC);
|
|
||||||
PhysicTriangle box2 = new PhysicTriangle();
|
|
||||||
if (selectCase1) {
|
|
||||||
box2.setPoints(new Vector3f(4, 0, 0), new Vector3f(0, 4, 0), new Vector3f(-2, -2, 1));
|
|
||||||
box2.setOrigin(new Vector3f(0, 0, 0));
|
|
||||||
box2.setMass(0);
|
|
||||||
physics2.addShape(box2);
|
|
||||||
box2 = new PhysicTriangle();
|
|
||||||
box2.setPoints(new Vector3f(4, 0, 0), new Vector3f(0, 4, 0), new Vector3f(600, 600, -100));
|
|
||||||
box2.setOrigin(new Vector3f(0, 0, 0));
|
|
||||||
box2.setMass(0);
|
|
||||||
box2.setFrictionCoefficient(1.0f);
|
|
||||||
box2.setBouncingCoefficient(0.5f);
|
|
||||||
} else {
|
|
||||||
box2.setPoints(new Vector3f(4, 0, 0), new Vector3f(0, 4, 0), new Vector3f(-2, -2, 1));
|
|
||||||
box2.setOrigin(new Vector3f(0, 0, 0));
|
|
||||||
box2.setMass(0);
|
|
||||||
box2.setBouncingCoefficient(0.5f);
|
|
||||||
}
|
|
||||||
physics2.addShape(box2);
|
|
||||||
localBox.addComponent(physics2);
|
|
||||||
this.env.addEntity(localBox);
|
|
||||||
}
|
|
||||||
if (selectCase1) {
|
|
||||||
// add a cube to test collision ...
|
|
||||||
final Entity localBox = new Entity(this.env);
|
|
||||||
localBox.addComponent(new ComponentStaticMesh(new Uri("RES", "cube-one.obj")));
|
|
||||||
localBox.addComponent(new ComponentTexture(new Uri("DATA", "blocks/clay.png", "loxelEngine")));
|
|
||||||
localBox.addComponent(new ComponentLight(
|
|
||||||
new Light(new Color(0.0f, 1.0f, 0.0f), new Vector3f(0, 0, 0), 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 ComponentPosition(new Transform3D(new Vector3f(1.1f, 5.1f, 1.0f),
|
|
||||||
Quaternion.fromEulerAngles(new Vector3f(0.15f, 0.95f, 0.3f)))));
|
|
||||||
final ComponentPhysics physics2 = new ComponentPhysics(this.env);
|
|
||||||
final PhysicSphere box2 = new PhysicSphere();
|
|
||||||
physics2.setBodyType(PhysicBodyType.BODY_STATIC);
|
|
||||||
box2.setSize(1.0f);
|
|
||||||
box2.setOrigin(new Vector3f(0, 0, 0));
|
|
||||||
box2.setMass(0);
|
|
||||||
box2.setBouncingCoefficient(0.5f);
|
|
||||||
physics2.addShape(box2);
|
|
||||||
localBox.addComponent(physics2);
|
|
||||||
this.env.addEntity(localBox);
|
|
||||||
}
|
|
||||||
if (true) {
|
|
||||||
// add a cube to test collision ...
|
|
||||||
final Entity localBox = new Entity(this.env);
|
|
||||||
localBox.addComponent(new ComponentStaticMesh(new Uri("RES", "cube-one.obj")));
|
|
||||||
localBox.addComponent(new ComponentTexture(new Uri("DATA", "blocks/clay.png", "loxelEngine")));
|
|
||||||
localBox.addComponent(new ComponentLight(
|
|
||||||
new Light(new Color(0.0f, 1.0f, 0.0f), new Vector3f(0, 0, 0), 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 ComponentPosition(new Transform3D(new Vector3f(1.8f, 5.8f, 4),
|
|
||||||
Quaternion.fromEulerAngles(new Vector3f(0.15f, 0.95f, 0.3f)))));
|
|
||||||
final ComponentPhysics physics2 = new ComponentPhysics(this.env);
|
|
||||||
physics2.setBodyType(PhysicBodyType.BODY_DYNAMIC);
|
|
||||||
final PhysicSphere box2 = new PhysicSphere();
|
|
||||||
box2.setSize(1.0f);
|
|
||||||
box2.setOrigin(new Vector3f(0, 0, 0));
|
|
||||||
box2.setMass(1);
|
|
||||||
physics2.addShape(box2);
|
|
||||||
localBox.addComponent(physics2);
|
|
||||||
this.env.addEntity(localBox);
|
|
||||||
}
|
|
||||||
|
|
||||||
final Entity gird = new Entity(this.env);
|
|
||||||
gird.addComponent(new ComponentPosition(new Transform3D(new Vector3f(0, 0, 0))));
|
|
||||||
gird.addComponent(new ComponentStaticMesh(MeshGenerator.createGrid(5)));
|
|
||||||
gird.addComponent(new ComponentRenderColoredStaticMesh(new Uri("DATA", "wireColor.vert", "ege"),
|
|
||||||
new Uri("DATA", "wireColor.frag", "ege")));
|
|
||||||
this.env.addEntity(gird);
|
|
||||||
|
|
||||||
final Entity player = new Entity(this.env);
|
|
||||||
if (false) {
|
|
||||||
final Transform3D playerTransform = new Transform3D(new Vector3f(0, -5, 1));
|
|
||||||
//this.objectPosition = new ComponentPositionPlayer();
|
|
||||||
//player.addComponent(this.objectPosition);
|
|
||||||
this.objectPlayer = new ComponentPlayer();
|
|
||||||
player.addComponent(this.objectPlayer);
|
|
||||||
player.addComponent(new ComponentMaterial(new Material()));
|
|
||||||
//player.addComponent(new ComponentStaticMesh(new Uri("RES", "person.obj")));
|
|
||||||
player.addComponent(new ComponentStaticMesh(new Uri("RES", "person_-yfw_zup.obj")));
|
|
||||||
player.addComponent(new ComponentTexture(new Uri("RES", "playerTexture.png")));
|
|
||||||
player.addComponent(
|
|
||||||
new ComponentRenderTexturedMaterialsStaticMesh(new Uri("DATA", "basicMaterial.vert", "loxelEngine"),
|
|
||||||
new Uri("DATA", "basicMaterial.frag", "loxelEngine"),
|
|
||||||
(EngineLight) this.env.getEngine(EngineLight.ENGINE_NAME)));
|
|
||||||
player.addComponent(new ComponentPosition(playerTransform));
|
|
||||||
final ComponentPhysics physics = new ComponentPhysics(this.env);
|
|
||||||
physics.setBodyType(PhysicBodyType.BODY_DYNAMIC);
|
|
||||||
//physics.setAngularReactionEnable(false);
|
|
||||||
//physics.setSleepingEnable(false);
|
|
||||||
final PhysicBox box = new PhysicBox();
|
|
||||||
box.setSize(new Vector3f(0.3f, 0.3f, 0.9f));
|
|
||||||
box.setOrigin(new Vector3f(0, 0, 0.9f));
|
|
||||||
box.setMass(1);
|
|
||||||
physics.addShape(box);
|
|
||||||
player.addComponent(physics);
|
|
||||||
this.env.addEntity(player);
|
|
||||||
} else {
|
|
||||||
final Transform3D playerTransform = new Transform3D(new Vector3f(0, -5, 0));
|
|
||||||
this.objectPosition = new ComponentPositionPlayer();
|
|
||||||
player.addComponent(this.objectPosition);
|
|
||||||
this.objectPlayer = new ComponentPlayer();
|
|
||||||
player.addComponent(this.objectPlayer);
|
|
||||||
player.addComponent(new ComponentMaterial(new Material()));
|
|
||||||
//player.addComponent(new ComponentStaticMesh(new Uri("RES", "person.obj")));
|
|
||||||
player.addComponent(new ComponentStaticMesh(new Uri("RES", "person_-yfw_zup.obj")));
|
|
||||||
player.addComponent(new ComponentTexture(new Uri("RES", "playerTexture.png")));
|
|
||||||
player.addComponent(
|
|
||||||
new ComponentRenderTexturedMaterialsStaticMesh(new Uri("DATA", "basicMaterial.vert", "loxelEngine"),
|
|
||||||
new Uri("DATA", "basicMaterial.frag", "loxelEngine"),
|
|
||||||
(EngineLight) this.env.getEngine(EngineLight.ENGINE_NAME)));
|
|
||||||
final ComponentPhysics physics = new ComponentPhysics(this.env);
|
|
||||||
physics.setBodyType(PhysicBodyType.BODY_DYNAMIC);
|
|
||||||
final PhysicBox box = new PhysicBox();
|
|
||||||
box.setSize(new Vector3f(0.6f, 0.6f, 1.8f));
|
|
||||||
box.setOrigin(new Vector3f(0, 0, 0.9f));
|
|
||||||
box.setMass(0);
|
|
||||||
physics.addShape(box);
|
|
||||||
player.addComponent(physics);
|
|
||||||
this.env.addEntity(player);
|
|
||||||
}
|
|
||||||
final Camera mainView = new Camera();
|
|
||||||
this.env.addCamera("default", mainView);
|
|
||||||
mainView.setPitch((float) Math.PI * -0.25f);
|
|
||||||
mainView.setPosition(new Vector3f(0, -5, 5));
|
|
||||||
|
|
||||||
this.simpleControl = new ControlCameraPlayer(mainView, player);
|
|
||||||
this.env.addControlInterface(this.simpleControl);
|
|
||||||
|
|
||||||
// start the engine.
|
|
||||||
this.env.setPropertyStatus(GameStatus.gameStart);
|
|
||||||
|
|
||||||
this.basicRotation = Quaternion.fromEulerAngles(new Vector3f(0.005f, 0.005f, 0.01f));
|
|
||||||
this.basicRotation2 = Quaternion.fromEulerAngles(new Vector3f(0.003f, 0.01f, 0.001f));
|
|
||||||
|
|
||||||
// ready to let Gale & Ege manage the display
|
|
||||||
LOGGER.info("==> Init APPL (END)");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDraw(final GaleContext context) {
|
|
||||||
//LOGGER.info("==> appl Draw ...");
|
|
||||||
final Vector2f size = getSize();
|
|
||||||
// Store openGl context.
|
|
||||||
OpenGL.push();
|
|
||||||
// set projection matrix:
|
|
||||||
final Matrix4f tmpProjection = Matrix4f.createMatrixPerspective(3.14f * 0.5f, getAspectRatio(), 0.1f, 50000);
|
|
||||||
OpenGL.setMatrix(tmpProjection);
|
|
||||||
|
|
||||||
// set the basic openGL view port: (Draw in all the windows...)
|
|
||||||
OpenGL.setViewPort(new Vector2f(0, 0), size);
|
|
||||||
|
|
||||||
// clear background
|
|
||||||
final Color bgColor = new Color(0.18f, 0.43f, 0.95f, 1.0f);
|
|
||||||
OpenGL.clearColor(bgColor);
|
|
||||||
// real clear request:
|
|
||||||
OpenGL.clear(OpenGL.ClearFlag.clearFlag_colorBuffer);
|
|
||||||
OpenGL.clear(OpenGL.ClearFlag.clearFlag_depthBuffer);
|
|
||||||
OpenGL.enable(Flag.flag_depthTest);
|
|
||||||
|
|
||||||
//LOGGER.info("==> appl Draw ...");
|
|
||||||
this.env.render(20, "default");
|
|
||||||
if (this.debugDrawProperty == null) {
|
|
||||||
this.debugDrawProperty = ResourceColored3DObject.create();
|
|
||||||
}
|
|
||||||
// now render the point test collision ...
|
|
||||||
for (int iii = 0; iii < LoxelApplicationPerso.testPoints.size(); iii++) {
|
|
||||||
final Vector3f elem = LoxelApplicationPerso.testPoints.get(iii);
|
|
||||||
final boolean collide = LoxelApplicationPerso.testPointsCollide.get(iii);
|
|
||||||
if (collide) {
|
|
||||||
this.debugDrawProperty.drawSquare(new Vector3f(0.1f, 0.1f, 0.1f),
|
|
||||||
Matrix4f.IDENTITY.multiply(
|
|
||||||
Matrix4f.createMatrixTranslate(new Vector3f(elem.x(), elem.y(), elem.z() + 14))),
|
|
||||||
new Color(1, 0, 0, 1));
|
|
||||||
} else if (iii == 0) {
|
|
||||||
this.debugDrawProperty.drawSquare(new Vector3f(0.05f, 0.05f, 0.05f),
|
|
||||||
Matrix4f.IDENTITY.multiply(
|
|
||||||
Matrix4f.createMatrixTranslate(new Vector3f(elem.x(), elem.y(), elem.z() + 14))),
|
|
||||||
new Color(0, 1, 0, 1));
|
|
||||||
} else if (iii == 7) {
|
|
||||||
this.debugDrawProperty.drawSquare(new Vector3f(0.05f, 0.05f, 0.05f),
|
|
||||||
Matrix4f.IDENTITY.multiply(
|
|
||||||
Matrix4f.createMatrixTranslate(new Vector3f(elem.x(), elem.y(), elem.z() + 14))),
|
|
||||||
new Color(1, 1, 0, 1));
|
|
||||||
} else {
|
|
||||||
this.debugDrawProperty.drawSquare(new Vector3f(0.1f, 0.1f, 0.1f),
|
|
||||||
Matrix4f.IDENTITY.multiply(
|
|
||||||
Matrix4f.createMatrixTranslate(new Vector3f(elem.x(), elem.y(), elem.z() + 14))),
|
|
||||||
new Color(1, 1, 1, 1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (int iii = 0; iii < LoxelApplicationPerso.testPointsBox.size(); iii++) {
|
|
||||||
final Vector3f elem = LoxelApplicationPerso.testPointsBox.get(iii);
|
|
||||||
if (iii == 0) {
|
|
||||||
this.debugDrawProperty.drawSquare(new Vector3f(0.05f, 0.05f, 0.05f),
|
|
||||||
Matrix4f.IDENTITY.multiply(
|
|
||||||
Matrix4f.createMatrixTranslate(new Vector3f(elem.x(), elem.y(), elem.z() + 14))),
|
|
||||||
new Color(0, 1, 0, 1));
|
|
||||||
} else if (iii == 7) {
|
|
||||||
this.debugDrawProperty.drawSquare(new Vector3f(0.05f, 0.05f, 0.05f),
|
|
||||||
Matrix4f.IDENTITY.multiply(
|
|
||||||
Matrix4f.createMatrixTranslate(new Vector3f(elem.x(), elem.y(), elem.z() + 14))),
|
|
||||||
new Color(1, 1, 0, 1));
|
|
||||||
} else {
|
|
||||||
this.debugDrawProperty.drawSquare(new Vector3f(0.1f, 0.1f, 0.1f),
|
|
||||||
Matrix4f.IDENTITY.multiply(
|
|
||||||
Matrix4f.createMatrixTranslate(new Vector3f(elem.x(), elem.y(), elem.z() + 14))),
|
|
||||||
new Color(0, 0, 1, 1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (LoxelApplicationPerso.testRpos != null) {
|
|
||||||
//debugDrawProperty.drawSquare(box2HalfSize, testQTransfert.getMatrix4().multiplyNew(Matrix4f.createMatrixTranslate(new Vector3f(testRpos.x,testRpos.y,testRpos.z+14))), new Color(0,1,0,0.5f));
|
|
||||||
//Matrix4f transformation = Matrix4f.createMatrixTranslate(new Vector3f(testRpos.x,testRpos.y,testRpos.z)).multiply(testQTransfert.getMatrix4()).multiply(Matrix4f.createMatrixTranslate(new Vector3f(0,0,14)));
|
|
||||||
//Matrix4f transformation = testQTransfert.getMatrix4().multiply(Matrix4f.createMatrixTranslate(new Vector3f(testRpos.x,testRpos.y,testRpos.z))).multiply(Matrix4f.createMatrixTranslate(new Vector3f(0,0,14)));
|
|
||||||
//Matrix4f transformation = testQTransfert.getMatrix4().multiply(Matrix4f.createMatrixTranslate(new Vector3f(testRpos.x,testRpos.y,testRpos.z))).multiply(Matrix4f.createMatrixTranslate(new Vector3f(0,0,14)));
|
|
||||||
final Matrix4f transformation = Matrix4f
|
|
||||||
.createMatrixTranslate(new Vector3f(LoxelApplicationPerso.testRpos.x(),
|
|
||||||
LoxelApplicationPerso.testRpos.y(), LoxelApplicationPerso.testRpos.z()))
|
|
||||||
.multiply(Matrix4f.createMatrixTranslate(new Vector3f(0, 0, 14)))
|
|
||||||
.multiply(LoxelApplicationPerso.testQTransfert.getMatrix4());
|
|
||||||
// OK sans la box1 orientation ...
|
|
||||||
//Matrix4f transformation = Matrix4f.createMatrixTranslate(new Vector3f(testRpos.x,testRpos.y,testRpos.z)).multiply(testQTransfert.getMatrix4()).multiply(Matrix4f.createMatrixTranslate(new Vector3f(0,0,14)));
|
|
||||||
//Matrix4f transformation = Matrix4f.createMatrixTranslate(new Vector3f(testRpos.x,testRpos.y,testRpos.z)).multiply(testQTransfert.getMatrix4()).multiply(Matrix4f.createMatrixTranslate(new Vector3f(0,0,14)));
|
|
||||||
this.debugDrawProperty.drawSquare(LoxelApplicationPerso.box2HalfSize, transformation,
|
|
||||||
new Color(0, 1, 0, 0.5f));
|
|
||||||
this.debugDrawProperty.drawSquare(LoxelApplicationPerso.box1HalfSize,
|
|
||||||
Matrix4f.createMatrixTranslate(new Vector3f(0, 0, 14)), new Color(0, 0, 1, 0.5f));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Restore context of matrix
|
|
||||||
OpenGL.pop();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onKeyboard(
|
|
||||||
final KeySpecial special,
|
|
||||||
final KeyKeyboard type,
|
|
||||||
final Character value,
|
|
||||||
final KeyStatus state) {
|
|
||||||
if (type == KeyKeyboard.F1) {
|
|
||||||
Gale.getContext().grabPointerEvents(false, new Vector2f(0, 0));
|
|
||||||
}
|
|
||||||
if (type == KeyKeyboard.F2) {
|
|
||||||
Gale.getContext().grabPointerEvents(true, new Vector2f(0, 0));
|
|
||||||
}
|
|
||||||
if (type == KeyKeyboard.F12) {
|
|
||||||
Gale.getContext().setFullScreen(!Gale.getContext().getFullScreen());
|
|
||||||
}
|
|
||||||
this.env.onKeyboard(special, type, value, state);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPointer(
|
|
||||||
final KeySpecial special,
|
|
||||||
final KeyType type,
|
|
||||||
final int pointerID,
|
|
||||||
final Vector2f pos,
|
|
||||||
final KeyStatus state) {
|
|
||||||
this.env.onPointer(special, type, pointerID, new Vector3f(pos.x(), pos.y(), 0), state);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onRegenerateDisplay(final GaleContext context) {
|
|
||||||
//LOGGER.trace("Regenerate Gale Application");
|
|
||||||
this.angleLight += 0.01;
|
|
||||||
this.lightPosition.setTransform(this.lightPosition.getTransform()
|
|
||||||
.withPosition(new Vector3f(5 + (float) Math.cos(this.angleLight) * 7.0f,
|
|
||||||
5 + (float) Math.sin(this.angleLight) * 7.0f,
|
|
||||||
this.lightPosition.getTransform().getPosition().z())));
|
|
||||||
this.env.periodicCall();
|
|
||||||
markDrawingIsNeeded();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
package sample.atriasoft.ege.loxelEngine;
|
|
||||||
|
|
||||||
import org.atriasoft.ege.Ege;
|
|
||||||
import org.atriasoft.etk.Uri;
|
|
||||||
import org.atriasoft.gale.Gale;
|
|
||||||
|
|
||||||
public class MainLoxelEnginePerso {
|
|
||||||
public static void main(final String[] args) {
|
|
||||||
Gale.init();
|
|
||||||
Ege.init();
|
|
||||||
Uri.setGroup("DATA", "data");
|
|
||||||
Uri.setGroup("RES", "res");
|
|
||||||
Uri.addLibrary("loxelEngine", MainLoxelEnginePerso.class, "resources/testDataLoxelEngine");
|
|
||||||
Uri.setApplication(MainLoxelEnginePerso.class, "resources");
|
|
||||||
Gale.run(new LoxelApplicationPerso(), args);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,72 +0,0 @@
|
|||||||
package sample.atriasoft.ege.mapFactory;
|
|
||||||
|
|
||||||
import org.atriasoft.etk.Configs;
|
|
||||||
import org.atriasoft.etk.math.Vector2f;
|
|
||||||
import org.atriasoft.ewol.context.EwolApplication;
|
|
||||||
import org.atriasoft.ewol.context.EwolContext;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
public class Appl implements EwolApplication {
|
|
||||||
final static private Logger LOGGER = LoggerFactory.getLogger(Appl.class);
|
|
||||||
|
|
||||||
private void localCreate(final EwolContext context) {
|
|
||||||
// parse all the argument of the application
|
|
||||||
for (int iii = 0; iii < context.getCmd().size(); iii++) {
|
|
||||||
String tmpppp = context.getCmd().get(iii);
|
|
||||||
if (tmpppp == "-h" || tmpppp == "--help") {
|
|
||||||
LOGGER.info(" -h/--help display this help");
|
|
||||||
System.exit(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
context.setSize(new Vector2f(800, 600));
|
|
||||||
Configs.getConfigFonts().set("FreeSherif", 12);
|
|
||||||
// Create the windows
|
|
||||||
MainWindows basicWindows = new MainWindows();
|
|
||||||
// configure the ewol context to use the new windows
|
|
||||||
context.setWindows(basicWindows);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreate(final EwolContext context) {
|
|
||||||
LOGGER.info("Application onCreate: [BEGIN]");
|
|
||||||
localCreate(context);
|
|
||||||
LOGGER.info("Application onCreate: [ END ]");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDestroy(final EwolContext context) {
|
|
||||||
LOGGER.info("Application onDestroy: [BEGIN]");
|
|
||||||
|
|
||||||
LOGGER.info("Application onDestroy: [ END ]");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPause(final EwolContext context) {
|
|
||||||
LOGGER.info("Application onPause: [BEGIN]");
|
|
||||||
|
|
||||||
LOGGER.info("Application onPause: [ END ]");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onResume(final EwolContext context) {
|
|
||||||
LOGGER.info("Application onResume: [BEGIN]");
|
|
||||||
|
|
||||||
LOGGER.info("Application onResume: [ END ]");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStart(final EwolContext context) {
|
|
||||||
LOGGER.info("Application onStart: [BEGIN]");
|
|
||||||
|
|
||||||
LOGGER.info("Application onStart: [ END ]");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStop(final EwolContext context) {
|
|
||||||
LOGGER.info("Application onStop: [BEGIN]");
|
|
||||||
|
|
||||||
LOGGER.info("Application onStop: [ END ]");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,108 +0,0 @@
|
|||||||
package sample.atriasoft.ege.mapFactory;
|
|
||||||
|
|
||||||
import org.atriasoft.ege.ControlCameraSimple;
|
|
||||||
import org.atriasoft.ege.ControlInterface;
|
|
||||||
import org.atriasoft.ege.Entity;
|
|
||||||
import org.atriasoft.ege.components.ComponentMesh;
|
|
||||||
import org.atriasoft.ege.components.ComponentPosition;
|
|
||||||
import org.atriasoft.ege.components.ComponentRenderMeshPalette;
|
|
||||||
import org.atriasoft.ege.components.ComponentTexturePalette;
|
|
||||||
import org.atriasoft.ege.engines.EngineLight;
|
|
||||||
import org.atriasoft.etk.Uri;
|
|
||||||
import org.atriasoft.etk.math.Transform3D;
|
|
||||||
import org.atriasoft.etk.math.Vector3f;
|
|
||||||
import org.atriasoft.ewol.event.EventEntry;
|
|
||||||
import org.atriasoft.ewol.event.EventInput;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import sample.atriasoft.ege.mapFactory.model.Map;
|
|
||||||
import sample.atriasoft.ege.mapFactory.tools.MapToolInterface;
|
|
||||||
|
|
||||||
public class ApplScene extends EgeScene {
|
|
||||||
final static private Logger LOGGER = LoggerFactory.getLogger(ApplScene.class);
|
|
||||||
//Ground ground = new Ground();
|
|
||||||
Map map = new Map();
|
|
||||||
private ControlInterface simpleControl;
|
|
||||||
private MapToolInterface currentTool = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
*/
|
|
||||||
public ApplScene() {
|
|
||||||
addGenericGird();
|
|
||||||
// test entity
|
|
||||||
Entity groundEntity = new Entity(this.env);
|
|
||||||
ComponentPosition objectPosition = new ComponentPosition(new Transform3D(new Vector3f(0, 0, 0)));
|
|
||||||
groundEntity.addComponent(objectPosition);
|
|
||||||
//this.materialCube = new Material();
|
|
||||||
//basicTree.addComponent(new ComponentMaterial(this.materialCube));
|
|
||||||
//groundEntity.addComponent(new ComponentMesh(new Uri("DATA", "tree1.emf", "plop")));
|
|
||||||
groundEntity.addComponent(new ComponentMesh(this.map.ground.createMesh()));
|
|
||||||
groundEntity.addComponent(new ComponentTexturePalette(new Uri("DATA", "palette_1.json")));
|
|
||||||
//basicTree.addComponent(new ComponentRenderTexturedStaticMesh(new Uri("DATA", "basic.vert", "loxelEngine"), new Uri("DATA", "basic.frag", "loxelEngine")));
|
|
||||||
groundEntity.addComponent(new ComponentRenderMeshPalette(new Uri("DATA", "basicPalette.vert"),
|
|
||||||
new Uri("DATA", "basicPalette.frag"), (EngineLight) this.env.getEngine(EngineLight.ENGINE_NAME)));
|
|
||||||
this.env.addEntity(groundEntity);
|
|
||||||
|
|
||||||
this.map.updateMesh();
|
|
||||||
this.simpleControl = new ControlCameraSimple(this.mainView);
|
|
||||||
this.env.addControlInterface(this.simpleControl);
|
|
||||||
|
|
||||||
// add a cube to test collision ...
|
|
||||||
// final Entity localBox = new Entity(this.env);
|
|
||||||
// localBox.addComponent(new ComponentStaticMesh(new Uri("DATA", "cube-one.obj")));
|
|
||||||
// localBox.addComponent(new ComponentTexture(new Uri("DATA", "clay.png")));
|
|
||||||
// //localBox.addComponent(new ComponentLight(new Light(new Color(0.0f, 1.0f, 0.0f), 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")));
|
|
||||||
// this.posRay = new ComponentPosition(new Transform3D(new Vector3f(0, 4, 2.5f)));
|
|
||||||
//
|
|
||||||
// localBox.addComponent(this.posRay);
|
|
||||||
// //final ComponentPhysics physics2 = new ComponentPhysics(this.env);
|
|
||||||
// //final PhysicBox box2 = new PhysicBox();
|
|
||||||
// //box2.setSize(new Vector3f(2.0f, 2.0f, 2.0f));
|
|
||||||
// //box2.setOrigin(new Vector3f(0, 0, 0));
|
|
||||||
// //box2.setMass(1);
|
|
||||||
// //physics2.addShape(box2);
|
|
||||||
// //localBox.addComponent(physics2);
|
|
||||||
// this.env.addEntity(localBox);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public MapToolInterface getCurrentTool() {
|
|
||||||
return this.currentTool;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onDrawScene() {
|
|
||||||
if (this.currentTool != null) {
|
|
||||||
this.currentTool.onDraw(this.map);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onEventEntry(final EventEntry event) {
|
|
||||||
if (this.currentTool != null) {
|
|
||||||
if (this.currentTool.onEventEntry(event, this.map, this)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return super.onEventEntry(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onEventInput(final EventInput event) {
|
|
||||||
if (this.currentTool != null) {
|
|
||||||
if (this.currentTool.onEventInput(event, this.map, this)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return super.onEventInput(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCurrentTool(MapToolInterface currentTool) {
|
|
||||||
this.currentTool = currentTool;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,157 +0,0 @@
|
|||||||
package sample.atriasoft.ege.mapFactory;
|
|
||||||
|
|
||||||
import org.atriasoft.ege.Entity;
|
|
||||||
import org.atriasoft.ege.Environement;
|
|
||||||
import org.atriasoft.ege.camera.Camera;
|
|
||||||
import org.atriasoft.ege.camera.ProjectionInterface;
|
|
||||||
import org.atriasoft.ege.camera.ProjectionPerspective;
|
|
||||||
import org.atriasoft.ege.components.ComponentPosition;
|
|
||||||
import org.atriasoft.ege.components.ComponentRenderColoredStaticMesh;
|
|
||||||
import org.atriasoft.ege.components.ComponentStaticMesh;
|
|
||||||
import org.atriasoft.ege.tools.MeshGenerator;
|
|
||||||
import org.atriasoft.esignal.Connection;
|
|
||||||
import org.atriasoft.etk.Uri;
|
|
||||||
import org.atriasoft.etk.math.Transform3D;
|
|
||||||
import org.atriasoft.etk.math.Vector2f;
|
|
||||||
import org.atriasoft.etk.math.Vector3f;
|
|
||||||
import org.atriasoft.ewol.event.EventEntry;
|
|
||||||
import org.atriasoft.ewol.event.EventInput;
|
|
||||||
import org.atriasoft.ewol.event.EventTime;
|
|
||||||
import org.atriasoft.ewol.widget.Widget;
|
|
||||||
import org.atriasoft.gale.backend3d.OpenGL;
|
|
||||||
import org.atriasoft.gale.backend3d.OpenGL.Flag;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
public class EgeScene extends Widget {
|
|
||||||
final static private Logger LOGGER = LoggerFactory.getLogger(EgeScene.class);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Periodic call to update grapgic display
|
|
||||||
* @param _event Time generic event
|
|
||||||
*/
|
|
||||||
protected static void periodicCall(final EgeScene self, final EventTime event) {
|
|
||||||
LOGGER.trace("Periodic call on Entry({});", event);
|
|
||||||
/*
|
|
||||||
if (!self.shape.periodicCall(event)) {
|
|
||||||
//LOGGER.error("end periodic call");
|
|
||||||
self.periodicConnectionHanble.close();
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
self.markToRedraw();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Widget display camera
|
|
||||||
public Camera mainView;
|
|
||||||
// Widget view mode
|
|
||||||
public ProjectionInterface projection;
|
|
||||||
// Environment model system.
|
|
||||||
protected Environement env;
|
|
||||||
|
|
||||||
/// Periodic call handle to remove it when needed
|
|
||||||
protected Connection periodicConnectionHanble = new Connection();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
*/
|
|
||||||
public EgeScene() {
|
|
||||||
this.propertyCanFocus = true;
|
|
||||||
markToRedraw();
|
|
||||||
// can not support multiple click...
|
|
||||||
setMouseLimit(2);
|
|
||||||
this.env = new Environement();
|
|
||||||
|
|
||||||
// default camera....
|
|
||||||
this.mainView = new Camera();
|
|
||||||
this.env.addCamera("default", this.mainView);
|
|
||||||
this.mainView.setPitch((float) Math.PI * -0.25f);
|
|
||||||
this.mainView.setPosition(new Vector3f(4, -5, 5));
|
|
||||||
|
|
||||||
this.projection = new ProjectionPerspective();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addGenericGird() {
|
|
||||||
// Simple Gird
|
|
||||||
final Entity gird = new Entity(this.env);
|
|
||||||
gird.addComponent(new ComponentPosition(new Transform3D(new Vector3f(0, 0, 0))));
|
|
||||||
gird.addComponent(new ComponentStaticMesh(MeshGenerator.createGrid(5)));
|
|
||||||
gird.addComponent(new ComponentRenderColoredStaticMesh(new Uri("DATA", "wireColor.vert", "ege"),
|
|
||||||
new Uri("DATA", "wireColor.frag", "ege")));
|
|
||||||
this.env.addEntity(gird);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void calculateMinMaxSize() {
|
|
||||||
// call main class
|
|
||||||
super.calculateMinMaxSize();
|
|
||||||
this.minSize = Vector3f.VALUE_128;
|
|
||||||
// verify the min max of the min size ...
|
|
||||||
checkMinSize();
|
|
||||||
LOGGER.error("min size = {}", this.minSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected float getAspectRatio() {
|
|
||||||
return this.size.x() / this.size.y();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onChangeSize() {
|
|
||||||
super.onChangeSize();
|
|
||||||
// update the projection matrix on the view size;
|
|
||||||
this.projection.updateMatrix(getSize());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onDraw() {
|
|
||||||
// Store openGl context.
|
|
||||||
OpenGL.push();
|
|
||||||
// set projection matrix:
|
|
||||||
OpenGL.setMatrix(this.projection.getMatrix());
|
|
||||||
|
|
||||||
// set the basic openGL view port: (Draw in all the windows...)
|
|
||||||
OpenGL.setViewPort(new Vector2f(0, 0), new Vector2f(getSize().x(), getSize().y()));
|
|
||||||
|
|
||||||
// clear background
|
|
||||||
//final Color bgColor = new Color(0.0f, 1.0f, 0.0f, 1.0f);
|
|
||||||
//OpenGL.clearColor(bgColor);
|
|
||||||
// real clear request:
|
|
||||||
//OpenGL.clear(OpenGL.ClearFlag.clearFlag_colorBuffer);
|
|
||||||
OpenGL.clear(OpenGL.ClearFlag.clearFlag_depthBuffer);
|
|
||||||
OpenGL.enable(Flag.flag_depthTest);
|
|
||||||
this.env.render(20, "default");
|
|
||||||
onDrawScene();
|
|
||||||
OpenGL.disable(Flag.flag_depthTest);
|
|
||||||
OpenGL.clear(OpenGL.ClearFlag.clearFlag_depthBuffer);
|
|
||||||
|
|
||||||
// Restore context of matrix
|
|
||||||
OpenGL.pop();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void onDrawScene() {
|
|
||||||
// nothing to do...
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onEventEntry(final EventEntry event) {
|
|
||||||
this.env.onKeyboard(event.specialKey(), event.type(), event.getChar(), event.status());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onEventInput(final EventInput event) {
|
|
||||||
keepFocus();
|
|
||||||
Vector3f relPos = relativePosition(new Vector3f(event.pos().x(), event.pos().y(), 0));
|
|
||||||
//LOGGER.warn("Event on Input ... {} relPos= {}", event, relPos);
|
|
||||||
this.env.onPointer(event.specialKey(), event.type(), event.inputId(), relPos, event.status());
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onRegenerateDisplay() {
|
|
||||||
this.env.periodicCall();
|
|
||||||
markToRedraw();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,101 +0,0 @@
|
|||||||
package sample.atriasoft.ege.mapFactory;
|
|
||||||
|
|
||||||
import java.util.function.BiFunction;
|
|
||||||
|
|
||||||
import org.atriasoft.etk.Color;
|
|
||||||
import org.atriasoft.etk.math.Transform3D;
|
|
||||||
import org.atriasoft.etk.math.Vector3f;
|
|
||||||
import org.atriasoft.etk.math.Vector4f;
|
|
||||||
import org.atriasoft.gale.resource.ResourceColored3DObject;
|
|
||||||
import org.atriasoft.loader3d.model.Material;
|
|
||||||
import org.atriasoft.loader3d.resources.ResourceMeshHeightMap;
|
|
||||||
|
|
||||||
import toolbox.Maths;
|
|
||||||
|
|
||||||
public class Ground {
|
|
||||||
int sizeX = 64;
|
|
||||||
int sizeY = 64;
|
|
||||||
float[][] heightMap = new float[this.sizeY][this.sizeX];
|
|
||||||
String[][] colorMap = new String[this.sizeY][this.sizeX * 2];
|
|
||||||
ResourceMeshHeightMap mesh = new ResourceMeshHeightMap();
|
|
||||||
String baseNamePalette = "palette:grass_1";
|
|
||||||
String baseNamePalette2 = "palette:grass_2";
|
|
||||||
String baseNamePalette3 = "palette:grass_3";
|
|
||||||
String baseNamePalette4 = "palette:grass_4";
|
|
||||||
|
|
||||||
public Ground() {
|
|
||||||
for (int yyy = 0; yyy < this.sizeY; yyy++) {
|
|
||||||
for (int xxx = 0; xxx < this.sizeX; xxx++) {
|
|
||||||
this.heightMap[yyy][xxx] = 0.0f;
|
|
||||||
if (xxx % 2 == 0) {
|
|
||||||
this.colorMap[yyy][xxx * 2] = this.baseNamePalette;
|
|
||||||
this.colorMap[yyy][xxx * 2 + 1] = this.baseNamePalette2;
|
|
||||||
} else {
|
|
||||||
this.colorMap[yyy][xxx * 2] = this.baseNamePalette3;
|
|
||||||
this.colorMap[yyy][xxx * 2 + 1] = this.baseNamePalette4;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void changeHeightOfElement(Vector3f position, float distance, BiFunction<Float, Float, Float> applyer) {
|
|
||||||
for (int yyy = 0; yyy < this.sizeY; yyy++) {
|
|
||||||
for (int xxx = 0; xxx < this.sizeX; xxx++) {
|
|
||||||
float offset = 0.0f;
|
|
||||||
if (xxx % 2 == 1) {
|
|
||||||
offset = 0.5f;
|
|
||||||
}
|
|
||||||
float dist2 = position.less(xxx, yyy + offset, 0).length2();
|
|
||||||
if (dist2 < distance * distance) {
|
|
||||||
this.heightMap[yyy][xxx] = applyer.apply(this.heightMap[yyy][xxx], Maths.sqrt(dist2));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
updateMesh();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ResourceMeshHeightMap createMesh() {
|
|
||||||
return this.mesh;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void drawDynamicElement(ResourceColored3DObject dynamicElement, Vector3f position, float distance) {
|
|
||||||
for (int yyy = 0; yyy < this.sizeY; yyy++) {
|
|
||||||
for (int xxx = 0; xxx < this.sizeX; xxx++) {
|
|
||||||
float dist2 = position.less(xxx, yyy, 0).length2();
|
|
||||||
if (dist2 < distance * distance) {
|
|
||||||
float coneHeight = 0.6f;
|
|
||||||
float offset = 0.0f;
|
|
||||||
if (xxx % 2 == 1) {
|
|
||||||
offset = 0.5f;
|
|
||||||
}
|
|
||||||
Transform3D tmpTransform = new Transform3D(new Vector3f(xxx, yyy + offset, this.heightMap[yyy][xxx] + coneHeight * 0.5f));
|
|
||||||
dynamicElement.drawCone(coneHeight * 0.5f, coneHeight, 10, 3, tmpTransform.getOpenGLMatrix(), Color.RED);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void updateMesh() {
|
|
||||||
this.mesh.clearData();
|
|
||||||
Material mat = new Material();
|
|
||||||
this.mesh.addMaterial(this.baseNamePalette, mat);
|
|
||||||
mat.setAmbientFactor(new Vector4f(1, 0, 0, 1.0f));
|
|
||||||
mat = new Material();
|
|
||||||
this.mesh.addMaterial(this.baseNamePalette2, mat);
|
|
||||||
mat.setAmbientFactor(new Vector4f(0, 1, 0, 1.0f));
|
|
||||||
mat = new Material();
|
|
||||||
this.mesh.addMaterial(this.baseNamePalette3, mat);
|
|
||||||
mat.setAmbientFactor(new Vector4f(0, 0, 1, 1.0f));
|
|
||||||
mat = new Material();
|
|
||||||
this.mesh.addMaterial(this.baseNamePalette4, mat);
|
|
||||||
mat.setAmbientFactor(new Vector4f(1, 1, 0, 1.0f));
|
|
||||||
try {
|
|
||||||
this.mesh.udateData(this.heightMap, this.colorMap, this.sizeX, this.sizeY);
|
|
||||||
} catch (Exception e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,65 +0,0 @@
|
|||||||
package sample.atriasoft.ege.mapFactory;
|
|
||||||
|
|
||||||
import org.atriasoft.etk.math.Vector3b;
|
|
||||||
import org.atriasoft.ewol.widget.Button;
|
|
||||||
import org.atriasoft.ewol.widget.Sizer;
|
|
||||||
import org.atriasoft.ewol.widget.Sizer.DisplayMode;
|
|
||||||
import org.atriasoft.ewol.widget.Widget;
|
|
||||||
import org.atriasoft.ewol.widget.Windows;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import sample.atriasoft.ege.mapFactory.tools.MapToolInterface;
|
|
||||||
import sample.atriasoft.ege.mapFactory.tools.ToolMapHeight;
|
|
||||||
|
|
||||||
public class MainWindows extends Windows {
|
|
||||||
final static private Logger LOGGER = LoggerFactory.getLogger(MainWindows.class);
|
|
||||||
|
|
||||||
public static void eventButtonTool(final MainWindows self, Boolean value) {
|
|
||||||
//Vector2b state = self.testWidget.getPropertyFill();
|
|
||||||
//self.testWidget.setPropertyFill(state.withY(!state.y()));
|
|
||||||
LOGGER.warn("event elements : {}", value);
|
|
||||||
if (value) {
|
|
||||||
self.scene.setCurrentTool(new ToolMapHeight());
|
|
||||||
} else {
|
|
||||||
self.scene.setCurrentTool(null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Button heightButton;
|
|
||||||
Button toolButton;
|
|
||||||
ApplScene scene;
|
|
||||||
|
|
||||||
public MainWindows() {
|
|
||||||
setPropertyTitle("Map Factory (create your dream world)");
|
|
||||||
|
|
||||||
Sizer sizerHoryMain = new Sizer(DisplayMode.HORIZONTAL);
|
|
||||||
sizerHoryMain.setPropertyExpand(Vector3b.TRUE);
|
|
||||||
sizerHoryMain.setPropertyFill(Vector3b.TRUE);
|
|
||||||
setSubWidget(sizerHoryMain);
|
|
||||||
|
|
||||||
this.scene = new ApplScene();
|
|
||||||
this.scene.setPropertyExpand(Vector3b.TRUE);
|
|
||||||
this.scene.setPropertyFill(Vector3b.TRUE);
|
|
||||||
sizerHoryMain.subWidgetAdd(this.scene);
|
|
||||||
|
|
||||||
Sizer sizerMenu = new Sizer(DisplayMode.VERTICAL);
|
|
||||||
sizerMenu.setPropertyExpand(Vector3b.FALSE_TRUE_FALSE);
|
|
||||||
sizerMenu.setPropertyLockExpand(Vector3b.TRUE);
|
|
||||||
sizerMenu.setPropertyFill(Vector3b.TRUE);
|
|
||||||
sizerHoryMain.subWidgetAdd(sizerMenu);
|
|
||||||
|
|
||||||
this.toolButton = Button.createToggleLabelButton("Heigher", "Brush");
|
|
||||||
this.toolButton.setPropertyExpand(Vector3b.TRUE_FALSE_FALSE);
|
|
||||||
this.toolButton.setPropertyFill(Vector3b.TRUE);
|
|
||||||
sizerMenu.subWidgetAdd(this.toolButton);
|
|
||||||
this.toolButton.signalValue.connectAuto(this, MainWindows::eventButtonTool);
|
|
||||||
|
|
||||||
// set default tools:
|
|
||||||
MapToolInterface tool = new ToolMapHeight();
|
|
||||||
this.scene.setCurrentTool(tool);
|
|
||||||
Widget toolDisplay = tool.getWidget();
|
|
||||||
sizerMenu.subWidgetAdd(toolDisplay);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
package sample.atriasoft.ege.mapFactory;
|
|
||||||
|
|
||||||
import org.atriasoft.ege.Ege;
|
|
||||||
import org.atriasoft.etk.Uri;
|
|
||||||
import org.atriasoft.ewol.Ewol;
|
|
||||||
import org.atriasoft.gale.Gale;
|
|
||||||
|
|
||||||
public class MapFactoryMain {
|
|
||||||
public static void main(final String[] args) {
|
|
||||||
Gale.init();
|
|
||||||
Ewol.init();
|
|
||||||
Ege.init();
|
|
||||||
Uri.setGroup("DATA", "data");
|
|
||||||
//Uri.setGroup("RES", "res");
|
|
||||||
//Uri.addLibrary("loxelEngine", MapFactoryMain.class, "/resources/testDataLoxelEngine");
|
|
||||||
//Uri.addLibrary("plop", Appl.class, "/resources/mapFactory");
|
|
||||||
Uri.setApplication(Appl.class, "resources/mapFactory");
|
|
||||||
Ewol.run(new Appl(), args);
|
|
||||||
}
|
|
||||||
|
|
||||||
private MapFactoryMain() {}
|
|
||||||
}
|
|
@ -1,12 +0,0 @@
|
|||||||
package sample.atriasoft.ege.mapFactory.model;
|
|
||||||
|
|
||||||
import sample.atriasoft.ege.mapFactory.Ground;
|
|
||||||
|
|
||||||
public class Map {
|
|
||||||
public Ground ground = new Ground();
|
|
||||||
|
|
||||||
public void updateMesh() {
|
|
||||||
this.ground.updateMesh();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,19 +0,0 @@
|
|||||||
package sample.atriasoft.ege.mapFactory.tools;
|
|
||||||
|
|
||||||
import org.atriasoft.ewol.event.EventEntry;
|
|
||||||
import org.atriasoft.ewol.event.EventInput;
|
|
||||||
import org.atriasoft.ewol.widget.Widget;
|
|
||||||
|
|
||||||
import sample.atriasoft.ege.mapFactory.EgeScene;
|
|
||||||
import sample.atriasoft.ege.mapFactory.model.Map;
|
|
||||||
|
|
||||||
public interface MapToolInterface {
|
|
||||||
Widget getWidget();
|
|
||||||
|
|
||||||
void onDraw(Map map);
|
|
||||||
|
|
||||||
boolean onEventEntry(final EventEntry event, Map map, EgeScene widget);
|
|
||||||
|
|
||||||
boolean onEventInput(final EventInput event, Map relPos, EgeScene widget);
|
|
||||||
|
|
||||||
}
|
|
@ -1,184 +0,0 @@
|
|||||||
package sample.atriasoft.ege.mapFactory.tools;
|
|
||||||
|
|
||||||
import org.atriasoft.ege.geometry.Ray;
|
|
||||||
import org.atriasoft.etk.Color;
|
|
||||||
import org.atriasoft.etk.Uri;
|
|
||||||
import org.atriasoft.etk.math.Transform3D;
|
|
||||||
import org.atriasoft.etk.math.Vector3f;
|
|
||||||
import org.atriasoft.ewol.event.EventEntry;
|
|
||||||
import org.atriasoft.ewol.event.EventInput;
|
|
||||||
import org.atriasoft.ewol.widget.Composer;
|
|
||||||
import org.atriasoft.ewol.widget.Slider;
|
|
||||||
import org.atriasoft.ewol.widget.Widget;
|
|
||||||
import org.atriasoft.gale.key.KeyStatus;
|
|
||||||
import org.atriasoft.gale.resource.ResourceColored3DObject;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import sample.atriasoft.ege.mapFactory.EgeScene;
|
|
||||||
import sample.atriasoft.ege.mapFactory.model.Map;
|
|
||||||
import toolbox.Maths;
|
|
||||||
|
|
||||||
public class ToolMapHeight implements MapToolInterface {
|
|
||||||
final static private Logger LOGGER = LoggerFactory.getLogger(ToolMapHeight.class);
|
|
||||||
|
|
||||||
protected static void onCallbackMaxChange(final ToolMapHeight self, final float value) {
|
|
||||||
LOGGER.warn("get new value {}", value);
|
|
||||||
self.onCallbackMax(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static void onCallbackMinChange(final ToolMapHeight self, final float value) {
|
|
||||||
LOGGER.warn("get new value {}", value);
|
|
||||||
self.onCallbackMin(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static void onCallbackWidthChange(final ToolMapHeight self, final float value) {
|
|
||||||
LOGGER.warn("get new value {}", value);
|
|
||||||
self.onCallbackValue(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
int uniqueID = 555245;
|
|
||||||
Vector3f positionRay = null;
|
|
||||||
|
|
||||||
float widthBrush = 3.0f;
|
|
||||||
float maxBrush = 10.0f;
|
|
||||||
float minBrush = -10.0f;
|
|
||||||
ResourceColored3DObject dynamicElement;
|
|
||||||
|
|
||||||
public ToolMapHeight() {
|
|
||||||
this.dynamicElement = ResourceColored3DObject.create();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Widget getWidget() {
|
|
||||||
final Widget data = Composer.composerGenerateFile(new Uri("DATA", "ToolMapHeight.xml"), this.uniqueID);
|
|
||||||
|
|
||||||
if (data.getSubObjectNamed(
|
|
||||||
"[" + Long.toString(this.uniqueID) + "]HeighMap:slider-width") instanceof final Slider tmp) {
|
|
||||||
tmp.signalValue.connectAuto(this, ToolMapHeight::onCallbackWidthChange);
|
|
||||||
}
|
|
||||||
if (data.getSubObjectNamed(
|
|
||||||
"[" + Long.toString(this.uniqueID) + "]HeighMap:slider-top") instanceof final Slider tmp) {
|
|
||||||
tmp.signalValue.connectAuto(this, ToolMapHeight::onCallbackMaxChange);
|
|
||||||
}
|
|
||||||
if (data.getSubObjectNamed(
|
|
||||||
"[" + Long.toString(this.uniqueID) + "]HeighMap:slider-bottom") instanceof final Slider tmp) {
|
|
||||||
tmp.signalValue.connectAuto(this, ToolMapHeight::onCallbackMinChange);
|
|
||||||
}
|
|
||||||
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void onCallbackMax(final float value) {
|
|
||||||
this.maxBrush = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void onCallbackMin(final float value) {
|
|
||||||
this.minBrush = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void onCallbackValue(final float value) {
|
|
||||||
this.widthBrush = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDraw(Map map) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
if (this.positionRay != null) {
|
|
||||||
map.ground.drawDynamicElement(this.dynamicElement, this.positionRay, this.widthBrush);
|
|
||||||
float size = this.maxBrush - this.minBrush;
|
|
||||||
Transform3D tmpTransform = new Transform3D(
|
|
||||||
this.positionRay.add(new Vector3f(0.0f, 0.0f, this.minBrush + size * 0.5f)));
|
|
||||||
this.dynamicElement.drawCylinder(this.widthBrush, size, 10, 22, tmpTransform.getOpenGLMatrix(),
|
|
||||||
Color.AZURE.withA(0.5f), false, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onEventEntry(EventEntry event, Map map, EgeScene widget) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onEventInput(EventInput event, Map map, EgeScene widget) {
|
|
||||||
Vector3f globalPos = new Vector3f(event.pos().x(), event.pos().y(), 0);
|
|
||||||
Vector3f relPos = widget.relativePosition(globalPos);
|
|
||||||
// simple ray-cast on the ground
|
|
||||||
Ray mouseRay = widget.mainView.getRayFromScreen(widget.projection, widget.getSize(), relPos);
|
|
||||||
this.positionRay = mouseRay.intersectPlane(new Vector3f(0.0f, 0.0f, 1.0f), 0.0f);
|
|
||||||
/*
|
|
||||||
if (this.positionRay != null) {
|
|
||||||
this.posRay.setTransform(this.posRay.getTransform().withPosition(this.positionRay));
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
if (event.inputId() == 1 && (event.status() == KeyStatus.move || event.status() == KeyStatus.down)) {
|
|
||||||
if (this.positionRay != null) {
|
|
||||||
map.ground.changeHeightOfElement(this.positionRay, this.widthBrush, (value, distance) -> {
|
|
||||||
if (value > this.maxBrush) {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
if (value < this.minBrush) {
|
|
||||||
return Maths.avg(-128.0f, value + 0.1f, this.maxBrush);
|
|
||||||
}
|
|
||||||
return Maths.avg(this.minBrush, value + 0.1f, this.maxBrush);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (event.inputId() == 3 && (event.status() == KeyStatus.move || event.status() == KeyStatus.down)) {
|
|
||||||
if (this.positionRay != null) {
|
|
||||||
map.ground.changeHeightOfElement(this.positionRay, this.widthBrush, (value, distance) -> {
|
|
||||||
if (value < this.minBrush) {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
if (value > this.maxBrush) {
|
|
||||||
return Maths.avg(this.minBrush, value - 0.1f, 128.0f);
|
|
||||||
}
|
|
||||||
return Maths.avg(this.minBrush, value - 0.1f, this.maxBrush);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
// max brush
|
|
||||||
if (event.inputId() == 4 && event.status() == KeyStatus.down && (event.specialKey() != null
|
|
||||||
&& event.specialKey().getAltLeft() && event.specialKey().getCtrlLeft())) {
|
|
||||||
this.maxBrush = Maths.avg(this.minBrush + 0.1f, this.maxBrush + 0.1f, 128.0f);
|
|
||||||
LOGGER.warn(" values: {} / {}", this.minBrush, this.maxBrush);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (event.inputId() == 5 && event.status() == KeyStatus.down && (event.specialKey() != null
|
|
||||||
&& event.specialKey().getAltLeft() && event.specialKey().getCtrlLeft())) {
|
|
||||||
this.maxBrush = Maths.avg(this.minBrush + 0.1f, this.maxBrush - 0.1f, 128.0f);
|
|
||||||
LOGGER.warn(" values: {} / {}", this.minBrush, this.maxBrush);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
// min brush
|
|
||||||
if (event.inputId() == 4 && event.status() == KeyStatus.down
|
|
||||||
&& (event.specialKey() != null && event.specialKey().getAltLeft())) {
|
|
||||||
this.minBrush = Maths.avg(-128.0f, this.minBrush + 0.1f, this.maxBrush - 0.1f);
|
|
||||||
LOGGER.warn(" values: {} / {}", this.minBrush, this.maxBrush);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (event.inputId() == 5 && event.status() == KeyStatus.down
|
|
||||||
&& (event.specialKey() != null && event.specialKey().getAltLeft())) {
|
|
||||||
this.minBrush = Maths.avg(-128.0f, this.minBrush - 0.1f, this.maxBrush - 0.1f);
|
|
||||||
LOGGER.warn(" values: {} / {}", this.minBrush, this.maxBrush);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
// width brush
|
|
||||||
if (event.inputId() == 4 && event.status() == KeyStatus.down
|
|
||||||
&& (event.specialKey() != null && event.specialKey().getCtrlLeft())) {
|
|
||||||
this.widthBrush = Maths.avg(0.1f, this.widthBrush + 0.1f, 30.0f);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (event.inputId() == 5 && event.status() == KeyStatus.down
|
|
||||||
&& (event.specialKey() != null && event.specialKey().getCtrlLeft())) {
|
|
||||||
this.widthBrush = Maths.avg(0.1f, this.widthBrush - 0.1f, 30.0f);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,110 +0,0 @@
|
|||||||
package sample.atriasoft.ege.oldTest;
|
|
||||||
|
|
||||||
import java.nio.IntBuffer;
|
|
||||||
|
|
||||||
import org.lwjgl.*;
|
|
||||||
import org.lwjgl.glfw.*;
|
|
||||||
import org.lwjgl.opengl.*;
|
|
||||||
import org.lwjgl.system.*;
|
|
||||||
|
|
||||||
public class HelloWorld {
|
|
||||||
|
|
||||||
public static void main(final String[] args) {
|
|
||||||
new HelloWorld().run();
|
|
||||||
}
|
|
||||||
|
|
||||||
// The window handle
|
|
||||||
private long window;
|
|
||||||
|
|
||||||
private void init() {
|
|
||||||
// Setup an error callback. The default implementation
|
|
||||||
// will print the error message in System.err.
|
|
||||||
//GLFWErrorCallback.createPrint(System.err).set();
|
|
||||||
|
|
||||||
// Initialize GLFW. Most GLFW functions will not work before doing this.
|
|
||||||
if (!GLFW.glfwInit()) {
|
|
||||||
throw new IllegalStateException("Unable to initialize GLFW");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Configure GLFW
|
|
||||||
GLFW.glfwDefaultWindowHints(); // optional, the current window hints are already the default
|
|
||||||
GLFW.glfwWindowHint(GLFW.GLFW_VISIBLE, GLFW.GLFW_FALSE); // the window will stay hidden after creation
|
|
||||||
GLFW.glfwWindowHint(GLFW.GLFW_RESIZABLE, GLFW.GLFW_TRUE); // the window will be resizable
|
|
||||||
|
|
||||||
// Create the window
|
|
||||||
this.window = GLFW.glfwCreateWindow(300, 300, "Hello World!", MemoryUtil.NULL, MemoryUtil.NULL);
|
|
||||||
if (this.window == MemoryUtil.NULL) {
|
|
||||||
throw new RuntimeException("Failed to create the GLFW window");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Setup a key callback. It will be called every time a key is pressed, repeated or released.
|
|
||||||
GLFW.glfwSetKeyCallback(this.window, (window, key, scancode, action, mods) -> {
|
|
||||||
if (key == GLFW.GLFW_KEY_ESCAPE && action == GLFW.GLFW_RELEASE) {
|
|
||||||
GLFW.glfwSetWindowShouldClose(window, true); // We will detect this in the rendering loop
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Get the thread stack and push a new frame
|
|
||||||
try (MemoryStack stack = MemoryStack.stackPush()) {
|
|
||||||
IntBuffer pWidth = stack.mallocInt(1); // int*
|
|
||||||
IntBuffer pHeight = stack.mallocInt(1); // int*
|
|
||||||
|
|
||||||
// Get the window size passed to glfwCreateWindow
|
|
||||||
GLFW.glfwGetWindowSize(this.window, pWidth, pHeight);
|
|
||||||
|
|
||||||
// Get the resolution of the primary monitor
|
|
||||||
GLFWVidMode vidmode = GLFW.glfwGetVideoMode(GLFW.glfwGetPrimaryMonitor());
|
|
||||||
|
|
||||||
// Center the window
|
|
||||||
GLFW.glfwSetWindowPos(this.window, (vidmode.width() - pWidth.get(0)) / 2, (vidmode.height() - pHeight.get(0)) / 2);
|
|
||||||
} // the stack frame is popped automatically
|
|
||||||
|
|
||||||
// Make the OpenGL context current
|
|
||||||
GLFW.glfwMakeContextCurrent(this.window);
|
|
||||||
// Enable v-sync
|
|
||||||
GLFW.glfwSwapInterval(1);
|
|
||||||
|
|
||||||
// Make the window visible
|
|
||||||
GLFW.glfwShowWindow(this.window);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void loop() {
|
|
||||||
// This line is critical for LWJGL's interoperation with GLFW's
|
|
||||||
// OpenGL context, or any context that is managed externally.
|
|
||||||
// LWJGL detects the context that is current in the current thread,
|
|
||||||
// creates the GLCapabilities instance and makes the OpenGL
|
|
||||||
// bindings available for use.
|
|
||||||
GL.createCapabilities();
|
|
||||||
|
|
||||||
// Set the clear color
|
|
||||||
GL11.glClearColor(1.0f, 0.0f, 0.0f, 0.0f);
|
|
||||||
|
|
||||||
// Run the rendering loop until the user has attempted to close
|
|
||||||
// the window or has pressed the ESCAPE key.
|
|
||||||
while (!GLFW.glfwWindowShouldClose(this.window)) {
|
|
||||||
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); // clear the framebuffer
|
|
||||||
|
|
||||||
GLFW.glfwSwapBuffers(this.window); // swap the color buffers
|
|
||||||
|
|
||||||
// Poll for window events. The key callback above will only be
|
|
||||||
// invoked during this call.
|
|
||||||
GLFW.glfwPollEvents();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void run() {
|
|
||||||
System.out.println("Hello LWJGL " + Version.getVersion() + "!");
|
|
||||||
|
|
||||||
init();
|
|
||||||
loop();
|
|
||||||
|
|
||||||
// Free the window callbacks and destroy the window
|
|
||||||
Callbacks.glfwFreeCallbacks(this.window);
|
|
||||||
GLFW.glfwDestroyWindow(this.window);
|
|
||||||
|
|
||||||
// Terminate GLFW and free the error callback
|
|
||||||
GLFW.glfwTerminate();
|
|
||||||
GLFW.glfwSetErrorCallback(null).free();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,175 +0,0 @@
|
|||||||
package sample.atriasoft.ege.oldTest;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
import org.atriasoft.ege.Ege;
|
|
||||||
import org.atriasoft.etk.Uri;
|
|
||||||
import org.atriasoft.etk.math.Vector2f;
|
|
||||||
import org.atriasoft.etk.math.Vector3f;
|
|
||||||
import org.atriasoft.gale.Gale;
|
|
||||||
|
|
||||||
import entities.Camera;
|
|
||||||
import entities.Entity;
|
|
||||||
import entities.Light;
|
|
||||||
import entities.Player;
|
|
||||||
import guis.GuiRenderer;
|
|
||||||
import guis.GuiTexture;
|
|
||||||
import models.TexturedModel;
|
|
||||||
import renderEngine.DisplayManager;
|
|
||||||
import renderEngine.DisplayManagerDraw;
|
|
||||||
import renderEngine.Loader;
|
|
||||||
import renderEngine.MasterRenderer;
|
|
||||||
import renderEngine.OBJLoader;
|
|
||||||
import terrains.Terrain;
|
|
||||||
import terrains.TerrainTexture;
|
|
||||||
import terrains.TerrainTexturePack;
|
|
||||||
import textures.ModelTexture;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This class contains the main method and is used to test the engine.
|
|
||||||
*
|
|
||||||
* @author Karl
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class MainGameLoop {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Loads up the position data for two triangles (which together make a quad)
|
|
||||||
* into a VAO. This VAO is then rendered to the screen every frame.
|
|
||||||
*
|
|
||||||
* @param args
|
|
||||||
*/
|
|
||||||
public static void main(final String[] args) {
|
|
||||||
Gale.init();
|
|
||||||
Ege.init();
|
|
||||||
Uri.setGroup("DATA", "data");
|
|
||||||
Uri.setGroup("RES", "res");
|
|
||||||
Uri.addLibrary("loxelEngine", MainGameLoop.class, "resources/testDataLoxelEngine");
|
|
||||||
Uri.setApplication(MainGameLoop.class, "resources");
|
|
||||||
|
|
||||||
final DisplayManager manager = new DisplayManager();
|
|
||||||
final Loader loader = new Loader();
|
|
||||||
manager.init();
|
|
||||||
|
|
||||||
final List<Entity> entities = new ArrayList<>();
|
|
||||||
final Random random = new Random();
|
|
||||||
|
|
||||||
final TexturedModel staticModel = new TexturedModel(
|
|
||||||
OBJLoader.loadObjModel(new Uri("RES", "tree.obj", "sample"), loader),
|
|
||||||
new ModelTexture(loader.loadTexture("tree")));
|
|
||||||
//ModelTexture texture = staticModel.getTexture();
|
|
||||||
//texture.setShineDamper(10);
|
|
||||||
//texture.setReflectivity(1);
|
|
||||||
|
|
||||||
final TexturedModel grassModel = new TexturedModel(
|
|
||||||
OBJLoader.loadObjModel(new Uri("RES", "grassModel.obj", "sample"), loader),
|
|
||||||
new ModelTexture(loader.loadTexture("grassTexture")));
|
|
||||||
grassModel.getTexture().setHasTransparency(true);
|
|
||||||
grassModel.getTexture().setUseFakeLighting(true);
|
|
||||||
|
|
||||||
final TexturedModel flowerModel = new TexturedModel(
|
|
||||||
OBJLoader.loadObjModel(new Uri("RES", "grassModel.obj", "sample"), loader),
|
|
||||||
new ModelTexture(loader.loadTexture("flower")));
|
|
||||||
flowerModel.getTexture().setHasTransparency(true);
|
|
||||||
flowerModel.getTexture().setUseFakeLighting(true);
|
|
||||||
|
|
||||||
final TexturedModel fernModel = new TexturedModel(
|
|
||||||
OBJLoader.loadObjModel(new Uri("RES", "fern.obj", "sample"), loader),
|
|
||||||
new ModelTexture(loader.loadTexture("fern_atlas")));
|
|
||||||
fernModel.getTexture().setHasTransparency(true);
|
|
||||||
fernModel.getTexture().setNumberOfRows(2);
|
|
||||||
|
|
||||||
final TexturedModel lampModel = new TexturedModel(
|
|
||||||
OBJLoader.loadObjModel(new Uri("RES", "lamp.obj", "sample"), loader),
|
|
||||||
new ModelTexture(loader.loadTexture("lamp")));
|
|
||||||
//lampModel.getTexture().setHasTransparency(true);
|
|
||||||
lampModel.getTexture().setUseFakeLighting(true); // this permit to the light to glow
|
|
||||||
|
|
||||||
final TexturedModel pineModel = new TexturedModel(
|
|
||||||
OBJLoader.loadObjModel(new Uri("RES", "pine.obj", "sample"), loader),
|
|
||||||
new ModelTexture(loader.loadTexture("pine")));
|
|
||||||
|
|
||||||
final List<Light> lights = new ArrayList<>();
|
|
||||||
lights.add(new Light(new Vector3f(0, 10000, -7000), new Vector3f(0.4f, 0.4f, 0.4f)));
|
|
||||||
lights.add(new Light(new Vector3f(185, 10, -293), new Vector3f(2, 0, 0), new Vector3f(1, 0.01f, 0.002f)));
|
|
||||||
lights.add(new Light(new Vector3f(370, 17, -300), new Vector3f(0, 2, 2), new Vector3f(1, 0.01f, 0.002f)));
|
|
||||||
lights.add(new Light(new Vector3f(293, 7, -305), new Vector3f(2, 2, 0), new Vector3f(1, 0.01f, 0.002f)));
|
|
||||||
|
|
||||||
entities.add(new Entity(lampModel, new Vector3f(185, -4.7f, -293), new Vector3f(0, 0, 0), 1));
|
|
||||||
entities.add(new Entity(lampModel, new Vector3f(370, 4.2f, -300), new Vector3f(0, 0, 0), 1));
|
|
||||||
entities.add(new Entity(lampModel, new Vector3f(293, -6.8f, -305), new Vector3f(0, 0, 0), 1));
|
|
||||||
|
|
||||||
final TerrainTexture backgroundTexture = new TerrainTexture(loader.loadTexture("grass"));
|
|
||||||
final TerrainTexture rTexture = new TerrainTexture(loader.loadTexture("dirt"));
|
|
||||||
final TerrainTexture gTexture = new TerrainTexture(loader.loadTexture("grassFlowers"));
|
|
||||||
final TerrainTexture bTexture = new TerrainTexture(loader.loadTexture("path"));
|
|
||||||
final TerrainTexturePack texturePack = new TerrainTexturePack(backgroundTexture, rTexture, gTexture, bTexture);
|
|
||||||
|
|
||||||
final TerrainTexture blendMap = new TerrainTexture(loader.loadTexture("blendMap"));
|
|
||||||
|
|
||||||
final Terrain terrain = new Terrain(0, -1, loader, texturePack, blendMap, "heightmap");
|
|
||||||
|
|
||||||
for (int iii = 0; iii < 250; iii++) {
|
|
||||||
final float x = random.nextFloat() * 800 - 400;
|
|
||||||
final float z = random.nextFloat() * -600;
|
|
||||||
final float y = terrain.getHeightOfTerrain(x, z);
|
|
||||||
entities.add(new Entity(staticModel, new Vector3f(x, y, z), new Vector3f(0, 0, 0), 3));
|
|
||||||
}
|
|
||||||
for (int iii = 0; iii < 250; iii++) {
|
|
||||||
final float x = random.nextFloat() * 800 - 400;
|
|
||||||
final float z = random.nextFloat() * -600;
|
|
||||||
final float y = terrain.getHeightOfTerrain(x, z);
|
|
||||||
entities.add(new Entity(pineModel, new Vector3f(x, y, z), new Vector3f(0, 0, 0), 0.5f));
|
|
||||||
}
|
|
||||||
for (int iii = 0; iii < 500; iii++) {
|
|
||||||
final float x = random.nextFloat() * 800 - 400;
|
|
||||||
final float z = random.nextFloat() * -600;
|
|
||||||
final float y = terrain.getHeightOfTerrain(x, z);
|
|
||||||
entities.add(new Entity(fernModel, random.nextInt(4), new Vector3f(x, y, z), new Vector3f(0, 0, 0), 0.6f));
|
|
||||||
}
|
|
||||||
|
|
||||||
final TexturedModel playerModel = new TexturedModel(
|
|
||||||
OBJLoader.loadObjModel(new Uri("RES", "person.obj", "sample"), loader),
|
|
||||||
new ModelTexture(loader.loadTexture("playerTexture")));
|
|
||||||
|
|
||||||
final Player player = new Player(playerModel, new Vector3f(180, terrain.getHeightOfTerrain(180, -250), -250),
|
|
||||||
new Vector3f(0, 3.14f, 0), 0.4f);
|
|
||||||
|
|
||||||
final Camera camera = new Camera(player);
|
|
||||||
|
|
||||||
final List<GuiTexture> guis = new ArrayList<>();
|
|
||||||
final GuiTexture gui = new GuiTexture(loader.loadTexture("health"), new Vector2f(-0.75f, 0.9f),
|
|
||||||
new Vector2f(0.25f, 0.25f));
|
|
||||||
guis.add(gui);
|
|
||||||
|
|
||||||
final GuiRenderer guiRenderer = new GuiRenderer(loader);
|
|
||||||
final MasterRenderer renderer = new MasterRenderer(loader);
|
|
||||||
|
|
||||||
manager.setDrawer(new DisplayManagerDraw() {
|
|
||||||
@Override
|
|
||||||
public void draw() {
|
|
||||||
//entity.increasePosition(0.0f, 0, -0.01f);
|
|
||||||
//entity.increaseRotation(0, 0, 0.01f);
|
|
||||||
//entity.increaseRotation(0.01f, 0.02f, 0.0f);
|
|
||||||
player.move(terrain);
|
|
||||||
camera.move();
|
|
||||||
renderer.processTerrain(terrain);
|
|
||||||
renderer.processEntity(player);
|
|
||||||
for (final Entity entity : entities) {
|
|
||||||
entity.increaseRotation(0, 0.01f, 0.0f);
|
|
||||||
renderer.processEntity(entity);
|
|
||||||
}
|
|
||||||
renderer.render(lights, camera);
|
|
||||||
guiRenderer.render(guis);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
manager.loop();
|
|
||||||
guiRenderer.cleanUp();
|
|
||||||
renderer.cleanUp();
|
|
||||||
loader.cleanUp();
|
|
||||||
manager.unInit();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
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(final String[] args) {
|
|
||||||
Gale.init();
|
|
||||||
Ege.init();
|
|
||||||
Uri.setGroup("DATA", "data");
|
|
||||||
Uri.setGroup("RES", "res");
|
|
||||||
// Add some base path of the providers:
|
|
||||||
Uri.addLibrary("sample", MainCollisionTest.class, "/resources/s1_textured_cube");
|
|
||||||
Uri.addLibrary("loxelEngine", MainCollisionTest.class, "/resources/testDataLoxelEngine");
|
|
||||||
Uri.setApplication(MainCollisionTest.class, "/resources");
|
|
||||||
Gale.run(new S1Application(), args);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Main() {}
|
|
||||||
}
|
|
@ -1,165 +0,0 @@
|
|||||||
package sample.atriasoft.ege.s1_texturedCube;
|
|
||||||
|
|
||||||
import org.atriasoft.ege.ControlCameraSimple;
|
|
||||||
import org.atriasoft.ege.Entity;
|
|
||||||
import org.atriasoft.ege.Environement;
|
|
||||||
import org.atriasoft.ege.GameStatus;
|
|
||||||
import org.atriasoft.ege.camera.Camera;
|
|
||||||
import org.atriasoft.ege.components.ComponentPosition;
|
|
||||||
import org.atriasoft.ege.components.ComponentRenderColoredStaticMesh;
|
|
||||||
import org.atriasoft.ege.components.ComponentRenderTexturedStaticMesh;
|
|
||||||
import org.atriasoft.ege.components.ComponentStaticMesh;
|
|
||||||
import org.atriasoft.ege.components.ComponentTexture;
|
|
||||||
import org.atriasoft.ege.tools.MeshGenerator;
|
|
||||||
import org.atriasoft.etk.Color;
|
|
||||||
import org.atriasoft.etk.Uri;
|
|
||||||
import org.atriasoft.etk.math.Matrix4f;
|
|
||||||
import org.atriasoft.etk.math.Quaternion;
|
|
||||||
import org.atriasoft.etk.math.Transform3D;
|
|
||||||
import org.atriasoft.etk.math.Vector2f;
|
|
||||||
import org.atriasoft.etk.math.Vector3f;
|
|
||||||
import org.atriasoft.gale.GaleApplication;
|
|
||||||
import org.atriasoft.gale.backend3d.OpenGL;
|
|
||||||
import org.atriasoft.gale.backend3d.OpenGL.Flag;
|
|
||||||
import org.atriasoft.gale.context.GaleContext;
|
|
||||||
import org.atriasoft.gale.key.KeyKeyboard;
|
|
||||||
import org.atriasoft.gale.key.KeySpecial;
|
|
||||||
import org.atriasoft.gale.key.KeyStatus;
|
|
||||||
import org.atriasoft.gale.key.KeyType;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
public class S1Application extends GaleApplication {
|
|
||||||
final static private Logger LOGGER = LoggerFactory.getLogger(S1Application.class);
|
|
||||||
|
|
||||||
private Quaternion basicRotation = Quaternion.IDENTITY;
|
|
||||||
private Quaternion basicRotation2 = Quaternion.IDENTITY;
|
|
||||||
private Environement env;
|
|
||||||
private Camera mainView;
|
|
||||||
private ComponentPosition objectPosition;
|
|
||||||
private boolean signe = false;
|
|
||||||
private ControlCameraSimple simpleControl;
|
|
||||||
|
|
||||||
public S1Application() {}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreate(final GaleContext context) {
|
|
||||||
LOGGER.info("On create .... [BEGIN]");
|
|
||||||
this.env = new Environement();
|
|
||||||
setSize(new Vector2f(800, 600));
|
|
||||||
setTitle("Low Poly sample");
|
|
||||||
|
|
||||||
final Entity gird = new Entity(this.env);
|
|
||||||
gird.addComponent(new ComponentPosition(new Transform3D(new Vector3f(0, 0, 0))));
|
|
||||||
gird.addComponent(new ComponentStaticMesh(MeshGenerator.createGrid(5)));
|
|
||||||
gird.addComponent(new ComponentRenderColoredStaticMesh(new Uri("DATA", "wireColor.vert", "ege"),
|
|
||||||
new Uri("DATA", "wireColor.frag", "ege")));
|
|
||||||
this.env.addEntity(gird);
|
|
||||||
|
|
||||||
final Entity basicTree = new Entity(this.env);
|
|
||||||
this.objectPosition = new ComponentPosition(new Transform3D(new Vector3f(0, 0, -5)));
|
|
||||||
basicTree.addComponent(this.objectPosition);
|
|
||||||
basicTree.addComponent(new ComponentStaticMesh(new Uri("RES", "cube.obj")));
|
|
||||||
basicTree.addComponent(new ComponentTexture(new Uri("DATA", "blocks/dirt.png", "loxelEngine")));
|
|
||||||
basicTree.addComponent(new ComponentRenderTexturedStaticMesh(new Uri("DATA", "basic.vert", "sample"),
|
|
||||||
new Uri("DATA", "basic.frag", "sample")));
|
|
||||||
this.env.addEntity(basicTree);
|
|
||||||
|
|
||||||
this.mainView = new Camera();
|
|
||||||
this.env.addCamera("default", this.mainView);
|
|
||||||
//mainView.setPitch((float) Math.PI * -0.25f);
|
|
||||||
//mainView.setPosition(new Vector3f(0, 0, -5));
|
|
||||||
|
|
||||||
this.simpleControl = new ControlCameraSimple(this.mainView);
|
|
||||||
this.env.addControlInterface(this.simpleControl);
|
|
||||||
|
|
||||||
// start the engine.
|
|
||||||
this.env.setPropertyStatus(GameStatus.gameStart);
|
|
||||||
|
|
||||||
this.basicRotation = Quaternion.fromEulerAngles(new Vector3f(0, 0, 0.01f));
|
|
||||||
this.basicRotation2 = Quaternion.fromEulerAngles(new Vector3f(0.003f, 0.01f, 0.001f));
|
|
||||||
// ready to let Gale & Ege manage the display
|
|
||||||
LOGGER.info("==> Init APPL (END)");
|
|
||||||
LOGGER.info("On create .... [ END ]");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDraw(final GaleContext context) {
|
|
||||||
LOGGER.info("On draw .... [BEGIN]");
|
|
||||||
//LOGGER.info("==> appl Draw ...");
|
|
||||||
final Vector2f size = getSize();
|
|
||||||
// Store openGl context.
|
|
||||||
OpenGL.push();
|
|
||||||
// set projection matrix:
|
|
||||||
final Matrix4f tmpProjection = Matrix4f.createMatrixPerspective(3.14f * 0.5f, getAspectRatio(), 0.1f, 50000);
|
|
||||||
//final Matrix4f tmpProjection = Matrix4f.createMatrixOrtho(300, 300, 400, 400, -50000, 50000);
|
|
||||||
OpenGL.setMatrix(tmpProjection);
|
|
||||||
|
|
||||||
// set the basic openGL view port: (Draw in all the windows...)
|
|
||||||
OpenGL.setViewPort(new Vector2f(0, 0), size);
|
|
||||||
|
|
||||||
// clear background
|
|
||||||
final Color bgColor = new Color(0.0f, 1.0f, 0.0f, 1.0f);
|
|
||||||
OpenGL.clearColor(bgColor);
|
|
||||||
// real clear request:
|
|
||||||
OpenGL.clear(OpenGL.ClearFlag.clearFlag_colorBuffer);
|
|
||||||
OpenGL.clear(OpenGL.ClearFlag.clearFlag_depthBuffer);
|
|
||||||
OpenGL.enable(Flag.flag_depthTest);
|
|
||||||
|
|
||||||
this.env.render(20, "default");
|
|
||||||
// Restore context of matrix
|
|
||||||
OpenGL.pop();
|
|
||||||
LOGGER.info("On draw .... [ END ]");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onKeyboard(
|
|
||||||
final KeySpecial special,
|
|
||||||
final KeyKeyboard type,
|
|
||||||
final Character value,
|
|
||||||
final KeyStatus state) {
|
|
||||||
this.env.onKeyboard(special, type, value, state);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPointer(
|
|
||||||
final KeySpecial special,
|
|
||||||
final KeyType type,
|
|
||||||
final int pointerID,
|
|
||||||
final Vector2f pos,
|
|
||||||
final KeyStatus state) {
|
|
||||||
this.env.onPointer(special, type, pointerID, new Vector3f(pos.x(), pos.y(), 0), state);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onRegenerateDisplay(final GaleContext context) {
|
|
||||||
LOGGER.info("On Regenerate Display .... [BEGIN]");
|
|
||||||
//LOGGER.trace("Regenerate Gale Application");
|
|
||||||
|
|
||||||
//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 little rotation to show the element move
|
|
||||||
this.objectPosition.setTransform(this.objectPosition.getTransform().rotate(this.basicRotation));
|
|
||||||
this.objectPosition.setTransform(this.objectPosition.getTransform().rotate(this.basicRotation2));
|
|
||||||
this.env.periodicCall();
|
|
||||||
markDrawingIsNeeded();
|
|
||||||
LOGGER.info("On Regenerate Display .... [ END ]");
|
|
||||||
}
|
|
||||||
}
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user