[DEV] add capability to load EMF

This commit is contained in:
Edouard DUPIN 2021-05-24 13:45:28 +02:00
parent 16ffcee086
commit 7df6179a53
30 changed files with 2601 additions and 15 deletions

7
.checkstyle Normal file
View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<fileset-config file-format-version="1.2.0" simple-config="true" sync-formatter="false">
<fileset name="all" enabled="true" check-config-name="Ewol" local="false">
<file-match-pattern match-pattern="." include-pattern="true"/>
</fileset>
</fileset-config>

View File

@ -1,12 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="resources"/>
<classpathentry kind="src" output="out/eclipse/classes-test" path="test/src">
<attributes>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/scenarium-logger">
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5"/>
<classpathentry combineaccessrules="false" kind="src" path="/atriasoft-gale">
<attributes>
<attribute name="module" value="true"/>
</attributes>
@ -16,10 +23,15 @@
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry combineaccessrules="false" kind="src" path="/atriasoft-gale">
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/scenarium-logger">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="out/eclipse/"/>
<classpathentry combineaccessrules="false" kind="src" path="/atriasoft-ejson">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="out/eclipse/classes"/>
</classpath>

1
out/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/eclipse/

File diff suppressed because one or more lines are too long

View File

@ -7,4 +7,6 @@ module org.atriasoft.loader3d {
requires transitive org.atriasoft.etk;
requires transitive org.atriasoft.gale;
requires org.atriasoft.egami;
requires org.atriasoft.ejson;
}

View File

@ -0,0 +1,117 @@
package org.atriasoft.loader3d;
public class Face {
public byte nbElement;
public final int[] vertex = new int[3];
public final int[] uv = new int[3];
public final int[] normal = new int[3];
public final int[] color = new int[3];
public Face() {
this.nbElement = 1;
this.vertex[0] = -1;
this.vertex[1] = -1;
this.vertex[2] = -1;
this.uv[0] = -1;
this.uv[1] = -1;
this.uv[2] = -1;
this.normal[0] = -1;
this.normal[1] = -1;
this.normal[2] = -1;
this.color[0] = -1;
this.color[1] = -1;
this.color[2] = -1;
}
public Face(int _v1, int _t1,
int _v2, int _t2,
int _v3, int _t3) {
this.nbElement = 3;
this.vertex[0] = _v1;
this.vertex[1] = _v2;
this.vertex[2] = _v3;
this.uv[0] = _t1;
this.uv[1] = _t2;
this.uv[2] = _t3;
this.normal[0] = -1;
this.normal[1] = -1;
this.normal[2] = -1;
this.color[0] = -1;
this.color[1] = -1;
this.color[2] = -1;
}
public Face(int _v1, int _t1, int _n1,
int _v2, int _t2, int _n2,
int _v3, int _t3, int _n3) {
this.nbElement = 3;
this.vertex[0] = _v1;
this.vertex[1] = _v2;
this.vertex[2] = _v3;
this.uv[0] = _t1;
this.uv[1] = _t2;
this.uv[2] = _t3;
this.normal[0] = _n1;
this.normal[1] = _n2;
this.normal[2] = _n3;
this.color[0] = -1;
this.color[1] = -1;
this.color[2] = -1;
}
public void setVertex(int _v1) {
this.nbElement = 1;
this.vertex[0] = _v1;
}
public void setVertex(int _v1, int _v2) {
this.nbElement = 2;
this.vertex[0] = _v1;
this.vertex[1] = _v2;
}
public void setVertex(int _v1, int _v2, int _v3) {
this.nbElement = 3;
this.vertex[0] = _v1;
this.vertex[1] = _v2;
this.vertex[2] = _v3;
}
public void setTexture(int _t1, int _t2, int _t3) {
this.uv[0] = _t1;
this.uv[1] = _t2;
this.uv[2] = _t3;
}
public void setNormal(int _n1, int _n2, int _n3) {
this.normal[0] = _n1;
this.normal[1] = _n2;
this.normal[2] = _n3;
}
public void setColor(int _c1, int _c2, int _c3) {
this.color[0] = _c1;
this.color[1] = _c2;
this.color[2] = _c3;
}
public static Face valueOf(String data, int offsetVertex, int offsetUV, int offsetNormal) {
while(data.length() >= 1 && data.charAt(0) == ' ') {
data = data.substring(1);
}
String[] elem = data.split(" |,|/");
if (elem.length != 6 && elem.length != 9) {
return null;
}
Face out = new Face();
if (elem.length == 9) {
out.vertex[0] = Integer.valueOf(elem[0]) + offsetVertex;
out.uv[0] = Integer.valueOf(elem[1]) + offsetUV;
out.normal[0] = Integer.valueOf(elem[2]) + offsetNormal;
out.vertex[1] = Integer.valueOf(elem[3]) + offsetVertex;
out.uv[1] = Integer.valueOf(elem[4]) + offsetUV;
out.normal[1] = Integer.valueOf(elem[5]) + offsetNormal;
out.vertex[2] = Integer.valueOf(elem[6]) + offsetVertex;
out.uv[2] = Integer.valueOf(elem[7]) + offsetUV;
out.normal[2] = Integer.valueOf(elem[8]) + offsetNormal;
} else {
out.vertex[0] = Integer.valueOf(elem[0]) + offsetVertex;
out.normal[0] = Integer.valueOf(elem[1]) + offsetNormal;
out.vertex[1] = Integer.valueOf(elem[2]) + offsetVertex;
out.normal[1] = Integer.valueOf(elem[3]) + offsetNormal;
out.vertex[2] = Integer.valueOf(elem[4]) + offsetVertex;
out.normal[2] = Integer.valueOf(elem[5]) + offsetNormal;
}
return out;
}
}

View File

@ -0,0 +1,12 @@
package org.atriasoft.loader3d;
import java.util.ArrayList;
import java.util.List;
public record FaceIndexing(
List<Face> face,
List<Integer> index) {
public FaceIndexing() {
this(new ArrayList<>(), new ArrayList<>());
}
}

View File

@ -0,0 +1,7 @@
package org.atriasoft.loader3d;
public enum NormalMode {
NONE,
FACE,
VERTEX,
}

View File

