Empty properties exception on Wavefront's material loading

Started by C3R14L.K1L4, February 06, 2009, 02:42:17 AM

Previous topic - Next topic

C3R14L.K1L4

When I load a material description where it's last material definition has empty properties, like the following example:

newmtl Explorer_Default
Ka 0.117647 0.117647 0.117647
Kd 0.752941 0.752941 0.752941
Ks 0.752941 0.752941 0.752941
illum 2
Ns 8
map_Kd
map_bump
bump
map_opacity
map_d
refl
map_kS
map_kA
map_Ns

I get this error on jPCT:

File models\bzz_Drunk_transparent.mtl loaded...643 bytes
Processing new material textures_alpha_t1!
Processing new material textures_alpha_l1!
Processing new material Explorer_Default!
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: -1
        at java.lang.String.substring(String.java:1938)
        at java.lang.String.substring(String.java:1905)
        at com.threed.jpct.Loader.loadOBJ(Unknown Source)
        at com.threed.jpct.Loader.loadOBJ(Unknown Source)
        at CK.IA.Engine.loadObj(Engine.java:465)
        at CK.IA.Engine.loadAndSetupModels(Engine.java:380)
        at CK.IA.Engine.initializeScene(Engine.java:279)
        at CK.IA.Engine.initialize(Engine.java:225)
        at CK.IA.Engine.<init>(Engine.java:64)
        at CK.IA.Engine.main(Engine.java:25)


I don't know which of the:

map_Kd
map_bump
bump
map_opacity
map_d
refl
map_kS
map_kA
map_Ns


causes the problem, but if I remove them, leaving only those "tags" with description, the loading goes nice and well. But quite boring to remove when an *.obj has lots of materials...
Only happens at the last material definition, if all the others before also have empty definitions, the loader only "explodes" at the last material.

(This is caused by Deep Exploration, I don't know why, but mine always stores materials with all tags, empty or with parameters.)