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