Hi,
I have an unusual dilemma with the FormatConverter. I have the following code, it based on the HelloModelLoading code:
private void loadVehicle()
{
URL model = TurtleScene.class.getClassLoader().getResource("bike.3ds");
URL textureURL=TurtleScene.class.getClassLoader().getResource("./");
// Create something to convert .3dsformat to .jme
FormatConverter converter = new MaxToJme();
// This byte array will hold my .jme file
ByteArrayOutputStream BO = new ByteArrayOutputStream();
try {
// Use the format converter to convert .3ds to .jme
converter.convert(model.openStream(), BO);
bike = (Node) BinaryImporter.getInstance().load(
new ByteArrayInputStream(BO.toByteArray()));
// shrink this baby down some
bike.setLocalScale(.01f);
bike.setModelBound(new BoundingSphere());
bike.updateModelBound();
} catch (IOException e) { // Just in case anything happens
System.exit(0);
}
//return bike;
}
The strange thing is, when I run this on a standalone BaseGame, the code works fine. However, when I use the same code within a class, the line
converter.convert(model.openStream(), BO);
throws the following exception:
31-Aug-2010 12:53:50 com.jme.system.lwjgl.LWJGLDisplaySystem <init>
INFO: LWJGL Display System created.
java.lang.NullPointerException
at com.jmex.model.converters.maxutils.MaterialBlock.initializeVariables(MaterialBlock.java:80)
at com.jmex.model.converters.maxutils.MaterialBlock.<init>(MaterialBlock.java:75)
at com.jmex.model.converters.maxutils.EditableObjectChunk.processChildChunk(EditableObjectChunk.java:94)
at com.jmex.model.converters.maxutils.ChunkerClass.chunk(ChunkerClass.java:94)
at com.jmex.model.converters.maxutils.EditableObjectChunk.<init>(EditableObjectChunk.java:80)
at com.jmex.model.converters.maxutils.TDSFile.processChildChunk(TDSFile.java:102)
at com.jmex.model.converters.maxutils.ChunkerClass.chunk(ChunkerClass.java:94)
at com.jmex.model.converters.maxutils.TDSFile.chunk(TDSFile.java:70)
at com.jmex.model.converters.maxutils.TDSFile.<init>(TDSFile.java:92)
at com.jmex.model.converters.MaxToJme.convert(MaxToJme.java:76)
at GameScene.loadVehicle(GameScene.java:268)
at Maze.main(Maze.java:134)
Any ideas as to why this would occur? There is no problem with compilation. This is a runtime error. The same file loads in a different program in the same directory! This is the same bike.3ds that is in the jmetest directory. I have a Node called bike.
Thanks
I forgot to mention that I am using JME2, as I have an old graphics card.