Author Topic: Empty properties exception on Wavefront's material loading  (Read 3180 times)

Offline C3R14L.K1L4

  • int
  • **
  • Posts: 54
    • View Profile
    • CK's place of many works
Empty properties exception on Wavefront's material loading
« on: February 06, 2009, 02:42:17 am »
When I load a material description where it's last material definition has empty properties, like the following example:

Code: [Select]
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:

Code: [Select]
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:

Code: [Select]
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.)
« Last Edit: February 06, 2009, 02:45:45 am by C3R14L.K1L4 »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: Empty properties exception on Wavefront's material loading
« Reply #1 on: February 19, 2009, 04:13:16 pm »
This version should fix the problem: http://www.jpct.net/download/beta/jpct.jar