Author Topic: Animate rigged model according to given commands  (Read 67314 times)

Offline aeroxr1

  • int
  • **
  • Posts: 82
    • View Profile
Re: Animate rigged model according to given commands
« Reply #75 on: September 12, 2014, 11:05:45 pm »
ooooh :D
I have two last aspect to improve :
- camera : to handle smartphone rotate, zoom and pan
- undestand if we can to edit bone's weight

:)

Offline raft

  • Moderator
  • quad
  • *****
  • Posts: 1993
    • View Profile
    • http://www.aptalkarga.com
Re: Animate rigged model according to given commands
« Reply #76 on: September 13, 2014, 01:37:21 pm »
- undestand if we can to edit bone's weight
i guess you cannot do that at the moment without changing Bones's source code

Offline aeroxr1

  • int
  • **
  • Posts: 82
    • View Profile
Re: Animate rigged model according to given commands
« Reply #77 on: September 13, 2014, 01:45:50 pm »
ah ok :)

@AGP :

do you know why we do this ?   
                mulMatrixByInverse(getJoint(joint.getParentIndex()), bind);
      pose.getLocal(getJointIndex(joint)).setTo(bind);
Author of skeletonhelper doesn't remember why he use this function XD


Offline aeroxr1

  • int
  • **
  • Posts: 82
    • View Profile
Re: Animate rigged model according to given commands
« Reply #78 on: September 22, 2014, 08:25:54 pm »
you can move camera closer to make the model look bigger. or you can scale the model.

Is the Fov angle the setting we have to change to obtain a correctly zoom ?

I would want a camera that rotate around my model then I have used this camera :
http://www.jpct.net/wiki/index.php/MultiTouch_camera_controls

In vertical it correctly works, but when I rotate to landscape it's too zoomed. I have to set the fov depending of resolution but I don't know how :/

Offline raft

  • Moderator
  • quad
  • *****
  • Posts: 1993
    • View Profile
    • http://www.aptalkarga.com
Re: Animate rigged model according to given commands
« Reply #79 on: September 23, 2014, 09:07:35 am »
changing FOV for zoom is like looking through a telescope. you see a narrow region zoomed.

for landscape, you can try different FOV values

Offline aeroxr1

  • int
  • **
  • Posts: 82
    • View Profile
Re: Animate rigged model according to given commands
« Reply #80 on: September 23, 2014, 11:34:59 am »
I'm trying but the results is wrong :(

I have searched in the web and the result is that I have to do in this way :

Code: [Select]
cameraDistance = ( modelHeight / 2 ) / tan( fovy / 2 )
Then place your camera:
cameraPos.z = modelPos.z - cameraDistance


I try to merge this math function in http://www.jpct.net/wiki/index.php/MultiTouch_camera_controls but it isn't simple because the camera's code isn't mine :/

Offline raft

  • Moderator
  • quad
  • *****
  • Posts: 1993
    • View Profile
    • http://www.aptalkarga.com
Re: Animate rigged model according to given commands
« Reply #81 on: September 23, 2014, 12:33:38 pm »
i havent done it myself. did you have a look at AbstractSkinSample.autoAdjustCamera method?

Offline aeroxr1

  • int
  • **
  • Posts: 82
    • View Profile
Re: Animate rigged model according to given commands
« Reply #82 on: September 24, 2014, 01:03:09 am »
raft another question :
I would implement a ghost of my first model, I want it in the same position of first model but it have to move in different way.  Then I want they will be in different color, for example draw the ghost with drawWireframe .

Is it possible ? Any suggestion ? :)


Offline raft

  • Moderator
  • quad
  • *****
  • Posts: 1993
    • View Profile
    • http://www.aptalkarga.com
Re: Animate rigged model according to given commands
« Reply #83 on: September 24, 2014, 12:38:58 pm »
i guess not. jPCT does not draw wireframe per object, it draws the whole scene or none.

buy you can try a hybrid solution, render two worlds on top of each other, one wireframe and contains only the ghost, over the other original world. or you can try giving similar effect with a special texture.

Offline aeroxr1

  • int
  • **
  • Posts: 82
    • View Profile
Re: Animate rigged model according to given commands
« Reply #84 on: September 25, 2014, 07:38:59 pm »
Is there a rapid way to add the same model but with a different physical appearance ? (without using 3d graphics programs)  ;D

Offline raft

  • Moderator
  • quad
  • *****
  • Posts: 1993
    • View Profile
    • http://www.aptalkarga.com
Re: Animate rigged model according to given commands
« Reply #85 on: September 26, 2014, 09:18:24 am »
apply a fancy effect to texture in a simple image editor program ;)

Offline aeroxr1

  • int
  • **
  • Posts: 82
    • View Profile
Re: Animate rigged model according to given commands
« Reply #86 on: September 27, 2014, 10:28:39 pm »
thanks :D

A last question :

is there some kind of tricks to pre-load  3d models and the relative textures? because in the ninja-bones-demo the model is loaded immediatelly, instead in mine app it's load after 5-8 seconds   >:(

Offline raft

  • Moderator
  • quad
  • *****
  • Posts: 1993
    • View Profile
    • http://www.aptalkarga.com
Re: Animate rigged model according to given commands
« Reply #87 on: September 28, 2014, 11:44:47 am »
loading them in surfaceCreated or surfaceChanged methods doesnt help?

Offline aeroxr1

  • int
  • **
  • Posts: 82
    • View Profile
Re: Animate rigged model according to given commands
« Reply #88 on: September 28, 2014, 12:53:40 pm »
I have imported the model in onSurfaceChanged in this way :

Code: [Select]
public MyGLRenderer(Context context,MovementHandler gestore) {
//impostiamo i settaggi del render
Config.maxPolysVisible = 500;
Config.farPlane = 1000;
ActivityContext=context;
this.gestore=gestore;
}


@Override
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
// TODO Auto-generated method stub
Logger.log("onSurfaceCreated");
}

@Override
public void onDrawFrame(GL10 gl)
{

if (frameBuffer == null)
return;

........

}


@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(width, height);

this.width=width;
this.height=height;

//in teoria .. potrebbe funzionare ..
if (world != null)
return;

world = new World();  //creiamo il mondo

//inseriamo il nostro modello nel mondo

Resources res = ActivityContext.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();
helper=new JointRotation(modello);

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();
}

//calcoliamo le grandezze del boundingbox del nostro modello

float[] bb = calcBoundingBox();
box_h = (bb[3] - bb[2]); // model height



Camera camera = world.getCamera();
if(width < height)
{
camera.setPosition(0,-box_h/2,0);
camera.moveCamera(Camera.CAMERA_MOVEOUT, 70);  //la sposto indietro
camera.lookAt(new SimpleVector(0, -box_h/2, 0));
}
else
{
float fovy=camera.getYFOV();

double cameraDistance = ( box_h / 2 ) / Math.tan( fovy / 2 );

camera.setPosition(0,-box_h/2,(float)cameraDistance-100);

camera.lookAt(new SimpleVector(0, -box_h/2, 0));

}

//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();

MemoryHelper.compact();  // dovrebbe liberare un pò di memoria
}

In on SurfaceCreated I have done nothing :)

Did I do something wrong ?

Offline raft

  • Moderator
  • quad
  • *****
  • Posts: 1993
    • View Profile
    • http://www.aptalkarga.com
Re: Animate rigged model according to given commands
« Reply #89 on: September 28, 2014, 06:06:30 pm »
not sure, it seems ok