www.jpct.net

jPCT-AE - a 3d engine for Android => Support => Topic started by: PaniX on September 15, 2013, 07:07:03 pm

Title: JPCT-AE error loading models (.md2, .3ds ...)[SOLVED]
Post by: PaniX 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
Title: Re: JPCT-AE error loading models (.md2, .3ds ...)
Post by: EgonOlsen on September 15, 2013, 08:57:56 pm
Impossible to tell unless you post the actual exception too.
Title: Re: JPCT-AE error loading models (.md2, .3ds ...)
Post by: PaniX 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.
Title: Re: JPCT-AE error loading models (.md2, .3ds ...)
Post by: EgonOlsen on September 16, 2013, 07:43:49 am
That can't be everything. Are you by any chance swallowing some exception in your code?
Title: Re: JPCT-AE error loading models (.md2, .3ds ...)
Post by: PaniX 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.
Title: Re: JPCT-AE error loading models (.md2, .3ds ...)
Post by: EgonOlsen 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.
Title: Re: JPCT-AE error loading models (.md2, .3ds ...)
Post by: PaniX 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...
Title: Re: JPCT-AE error loading models (.md2, .3ds ...)
Post by: PaniX 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
Title: Re: JPCT-AE error loading models (.md2, .3ds ...)
Post by: EgonOlsen on September 16, 2013, 03:09:33 pm
Try to put a try-catch around the loading code and log the exception.
Title: Re: JPCT-AE error loading models (.md2, .3ds ...)
Post by: EgonOlsen on September 16, 2013, 03:09:59 pm
...and make sure to catch Throwable, not just Exception.
Title: Re: JPCT-AE error loading models (.md2, .3ds ...)
Post by: PaniX 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
Title: Re: JPCT-AE error loading models (.md2, .3ds ...)
Post by: EgonOlsen 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.
Title: Re: JPCT-AE error loading models (.md2, .3ds ...)
Post by: PaniX 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
Title: Re: JPCT-AE error loading models (.md2, .3ds ...)
Post by: PaniX 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?
Title: Re: JPCT-AE error loading models (.md2, .3ds ...)
Post by: EgonOlsen 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.
Title: Re: JPCT-AE error loading models (.md2, .3ds ...)
Post by: PaniX on September 16, 2013, 08:54:43 pm
I don't think getResource() returns null, or even gun.md2 is null, because it works in the real example. What could be wrong in the project setup, and how it has to be fixed? I hate sdk's, normally I just use nano for programming, but Android needs J***...
Title: Re: JPCT-AE error loading models (.md2, .3ds ...)
Post by: EgonOlsen on September 16, 2013, 08:56:38 pm
Just TEST what's null and you'll see..."I don't think" won't take you anywhere.
Title: Re: JPCT-AE error loading models (.md2, .3ds ...)
Post by: PaniX on September 17, 2013, 06:08:46 am
Somehow an import com.threed.jpct.example.R; or something like that managed to get into my Java codings...
 :-[
But thank you for your great help, now I also have some informations how to debug with try-catches, thanks!