Hello again!
I’m making a game using a “tile system”. After finishing my first tiles and exporting them I get this:
Deled model:
After exporting to .obj format and previewing in jME:
When I tested that obj file in MeshLab and reimported to deleD everything still looked fine and ok…
Maybe this code might help you(my obj import class):
package engine;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
import com.jme.bounding.BoundingSphere;
import com.jme.scene.Node;
import com.jme.scene.Spatial;
import com.jme.util.export.binary.BinaryImporter;
import com.jme.util.resource.ResourceLocatorTool;
import com.jme.util.resource.SimpleResourceLocator;
import com.jmex.model.converters.ObjToJme;
public class ObjLoader{
public static Node GetObjFromLocation(String ObjFileLoc, String TexFolderLoc){
try {
ResourceLocatorTool.addResourceLocator(
ResourceLocatorTool.TYPE_TEXTURE,
new SimpleResourceLocator(ObjLoader.class.getResource(TexFolderLoc)));
} catch (URISyntaxException e){e.printStackTrace();}
Node model = new Node();
ObjToJme converter = new ObjToJme();
try {
URL objFile = ObjLoader.class.getClassLoader().getResource(
ObjFileLoc);
converter.setProperty("mtllib", objFile);
converter.setProperty(TexFolderLoc,objFile);
ByteArrayOutputStream BO = new ByteArrayOutputStream();
converter.convert(objFile.openStream(), BO);
model.attachChild((Spatial)BinaryImporter.getInstance().load(
new ByteArrayInputStream(BO.toByteArray())));
model.setModelBound(new BoundingSphere());
model.updateModelBound();
} catch (IOException e) {
System.out.println("Error while loading obj: "+ObjFileLoc);
e.printStackTrace();
}
return model;
}
}