Author Topic: JPCT-AE error loading models (.md2, .3ds ...)[SOLVED]  (Read 9075 times)

Offline PaniX

  • byte
  • *
  • Posts: 18
    • View Profile
JPCT-AE error loading models (.md2, .3ds ...)[SOLVED]
« on: September 15, 2013, 07:07:03 pm »
Hello guys,
as I'm an Android and JPCT-AE noob, I have to ask something.
I'm currently playing a little bit around with the HelloWorld-AE example, and found a problem.
The normal
Code: [Select]
cube = Primitives.getCube(10.0f);
cube.calcTextureWrap();
cube.setTexture("texture");
cube.strip();
cube.build();
method works. But when I try to load my own Model instead, like this:
Code: [Select]
cube = Loader.loadMD2(getResource().openRawResource(R.raw.gun), 0.5f);
//cube = Primitives.getCube(10.0f);
cube.calcTextureWrap();
cube.setTexture("texture");
cube.strip();
cube.build();
the Application crashs. I'm not sure why, as it worked already for me. The same happens when I try to load a 3DS file, like it's written in the wiki.
Does someone knows what's the problem?
Thanks
PaniX
« Last Edit: September 17, 2013, 06:09:03 am by PaniX »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: JPCT-AE error loading models (.md2, .3ds ...)
« Reply #1 on: September 15, 2013, 08:57:56 pm »
Impossible to tell unless you post the actual exception too.

Offline PaniX

  • byte
  • *
  • Posts: 18
    • View Profile
Re: JPCT-AE error loading models (.md2, .3ds ...)
« Reply #2 on: September 16, 2013, 06:24:44 am »
The logcat doesn't help either:
Code: [Select]
Android Log: Sep 16, 2013 06:21:28 +0200 - I/ActivityManager(  236): START {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10304000 cmp=free.codeninja.theone/.MainActivity} from pid 314
I/ActivityManager(  236): Start proc free.codeninja.theone for activity free.codeninja.theone/.MainActivity: pid=1259 uid=10085 gids={}
I/ActivityManager(  236): Displayed free.codeninja.theone/.MainActivity: +657ms
E/AndroidRuntime( 1259): at free.codeninja.theone.MainActivity$MyRenderer.onSurfaceChanged(MainActivity.java:175)
W/ActivityManager(  236):   Force finishing activity free.codeninja.theone/.MainActivity
I/ActivityManager(  236): Process free.codeninja.theone (pid 1259) has died.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: JPCT-AE error loading models (.md2, .3ds ...)
« Reply #3 on: September 16, 2013, 07:43:49 am »
That can't be everything. Are you by any chance swallowing some exception in your code?

Offline PaniX

  • byte
  • *
  • Posts: 18
    • View Profile
Re: JPCT-AE error loading models (.md2, .3ds ...)
« Reply #4 on: September 16, 2013, 01:23:14 pm »
May it be that there is something wrong with the inputstream? Not the object, I mean in the code? A wrong import? I'm not sure, but I think I've changed something in the imports.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: JPCT-AE error loading models (.md2, .3ds ...)
« Reply #5 on: September 16, 2013, 01:39:19 pm »
Looks fine to me. Even if it's wrong, there should be more info than just start/exit.

Offline PaniX

  • byte
  • *
  • Posts: 18
    • View Profile
Re: JPCT-AE error loading models (.md2, .3ds ...)
« Reply #6 on: September 16, 2013, 02:18:25 pm »
There is nothing more in the logcat. Maybe in the .xml files? Could there be a problem? I don't think so, because getCube works...

Offline PaniX

  • byte
  • *
  • Posts: 18
    • View Profile
Re: JPCT-AE error loading models (.md2, .3ds ...)
« Reply #7 on: September 16, 2013, 02:41:33 pm »
Made a Logger.log();
before cube = Loader.load [..]
It tells me that it fails loading the model, because the next Logger.log(); after Loader.loadMD2(); doesn't come (bad english, yay)
But I don't know what's wrong. Because I loaded the model before in JPCT-AE without any problems...
The model is in res/raw/gun.md2

Code: [Select]
09-16 14:54:43.977: I/jPCT-AE(2378): Loading model
09-16 14:54:44.007: W/dalvikvm(2378): threadid=11: thread exiting with uncaught exception (group=0x2b4e71f8)
09-16 14:54:44.007: E/AndroidRuntime(2378): FATAL EXCEPTION: GLThread 219
« Last Edit: September 16, 2013, 02:55:53 pm by PaniX »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: JPCT-AE error loading models (.md2, .3ds ...)
« Reply #8 on: September 16, 2013, 03:09:33 pm »
Try to put a try-catch around the loading code and log the exception.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: JPCT-AE error loading models (.md2, .3ds ...)
« Reply #9 on: September 16, 2013, 03:09:59 pm »
...and make sure to catch Throwable, not just Exception.

