Author Topic: [resolved] Bones position issue with jPCT-AE 1.29  (Read 14656 times)

Offline MLG

  • byte
  • *
  • Posts: 4
    • View Profile
[resolved] Bones position issue with jPCT-AE 1.29
« on: November 24, 2015, 10:18:11 am »
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:

Code: [Select]
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 ?
« Last Edit: December 02, 2015, 10:14:11 am by MLG »

Offline raft

  • Moderator
  • quad
  • *****
  • Posts: 1993
    • View Profile
    • http://www.aptalkarga.com
Re: Bones position issue with jPCT-AE 1.29
« Reply #1 on: November 27, 2015, 08:34:37 pm »
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?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Bones position issue with jPCT-AE 1.29
« Reply #2 on: November 27, 2015, 09:13:03 pm »
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...

Offline raft

  • Moderator
  • quad
  • *****
  • Posts: 1993
    • View Profile
    • http://www.aptalkarga.com
Re: Bones position issue with jPCT-AE 1.29
« Reply #3 on: November 28, 2015, 10:09:20 am »
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?


Offline MLG

  • byte
  • *
  • Posts: 4
    • View Profile
Re: Bones position issue with jPCT-AE 1.29
« Reply #4 on: November 30, 2015, 11:48:45 am »
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:
Code: [Select]
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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Bones position issue with jPCT-AE 1.29
« Reply #5 on: November 30, 2015, 09:38:35 pm »
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...)?
« Last Edit: November 30, 2015, 09:47:28 pm by EgonOlsen »

Offline MLG

  • byte
  • *
  • Posts: 4
    • View Profile
Re: Bones position issue with jPCT-AE 1.29
« Reply #6 on: December 01, 2015, 05:10:15 am »
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:
   
Code: [Select]
masterNinja = BonesIO.loadGroup(res.openRawResource(R.raw.ninja));
Texture texture = new Texture(res.openRawResource(R.raw.ninja_texture));

   by these ones:
   
Code: [Select]
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:
   
Code: [Select]
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.
« Last Edit: December 01, 2015, 05:12:03 am by MLG »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Bones position issue with jPCT-AE 1.29
« Reply #7 on: December 01, 2015, 07:50:32 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...

Offline raft

  • Moderator
  • quad
  • *****
  • Posts: 1993
    • View Profile
    • http://www.aptalkarga.com
Re: Bones position issue with jPCT-AE 1.29
« Reply #8 on: December 01, 2015, 08:40:40 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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Bones position issue with jPCT-AE 1.29
« Reply #9 on: December 01, 2015, 04:59:53 pm »
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...

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Bones position issue with jPCT-AE 1.29
« Reply #10 on: December 01, 2015, 06:02:05 pm »
Found it! It's caused by the additional call to

Code: [Select]
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:

Quote
Fixed 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.

« Last Edit: December 01, 2015, 07:01:25 pm by EgonOlsen »

Offline raft

  • Moderator
  • quad
  • *****
  • Posts: 1993
    • View Profile
    • http://www.aptalkarga.com
Re: Bones position issue with jPCT-AE 1.29
« Reply #11 on: December 01, 2015, 06:28:04 pm »
Quote
Found it!
cool :)

Quote
I 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

Offline MLG

  • byte
  • *
  • Posts: 4
    • View Profile
Re: Bones position issue with jPCT-AE 1.29
« Reply #12 on: December 02, 2015, 10:13:47 am »
Ah yes I've forgotten calling build() function modify the rotation pivot.

Thank you for your quick answer.  ;)