Author Topic: skeletonDebugger doesn't work  (Read 1737 times)

Offline aeroxr1

  • int
  • **
  • Posts: 82
    • View Profile
skeletonDebugger doesn't work
« on: September 10, 2014, 12:05:40 am »
Hi :)
I would like to see skeleton of my human models, for do that in onDrawFrame I have only used "drawWireframe"

Code: [Select]
@Override
public void onDrawFrame(GL10 gl)
{
if (frameBuffer == null)
return;

frameBuffer.clear(back); //ripulisco il frameBuffer e lo setto con il colore di sfondo voluto
world.renderScene(frameBuffer);
world.drawWireframe(frameBuffer, wireFrameColor, 1, true);
//world.draw(frameBuffer);
//frameBuffer.display();

}

And in onSurfaceChanged I have did this  :

Code: [Select]

private AnimatedGroup modello;

@Override
public void onSurfaceChanged(GL10 gl, int width, int height) {
// TODO Auto-generated method stub
Logger.log("onSurfaceChanged");
if (frameBuffer != null) {
frameBuffer.dispose();
}
frameBuffer = new FrameBuffer(gl, width, height);

if (master == null) { 


world = new World(); 


Resources res = getResources();
try {

modello = BonesIO.loadGroup(res.openRawResource(R.raw.vincent));
modello.addToWorld(world);
}
catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}

world.setAmbientLight(127, 127, 127);
world.buildAllObjects();

TextureManager.getInstance().flush();
Texture texture = new Texture(res.openRawResource(R.raw.vincent_texture));
texture.keepPixelData(true);
TextureManager.getInstance().addTexture("vincent", texture);

for (Animated3D a : modello)
{
a.setTexture("vincent");
a.discardMeshData();
}



float[] bb = renderer.calcBoundingBox();
float box_h = (bb[3] - bb[2]);

Camera cam = world.getCamera();
cam.setPosition(0,-box_h/2,0);
cam.moveCamera(Camera.CAMERA_MOVEOUT, 70); 
cam.lookAt(new SimpleVector(0, -box_h/2, 0));

new Light(world).setPosition(new SimpleVector(0, -box_h/2, box_h));

currentPose = modello.get(0).getSkeletonPose();
skeletonDebugger = new SkeletonDebugger(currentPose);
skeletonDebugger.setVisibility(true);
skeletonDebugger.addToWorld(world);


MemoryHelper.compact();


if (master == null) {
Logger.log("Saving master Activity!");
master = MainActivity.this;
}

}


int num=modello.get(0).getSkeleton().getNumberOfJoints();
int dim=modello.getSize();
Logger.log("numbers of joints ="+num+",size="+dim);

}

But the skeleton doesn't appear. 
The log the result is
"numbers of joints=67,size=1"

To this message I have attached the skeleton xml
« Last Edit: September 10, 2014, 12:22:28 am by aeroxr1 »

Offline AGP

  • quad
  • ******
  • Posts: 1518
    • View Profile
Re: skeletonDebugger doesn't work
« Reply #1 on: September 10, 2014, 07:20:03 am »
Skeleton isn't something that you're supposed to see. One way or another, you need frameBuffer.display(). Here's what you could do:

Code: [Select]
     public SimpleVector getJointPosition(Joint joint) {
SimpleVector location = skeletonPose.getGlobal(joint.getIndex()).getTranslation();
location.matMul(model.get(0).getWorldTransformation());
return location;
     }

Call that for each joint, then use Polyline to draw the skeleton.

Offline raft

  • Moderator
  • quad
  • *****
  • Posts: 1966
    • View Profile
    • http://www.aptalkarga.com
Re: skeletonDebugger doesn't work
« Reply #2 on: September 10, 2014, 08:50:46 am »
i cant see in your code anything related to SkeletonDebugger.

and it works for single object groups as can be seen in AnimationBlendSample.

Offline aeroxr1

  • int
  • **
  • Posts: 82
    • View Profile
Re: skeletonDebugger doesn't work
« Reply #3 on: September 10, 2014, 10:05:33 am »
I thought that skeletondebugger was used to keep the skeleton visible , but now I think that I am not really understanding what skeletondebugger is used for .

Code: [Select]
currentPose = modello.get(0).getSkeletonPose();
skeletonDebugger = new SkeletonDebugger(currentPose);
skeletonDebugger.setVisibility(true);
skeletonDebugger.addToWorld(world);

