Hi :)
I would like to see skeleton of my human models, for do that in onDrawFrame I have only used "drawWireframe"
@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 :
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
Skeleton isn't something that you're supposed to see. One way or another, you need frameBuffer.display(). Here's what you could do:
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.
i cant see in your code anything related to SkeletonDebugger.
and it works for single object groups as can be seen in AnimationBlendSample.
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 .
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
as the javadoc says SkeletonDebugger is a "Helper class to visually represent a SkeletonPose."
Quote from: aeroxr1 on September 10, 2014, 10:05:33 AM
And another doubt why on android the models is visible also if i'm not used display() ? O.o
I dont understand your question?
I try to say that I don't use frameBuffer.display();
in my code, but when I run my application the model is visible O.o Why does it works without display() ?
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 :
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 :
public SimpleVector getJointPosition(Joint joint) {
SimpleVector location = skeletonPose.getGlobal(joint.getIndex()).getTranslation();
location.matMul(model.get(0).getWorldTransformation());
return location;
}
Quote from: aeroxr1 on September 10, 2014, 10:33:52 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
Thanks :)
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);
is this a question?
ahahah no, I only posted the works code :P
:)