We can do all we need with the DummyDisplaySystem. Eventually I'll be able

to turn this into an ant task.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3584 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2005-05-31 23:14:51 +00:00
parent 5a4df194ec
commit c6ceb654e4
@@ -29,10 +29,8 @@ import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.net.URL; import java.net.URL;
import com.jme.app.SimpleGame;
import com.jme.renderer.lwjgl.LWJGLRenderer;
import com.jme.system.DisplaySystem;
import com.jmex.model.XMLparser.Converters.AseToJme; import com.jmex.model.XMLparser.Converters.AseToJme;
import com.jmex.model.XMLparser.Converters.DummyDisplaySystem;
import com.jmex.model.XMLparser.Converters.FormatConverter; import com.jmex.model.XMLparser.Converters.FormatConverter;
import com.jmex.model.XMLparser.Converters.MaxToJme; import com.jmex.model.XMLparser.Converters.MaxToJme;
import com.jmex.model.XMLparser.Converters.Md2ToJme; import com.jmex.model.XMLparser.Converters.Md2ToJme;
@@ -43,7 +41,7 @@ import com.jmex.model.XMLparser.Converters.ObjToJme;
* A tool for converting various 3D model formats into JME's internal * A tool for converting various 3D model formats into JME's internal
* format. * format.
*/ */
public class ConvertModel extends SimpleGame public class ConvertModel
{ {
public static void main (String[] args) public static void main (String[] args)
{ {
@@ -52,18 +50,14 @@ public class ConvertModel extends SimpleGame
System.exit(-1); System.exit(-1);
} }
// create a dummy display system which the converters need
new DummyDisplaySystem();
ConvertModel app = new ConvertModel(); ConvertModel app = new ConvertModel();
app._source = new File(args[0]); File source = new File(args[0]);
app._target = new File(args[1]); File target = new File(args[1]);
app.setDialogBehaviour( String path = source.getPath().toLowerCase();
SimpleGame.FIRSTRUN_OR_NOCONFIGFILE_SHOW_PROPS_DIALOG);
app.start();
}
protected void simpleInitGame ()
{
String path = _source.getPath().toLowerCase();
String type = path.substring(path.lastIndexOf(".") + 1); String type = path.substring(path.lastIndexOf(".") + 1);
// set up our converter // set up our converter
@@ -71,7 +65,7 @@ public class ConvertModel extends SimpleGame
if (type.equals("obj")) { if (type.equals("obj")) {
convert = new ObjToJme(); convert = new ObjToJme();
try { try {
convert.setProperty("mtllib", new URL("file:" + _source)); convert.setProperty("mtllib", new URL("file:" + source));
} catch (Exception e) { } catch (Exception e) {
System.err.println("Failed to create material URL: " + e); System.err.println("Failed to create material URL: " + e);
System.exit(-1); System.exit(-1);
@@ -92,20 +86,16 @@ public class ConvertModel extends SimpleGame
// and do the deed // and do the deed
try { try {
BufferedOutputStream bout = new BufferedOutputStream( BufferedOutputStream bout = new BufferedOutputStream(
new FileOutputStream(_target)); new FileOutputStream(target));
BufferedInputStream bin = new BufferedInputStream( BufferedInputStream bin = new BufferedInputStream(
new FileInputStream(_source)); new FileInputStream(source));
convert.convert(bin, bout); convert.convert(bin, bout);
bout.close(); bout.close();
} catch (IOException ioe) { } catch (IOException ioe) {
System.err.println("Error converting '" + _source + System.err.println("Error converting '" + source +
"' to '" + _target + "'."); "' to '" + target + "'.");
ioe.printStackTrace(System.err); ioe.printStackTrace(System.err);
System.exit(-1); System.exit(-1);
} }
finish();
} }
protected File _source, _target;
} }