Offline PaniX

  • byte
  • *
  • Posts: 18
    • View Profile
Re: JPCT-AE error loading models (.md2, .3ds ...)
« Reply #10 on: September 16, 2013, 05:12:52 pm »
When I do it like this:
Code: [Select]
Logger.log("Loading model");
try {
cube = Loader.loadMD2(getResource().openRawResource(R.raw.gun), 0.5f);
Logger.log("Loaded model!");
}catch(Throwable e) {
Logger.log("ERROR:" + e.getMessage());
}

(not sure if this IS right, I'm new to Java)

It tells me this:

Code: [Select]
09-16 17:10:51.987: I/jPCT-AE(3728): Loading model
09-16 17:10:51.987: I/jPCT-AE(3728): ERROR:null
09-16 17:10:52.017: W/dalvikvm(3728): threadid=11: thread exiting with uncaught exception (group=0x2b4e71f8)
09-16 17:10:52.017: E/AndroidRuntime(3728): FATAL EXCEPTION: GLThread 366
Hopefully it helps :D

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: JPCT-AE error loading models (.md2, .3ds ...)
« Reply #11 on: September 16, 2013, 07:21:07 pm »
...not really. getMessage() on Exceptions often returns null. It would be better to simply do Logger.log(e); because that will print the actual stack trace.

Offline PaniX

  • byte
  • *
  • Posts: 18
    • View Profile
Re: JPCT-AE error loading models (.md2, .3ds ...)
« Reply #12 on: September 16, 2013, 08:12:34 pm »
Code: [Select]
09-16 20:10:49.377: I/jPCT-AE(6202): Texture loaded...16384 bytes/64*64 pixels!
09-16 20:10:49.377: I/jPCT-AE(6202): Loading model
09-16 20:10:49.397: I/jPCT-AE(6202): [ 1379355049402 ] - ERROR: java.lang.NullPointerException
09-16 20:10:49.397: I/jPCT-AE(6202): at free.codeninja.theone.MainActivity$MyRenderer.onSurfaceChanged(MainActivity.java:177)
09-16 20:10:49.397: I/jPCT-AE(6202): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1456)
09-16 20:10:49.397: I/jPCT-AE(6202): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1217)
09-16 20:10:49.407: W/dalvikvm(6202): threadid=11: thread exiting with uncaught exception (group=0x2b4e71f8)
09-16 20:10:49.417: E/AndroidRuntime(6202): FATAL EXCEPTION: GLThread 627
09-16 20:10:49.417: E/AndroidRuntime(6202): java.lang.RuntimeException: [ 1379355049402 ] - ERROR: java.lang.NullPointerException
09-16 20:10:49.417: E/AndroidRuntime(6202): at free.codeninja.theone.MainActivity$MyRenderer.onSurfaceChanged(MainActivity.java:177)
09-16 20:10:49.417: E/AndroidRuntime(6202): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1456)
09-16 20:10:49.417: E/AndroidRuntime(6202): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1217)
09-16 20:10:49.417: E/AndroidRuntime(6202): at com.threed.jpct.Logger.log(Logger.java:189)
09-16 20:10:49.417: E/AndroidRuntime(6202): at com.threed.jpct.Logger.log(Logger.java:136)
09-16 20:10:49.417: E/AndroidRuntime(6202): at free.codeninja.theone.MainActivity$MyRenderer.onSurfaceChanged(MainActivity.java:180)
09-16 20:10:49.417: E/AndroidRuntime(6202): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1456)
09-16 20:10:49.417: E/AndroidRuntime(6202): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1217)
09-16 20:10:49.517: D/OpenGLRenderer(6202): Flushing caches (mode 0)
09-16 20:10:50.247: D/OpenGLRenderer(6202): Flushing caches (mode 1)
09-16 20:10:51.257: I/Process(6202): Sending signal. PID: 6202 SIG: 9

Offline PaniX

  • byte
  • *
  • Posts: 18
    • View Profile
Re: JPCT-AE error loading models (.md2, .3ds ...)
« Reply #13 on: September 16, 2013, 08:42:14 pm »
Must be something wrong in the project setup. In the original HelloWorld-AE example (Android Application from Existing File) it works, in my project it doesn't work (Android Application Project)...
Where could the error be?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: JPCT-AE error loading models (.md2, .3ds ...)
« Reply #14 on: September 16, 2013, 08:51:13 pm »
If this is line 177

Code: [Select]
cube = Loader.loadMD2(getResource().openRawResource(R.raw.gun), 0.5f);

then only getResource() may return null or R.raw is null. Both seem strange to me, but it might indicate a problem with your project setup. Just try to create a new from scratch and see if that helps.