Animate rigged model according to given commands

Started by aeroxr1, June 05, 2014, 10:14:22 PM

Previous topic - Next topic

aeroxr1

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

:)

raft

Quote from: aeroxr1 on September 12, 2014, 11:05:45 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

aeroxr1

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


aeroxr1

Quote from: raft on September 06, 2014, 06:51:53 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 :/

raft

changing FOV for zoom is like looking through a telescope. you see a narrow region zoomed.

for landscape, you can try different FOV values

aeroxr1

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 :

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 :/

raft

i havent done it myself. did you have a look at AbstractSkinSample.autoAdjustCamera method?

aeroxr1

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 ? :)


raft

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.

aeroxr1

Is there a rapid way to add the same model but with a different physical appearance ? (without using 3d graphics programs)  ;D

raft

apply a fancy effect to texture in a simple image editor program ;)

aeroxr1

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   >:(

raft

loading them in surfaceCreated or surfaceChanged methods doesnt help?

aeroxr1

I have imported the model in onSurfaceChanged in this way :


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 ?

raft