Author Topic: OBJLoader problem with some obj line (nan)  (Read 672 times)

Offline nIkO_mx

  • byte
  • *
  • Posts: 5
    • View Profile
OBJLoader problem with some obj line (nan)
« on: August 18, 2015, 01:31:51 pm »
Hello
I'm working on an OBJ viewer and I'm having some problem with some objs in particular.
The 3D scanner that I'm using sometimes put some lines with "nan" in the obj file

(Example)

Code: [Select]
v 0.5969 0.9050 0.7055
vn nan nan nan
vt nan nan
v 0.5970 0.9050 0.7054
vn nan nan nan
vt nan nan
v 0.5970 0.9050 0.7055
vn nan nan nan
vt nan nan
v 0.6056 0.9209 0.6957

So the obj loader crash when it try to recognize them at this point:

Code: [Select]
try {
                        uvs[var55][var61] = Float.valueOf(var62).floatValue();
                    } catch (Exception var48) {
                        uvs[var55][var61] = 0.0F;
                        Logger.log("Error in OBJ-file near: " + line, 0);
                    }
                }



I was thinking to do a little change in the library just to tell objloader to simply ignore those line with "nan" values, putting something inside it like " if (var62 == "nan") ....etc", but as i know is not nice to modify the code of someone else library, plus I think I'm not enought experienced to do it right so...I'm asking here...has someone some advice for my problem??

thank you!

p.s.
here is the Log:

Code: [Select]
08-18 13:16:26.218  28622-28652/it.proteomed.www.proteoviewer E/AndroidRuntime﹕ FATAL EXCEPTION: AsyncTask #1
    Process: it.proteomed.www.proteoviewer, PID: 28622
    java.lang.RuntimeException: An error occured while executing doInBackground()
            at android.os.AsyncTask$3.done(AsyncTask.java:300)
            at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
            at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
            at java.util.concurrent.FutureTask.run(FutureTask.java:242)
            at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
            at java.lang.Thread.run(Thread.java:841)
     [b]Caused by: java.lang.RuntimeException: [ 1439896586207 ] - ERROR: Error in OBJ-file near: vt nan nan[/b]
            at com.threed.jpct.Logger.log(Logger.java:206)
            [b]at com.threed.jpct.Loader.loadOBJ(Loader.java:419)
            at com.threed.jpct.Loader.loadOBJ(Loader.java:229)[/b]
            at it.proteomed.www.proteoviewer.MainActivity$2.doInBackground(MainActivity.java:220)
            at it.proteomed.www.proteoviewer.MainActivity$2.doInBackground(MainActivity.java:194)
            at android.os.AsyncTask$2.call(AsyncTask.java:288)
            at java.util.concurrent.FutureTask.run(FutureTask.java:237)
            at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
            at java.lang.Thread.run(Thread.java:841)
« Last Edit: August 18, 2015, 01:38:16 pm by nIkO_mx »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11747
    • View Profile
    • http://www.jpct.net
Re: OBJLoader problem with some obj line (nan)
« Reply #1 on: August 18, 2015, 01:54:39 pm »
I could do that, but isn't that the wrong way? The actual problem is that nan (Not a Number) is written into the file in the first place. You could preprocess the files yourself and replace all the nan-entries with 0.

Offline nIkO_mx

  • byte
  • *
  • Posts: 5
    • View Profile
Re: OBJLoader problem with some obj line (nan)
« Reply #2 on: August 18, 2015, 02:04:00 pm »
It seems a good idea...can you give me some tips about it?  As i said i'm not so experienced so every help is very appreciate!
thank you!

N.