Problem with the FormatLoader ObjToJme class

Hello,



I've a problem with the FormatLoader ObjToJme class. I got a



java.lang.NullPointerException

at com.jmex.model.XMLparser.Converters.TDSChunkingFiles.MaterialBlock.initializeVariables(Unknown Source)

at com.jmex.model.XMLparser.Converters.TDSChunkingFiles.MaterialBlock.<init>(Unknown Source)

at com.jmex.model.XMLparser.Converters.TDSChunkingFiles.EditableObjectChunk.processChildChunk(Unknown Source)

at com.jmex.model.XMLparser.Converters.TDSChunkingFiles.ChunkerClass.chunk(Unknown Source)

at com.jmex.model.XMLparser.Converters.TDSChunkingFiles.EditableObjectChunk.<init>(Unknown Source)

at com.jmex.model.XMLparser.Converters.TDSChunkingFiles.TDSFile.processChildChunk(Unknown Source)

at com.jmex.model.XMLparser.Converters.TDSChunkingFiles.ChunkerClass.chunk(Unknown Source)

at com.jmex.model.XMLparser.Converters.TDSChunkingFiles.TDSFile.<init>(Unknown Source)

at com.jmex.model.XMLparser.Converters.MaxToJme.convert(Unknown Source)





when I try to load a 'OBJ' file.



What is maybe wrong?



Thanks, Arvid

Sorry,



I get this exception by loading severals 3DS files!

When I loading a OBJ file I get this exception:



java.lang.NullPointerException

at com.jmex.model.XMLparser.Converters.ObjToJme$MaterialGrouping.<init>(Unknown Source)

at com.jmex.model.XMLparser.Converters.ObjToJme.convert(Unknown Source)





Is the material missing? Any Idea?



Thanks, Arvid




Is the material missing? Any Idea?


Check that You have a .mtl file whith the same name as the .obj
It specifies the materials used in the .obj

Hello,



first, thanks a lot for answer.



I testet with several obj files with mtl files. I can't convert anyone (same exception like above)!

And, I testet 3ds files, also! Only 2 converted without a exception at the MaterialBlock.initializeVariables() method!



When I tried to load the generated jme files (gzip), one returned a 'NullPointerException'

at com.jme.util.export.binary.modules.BinaryMaterialStateModule.load(Unknown Source)

at com.jme.util.export.binary.BinaryClassLoader.fromName(Unknown Source)

at com.jme.util.export.binary.BinaryImporter.readObject(Unknown Source)

at com.jme.util.export.binary.BinaryInputCapsule.resolveIDs(Unknown Source)

at com.jme.util.export.binary.BinaryInputCapsule.readSavableArray(Unknown Source)





Only one looks good in the rendered scene!



I think the 3ds files need a special kind of material items. ???



Can anyone write, which standard or version or items, the 3ds file must have?

And what is important for the obj files?

Has anyone experience with loading model files?



Thanks, Arvid

it seems like you have problems with the materials in general. you might want to search the board (there are many threads about models and model loading).

which tool do you use to create your models? did you try to also load them in another application(like another modeler or 3d viewer)?

also make sure you triangulate your models prior to importing them into jme.



there's nothing special about obj files. they are plain text. usually in the .obj files reference a .mtl file (which contains the materials definitions, including texture paths and names).

Alternatively you can use a FormatConverter along with the material property. Obj bt default read a .mtl of the same name of the model (as explained above).



        URL model=MyClass.class.getClassLoader().getResource("path/to/model.obj");
        FormatConverter f = new ObjToJme();
        f.setProperty("newmtl", model);
        ByteArrayOutputStream output=new ByteArrayOutputStream();
        f.convert(model.openStream(), output);