www.jpct.net

jPCT - a 3d engine for Java => Support => Topic started by: AGP on October 31, 2017, 08:33:08 pm

Title: Loader.loadOBJ Problem
Post by: AGP on October 31, 2017, 08:33:08 pm
Code: [Select]
System.out.println("\n\n\nWarcraft.loadObject: "+fileName +" Is the mtl null? "+(mtlFile==null));
System.out.println("Is loadOBJ(fileName, mtlFile) null? "+(Loader.loadOBJ(fileName, mtlFile, .5f)==null));

Produces:
Quote
Warcraft.loadObject: buildings\castle_construction0.obj Is the mtl null? false
Exception in thread "main" java.lang.NullPointerException
        at java.util.Hashtable.put(Unknown Source)
        at com.threed.jpct.Loader.loadOBJ(Loader.java:819)
        at com.threed.jpct.Loader.loadOBJ(Loader.java:508)
        at Warcraft.loadObject(Warcraft.java:250)
        at Worker.moveTowardsDest(Character.java:393)
        at Warcraft.loop(Warcraft.java:320)
        at Warcraft.<init>(Warcraft.java:163)
        at Warcraft.main(Warcraft.java:1058)

I've opened the file in Blender and it loads just fine.
Title: Re: Loader.loadOBJ Problem
Post by: EgonOlsen on October 31, 2017, 11:17:32 pm
mtlFile might be not null, but does the actual file exist? For desktop jPCT, it's best to set the Logger to ON_ERROR_THROW_EXCEPTION, so that it exists early. jPCT-AE already does this, the desktop version just doesn't for compatibility reasons. Maybe that reveals the actual problem.
Title: Re: Loader.loadOBJ Problem
Post by: AGP on November 22, 2017, 07:10:49 pm
Sorry for taking this long but this baffling bug discouraged me. The file exists.
This:
Code: [Select]
System.out.println("\n\n\nWarcraft.loadObject: "+fileName +" Is the mtl null? "+(mtlFile==null) +" Does the file exist? "+new File(fileName).exists());

Prints:
Quote
Warcraft.loadObject: buildings\castle_construction1.obj Is the mtl null? false Does the file exist? true
Title: Re: Loader.loadOBJ Problem
Post by: EgonOlsen on November 23, 2017, 07:57:25 am
Can you post the content of the mtl-file? Looks like as if there's no actual material definition in there or it's done in a way that I've never encountered before.
Title: Re: Loader.loadOBJ Problem
Post by: AGP on November 28, 2017, 05:06:22 pm
As soon as you posted this, I re-exported for the hundredth time and, for reasons passing understanding, it worked. Just to let you know.