[DEV] set game working

This commit is contained in:
Edouard DUPIN 2021-05-27 00:17:48 +02:00
parent 7df6179a53
commit 891f6ba5bc
5 changed files with 26 additions and 2 deletions

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="resources"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" output="out/eclipse/classes-test" path="test/src">
<attributes>
<attribute name="test" value="true"/>

View File

@ -413,6 +413,8 @@ void setNormalMode(NormalMode _mode) {
// Log.debug("nb cycle ? : " + tmpppppp);
// #endif
}
List<Integer> outIndex = new ArrayList<>();
if (this.listPaletteFaces.size() != 0) {
FaceIndexing outputIndex = new FaceIndexing();
//Add palette virtual material:
@ -481,6 +483,7 @@ void setNormalMode(NormalMode _mode) {
}
for(int indice=0 ; indice<nbIndicInFace; indice++) {
outputIndex.index().add(vertexVBOId[indice]);
outIndex.add(vertexVBOId[indice]);
}
}
}
@ -490,6 +493,7 @@ void setNormalMode(NormalMode _mode) {
this.vao.setPosition(outPosition);
this.vao.setTextureCoordinate(outTexturePosition);
this.vao.setColors(outColor);
this.vao.setIndices(outIndex);
this.vao.flush();
}

View File

@ -10,6 +10,7 @@ import org.atriasoft.etk.math.Vector2f;
import org.atriasoft.etk.math.Vector3f;
import org.atriasoft.etk.math.Vector4f;
import org.atriasoft.etk.util.Dynamic;
import org.atriasoft.gale.backend3d.OpenGL.RenderMode;
import org.atriasoft.loader3d.Face;
import org.atriasoft.loader3d.FaceIndexing;
import org.atriasoft.loader3d.NormalMode;
@ -54,6 +55,7 @@ enum emfModuleMode {
// TODO : rework with string line extractor
public ResourceMeshEmf(Uri _fileName) {
super(_fileName);
mode = RenderMode.TRIANGLE;
this.checkNormal = true;
this.normalMode = NormalMode.NONE;
InputStream fileIOStream = Uri.getStream(_fileName);

View File

@ -33,7 +33,7 @@ import org.atriasoft.gale.resource.Resource;
* example black, or white or orange ...)
*/
public class ResourcePaletteFile extends Resource {
private static final int COUNT_MAX_COLOR_PALETTE = 4096;
private static final int COUNT_MAX_COLOR_PALETTE = 32;
private static final List<String> PALETTE_ELEMENTS = new ArrayList<>(COUNT_MAX_COLOR_PALETTE);
static {
PALETTE_ELEMENTS.add("unknown");
@ -180,9 +180,21 @@ public class ResourcePaletteFile extends Resource {
int width = COUNT_MAX_COLOR_PALETTE;
int height = 8;
ImageByteRGBA out = new ImageByteRGBA(width, height);
//ImageByteRGB out = new ImageByteRGB(width, height);
// clear the palette:
//float val = 0.0f;
for (int xxx=0; xxx < width; xxx++) {
for (int yyy=0; yyy < 8; yyy++) {
out.setColorFloat(xxx, yyy, 1, 1, 1, 1);
//out.setColorFloat(xxx, yyy, val, val + 0.125f, val + 0.85f, 1);
//val += 0.01f;
}
}
for (Entry<String, MaterialBase> it : this.list.entrySet()) {
int id = getColorId(it.getKey());
MaterialBase mat = it.getValue();
Log.error("add Material in texture: '" + it.getKey() + "' ==> " + id + " mat=" + mat);
// 2 element this will permit to change color in the future on depend on some parameters...
out.setColorFloat(id, 0, mat.getDiffuseFactor().x(), mat.getDiffuseFactor().y(), mat.getDiffuseFactor().z(), mat.getDiffuseFactor().w());
out.setColorFloat(id, 1, mat.getDiffuseFactor().x(), mat.getDiffuseFactor().y(), mat.getDiffuseFactor().z(), mat.getDiffuseFactor().w());

View File

@ -39,6 +39,12 @@ public class ResourceStaticMesh extends Resource {
}
this.vao.render(this.mode);
}
public void renderArrays() {
if (this.vao == null) {
return;
}
this.vao.renderArrays(this.mode);
}
public void setMode(final RenderMode mode) {
this.mode = mode;