[resolved] Bones position issue with jPCT-AE 1.29

Started by MLG, November 24, 2015, 10:18:11 AM

Previous topic - Next topic

MLG

Hello,

I develop an Android application with jPCT-AE and I have an issue with the version 1.29 and Bones.
On my application, I use the Seymour example character and I want to display its skeleton. So I use this code:

mCurrentPose = mMainActivity.avatar.get(0).getSkeletonPose();
SkeletonDebugger skeletonDebugger = new SkeletonDebugger(mCurrentPose, 5f, 0.02f);
skeletonDebugger.setVisibility(true);
skeletonDebugger.addToWorld(mWorld);


With the library 1.23 beta it works well like the picture below:


But with the newest version 1.29, bones are displayed with a shift like the picture below:


Do you remark this issue ?

raft

interesting. the bones and joints in skeleton debugger are just primitive jPCT objects. they are simply placed in the world with corresponding translations and rotations.

unless sth changed in jPCT's primitives I have no idea what can cause this.

did you try it with desktop jPCT? for example by using Collada sample?

EgonOlsen

Older versions are still available for download, if you know where to look. For example: http://jpct.de/download/net/jpct-ae_122.zip

The files are named

jpct-ae_1xx.zip

where xx ranges from 22 to 29. It would help, if you could tell me the version that breaks it.

BTW: Have you tried the latest one (1.30)? I doubt that it will fix anything, but you never know...

raft

in desktop jPCT with Software renderer, all looks good with both jPCT-1.26 and 1.30. (I couldnt find 1.29 to download)

but please notice the size difference of joint objects. SkeletonDebugger allows to change size of joint and bone objects. @MLG can you please confirm that you adjusted size of joint objects in SkeletonDebugger?


MLG

My Seymour model has a different orientation and scale that's why I choose a bone scale of 5 and a joint scale of 0.02. It is generated with this command line:
ardorCollada2Bones.bat -out seymour.bones -scale 0.2 -rotation x180 -in Seymour.dae

I just tried with jPCT 1.26 and it works well.
With jPCT-AE version it works with the 1.24 but not with 1.25 or newer so it seems to be just an Android version problem.

EgonOlsen

#5
I tried to create myself a test case that creates an pyramid from Primitives and does the exact some operations on it that the SkeletonDebugger does and I tested it with 1.23, 1.24 and 1.30 and I couldn't find any difference in behaviour between them. Position in object space, center, pivot, transformed center and rotation matrix were all exactly the same. I've no idea what goes wrong here (or maybe even right...). I not aware of any problem of that kind and I'm using jPCT and jPCT-AE with the same code base all day long...if there would be a difference between them, I think that I should have noticed it... ???

Can you provide me with a test case for Android that shows this problem (Eclipse if possible, but Android Studio would be fine as well...)?

MLG

#6
Yes, you can easily reproduce the issue like that:
- Download Bones and Bones-Android-Ninja projects -> http://www.aptalkarga.com/bones/
- Import them into your Eclipse workspace
- Copy "Bones\samples\data\seymour\seymour.group.bones" into "Bones-Android-Ninja\res\raw" folder
- Copy "Bones\samples\data\seymour\seymour.png" into "Bones-Android-Ninja\res\raw" folder (rename it to "seymour_texture.png" to avoid name error in resource matrix  ;))
- Replace the "NinjaDemoActivity.java" file by my attached file.
   I just replaced these lines:
   masterNinja = BonesIO.loadGroup(res.openRawResource(R.raw.ninja));
Texture texture = new Texture(res.openRawResource(R.raw.ninja_texture));


   by these ones:
   masterNinja = BonesIO.loadGroup(res.openRawResource(R.raw.seymour));
Texture texture = new Texture(res.openRawResource(R.raw.seymour_texture));


   and I added these lines in "addNinja" function:
   SkeletonDebugger skeletonDebugger = new SkeletonDebugger(masterNinja.get(0).getSkeletonPose(), 5f, 0.05f);
skeletonDebugger.setVisibility(true);
skeletonDebugger.addToWorld(world);


It's weird because it doesn't seem to have the issue for the ninja.

EgonOlsen

Quote from: MLG on December 01, 2015, 05:10:15 AM
It's weird because it doesn't seem to have the issue for the ninja.
...which leads me to think that it's actually something completely different than we think that it is...I'll have a look this evening and report back...

raft

Quote from: EgonOlsen on December 01, 2015, 07:50:32 AM
Quote from: MLG on December 01, 2015, 05:10:15 AM
It's weird because it doesn't seem to have the issue for the ninja.
...which leads me to think that it's actually something completely different than we think that it is...I'll have a look this evening and report back...
likewise. but I have no clue how this is related with jPCT version.

EgonOlsen

Quote from: raft on December 01, 2015, 08:40:40 AM
likewise. but I have no clue how this is related with jPCT version.
Neither do I. I'll try to create that test case and see what happens...

EgonOlsen

#10
Found it! It's caused by the additional call to

world.buildAllObjects();

in the demo Activity. This call resets the rotation pivots to the calculated values where they should actually be (0,0,0). The solution is to simply comment out that line and all is well. This should happen in desktop jPCT as well. I haven't checked, but I assume that the desktop example simply doesn't call this method!?

Why is this different in 1.24 and prior? Because of this change in 1.25:

QuoteFixed behaviour of build() when used on models on which calcNormals() has been called before.

Before this fix, build() does actually nothing when calcNormals() has been called before. After the fix, it does it's usual calculations except for the normals and that resets the rotation pivot as well.

Just remove that line mentioned above and you should be good to go.

Edit: I should mention that calcNormals() is part of build() for a better understanding.


raft

Quote
Found it!
cool :)

QuoteI haven't checked, but I assume that the desktop example simply doesn't call this method!?
correct, primitives in SkeletonDebugger are build() when they are created and then added to world and world.buildAllObjects() is never called

MLG

Ah yes I've forgotten calling build() function modify the rotation pivot.

Thank you for your quick answer.  ;)