@ -4,6 +4,7 @@ import io.scenarium.logger.LogLevel;
import io.scenarium.logger.Logger;
public class Log {
private static final boolean FORCE_DISPLAY = true;
private static final String LIB_NAME = "loader3d";
private static final String LIB_NAME_DRAW = Logger.getDrawableName(Log.LIB_NAME);
private static final boolean PRINT_CRITICAL = Logger.getNeedPrint(Log.LIB_NAME, LogLevel.CRITICAL);
@ -16,49 +17,49 @@ public class Log {
private static final boolean PRINT_WARNING = Logger.getNeedPrint(Log.LIB_NAME, LogLevel.WARNING);
public static void critical(final String data) {
if (Log.PRINT_CRITICAL) {
if (Log.PRINT_CRITICAL || FORCE_DISPLAY) {
Logger.critical(Log.LIB_NAME_DRAW, data);
}
}
public static void debug(final String data) {
if (Log.PRINT_DEBUG) {
if (Log.PRINT_DEBUG || FORCE_DISPLAY) {
Logger.debug(Log.LIB_NAME_DRAW, data);
}
}
public static void error(final String data) {
if (Log.PRINT_ERROR) {
if (Log.PRINT_ERROR || FORCE_DISPLAY) {
Logger.error(Log.LIB_NAME_DRAW, data);
}
}
public static void info(final String data) {
if (Log.PRINT_INFO) {
if (Log.PRINT_INFO || FORCE_DISPLAY) {
Logger.info(Log.LIB_NAME_DRAW, data);
}
}
public static void print(final String data) {
if (Log.PRINT_PRINT) {
if (Log.PRINT_PRINT || FORCE_DISPLAY) {
Logger.print(Log.LIB_NAME_DRAW, data);
}
}
public static void todo(final String data) {
if (Log.PRINT_TODO) {
if (Log.PRINT_TODO || FORCE_DISPLAY) {
Logger.todo(Log.LIB_NAME_DRAW, data);
}
}
public static void verbose(final String data) {
if (Log.PRINT_VERBOSE) {
if (Log.PRINT_VERBOSE || FORCE_DISPLAY) {
Logger.verbose(Log.LIB_NAME_DRAW, data);
}
}
public static void warning(final String data) {
if (Log.PRINT_WARNING) {
if (Log.PRINT_WARNING || FORCE_DISPLAY) {
Logger.warning(Log.LIB_NAME_DRAW, data);
}
}

View File

@ -0,0 +1,145 @@
package org.atriasoft.loader3d.model;
import java.util.List;
import org.atriasoft.egami.Image;
import org.atriasoft.etk.Color;
import org.atriasoft.etk.Uri;
import org.atriasoft.etk.math.Vector2i;
import org.atriasoft.etk.math.Vector4f;
import org.atriasoft.gale.backend3d.OpenGL.RenderMode;
import org.atriasoft.gale.resource.ResourceProgram;
import org.atriasoft.gale.resource.ResourceTexture2;
import org.atriasoft.gale.resource.ResourceTextureFile;
import org.atriasoft.loader3d.internal.Log;
public class Material extends MaterialBase{
// values
private RenderMode renderMode = RenderMode.TRIANGLE; //!< Select Render mode (triangle/Line/point ...)
private ResourceTexture2 texture0 = null;
public List<Integer> listIndexFaces;
public Material() {
super();
}
public void draw(ResourceProgram _prog, MaterialGlId _glID){
Log.verbose("draw Material : (start)");
_prog.uniformVector(_glID.oglAmbientFactor(), this.ambientFactor);
_prog.uniformVector(_glID.oglDiffuseFactor(), this.diffuseFactor);
_prog.uniformVector(_glID.oglSpecularFactor(), this.specularFactor);
_prog.uniformFloat(_glID.oglShininess(), this.shininess);
if (this.texture0 != null) {
Log.verbose(" set texture: " + _glID.oglTexture0() + " " + this.texture0.getId());
_prog.setTexture0(_glID.oglTexture0(), this.texture0.getRendererId());
if (false) {
if (_prog.checkIdValidity(_glID.oglTexture0()) == false) {
Log.error("try to set texture on a unexistant shader interface (wrong ID)");
}
}
} else {
if (false) {
if (_prog.checkIdValidity(_glID.oglTexture0()) == true) {
Log.error("Missing texture to send on the shader ...");
}
}
}
Log.verbose("draw Material: ( end )");
}
public void setRenderMode(RenderMode _val) {
switch (_val) {
case POINT:
break;
case LINE:
break;
case LINE_STRIP:
Log.info("Does not support " + _val + " auto convert it in 'LINE'");
_val = RenderMode.LINE;
break;
case LINE_LOOP:
Log.info("Does not support " + _val + " auto convert it in 'LINE'");
_val = RenderMode.LINE;
break;
case TRIANGLE:
break;
case TRIANGLE_STRIP:
Log.info("Does not support " + _val + " auto convert it in 'TRIANGLE'");
_val = RenderMode.TRIANGLE;
break;
case TRIANGLE_FAN:
Log.info("Does not support " + _val + " auto convert it in 'TRIANGLE'");
_val = RenderMode.TRIANGLE;
break;
case QUAD:
Log.info("Does not support " + _val + " auto convert it in 'TRIANGLE'");
_val = RenderMode.TRIANGLE;
break;
case QUAD_STRIP:
Log.info("Does not support " + _val + " auto convert it in 'TRIANGLE'");
_val = RenderMode.TRIANGLE;
break;
case POLYGON:
Log.error("Does not support " + _val + " try convert it in 'TRIANGLE'");
_val = RenderMode.TRIANGLE;
break;
}
this.renderMode = _val;
}
public RenderMode getRenderModeOpenGl() {
return this.renderMode;
}
public RenderMode getRenderMode() {
return this.renderMode;
}
public void setTexture0( Uri _uri) {
Vector2i tmpSize = new Vector2i(256, 256);
if (_uri.isEmpty() == false) {
// prevent overloard error :
ResourceTexture2 tmpCopy = this.texture0;
this.texture0 = ResourceTextureFile.create(_uri, tmpSize);
if (this.texture0 == null) {
Log.error("Can not load specific texture : " + _uri);
// retreave previous texture:
this.texture0 = tmpCopy;
if (this.texture0 != null) {
return;
}
}
} else {
this.texture0 = null;;
}
}
public void setTexture0Magic( Vector2i _size) {
// create a simple custum texture :
this.texture0 = new ResourceTexture2();
setImageSize(_size);
Image img = this.texture0.get();
for (int xxx=0; xxx<_size.x(); ++xxx) {
for (int yyy=0; yyy<_size.y(); ++yyy) {
img.setColor(xxx,yyy, Color.RED);
}
}
}
public void setImageSize( Vector2i _newSize){
if (this.texture0 == null){
return;
}
this.texture0.setImageSize(_newSize);
}
// get the reference on this image to draw nomething on it ...
public Image get(){
if (this.texture0 == null){
return null;
}
return this.texture0.get();
}
// flush the data to send it at the openGl system
public void flush() {
if (this.texture0 == null){
return;
}
this.texture0.flush();
}
public boolean haveTexture() {
return this.texture0 != null;
}
}

View File

@ -0,0 +1,53 @@
package org.atriasoft.loader3d.model;
import org.atriasoft.etk.math.Vector4f;
public class MaterialBase {
public MaterialBase() {
}
public MaterialBase(Vector4f ambientFactor, Vector4f diffuseFactor, Vector4f specularFactor, float shininess) {
this.ambientFactor = ambientFactor;
this.diffuseFactor = diffuseFactor;
this.specularFactor = specularFactor;
this.shininess = shininess;
}
@Override
public String toString() {
return "MaterialBase [ambientFactor=" + ambientFactor + ", diffuseFactor=" + diffuseFactor + ", specularFactor=" + specularFactor + ", shininess=" + shininess + "]";
}
protected Vector4f ambientFactor = Vector4f.ONE;
protected Vector4f diffuseFactor = Vector4f.ONE_W;
protected Vector4f specularFactor = Vector4f.ONE_W;
protected float shininess = 1;
public void setAmbientFactor( Vector4f _val) {
this.ambientFactor = _val;
}
public void setDiffuseFactor( Vector4f _val){
//Log.error("**************** set difuse factor:" + _val);
this.diffuseFactor = _val;
}
public void setSpecularFactor( Vector4f _val){
this.specularFactor = _val;
}
public void setShininess(float _val){
this.shininess = _val;
}
public Vector4f getAmbientFactor() {
return ambientFactor;
}
public Vector4f getDiffuseFactor() {
return diffuseFactor;
}
public Vector4f getSpecularFactor() {
return specularFactor;
}
public float getShininess() {
return shininess;
}
@Override
public MaterialBase clone() {
return new MaterialBase(ambientFactor, diffuseFactor, specularFactor, shininess);
}
}

View File

@ -0,0 +1,18 @@
package org.atriasoft.loader3d.model;
import org.atriasoft.gale.resource.ResourceProgram;
public record MaterialGlId (
int oglAmbientFactor,
int oglDiffuseFactor,
int oglSpecularFactor,
int oglShininess,
int oglTexture0) {
public MaterialGlId(ResourceProgram _prog, String _baseName) {
this( _prog.getUniform(_baseName+".ambientFactor"),
_prog.getUniform(_baseName+".diffuseFactor"),
_prog.getUniform(_baseName+".specularFactor"),
_prog.getUniform(_baseName+".shininess"),
_prog.getUniform("EW_texID"));
}
}

View File

@ -0,0 +1,5 @@
package org.atriasoft.loader3d.model;
public class PhysicShape {
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,549 @@
package org.atriasoft.loader3d.resources;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import org.atriasoft.etk.Uri;
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.loader3d.Face;
import org.atriasoft.loader3d.FaceIndexing;
import org.atriasoft.loader3d.NormalMode;
import org.atriasoft.loader3d.internal.Log;
import org.atriasoft.loader3d.model.Material;
import org.atriasoft.loader3d.model.PhysicShape;
public class ResourceMeshEmf extends ResourceMesh {
enum emfModuleMode {
EMFModuleNone(0),
EMFModuleMesh(1),
EMFModuleMeshVertex(2),
EMFModuleMeshUVMapping(3),
EMFModuleMeshNormalVertex(4),
EMFModuleMeshNormalFace(5),
EMFModuleMeshFace(6),
EMFModuleMeshFaceMaterial(7),
EMFModuleMeshPhysics(8),
EMFModuleMeshPhysicsNamed(9),
EMFModuleMesh_END(100),
EMFModuleMaterial(101),
EMFModuleMaterial_END(200),
EMFModulePalette(201),
EMFModulePalette_END(300),
EMFModulePhysics(301),
EMFModulePhysicsNamed(302),
EMFModulePhysics_END(400);
private final int value;
emfModuleMode(int value) {
this.value = value;
}
int getValue() {
return this.value;
}
};
// TODO : rework with string line extractor
public ResourceMeshEmf(Uri _fileName) {
super(_fileName);
this.checkNormal = true;
this.normalMode = NormalMode.NONE;
InputStream fileIOStream = Uri.getStream(_fileName);
if (fileIOStream == null ) {
Log.error("CAn not get the file named='" + _fileName + "'");
return; // TODO false;
}
BufferedReader fileIO = new BufferedReader(new InputStreamReader(fileIOStream));
// get the fileSize ...
//int size = fileIO.size();
String inputDataLine;
Dynamic<Integer> levelIO = new Dynamic<Integer>(0);
// load the first line :
inputDataLine = readLine(fileIO, levelIO);
if (inputDataLine.startsWith("EMF(STRING)") == true) {
// parse in string mode ...
} else if (inputDataLine.startsWith("EMF(BINARY)") == true) {
Log.error(" file binary mode is not supported now : 'EMF(BINARY)'");
return; // TODO false;
} else {
Log.error(" file mode is not supported now : 'EMF(? ? ?)' = '" + inputDataLine + "'");
return; // TODO false;
}
emfModuleMode currentMode = emfModuleMode.EMFModuleNone;
Log.verbose("Start parsing Mesh file : " + _fileName);
// mesh global param :
String currentMeshName = "";
FaceIndexing currentFaceIndexing = null;
// material global param :
String materialName = "";
Material material = null;
// physical shape:
PhysicShape physics = null;
boolean haveUVMapping = false;
int offsetVertexId = 0;
int offsetUV = 0;
int offsetFaceNormal = 0;
int offsetVertexNormal = 0;
while ((inputDataLine = readLine(fileIO, levelIO)) != null) {
int level = levelIO.value;
if (level == -1) {
// detect comment;
Log.warning("Detect comment");
continue;
}
if (level == 0) {
// new section ...
if(inputDataLine.startsWith("Mesh:") == true) {
currentMode = emfModuleMode.EMFModuleMesh;
currentMeshName = inputDataLine.substring(5);
Log.verbose("Parse Mesh: " + currentMeshName);
offsetVertexId = this.listVertex.size();
offsetUV = this.listUV.size();
offsetFaceNormal = this.listFacesNormal.size();
offsetVertexNormal = this.listVertexNormal.size();
//Log.error("new offset: " + offsetVertexId + " " + offsetUV + " " + offsetFaceNormal + " " + offsetVertexNormal);
} else if(inputDataLine.startsWith("Materials:")) {
// add previous material:
if( materialName != ""
&& material != null) {
if (currentMode == emfModuleMode.EMFModulePalette) {
this.palettes.put(materialName, material);
// TODO Remove this later ...
this.materials.put("palette:" + materialName, material);
} else {
this.materials.put(materialName, material);
}
materialName = "";
material = null;
}
currentMode = emfModuleMode.EMFModuleMaterial;
material = new Material();
materialName = inputDataLine.substring(10);
Log.verbose("Parse Material: " + materialName);
} else if(inputDataLine.startsWith("Palettes:")) {
// add previous material:
if( materialName != ""
&& material != null) {
if (currentMode == emfModuleMode.EMFModulePalette) {
this.palettes.put(materialName, material);
// TODO Remove this later ...
this.materials.put("palette:" + materialName, material);
} else {
this.materials.put(materialName, material);
}
materialName = "";
material = null;
}
currentMode = emfModuleMode.EMFModulePalette;
material = new Material();
materialName = inputDataLine.substring(9);
Log.verbose("Parse Palette: " + materialName);
} else if(inputDataLine.startsWith("Physics:") == true) {
currentMode = emfModuleMode.EMFModulePhysics;
Log.verbose("Parse global Physics: ");
} else {
currentMode = emfModuleMode.EMFModuleNone;
}
} else {
if ( currentMode.getValue() >= emfModuleMode.EMFModuleMesh.getValue()
&& currentMode.getValue() <= emfModuleMode.EMFModuleMesh_END.getValue()) {
if (level == 1) {
if(inputDataLine.startsWith("Vertex:") == true) {
currentMode = emfModuleMode.EMFModuleMeshVertex;
Log.verbose(" Vertex ...");
} else if(inputDataLine.startsWith("UV-mapping:") == true) {
currentMode = emfModuleMode.EMFModuleMeshUVMapping;
haveUVMapping = true;
Log.verbose(" UV-mapping ...");
} else if(inputDataLine.startsWith("Normal(vertex):") == true) {
currentMode = emfModuleMode.EMFModuleMeshNormalVertex;
Log.verbose(" Normal(vertex) ...");
} else if(inputDataLine.startsWith("Normal(face):") == true) {
currentMode = emfModuleMode.EMFModuleMeshNormalFace;
Log.verbose(" Normal(face) ...");
} else if(inputDataLine.startsWith("Face:") == true) {
currentMode = emfModuleMode.EMFModuleMeshFace;
Log.verbose(" Face ...");
} else if(inputDataLine.startsWith("Physics:") == true) {
currentMode = emfModuleMode.EMFModuleMeshPhysics;
Log.verbose(" Physics ...");
} else {
Log.error(" Unknow mesh property '" + inputDataLine + "'");
currentMode = emfModuleMode.EMFModuleMesh;
}
continue;
}
// level > 1
switch (currentMode) {
default:
Log.error("Unknow ... " + level);
break;
case EMFModuleMeshVertex: {
for (String elem : inputDataLine.split("\\|")) {
Vector3f vertex = Vector3f.valueOf(elem);
this.listVertex.add(vertex);
}
Log.verbose(" " + this.listVertex.size() + " vertex");
break;
}
case EMFModuleMeshUVMapping: {
for (String elem : inputDataLine.split("\\|")) {
Vector2f uvMap = Vector2f.valueOf(elem);
this.listUV.add(uvMap);
}
Log.verbose(" " + this.listUV.size() + " coord");
break;
}
case EMFModuleMeshNormalVertex: {
this.normalMode = NormalMode.VERTEX;
for (String elem : inputDataLine.split("\\|")) {
Vector3f normal = Vector3f.valueOf(elem);
this.listVertexNormal.add(normal);
}
Log.verbose(" " + this.listVertexNormal.size() + " Normals");
break;
}
case EMFModuleMeshNormalFace: {
Log.error("Change mode in face mode ...");
this.normalMode = NormalMode.FACE;
for (String elem : inputDataLine.split("\\|")) {
Vector3f normal = Vector3f.valueOf(elem);
this.listFacesNormal.add(normal);
}
Log.verbose(" " + this.listFacesNormal.size() + " Normals");
break;
}
case EMFModuleMeshFace:
case EMFModuleMeshFaceMaterial:
if (level == 2) {
String meshFaceMaterialID = inputDataLine;
// new material selection
currentMode = emfModuleMode.EMFModuleMeshFaceMaterial;
if (inputDataLine.startsWith("palette:")) {
if (this.listPaletteFaces.containsKey(meshFaceMaterialID) == false) {
currentFaceIndexing = new FaceIndexing();
this.listPaletteFaces.put(meshFaceMaterialID, currentFaceIndexing);
} else {
currentFaceIndexing = this.listPaletteFaces.get(meshFaceMaterialID);
}
} else {
if (this.listFaces.containsKey(meshFaceMaterialID) == false) {
currentFaceIndexing = new FaceIndexing();
this.listFaces.put(meshFaceMaterialID, currentFaceIndexing);
} else {
currentFaceIndexing = this.listFaces.get(meshFaceMaterialID);
}
}
Log.verbose(" " + inputDataLine);
} else if (currentMode == emfModuleMode.EMFModuleMeshFaceMaterial) {
if (currentFaceIndexing == null) {
Log.error("Get elements without material defined ...");
continue;
}
for (String elem : inputDataLine.split("\\|")) {
Face tmp = null;
if (this.normalMode == NormalMode.FACE) {
tmp = Face.valueOf(elem, offsetVertexId, offsetUV, offsetFaceNormal);
} else {
tmp = Face.valueOf(elem, offsetVertexId, offsetUV, offsetVertexNormal);
}
currentFaceIndexing.face().add(tmp);
}
Log.verbose(" " + currentFaceIndexing.face().size() + " faces");
} else {
// insert element without material ...
Log.error(" try to add face without material selection ...");
}
break;
case EMFModuleMeshPhysics:
case EMFModuleMeshPhysicsNamed:
/*
if (level == 2) {
physics = ege::physics::Shape::create(inputDataLine);
if (physics == null) {
Log.error("Allocation error when creating physical shape ...");
continue;
}
addPhysicElement(physics);
Log.verbose(" " + this.physics.size() + " " + inputDataLine);
currentMode = emfModuleMode.EMFModuleMeshPhysicsNamed;
} else if (currentMode == EMFModuleMeshPhysicsNamed) {
if (physics == null) {
Log.error("Can not parse :'" + inputDataLine + "' in physical shape ...");
continue;
}
if (physics.parse(&inputDataLine[0]) == false) {
Log.error("ERROR when parsing :'" + inputDataLine + "' in physical shape ...");
}
}
*/
break;
}
continue;
} else if ( ( currentMode.getValue() >= emfModuleMode.EMFModuleMaterial.getValue()
&& currentMode.getValue() <= emfModuleMode.EMFModuleMaterial_END.getValue())
|| ( currentMode.getValue() >= emfModuleMode.EMFModulePalette.getValue()
&& currentMode.getValue() <= emfModuleMode.EMFModulePalette_END.getValue())) {
if (material == null) {
Log.error("material allocation error");
continue;
}
if(inputDataLine.startsWith("Ns ") == true) {
float tmpVal=Float.valueOf(inputDataLine.substring(3));
material.setShininess(tmpVal);
Log.verbose(" Shininess " + tmpVal);
} else if(inputDataLine.startsWith("Ka ") == true) {
Vector4f tmp = Vector4f.valueOf(inputDataLine.substring(3));
tmp = tmp.withW(1);
material.setAmbientFactor(tmp);
Log.verbose(" AmbientFactor " + tmp);
} else if(inputDataLine.startsWith("Kd ") == true) {
Vector4f tmp = Vector4f.valueOf(inputDataLine.substring(3));
tmp = tmp.withW(1);
material.setDiffuseFactor(tmp);
Log.error(" DiffuseFactor " + tmp);
} else if(inputDataLine.startsWith("Ks ") == true) {
Vector4f tmp = Vector4f.valueOf(inputDataLine.substring(3));
tmp = tmp.withW(1);
material.setSpecularFactor(tmp);
Log.verbose(" SpecularFactor " + tmp);
} else if(inputDataLine.startsWith("Ni ") == true) {
float tmpVal=Float.valueOf(inputDataLine.substring(3));
// TODO : ...
Log.verbose(" Ni " + tmpVal);
} else if(inputDataLine.startsWith("d ") == true) {
float tmpVal=Float.valueOf(inputDataLine.substring(2));
// TODO : ...
Log.verbose(" d " + tmpVal);
} else if(inputDataLine.startsWith("illum ") == true) {
float tmpVal=Float.valueOf(inputDataLine.substring(6));
// TODO : ...
Log.verbose(" illum " + tmpVal);
} else if(inputDataLine.startsWith("map_Kd ") == true) {
Uri tmpTexture = _fileName.getParent();
tmpTexture = tmpTexture.pathAdd(inputDataLine.substring(7));
material.setTexture0(tmpTexture);
Log.verbose(" Texture " + tmpTexture);
} else if(inputDataLine.startsWith("renderMode ") == true) {
//RenderMode mode;
//frothis.string(mode, &inputDataLine[11]);
//material.setRenderMode(mode);
Log.verbose(" Texture " + mode);
} else {
Log.error("unknow material property ... : '" + inputDataLine + "'");
}
} else if ( currentMode.getValue() >= emfModuleMode.EMFModulePhysics.getValue()
&& currentMode.getValue() <= emfModuleMode.EMFModulePhysics_END.getValue()) {
if (level == 1) {
Log.error("Load shape : " + inputDataLine);
// physics = ege::physics::Shape::create(inputDataLine);
// if (physics == null) {
// Log.error("Allocation error when creating physical shape ...");
// continue;
// }
// addPhysicElement(physics);
// Log.verbose(" " + this.physics.size() + " " + inputDataLine);
// currentMode = emfModuleMode.EMFModulePhysicsNamed;
} else if (currentMode == emfModuleMode.EMFModulePhysicsNamed) {
// if (physics == null) {
// Log.error("Can not parse :'" + inputDataLine + "' in physical shape ...");
// continue;
// }
// if (physics.parse(&inputDataLine[0]) == false) {
// Log.error("ERROR when parsing :'" + inputDataLine + "' in physical shape ...");
// }
}
} else {
// unknow ...
Log.warning("Unknow type of line == > jump end of line ... " + inputDataLine);
}
}
}
// add last material ...
if( materialName != ""
&& material != null) {
if (currentMode == emfModuleMode.EMFModulePalette) {
this.palettes.put(materialName, material);
// TODO Remove this later ...
this.materials.put("palette:" + materialName, material);
} else {
this.materials.put(materialName, material);
}
materialName = "";
material = null;
}
Log.verbose("Stop parsing Mesh file");
try {
fileIO.close();
fileIOStream.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Log.verbose("New mesh : ");
Log.verbose(" nb vertex: " + this.listVertex.size());
Log.verbose(" nb UV: " + this.listUV.size());
Log.verbose(" nb Colors: " + this.listColor.size());
Log.verbose(" nb Normal face: " + this.listFacesNormal.size());
Log.verbose(" nb Normal vertex: " + this.listVertexNormal.size());
Log.verbose(" nb Faces: " + this.listFaces.size());
Log.verbose(" nb Faces (palette): " + this.listPaletteFaces.size());
Log.verbose(" nb material: " + this.materials.size());
Log.verbose(" nb palettes: " + this.palettes.size());
//Log.verbose(" nb physic: " + this.physics.size());
generateVBO();
}
//private String loadNextData(int _maxData,
// BufferedReader _file) {
// return loadNextData(_maxData, _file, false, false, true);
//}
//
//private String loadNextData(int _maxData,
// BufferedReader _file,
// boolean _removeTabs,
// boolean _stopColomn,
// boolean _stopPipe) {
// StringBuffer buf = new StringBuffer();
// int outSize = 0;
// /*
// if (this.zipReadingOffset >= this.zipContent.size()) {
// element[0] = '\0';
// return null;
// }
// */
// int current = '\0';
// try {
// current = _file.read();
// } catch (IOException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// while (current != '\0') {
// if( _removeTabs == false
// || buf.length() == 0) {
// buf.append((char)current);
// }
// if( current == '\n'
// || current == '\r'
// || ( current == '|'
// && _stopPipe == true)
// || ( current == ':'
// && _stopColomn == true) )
// {
// //Log.debug(" plop : '" + _elementLine + "'" );
// return buf.toString();
// } else if( buf.length() == 0
// && current != '\t') {
// buf.append((char)current);
// }
// // check maxData size ...
// if (outSize >= _maxData-1) {
// return buf.toString();
// }
// try {
// current = _file.read();
// } catch (IOException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// }
// if (outSize != 0) {
// // send last line
// return buf.toString();
// }
// return null;
//}
private String readLine(BufferedReader _file, Dynamic<Integer> level) {
level.value = 0;
StringBuffer buf = new StringBuffer();
boolean startLine = true;
boolean differentThanSpace = false;
boolean hasSpace = false;
int current = '\0';
try {
current = _file.read();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
while(current != '\0' && current != -1) {
if (current == '\r') {
// nothing to do ...
} else if (current == '\t' && startLine) {
level.value++;
} else if (current == '\n') {
if (!startLine) {
break;
}
} else {
startLine = false;
if (current == '#') {
// detect comment ==> remove to the end of file ==> no data availlable
if (differentThanSpace == false) {
while(current != '\0' && current != '\n') {
try {
current = _file.read();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
buf = new StringBuffer();
startLine = true;
differentThanSpace = false;
hasSpace = false;
level.value = 0;
continue;
}
// end of data removed
while(current != '\0' && current != '\n') {
try {
current = _file.read();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
break;
}
differentThanSpace = true;
if (current == '\t' || current == ' ') {
hasSpace = true;
} else {
if (hasSpace == true) {
buf.append(' ');
hasSpace = false;
}
buf.append((char)current);
}
}
try {
current=_file.read();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Log.error("Read line: offset=" + level.value + "\n" + buf.toString());
if (buf.length() == 0) {
return null;
}
return buf.toString();
}
}

View File

@ -0,0 +1,202 @@
package org.atriasoft.loader3d.resources;
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
import java.util.ArrayList;
import java.util.List;
import java.util.SortedMap;
import java.util.TreeMap;
import java.util.Map;
import java.util.Map.Entry;
import org.atriasoft.egami.ImageByte;
import org.atriasoft.egami.ImageByteRGB;
import org.atriasoft.egami.ImageByteRGBA;
import org.atriasoft.ejson.Ejson;
import org.atriasoft.ejson.model.JsonArray;
import org.atriasoft.ejson.model.JsonNode;
import org.atriasoft.ejson.model.JsonObject;
import org.atriasoft.etk.Color;
import org.atriasoft.etk.Tools;
import org.atriasoft.etk.Uri;
import org.atriasoft.etk.math.Vector4f;
import org.atriasoft.loader3d.internal.Log;
import org.atriasoft.loader3d.model.Material;
import org.atriasoft.loader3d.model.MaterialBase;
import org.atriasoft.gale.resource.Resource;
/**
* ColorFile is a Resource designed to be specific with the theme (for
* example black, or white or orange ...)
*/
public class ResourcePaletteFile extends Resource {
private static final int COUNT_MAX_COLOR_PALETTE = 4096;
private static final List<String> PALETTE_ELEMENTS = new ArrayList<>(COUNT_MAX_COLOR_PALETTE);
static {
PALETTE_ELEMENTS.add("unknown");
}
public static synchronized int getColorId(String color) {
for (int iii=0; iii<PALETTE_ELEMENTS.size(); iii++) {
if (PALETTE_ELEMENTS.get(iii).equals(color)) {
return iii;
}
}
PALETTE_ELEMENTS.add(color);
return PALETTE_ELEMENTS.size()-1;
}
public static int getColorMax() {
return COUNT_MAX_COLOR_PALETTE;
}
private Runnable updatePostAction = null;
public static ResourcePaletteFile create(final Uri uri) {
Log.verbose("KEEP: ColorFile: " + uri);
ResourcePaletteFile object = null;
final Resource object2 = Resource.getManager().localKeep(uri);
if (object2 != null) {
if (object2 instanceof ResourcePaletteFile) {
return (ResourcePaletteFile) object2;
}
Log.critical("Request resource file : '" + uri + "' With the wrong type (dynamic cast error)");
return null;
}
Log.debug("CREATE: FontFreeType: " + uri);
// need to crate a new one ...
return new ResourcePaletteFile(uri);
}
private Color errorColor = Color.ORANGE;
private MaterialBase base = new MaterialBase();
private final SortedMap<String, MaterialBase> list = new TreeMap<String, MaterialBase>(); // !< List of all color in the file
/**
* Constructor of the color property file
* @param uri Name of the file needed
*/
public ResourcePaletteFile(final Uri uri) {
super(uri);
Log.debug("CF : load '" + uri + "'");
reload();
// Log.debug("List of all color : " + this.list.keySet());
}
@Override
public void cleanUp() {
}
/**
* Get the associated color of the ID.
* @param id Id of the color.
* @return The requested color.
*/
public Color get(final String id) {
if (id == null) {
return this.errorColor;
}
Vector4f color = this.list.get(id).getAmbientFactor();
return new Color(color.x(), color.y(), color.z(), color.w());
}
private MaterialBase configMaterial(JsonObject baseDefault) {
MaterialBase element = this.base.clone();
try {
if (baseDefault != null) {
if (baseDefault.exist("Ns")) {
final double data = baseDefault.get("Ns").toJsonNumber().getValue();
Log.verbose(" Shininess " + data);
element.setShininess((float)data);
}
if (baseDefault.exist("Ka")) {
final String data = baseDefault.get("Ka").toJsonString().getValue();
Vector4f tmp = Vector4f.valueOf(data);
tmp = tmp.withW(1);
Log.verbose(" AmbientFactor " + tmp);
element.setAmbientFactor(tmp);
}
if (baseDefault.exist("Kd")) {
final String data = baseDefault.get("Kd").toJsonString().getValue();
Vector4f tmp = Vector4f.valueOf(data);
tmp = tmp.withW(1);
Log.verbose(" DiffuseFactor " + tmp);
element.setDiffuseFactor(tmp);
}
if (baseDefault.exist("Ks")) {
final String data = baseDefault.get("Ks").toJsonString().getValue();
Vector4f tmp = Vector4f.valueOf(data);
tmp = tmp.withW(1);
Log.verbose(" SpecularFactor " + tmp);
element.setSpecularFactor(tmp);
}
}
} catch (final Exception e) {
Log.error("chach exception in parsing config file... " + e.getMessage());
e.printStackTrace();
}
return element;
}
@Override
public synchronized void reload() {
this.list.clear();
this.base = new MaterialBase();
try {
final JsonObject out = Ejson.parse(Uri.valueOf(this.name)).toJsonObject();
final JsonObject baseDefault = out.get("default").toJsonObject();
this.base = configMaterial(baseDefault);
final JsonObject baseObject = out.get("palette").toJsonObject();
if (baseObject == null) {
Log.error("Can not get basic object : 'palette' in file:" + this.name);
Ejson.display(out);
return;
}
for (Entry<String, JsonNode> it : baseObject.getNodes().entrySet()) {
MaterialBase mat = configMaterial(it.getValue().toJsonObject());
list.put(it.getKey(), mat);
}
} catch (final Exception e) {
Log.error("chach exception in parsing config file... " + e.getMessage());
e.printStackTrace();
}
if (this.updatePostAction != null) {
Log.warning("Detect auto_update on onthe element ...");
this.updatePostAction.run();
Log.warning("Detect auto_update on onthe element ... (DONE)");
}
}
public void onUpdate(Runnable object) {
this.updatePostAction = object;
}
public ImageByte getImageByte() {
int width = COUNT_MAX_COLOR_PALETTE;
int height = 8;
ImageByteRGBA out = new ImageByteRGBA(width, height);
for (Entry<String, MaterialBase> it : this.list.entrySet()) {
int id = getColorId(it.getKey());
MaterialBase mat = it.getValue();
// 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());
out.setColorFloat(id, 2, mat.getSpecularFactor().x(), mat.getSpecularFactor().y(), mat.getSpecularFactor().z(), mat.getSpecularFactor().w());
out.setColorFloat(id, 3, mat.getSpecularFactor().x(), mat.getSpecularFactor().y(), mat.getSpecularFactor().z(), mat.getSpecularFactor().w());
out.setColorFloat(id, 4, mat.getAmbientFactor().x(), mat.getAmbientFactor().y(), mat.getAmbientFactor().z(), mat.getAmbientFactor().w());
out.setColorFloat(id, 5, mat.getAmbientFactor().x(), mat.getAmbientFactor().y(), mat.getAmbientFactor().z(), mat.getAmbientFactor().w());
out.setColorFloat(id, 6, mat.getShininess(), 1.0f, 1.0f, 1.0f);
}
return out;
}
}

View File

@ -14,7 +14,6 @@ public class ResourceStaticColoredMesh extends ResourceStaticMesh {
protected float[] vertices = null;
protected float[] colors = null;
protected float[] normals = null;
protected int[] indices = null;
protected ResourceStaticColoredMesh(final float[] vertices, final float[] colors, final float[] normals, final int[] indices, final RenderMode mode) {

View File

@ -6,7 +6,7 @@ import org.atriasoft.gale.resource.Resource;
import org.atriasoft.gale.resource.ResourceVirtualArrayObject;
public class ResourceStaticMesh extends Resource {
protected RenderMode mode = RenderMode.quadStrip;
protected RenderMode mode = RenderMode.QUAD_STRIP;
protected ResourceVirtualArrayObject vao = null;
protected ResourceStaticMesh(final RenderMode mode) {

View File

@ -42,7 +42,7 @@ public class ResourceStaticMeshObj extends ResourceStaticTexturedMesh {
this.textureCoords = data.textureCoords();
this.normals = data.normals();
this.indices = data.indices();
this.mode = RenderMode.triangle;
this.mode = RenderMode.TRIANGLE;
flush();
}

View File

@ -24,7 +24,6 @@ public class ResourceStaticTexturedMesh extends ResourceStaticMesh {
this.textureCoords = textureCoordinates;
this.normals = normals;
this.indices = indices;
flush();
}
protected ResourceStaticTexturedMesh(final Uri uriFile) {

View File

@ -0,0 +1,71 @@
EMF(STRING)
# Blender v2.92.0 EMF File: 'Entry.blend'
Mesh:EntryBox_Cube
Vertex:16
20.042355 7.751226 20.042355|20.042355 7.751226 -20.042355|20.042355 -4.633502 20.042355|20.042355 -4.633502 -20.042355|-20.042355 7.751226 20.042355|-20.042355 7.751226 -20.042355|-20.042355 -4.633502 20.042355|-20.042355 -4.633502 -20.042355|10.127714 -7.726907 10.127714|10.127714 -7.726907 -10.127714|-10.127714 -7.726907 10.127714|-10.127714 -7.726907 -10.127714|-10.127714 -9.146553 -10.127714|-10.127714 -9.146553 10.127714|10.127714 -9.146553 10.127714|10.127714 -9.146553 -10.127714|
UV-mapping:
0.000100 0.000100|0.999900 0.999900|0.000100 0.999900|0.999900 0.000100|0.074219 0.995849|0.120606 0.943115|0.121582 0.993408|0.112927 0.992387|0.078245 0.948093|0.073324 0.991157|0.101769 0.970961|0.080974 0.959440|0.102023 0.957458|0.111927 0.985005|0.078476 0.953015|0.082167 0.983774|0.074219 0.944092|0.111696 0.944402|0.080720 0.975385|0.113157 0.949323|0.174907 0.947863|0.131613 0.991157|0.132843 0.945402|0.178368 0.944941|0.137534 0.984544|0.142456 0.948632|0.171985 0.949093|0.136074 0.991157|0.137304 0.950323|0.174677 0.949093|0.135074 0.992387|0.136304 0.949093|0.178598 0.993618|0.178368 0.988235|0.173216 0.991157|0.175907 0.989926|0.013265 0.951784|0.051868 0.992387|0.013034 0.993618|0.054098 0.951784|0.137534 0.988235|0.177138 0.947863|0.135074 0.947862|0.172446 0.988465|
Normal(face):22
0.000000 -1.000000 0.000000|-0.297843 -0.954615 0.000000|0.000000 -0.954615 -0.297843|0.000000 -0.954615 0.297843|0.297843 -0.954615 0.000000|0.000000 0.000000 1.000000|-1.000000 0.000000 0.000000|0.000000 0.000000 -1.000000|1.000000 0.000000 -0.000000|0.000000 1.000000 -0.000000|
Face:22
gui_dynamic_1
14/0/0 12/1/0 15/2/0| 14/0/0 13/3/0 12/1/0|
palette:gui_border_1
7/4/1 10/5/1 6/6/1| 3/7/2 11/8/2 7/9/2| 6/10/3 8/11/3 2/12/3| 2/13/4 9/14/4 3/15/4| 7/4/1 11/16/1 10/5/1| 3/7/2 9/17/2 11/8/2| 6/10/3 10/18/3 8/11/3| 2/13/4 8/19/4 9/14/4|
palette:gui_border_2
4/20/5 2/21/5 0/22/5| 6/23/6 5/24/6 7/25/6| 1/26/7 7/27/7 5/28/7| 0/29/8 3/30/8 1/31/8| 4/20/5 6/32/5 2/21/5| 6/23/6 4/33/6 5/24/6| 1/26/7 3/34/7 7/27/7| 0/29/8 2/35/8 3/30/8|
palette:gui_center
9/36/0 10/37/0 11/38/0| 9/36/0 8/39/0 10/37/0|
palette:gui_back
5/40/9 0/41/9 1/42/9| 5/40/9 4/43/9 0/41/9|
Materials:gui_dynamic_1
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.450000
d 1.000000
illum 2
map_Kd /home/heero/dev/workspace-game/atriasoft/ewol/resources/resources/ewol/theme/shape/empty_area.png
# Just for information:
Palettes:gui_back
Ns 225.000000
Ka 1.000000 1.000000 1.000000
Kd 0.800000 0.000000 0.005632
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
vNi 1.450000
d 1.000000
illum 2
# Just for information:
Palettes:gui_border_1
Ns 225.000000
Ka 1.000000 1.000000 1.000000
Kd 0.000000 0.002615 0.800000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
vNi 1.450000
d 1.000000
illum 2
# Just for information:
Palettes:gui_border_2
Ns 225.000000
Ka 1.000000 1.000000 1.000000
Kd 0.000000 0.800000 0.170495
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
vNi 1.450000
d 1.000000
illum 2
# Just for information:
Palettes:gui_center
Ns 225.000000
Ka 1.000000 1.000000 1.000000
Kd 0.438544 0.438544 0.438544
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
vNi 1.450000
d 1.000000
illum 2

View File

@ -0,0 +1,57 @@
EMF(STRING)
# Blender v2.92.0 EMF File: 'tower.blend'
Mesh:tower_Cube
Vertex:68
1.000000 1.000000 1.968156|1.000000 1.000000 0.509101|1.000000 -1.000000 1.968156|1.000000 -1.000000 0.509101|-1.000000 1.000000 1.968156|-1.000000 1.000000 0.509101|-1.000000 -1.000000 1.968156|-1.000000 -1.000000 0.509101|0.519091 0.519091 2.988363|0.519091 -0.519091 2.988363|-0.519091 0.519091 2.988363|-0.519091 -0.519091 2.988363|1.267435 0.519091 3.279218|1.267435 -0.519091 3.279218|-0.519091 0.519091 3.279218|-0.519091 -0.519091 3.279218|1.267435 0.519091 4.102064|1.267435 -0.519091 4.102064|-0.519091 0.519091 4.102064|-0.519091 -0.519091 4.102064|-1.007701 0.133857 3.584548|-1.007701 -0.133857 3.584548|-1.007701 0.133857 3.796734|-1.007701 -0.133857 3.796734|-3.394721 0.108124 3.604944|-3.394721 -0.108124 3.604944|-3.394721 0.108124 3.776338|-3.394721 -0.108124 3.776338|-3.394721 0.148343 3.573067|-3.394721 -0.148343 3.573067|-3.394721 0.148343 3.808215|-3.394721 -0.148343 3.808215|-3.865651 0.148343 3.573067|-3.865651 -0.148343 3.573067|-3.865651 0.148343 3.808215|-3.865651 -0.148343 3.808215|0.468620 0.227433 3.055862|0.468620 -0.227433 3.055862|-0.227433 0.227433 3.055862|-0.227433 -0.227433 3.055862|0.671236 0.227433 3.376956|0.671236 -0.227433 3.376956|0.216371 0.227433 3.376956|0.216371 -0.227433 3.376956|1.304951 1.304951 0.327262|1.304951 -1.304951 0.327262|-1.304951 1.304951 0.327262|-1.304951 -1.304951 0.327262|1.304951 1.304951 -0.001257|1.304951 -1.304951 -0.001257|-1.304951 1.304951 -0.001257|-1.304951 -1.304951 -0.001257|1.644974 0.319018 3.437792|1.644974 -0.319018 3.437792|1.644974 0.319018 3.943490|1.644974 -0.319018 3.943490|1.469387 0.154815 3.567937|1.469387 -0.154815 3.567937|1.469387 0.154815 3.813344|1.469387 -0.154815 3.813344|-3.865651 0.081533 3.626019|-3.865651 -0.081533 3.626019|-3.865651 0.081533 3.755262|-3.865651 -0.081533 3.755262|0.301836 0.081533 3.626019|0.301836 -0.081533 3.626019|0.301836 0.081533 3.755262|0.301836 -0.081533 3.755262|
Normal(face):128
-0.000000 0.000000 -1.000000|0.000000 1.000000 -0.000000|0.000000 -0.225474 0.974249|-0.225474 0.000000 0.974249|0.000000 0.000000 1.000000|-0.619140 0.785281 0.000000|0.000000 -1.000000 0.000000|-0.529936 0.000000 0.848038|-0.619140 -0.785281 0.000000|-0.529936 0.000000 -0.848038|1.000000 -0.000000 -0.000000|-1.000000 0.000000 0.000000|0.000000 0.225474 0.974249|0.800875 0.000000 0.598832|0.845703 0.000000 -0.533654|-0.586173 0.000000 0.810186|0.595465 0.000000 0.803381|0.683034 0.730387 0.000000|0.595465 0.000000 -0.803381|0.683034 -0.730387 0.000000|0.468253 0.883595 0.000000|-0.010780 -0.999942 0.000000|-0.008544 0.000000 0.999964|-0.010780 0.999942 0.000000|-0.008544 0.000000 -0.999964|0.387250 0.000000 0.921975|0.468253 -0.883595 0.000000|0.387250 0.000000 -0.921975|-0.008544 0.000000 0.999963|-0.008544 -0.000000 -0.999963|0.000000 0.904541 0.426386|0.000000 -0.904541 0.426386|-0.904541 0.000000 0.426386|0.904541 0.000000 0.426386|-0.000000 -0.512150 0.858896|-0.512150 0.000000 0.858896|0.512150 0.000000 0.858896|-0.000000 0.512150 0.858896|
Face:128
palette:canon_2
15/0 12/0 13/0| 14/1 16/1 12/1| 9/2 39/2 11/2| 36/1 42/1 40/1| 11/3 38/3 10/3| 18/4 17/4 16/4| 14/5 22/5 18/5| 13/6 19/6 15/6| 18/7 23/7 19/7| 19/8 21/8 15/8| 15/9 20/9 14/9| 26/10 31/10 27/10| 28/1 34/1 30/1| 24/10 30/10 26/10| 25/10 28/10 24/10| 27/10 29/10 25/10| 35/11 61/11 33/11| 29/0 32/0 28/0| 31/6 33/6 29/6| 30/4 35/4 31/4| 8/12 38/12 36/12| 8/13 37/13 9/13| 40/4 43/4 41/4| 36/14 41/14 37/14| 37/6 43/6 39/6| 39/15 42/15 38/15| 52/16 57/16 53/16| 56/10 59/10 57/10| 53/17 59/17 55/17| 55/18 58/18 54/18| 54/19 56/19 52/19| 60/6 66/6 62/6| 34/11 63/11 35/11| 32/11 62/11 34/11| 33/11 60/11 32/11| 65/11 66/11 64/11| 61/4 64/4 60/4| 63/1 65/1 61/1| 62/0 67/0 63/0| 15/0 14/0 12/0| 14/1 18/1 16/1| 9/2 37/2 39/2| 36/1 38/1 42/1| 11/3 39/3 38/3| 18/4 19/4 17/4| 14/5 20/5 22/5| 13/6 17/6 19/6| 18/7 22/7 23/7| 19/8 23/8 21/8| 15/9 21/9 20/9| 26/10 30/10 31/10| 28/1 32/1 34/1| 24/10 28/10 30/10| 25/10 29/10 28/10| 27/10 31/10 29/10| 35/11 63/11 61/11| 29/0 33/0 32/0| 31/6 35/6 33/6| 30/4 34/4 35/4| 8/12 10/12 38/12| 8/13 36/13 37/13| 40/4 42/4 43/4| 36/14 40/14 41/14| 37/6 41/6 43/6| 39/15 43/15 42/15| 52/16 56/16 57/16| 56/10 58/10 59/10| 53/17 57/17 59/17| 55/18 59/18 58/18| 54/19 58/19 56/19| 60/6 64/6 66/6| 34/11 62/11 63/11| 32/11 60/11 62/11| 33/11 61/11 60/11| 65/11 67/11 66/11| 61/4 65/4 64/4| 63/1 67/1 65/1| 62/0 66/0 67/0|
palette:canon_1
16/20 52/20 12/20| 23/21 25/21 21/21| 22/22 27/22 23/22| 20/23 26/23 22/23| 21/24 24/24 20/24| 17/25 54/25 16/25| 13/26 55/26 17/26| 12/27 53/27 13/27| 16/20 54/20 52/20| 23/21 27/21 25/21| 22/28 26/28 27/28| 20/23 24/23 26/23| 21/29 25/29 24/29| 17/25 55/25 54/25| 13/26 53/26 55/26| 12/27 52/27 53/27|
palette:user_1
4/30 8/30 0/30| 2/6 7/6 3/6| 6/11 5/11 7/11| 0/10 3/10 1/10| 4/1 1/1 5/1| 6/31 9/31 11/31| 6/32 10/32 4/32| 0/33 9/33 2/33| 4/30 10/30 8/30| 2/6 6/6 7/6| 6/11 4/11 5/11| 0/10 2/10 3/10| 4/1 0/1 1/1| 6/31 2/31 9/31| 6/32 11/32 10/32| 0/33 8/33 9/33|
palette:bulding_base_1
7/34 45/34 3/34| 45/10 48/10 44/10| 5/35 47/35 7/35| 3/36 44/36 1/36| 1/37 46/37 5/37| 48/0 51/0 50/0| 44/1 50/1 46/1| 47/6 49/6 45/6| 46/11 51/11 47/11| 7/34 47/34 45/34| 45/10 49/10 48/10| 5/35 46/35 47/35| 3/36 45/36 44/36| 1/37 44/37 46/37| 48/0 49/0 51/0| 44/1 48/1 50/1| 47/6 51/6 49/6| 46/11 50/11 51/11|
# Just for information:
Palettes:bulding_base_1
Ns 225.000000
Ka 1.000000 1.000000 1.000000
Kd 0.014670 0.014670 0.014670
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
vNi 1.450000
d 1.000000
illum 2
# Just for information:
Palettes:canon_1
Ns 225.000000
Ka 1.000000 1.000000 1.000000
Kd 0.800000 0.000000 0.008711
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
vNi 1.450000
d 1.000000
illum 2
# Just for information:
Palettes:canon_2
Ns 323.999994
Ka 1.000000 1.000000 1.000000
Kd 0.001354 0.800000 0.053320
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
vNi 1.450000
d 1.000000
illum 2
# Just for information:
Palettes:user_1
Ns 225.000000
Ka 1.000000 1.000000 1.000000
Kd 0.113655 0.510074 0.800000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
vNi 1.450000
d 1.000000
illum 2

Binary file not shown.

Binary file not shown.

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,2 @@
# Blender MTL File: 'tree1.blend'
# Material Count: 0

View File

@ -0,0 +1,3 @@
# Blender v2.92.0 OBJ File: 'tree1.blend'
# www.blender.org
mtllib tree1.mtl

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,59 @@
package test.atriasoft.loader3d;
import io.scenarium.logger.LogLevel;
import io.scenarium.logger.Logger;
public class Log {
private static final String LIB_NAME = "loader3d-test";
private static final String LIB_NAME_DRAW = Logger.getDrawableName(LIB_NAME);
private static final boolean PRINT_CRITICAL = Logger.getNeedPrint(LIB_NAME, LogLevel.CRITICAL);
private static final boolean PRINT_ERROR = Logger.getNeedPrint(LIB_NAME, LogLevel.ERROR);
private static final boolean PRINT_WARNING = Logger.getNeedPrint(LIB_NAME, LogLevel.WARNING);
private static final boolean PRINT_INFO = Logger.getNeedPrint(LIB_NAME, LogLevel.INFO);
private static final boolean PRINT_DEBUG = Logger.getNeedPrint(LIB_NAME, LogLevel.DEBUG);
private static final boolean PRINT_VERBOSE = Logger.getNeedPrint(LIB_NAME, LogLevel.VERBOSE);
private static final boolean PRINT_TODO = Logger.getNeedPrint(LIB_NAME, LogLevel.TODO);
private static final boolean PRINT_PRINT = Logger.getNeedPrint(LIB_NAME, LogLevel.PRINT);
private Log() {}
public static void print(String data) {
if (PRINT_PRINT)
Logger.print(LIB_NAME_DRAW, data);
}
public static void critical(String data) {
if (PRINT_CRITICAL)
Logger.critical(LIB_NAME_DRAW, data);
}
public static void error(String data) {
if (PRINT_ERROR)
Logger.error(LIB_NAME_DRAW, data);
}
public static void warning(String data) {
if (PRINT_WARNING)
Logger.warning(LIB_NAME_DRAW, data);
}
public static void info(String data) {
if (PRINT_INFO)
Logger.info(LIB_NAME_DRAW, data);
}
public static void debug(String data) {
if (PRINT_DEBUG)
Logger.debug(LIB_NAME_DRAW, data);
}
public static void verbose(String data) {
if (PRINT_VERBOSE)
Logger.verbose(LIB_NAME_DRAW, data);
}
public static void todo(String data) {
if (PRINT_TODO)
Logger.todo(LIB_NAME_DRAW, data);
}
}

View File

@ -0,0 +1,37 @@
/*******************************************************************************
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* Contributors:
* Edouard DUPIN - initial API and implementation
******************************************************************************/
package test.atriasoft.loader3d;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.MethodOrderer.OrderAnnotation;
import org.atriasoft.etk.Uri;
import org.atriasoft.gale.Gale;
import org.atriasoft.gale.context.GaleContextTest;
import org.atriasoft.loader3d.resources.ResourceMeshEmf;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.TestMethodOrder;
@TestMethodOrder(OrderAnnotation.class)
public class TestBasicLog {
@Test
@Order(1)
public void aaFirstInitialisation() {
Gale.init();
GaleContextTest tmpContext = new GaleContextTest();
Uri.setGroup("EMF", "emf");
Uri.setApplication(TestBasicLog.class, "");
Uri.addLibrary("test", ResourceMeshEmf.class, "/resources");
//ResourceMeshEmf tmp = new ResourceMeshEmf(new Uri("EMF", "tree1.emf", "test"));
ResourceMeshEmf tmp = new ResourceMeshEmf(new Uri("FILE", "/home/heero/dev/workspace-game/atriasoft/loader3d/out/eclipse/classes/resources/emf/tree1.emf"));
}
}