Loading Bones on Android

Started by AGP, August 29, 2011, 10:02:52 AM

Previous topic - Next topic

AGP

Assuming this is right (on the desktop app to save the bones file):

     private void saveToBones(String outFileName) {
FileOutputStream outStream = null;
try {
     outStream = new FileOutputStream(outFileName);
     BonesIO.saveGroup(animatedGroup, outStream);
     outStream.close();
}
catch (FileNotFoundException e) {System.err.println("File Not Found Problem: "+e.getMessage());}
catch (IOException e) {System.err.println("IO Problem: "+e.getMessage());}
     }


createAnimatedGroup() should look like:

protected AnimatedGroup createAnimatedGroup() throws Exception {
AnimatedGroup animatedGroup = BonesIO.loadGroup(getResources().openRawResource(R.raw.andersonbones));

Texture texture = new Texture(getResources().openRawResource(R.raw.andersondiffuse));
TextureManager.getInstance().addTexture("texture", texture);

for (Animated3D o : animatedGroup) {
o.setTexture("texture");
o.build();
o.discardMeshData();
}
return animatedGroup;
}


Right? But this isn't working on my phone. I also tried

AnimatedGroup animatedGroup = BonesIO.loadGroup(new FileInputStream(objectFileName));

on the desktop, but it crashes. I should point out that the .bones file looks about right at 2241 KB. I appreciate any insights.

raft

post logs and stack trace please

AGP

#2
Actually, I got it to a point in which it no longer crashes. But try as I might I can't get the camera to see it.

I've tried NOT calling discardMeshData() and specifically setting each Animated3D instance to setVisibility(true). Nothing works, but it looks a lot like it should. I even called calcNormals() just to be sure and that didn't make it visible either.

But, by the way,    

AnimatedGroup animatedGroup = BonesIO.loadGroup(new FileInputStream(objectFileName));

is now working. But the same file still doesn't load on my phone. And the same camera is on both versions (camera should see the same thing but it shows nothing on phone version).

AGP

Now, I've also played with the near and far plane. To sum up:
-I'm seeing the "world" (the FrameBuffer's background color is being drawn) but not the model
-It's not crashing
-The file works and is visible on the PC version
-The camera is in the exact same position as the one on the PC version
-Config.maxPolysVisible > number of polys on the model
-near and far planes are very small and very large respectively
I have nothing left to try as far as I can tell (even the normals don't seem to be the problem). Help?

EgonOlsen

Quote from: AGP on August 29, 2011, 08:59:11 PM
-Config.maxPolysVisible > number of polys on the model
This isn't related to your problem, but i though i should mention it: This is wasteful. For the Android version, you don't have to reserve that much space, because it doesn't really stand for polygons anymore (but the naming stayed the same for compatibility reasons) but for compiled object parts. An object with 32,000 polygons can very well get away with 4 entries in that structure instead of 32,000.

I'll adjust the docs for this setting.

AGP

#5
Cool, thanks. But I suggest renaming maxPolysVisible. Since I already knew it, I didn't look it up on the AE-specific docs. If it's going to do something potentially counter-productive you should totally just rename it. jpct-AE is too young for you to have grave concerns about backward-compatibility anyway.

Do you have any clue as to what might be causing my problem? I assume if it were memory-related it would be crashing, so it really makes no sense to me.

EgonOlsen

Have you tried to replace your model with some placeholder (for example from Primitives) to see if that actually appears?

AGP

Yes, even an OBJ version of the same model works.

AGP

#8
Hey, now I'm getting (for the first time!) a "version mismatch" message: "Current version: 3, stream version: 2". That's a jpct message, what does it mean?

No, that was just when I tried replacing my model with Raft's ninja (I guess it was saved with an older version of the exporter).

AGP

OK, I narrowed it down to the fact that it crashes just before the following loop ("all's well" is printed before any problem occurs). But again, the file is working (the desktop version of the program loads it nicely). "o is null!" never gets printed.

Logger.log("\n\n************************************************************************All's well.\n\n\n");
for (Animated3D o : animatedGroup) {
if (o == null)
Logger.log("****************************************o is null!!!!");
o.setTexture("texture");
o.build();
o.discardMeshData();
}


Someone help me, please.

AGP

I solved it. I'm not remotely sure as to what changed between yesterday it not crashing to it crashing today. But crashing is far more useful becuase it lets you debug it!

raft

you use a Bones file which was serialized by version 2 but you try to open it with version 3.

btw, this is not a log message. this is an exception and you possibly catch print and ignore it.

Quote from: AGP on August 30, 2011, 06:11:04 PM
Hey, now I'm getting (for the first time!) a "version mismatch" message: "Current version: 3, stream version: 2". That's a jpct message, what does it mean?

No, that was just when I tried replacing my model with Raft's ninja (I guess it was saved with an older version of the exporter).

AGP

#12
On one of my posts I replaced my model with yours. I noticed it was your model that caused that message and edited that post. At one point an exception was being thrown, and then I changed a few things (not very scientific, I know, but I was trying this for the first time and kind of in a hurry to see it working), one of which the model. I had fixed some things but, in replacing my model with yours, had introduced that message. But anyway, I got it working. But my 9300-poly model (+-4500 vertices) is only rendering at a measly 11 fps on a Galaxy S 2, so the test isn't very good.

raft

i'm afraid 9300 polys is a bit high for such devices

AGP

On Egon's request, I just did a very valid test: didn't call animateSkin or animatePose. Otherwise, it's the same program and the same model. It shot up to 60 frames/second. The same model in Unity runs perfectly, so there is, no doubt (now that we know that it's not the graphics pipeline) a lot of room for optimization for Bones.