what do it does ?


And another doubt why on android the models is visible also if i'm not used display() ? O.o
« Last Edit: September 10, 2014, 10:08:57 am by aeroxr1 »

Offline raft

  • Moderator
  • quad
  • *****
  • Posts: 1966
    • View Profile
    • http://www.aptalkarga.com
Re: skeletonDebugger doesn't work
« Reply #4 on: September 10, 2014, 10:14:31 am »
as the javadoc says SkeletonDebugger is a "Helper class to visually represent a SkeletonPose."

And another doubt why on android the models is visible also if i'm not used display() ? O.o
I dont understand your question?

Offline aeroxr1

  • int
  • **
  • Posts: 82
    • View Profile
Re: skeletonDebugger doesn't work
« Reply #5 on: September 10, 2014, 10:33:52 am »
I try to say that I don't use
Code: [Select]
frameBuffer.display(); in my code, but when I run my application the model is visible O.o Why does it works without display() ?

Code: [Select]
Skeleton isn't something that you're supposed to see. One way or another, you need frameBuffer.display(). Here's what you could do:
Ok, SkeletonDebugger help me to visually represent a SkeletonPose, but i thought If I did this :

Code: [Select]
currentPose = modello.get(0).getSkeletonPose();
skeletonDebugger = new SkeletonDebugger(currentPose);
skeletonDebugger.setVisibility(true);
skeletonDebugger.addToWorld(world);

the skeleton would be visible .

But AGP told me that I have to use something like this code :

Code: [Select]
     public SimpleVector getJointPosition(Joint joint) {
SimpleVector location = skeletonPose.getGlobal(joint.getIndex()).getTranslation();
location.matMul(model.get(0).getWorldTransformation());
return location;
     }

Offline raft

  • Moderator
  • quad
  • *****
  • Posts: 1966
    • View Profile
    • http://www.aptalkarga.com
Re: skeletonDebugger doesn't work
« Reply #6 on: September 10, 2014, 10:40:40 am »
Why does it works without display() ?
I dont know, it shouldn't. Egon may clarify it

for the SkeletonDebugger, either:

* it's hidden inside the model and cant be seen
* you move/rotate your model to somewhere else. SkeletonDebugger does not move/rotate with the model

Offline aeroxr1

  • int
  • **
  • Posts: 82
    • View Profile
Re: skeletonDebugger doesn't work
« Reply #7 on: September 10, 2014, 10:47:53 am »
Thanks :)

Code: [Select]
for (Animated3D a : modello)
{
a.setTexture("vincent");
a.discardMeshData();
a.setVisibility(false);
}



//calcoliamo le grandezze del boundingbox del nostro modello

float[] bb = renderer.calcBoundingBox();
float box_h = (bb[3] - bb[2]); // ninja height
// ora si crea una telecamera e devo capire come posizionarlo
Camera cam = world.getCamera();
cam.setPosition(0,-box_h/2,0);
cam.moveCamera(Camera.CAMERA_MOVEOUT, 70);  //la sposto indietro
cam.lookAt(new SimpleVector(0, -box_h/2, 0));
//rivedere la direzione giusta della camera

//ora si crea un vettore per indirizzare il sole
new Light(world).setPosition(new SimpleVector(0, -box_h/2, box_h));

currentPose = modello.get(0).getSkeletonPose();

skeletonDebugger = new SkeletonDebugger(currentPose,10f, (short)0);
skeletonDebugger.addToWorld(world);
skeletonDebugger.setVisibility(true);
« Last Edit: September 10, 2014, 11:05:51 am by aeroxr1 »

Offline raft

  • Moderator
  • quad
  • *****
  • Posts: 1966
    • View Profile
    • http://www.aptalkarga.com
Re: skeletonDebugger doesn't work
« Reply #8 on: September 10, 2014, 12:24:42 pm »
is this a question?

Offline aeroxr1

  • int
  • **
  • Posts: 82
    • View Profile
Re: skeletonDebugger doesn't work
« Reply #9 on: September 10, 2014, 12:40:56 pm »
ahahah no, I only posted the works code  :P

Offline raft

  • Moderator
  • quad
  • *****
  • Posts: 1966
    • View Profile
    • http://www.aptalkarga.com
Re: skeletonDebugger doesn't work
« Reply #10 on: September 10, 2014, 12:41:33 pm »
:)