I know this topic has come up before but i have not found an answer to the problem. I load the model fine from 3ds, the texture and materals are all there. But the problem is that the object is rotated 90 degrees to the right… I would prefer to not have to rotate every object i load 90 degrees. Can someone please tell me if there is something wrong with the code.
public static Node loadModel (String modelFile){
Node loadedModel = null;
FormatConverter formatConverter = null;
ByteArrayOutputStream BO = new ByteArrayOutputStream();
String modelFormat = modelFile.substring(modelFile.lastIndexOf(".") + 1, modelFile.length());
String modelBinary = modelFile.substring(0, modelFile.lastIndexOf(".") + 1) + "jbin";
URL modelURL = ModelLoader.class.getClassLoader().getResource(modelBinary);
System.out.println("If");
//verify the presence of the jbin model
if (modelURL == null){
modelURL = ModelLoader.class.getClassLoader().getResource(modelFile);
//evaluate the format
if (modelFormat.equals("3DS")){
formatConverter = new MaxToJme();
} else if (modelFormat.equals("md2")){
formatConverter = new Md2ToJme();
} else if (modelFormat.equals("md3")){
formatConverter = new Md3ToJme();
} else if (modelFormat.equals("ms3d")){
formatConverter = new MilkToJme();
} else if (modelFormat.equals("ase")){
formatConverter = new AseToJme();
} else if (modelFormat.equals("obj")){
System.out.println("OBJ");
formatConverter = new ObjToJme();
}
formatConverter.setProperty("mtllib", modelURL);
try {
formatConverter.convert(modelURL.openStream(), BO);
loadedModel = (Node) BinaryImporter.getInstance().load(new ByteArrayInputStream(BO.toByteArray()));
//save the jbin format
BinaryExporter.getInstance().save(loadedModel, new File(modelBinary));
} catch (IOException e) {
e.printStackTrace();
return null;
}
}else{
try {
//load the jbin format
loadedModel = (Node) BinaryImporter.getInstance().load(modelURL.openStream());
} catch (IOException e) {
return null;
}
}
return loadedModel;
}
iIf someone could please help me that would be fantastic.
Nothing wrong with your code. 3DS has a different coordinate system than jME (or openGL). It is not translated by the 3ds loader.