dcdcdc
This commit is contained in:
parent
1679d62300
commit
8ba3c34262
@ -1,100 +1,16 @@
|
||||
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) == ' ') {
|
||||
while (data.length() >= 1 && data.charAt(0) == ' ') {
|
||||
data = data.substring(1);
|
||||
}
|
||||
String[] elem = data.split(" |,|/");
|
||||
String[] elem = data.split(" |,|/");
|
||||
if (elem.length != 6 && elem.length != 9) {
|
||||
return null;
|
||||
}
|
||||
Face out = new Face();
|
||||
if (elem.length == 9) {
|
||||
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;
|
||||
@ -114,4 +30,100 @@ public class Face {
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
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 setColor(int _c1, int _c2, int _c3) {
|
||||
this.color[0] = _c1;
|
||||
this.color[1] = _c2;
|
||||
this.color[2] = _c3;
|
||||
}
|
||||
|
||||
public void setNormal(int _n) {
|
||||
this.normal[0] = _n;
|
||||
this.normal[1] = _n;
|
||||
this.normal[2] = _n;
|
||||
}
|
||||
|
||||
public void setNormal(int _n1, int _n2, int _n3) {
|
||||
this.normal[0] = _n1;
|
||||
this.normal[1] = _n2;
|
||||
this.normal[2] = _n3;
|
||||
}
|
||||
|
||||
public void setTexture(int _t1, int _t2, int _t3) {
|
||||
this.uv[0] = _t1;
|
||||
this.uv[1] = _t2;
|
||||
this.uv[2] = _t3;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -4,6 +4,8 @@ import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.atriasoft.etk.Uri;
|
||||
import org.atriasoft.etk.math.Vector2f;
|
||||
@ -19,164 +21,185 @@ 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);
|
||||
mode = RenderMode.TRIANGLE;
|
||||
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;
|
||||
enum emfModuleMode {
|
||||
EMFModuleSkip(-1), //!< skip the current module ==> filtered...
|
||||
EMFModuleNone(0), //!< Nothing in parsing
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
int getValue() {
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO : rework with string line extractor
|
||||
/**
|
||||
* Create a mesh from Ewol Mesh File.
|
||||
* @param fileName generic URI if parameter filter is set the mesh is partially loaded applying the filter
|
||||
* @throws Exception pb in parsing the file maybe no vertices inside...
|
||||
*/
|
||||
public ResourceMeshEmf(Uri fileName) throws Exception {
|
||||
super(fileName);
|
||||
Pattern filterPattern = null;
|
||||
if (fileName.hasProperty("filter")) {
|
||||
filterPattern = Pattern.compile(fileName.getProperty("filter"));
|
||||
}
|
||||
this.mode = RenderMode.TRIANGLE;
|
||||
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<>(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 {
|
||||
if ( currentMode.getValue() >= emfModuleMode.EMFModuleMesh.getValue()
|
||||
&& currentMode.getValue() <= emfModuleMode.EMFModuleMesh_END.getValue()) {
|
||||
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);
|
||||
if (filterPattern != null) {
|
||||
Matcher m = filterPattern.matcher(currentMeshName);
|
||||
if (!m.matches()) {
|
||||
currentMode = emfModuleMode.EMFModuleSkip;
|
||||
Log.verbose("Parse Mesh(SKIP): " + currentMeshName);
|
||||
} else {
|
||||
Log.verbose("Parse Mesh: " + currentMeshName);
|
||||
}
|
||||
} else {
|
||||
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;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (currentMode == emfModuleMode.EMFModuleSkip) {
|
||||
// skip the content...
|
||||
continue;
|
||||
}
|
||||
if (currentMode.getValue() >= emfModuleMode.EMFModuleMesh.getValue() && currentMode.getValue() <= emfModuleMode.EMFModuleMesh_END.getValue()) {
|
||||
if (level == 1) {
|
||||
if(inputDataLine.startsWith("Vertex:") == true) {
|
||||
if (inputDataLine.startsWith("Vertex:") == true) {
|
||||
currentMode = emfModuleMode.EMFModuleMeshVertex;
|
||||
Log.verbose(" Vertex ...");
|
||||
} else if(inputDataLine.startsWith("UV-mapping:") == true) {
|
||||
} else if (inputDataLine.startsWith("UV-mapping:") == true) {
|
||||
currentMode = emfModuleMode.EMFModuleMeshUVMapping;
|
||||
haveUVMapping = true;
|
||||
Log.verbose(" UV-mapping ...");
|
||||
} else if(inputDataLine.startsWith("Normal(vertex):") == true) {
|
||||
} else if (inputDataLine.startsWith("Normal(vertex):") == true) {
|
||||
currentMode = emfModuleMode.EMFModuleMeshNormalVertex;
|
||||
Log.verbose(" Normal(vertex) ...");
|
||||
} else if(inputDataLine.startsWith("Normal(face):") == true) {
|
||||
} else if (inputDataLine.startsWith("Normal(face):") == true) {
|
||||
currentMode = emfModuleMode.EMFModuleMeshNormalFace;
|
||||
Log.verbose(" Normal(face) ...");
|
||||
} else if(inputDataLine.startsWith("Face:") == true) {
|
||||
} else if (inputDataLine.startsWith("Face:") == true) {
|
||||
currentMode = emfModuleMode.EMFModuleMeshFace;
|
||||
Log.verbose(" Face ...");
|
||||
} else if(inputDataLine.startsWith("Physics:") == true) {
|
||||
} else if (inputDataLine.startsWith("Physics:") == true) {
|
||||
currentMode = emfModuleMode.EMFModuleMeshPhysics;
|
||||
Log.verbose(" Physics ...");
|
||||
} else {
|
||||
@ -292,212 +315,228 @@ public ResourceMeshEmf(Uri _fileName) {
|
||||
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 ((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));
|
||||
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) {
|
||||
} 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) {
|
||||
} 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) {
|
||||
} else if (inputDataLine.startsWith("Ks ") == true) {
|
||||
Vector4f tmp = Vector4f.valueOf(inputDataLine.substring(3));
|
||||
tmp = tmp.withW(1);
|
||||
material.setSpecularFactor(tmp);
|
||||
material.setSpecularFactor(tmp);
|
||||
Log.verbose(" SpecularFactor " + tmp);
|
||||
} else if(inputDataLine.startsWith("Ni ") == true) {
|
||||
float tmpVal=Float.valueOf(inputDataLine.substring(3));
|
||||
} 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));
|
||||
} 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));
|
||||
} 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();
|
||||
} 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) {
|
||||
} else if (inputDataLine.startsWith("renderMode ") == true) {
|
||||
//RenderMode mode;
|
||||
//frothis.string(mode, &inputDataLine[11]);
|
||||
//material.setRenderMode(mode);
|
||||
Log.verbose(" Texture " + mode);
|
||||
Log.verbose(" Texture " + this.mode);
|
||||
} else {
|
||||
Log.error("unknow material property ... : '" + inputDataLine + "'");
|
||||
}
|
||||
} else if ( currentMode.getValue() >= emfModuleMode.EMFModulePhysics.getValue()
|
||||
&& currentMode.getValue() <= emfModuleMode.EMFModulePhysics_END.getValue()) {
|
||||
continue;
|
||||
}
|
||||
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;
|
||||
// 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 ...");
|
||||
// }
|
||||
// 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 ...");
|
||||
// }
|
||||
}
|
||||
continue;
|
||||
}
|
||||
// unknown ...
|
||||
Log.warning("Unknown 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());
|
||||
if (this.listVertex.size() == 0) {
|
||||
throw new Exception("unable to load the mesh file: " + fileName + " ==> no vertex available.");
|
||||
}
|
||||
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 {
|
||||
// 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') {
|
||||
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) {
|
||||
@ -505,47 +544,31 @@ private String readLine(BufferedReader _file, Dynamic<Integer> level) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
buf = new StringBuffer();
|
||||
startLine = true;
|
||||
differentThanSpace = false;
|
||||
hasSpace = false;
|
||||
level.value = 0;
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
// end of data removed
|
||||
while(current != '\0' && current != '\n') {
|
||||
try {
|
||||
current = _file.read();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
differentThanSpace = true;
|
||||
if (current == '\t' || current == ' ') {
|
||||
hasSpace = true;
|
||||
} else {
|
||||
if (hasSpace == true) {
|
||||
buf.append(' ');
|
||||
hasSpace = false;
|
||||
}
|
||||
buf.append((char) current);
|
||||
}
|
||||
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();
|
||||
}
|
||||
}
|
||||
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();
|
||||
}
|
||||
Log.error("Read line: offset=" + level.value + "\n" + buf.toString());
|
||||
if (buf.length() == 0) {
|
||||
return null;
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,64 @@
|
||||
package org.atriasoft.loader3d.resources;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.atriasoft.etk.math.Vector3f;
|
||||
import org.atriasoft.loader3d.Face;
|
||||
import org.atriasoft.loader3d.FaceIndexing;
|
||||
import org.atriasoft.loader3d.NormalMode;
|
||||
import org.atriasoft.loader3d.model.Material;
|
||||
|
||||
public class ResourceMeshHeightMap extends ResourceMesh {
|
||||
/*
|
||||
* 0 1 2 3
|
||||
* 0 *-------*-------*-------*
|
||||
* \ OO / \ 02 / \ 04 / \
|
||||
* \ / \ / \ / \
|
||||
* \ / 01 \ / 03 \ / 05 \
|
||||
* *-------*-------*-------*
|
||||
* / \ / \ / \ /
|
||||
* / \ / \ / \ /
|
||||
* / \ / \ / \ /
|
||||
* *-------*-------*-------*
|
||||
*/
|
||||
public ResourceMeshHeightMap() {
|
||||
this.normalMode = NormalMode.FACE;
|
||||
}
|
||||
|
||||
void addPalette(String key, Material mat) {
|
||||
this.palettes.put(key, mat);
|
||||
}
|
||||
|
||||
Map<String, Material> getPalette() {
|
||||
return this.palettes;
|
||||
}
|
||||
|
||||
public void udateData(float[][] heightMap, String[][] colorMap, int width, int length) throws Exception {
|
||||
float ratio = 0.2f;
|
||||
for (int yyy = 0; yyy < length - 1; yyy++) {
|
||||
for (int xxx = 0; xxx < width - 1; xxx++) {
|
||||
Vector3f vertex1 = new Vector3f(ratio * xxx, ratio * yyy, ratio * heightMap[yyy][xxx]);
|
||||
this.listVertex.add(vertex1);
|
||||
Vector3f vertex2 = new Vector3f(ratio * (xxx + 1), ratio * yyy, ratio * heightMap[yyy][xxx + 1]);
|
||||
this.listVertex.add(vertex2);
|
||||
Vector3f vertex3 = new Vector3f(ratio * xxx, ratio * (yyy + 1), ratio * heightMap[yyy + 1][xxx]);
|
||||
this.listVertex.add(vertex3);
|
||||
FaceIndexing currentFaceIndexing = null;
|
||||
String meshFaceMaterialID = colorMap[yyy][xxx * 2];
|
||||
if (this.listPaletteFaces.containsKey(meshFaceMaterialID) == false) {
|
||||
currentFaceIndexing = new FaceIndexing();
|
||||
this.listPaletteFaces.put(meshFaceMaterialID, currentFaceIndexing);
|
||||
} else {
|
||||
currentFaceIndexing = this.listPaletteFaces.get(meshFaceMaterialID);
|
||||
}
|
||||
Face face = new Face();
|
||||
int pos = this.listVertex.size() - 3;
|
||||
face.setVertex(pos, pos + 1, pos + 2);
|
||||
|
||||
currentFaceIndexing.face().add(face);
|
||||
}
|
||||
}
|
||||
generateVBO();
|
||||
}
|
||||
|
||||
}
|
@ -5,10 +5,10 @@ import org.atriasoft.gale.resource.Resource;
|
||||
import org.atriasoft.gale.resource.ResourceVirtualArrayObject;
|
||||
import org.atriasoft.loader3d.internal.Log;
|
||||
|
||||
public class ResourceStaticMeshObjBynamic extends ResourceStaticMeshObj {
|
||||
public class ResourceStaticMeshObjDynamic extends ResourceStaticMeshObj {
|
||||
|
||||
public static ResourceStaticMeshObjBynamic create(final Uri uriObj) {
|
||||
ResourceStaticMeshObjBynamic resource;
|
||||
public static ResourceStaticMeshObjDynamic create(final Uri uriObj) {
|
||||
ResourceStaticMeshObjDynamic resource;
|
||||
Resource resource2;
|
||||
final String name = uriObj.getValue();
|
||||
if (name.isEmpty() || name.equals("---")) {
|
||||
@ -17,19 +17,19 @@ public class ResourceStaticMeshObjBynamic extends ResourceStaticMeshObj {
|
||||
}
|
||||
resource2 = Resource.getManager().localKeep(name);
|
||||
if (resource2 != null) {
|
||||
if (resource2 instanceof ResourceStaticMeshObjBynamic tmpp) {
|
||||
if (resource2 instanceof ResourceStaticMeshObjDynamic tmpp) {
|
||||
resource2.keep();
|
||||
return tmpp;
|
||||
}
|
||||
Log.critical("Request resource file : '" + name + "' With the wrong type (dynamic cast error)");
|
||||
return null;
|
||||
}
|
||||
resource = new ResourceStaticMeshObjBynamic(uriObj);
|
||||
resource = new ResourceStaticMeshObjDynamic(uriObj);
|
||||
Resource.getManager().localAdd(resource);
|
||||
return resource;
|
||||
}
|
||||
|
||||
protected ResourceStaticMeshObjBynamic(final Uri uriFile) {
|
||||
protected ResourceStaticMeshObjDynamic(final Uri uriFile) {
|
||||
super(uriFile);
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ 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.atriasoft.loader3d.resources.ResourceMeshHeightMap;
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
|
||||
@ -27,10 +27,10 @@ public class TestBasicLog {
|
||||
GaleContextTest tmpContext = new GaleContextTest();
|
||||
Uri.setGroup("EMF", "emf");
|
||||
Uri.setApplication(TestBasicLog.class, "");
|
||||
Uri.addLibrary("test", ResourceMeshEmf.class, "/resources");
|
||||
Uri.addLibrary("test", ResourceMeshHeightMap.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"));
|
||||
ResourceMeshHeightMap tmp = new ResourceMeshHeightMap(new Uri("FILE", "/home/heero/dev/workspace-game/atriasoft/loader3d/out/eclipse/classes/resources/emf/tree1.emf"));
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user