jMonkeyEngine quick loading of 3D models
Creating visualizations, games or other types of animation will meet with the need to load some kind of 3D models. It is no different in the case of an engine jMonkeyEngine, however, is a question as soon as possible to read such models? It is best to use the format provided by JME. Such a change of format will save a considerable amount of time needed to parse loaded models. Following is the code by which the model loaded in the format .obj, we now export to .dat:
URL model = Court.class.getClassLoader().getResource(
"model/Court.obj");
Spatial courtNode = null;
try {
FormatConverter converter = new ObjToJme();
converter.setProperty("mtllib", model);
ByteArrayOutputStream BO = new ByteArrayOutputStream();
converter.convert(model.openStream(), BO);
courtNode = (Spatial)BinaryImporter.getInstance().load(new ByteArrayInputStream(BO
.toByteArray()));
} catch (IOException e) { // Just in case anything happens
logger.logp(Level.SEVERE, this.getClass().toString(),
"simpleInitGame()", "Exception", e);
System.exit(0);
}

Memorized object we can now export:
export(courtNode,"model/Court");</pre>
Related prepared model:
courtNode = open("model/Court");












No comments yet.