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

Offline aeroxr1

  • int
  • **
  • Posts: 82
    • View Profile
Re: Animate rigged model according to given commands
« Reply #45 on: September 03, 2014, 05:51:40 pm »
Where do you suggest to create the model ?

in the onSurfaceCreated function ? Or is better if I create the model in an other function ? :)

Offline raft

  • Moderator
  • quad
  • *****
  • Posts: 1972
    • View Profile
    • http://www.aptalkarga.com
Re: Animate rigged model according to given commands
« Reply #46 on: September 03, 2014, 06:13:50 pm »
doesnt really matter at this stage of the project. you can load them in any thread and anytime

Offline aeroxr1

  • int
  • **
  • Posts: 82
    • View Profile
Re: Animate rigged model according to given commands
« Reply #47 on: September 03, 2014, 07:32:57 pm »
 8)

Offline aeroxr1

  • int
  • **
  • Posts: 82
    • View Profile
Re: Animate rigged model according to given commands
« Reply #48 on: September 04, 2014, 08:10:12 pm »
Hi :)
why I have to put the bones file in the animatedgroup and not in animate3d ?

(i watched ninja bones android demo)

Quote
masterNinja = BonesIO.loadGroup(res.openRawResource(R.raw.ninja));

And why the texture is applicate in this for function ?
Code: [Select]
for (Animated3D a : masterNinja)
a.setTexture("ninja");

If I have only one bones file with only one 3d model , do I have to do  same thing ?

Offline raft

  • Moderator
  • quad
  • *****
  • Posts: 1972
    • View Profile
    • http://www.aptalkarga.com
Re: Animate rigged model according to given commands
« Reply #49 on: September 05, 2014, 10:08:25 am »
yes, you should do the same thing.

if you will always have one object in your group, you can use BonesIO methods to save a single object. but personally I dont see any point in that

Offline aeroxr1

  • int
  • **
  • Posts: 82
    • View Profile
Re: Animate rigged model according to given commands
« Reply #50 on: September 05, 2014, 07:17:59 pm »
I set the camera in this way :

Code: [Select]
cam.moveCamera(Camera.CAMERA_MOVEOUT, 50);
cam.lookAt(new SimpleVector(0, -box_h/2, box_h));

protected float[] calcBoundingBox() {
float[] box = null;

for (Animated3D skin : modello) {
float[] skinBB = skin.getMesh().getBoundingBox();

if (box == null) {
box = skinBB;
} else {
// x
box[0] = Math.min(box[0], skinBB[0]);
box[1] = Math.max(box[1], skinBB[1]);
// y
box[2] = Math.min(box[2], skinBB[2]);
box[3] = Math.max(box[3], skinBB[3]);
// z
box[4] = Math.min(box[4], skinBB[4]);
box[5] = Math.max(box[5], skinBB[5]);
}
}
return box;
}

and the result is :


it isn't as I wanted  :(

I would set the camera in front of the model :( Where did I wrong ?

And I have seen helloworld and other jpct-ae's examples and in all of those the world is created in onSurfaceChange; it works but how ? Does Onsurfacechange runs only when the display is rotated ?

And another things, is there a function to scale the model in landscape mode ? I mean when I rotate the display from portrait to landscape mode the human model has to become little :D
« Last Edit: September 05, 2014, 08:05:37 pm by aeroxr1 »

Offline raft

  • Moderator
  • quad
  • *****
  • Posts: 1972
    • View Profile
    • http://www.aptalkarga.com
Re: Animate rigged model according to given commands
« Reply #51 on: September 06, 2014, 06:51:53 pm »
just move the camera to other part of model. or rotate the model.

you can move camera closer to make the model look bigger. or you can scale the model.

onSurfaceChanged is called every time the surface is created. just read the docs:)

Offline aeroxr1

  • int
  • **
  • Posts: 82
    • View Profile
Re: Animate rigged model according to given commands
« Reply #52 on: September 06, 2014, 08:38:59 pm »
just move the camera to other part of model. or rotate the model.

you can move camera closer to make the model look bigger. or you can scale the model.

onSurfaceChanged is called every time the surface is created. just read the docs:)


Quote
Called when the surface changed size.

Called after the surface is created and whenever the OpenGL ES surface size changes.

Typically you will set your viewport here. If your camera is fixed then you could also set your projection matrix here

I didn't see this line -.-"""" sorry  ::)

Another stupid question :
when I import a new model, in what position will be place ? 0,0,0 ? :D
I imagine is very stupid question, but I know little of 3d graphics -.-"



Offline raft

  • Moderator
  • quad
  • *****
  • Posts: 1972
    • View Profile
    • http://www.aptalkarga.com
Re: Animate rigged model according to given commands
« Reply #53 on: September 06, 2014, 08:43:10 pm »
yes, it will be in origin (0,0,0) in world space.

but that does not necessarily means you will see your model in origin. that depends on the model position when it's exported

Offline aeroxr1

  • int
  • **
  • Posts: 82
    • View Profile
Re: Animate rigged model according to given commands
« Reply #54 on: September 06, 2014, 09:45:21 pm »
All the object after the inserting is positionated in 0,0,0 ?

For example when I use getcamera() the camera initially is in 0,0,0 ?

I try to ask :D :
Is there an example where the model is scaled when the smartphone is rotated from portrait to landscape view ? :D

Now I'm trying to experiment with direction,simplevector and rotation matrix  ;D

Offline raft

  • Moderator
  • quad
  • *****
  • Posts: 1972
    • View Profile
    • http://www.aptalkarga.com
Re: Animate rigged model according to given commands
« Reply #55 on: September 06, 2014, 09:51:40 pm »
yes everything is initially at origin until you move them to somewhere

Is there an example where the model is scaled when the smartphone is rotated from portrait to landscape view ? :D

possibly there is somewhere in the forum. just try different scaling values.

it's also possible to make the model occupy same height of the screen by adjusting camera distance. have a look at AbstractSkinSample.autoAdjustCamera method

Offline aeroxr1

  • int
  • **
  • Posts: 82
    • View Profile
Re: Animate rigged model according to given commands
« Reply #56 on: September 07, 2014, 09:45:18 am »
off-topic : bones's website is down

Offline raft

  • Moderator
  • quad
  • *****
  • Posts: 1972
    • View Profile
    • http://www.aptalkarga.com
Re: Animate rigged model according to given commands
« Reply #57 on: September 07, 2014, 11:47:26 am »
yes, i know, thx. my hosting company says my server is DDOS attacked ???

Offline aeroxr1

  • int
  • **
  • Posts: 82
    • View Profile
Re: Animate rigged model according to given commands
« Reply #58 on: September 07, 2014, 01:12:46 pm »
Do Hacker wants to obtain your private images ? xD
Now I'm trying to understand the rotation matrix to applied it to the arms , I want they lies along the body :)
( I want to set the position of model's arms via programmatically )
« Last Edit: September 07, 2014, 01:14:54 pm by aeroxr1 »

Offline aeroxr1

  • int
  • **
  • Posts: 82
    • View Profile
Re: Animate rigged model according to given commands
« Reply #59 on: September 08, 2014, 08:08:42 pm »
I searched into the web, but I didn't found an explanation of the use of matrix bindpose , matrix inverse bind pose and the relation between them.

EDIT : I found this explanation http://www.gamedev.net/topic/571044-skeletal-animation-bonespace/ . It is wrong ?

But remain this doubts :

Code: [Select]
        final Matrix jointInverseBindPose = pose.getSkeleton().getJoint(jointIndex).getInverseBindPose();
        final Matrix jointBindPose = jointInverseBindPose.invert();

jointInverseBindPose ok, now , maybe I understand whats is it.
But why do we do this :
Code: [Select]
jointBindPose =  jointBindPose = jointInverseBindPose.invert(); ?
in the precedent link this thing there isn't .. :(


Other parts of code that I don't really understand are :
Code: [Select]
        // Get a vector representing forward direction in neck space, use inverse to take from world -> neck space.
        SimpleVector forwardDirection = new SimpleVector(bindPoseDirection);
        forwardDirection.rotate(jointInverseBindPose);

        // Get a vector representing a direction to target point in neck space.
        SimpleVector targetDirection = targetPos.calcSub(pose.getGlobal(jointIndex).getTranslation()).normalize();
        targetDirection.rotate(jointInverseBindPose);


in particular why do we use jointinversebindpose to rotate the forwarDirection and the targetdirection ? to take from world to neck space don't we need to multiply vector to jointinversebindpose ?

And I don't understand this :
Code: [Select]
pose.getGlobal(jointIndex).getTranslation()
Can you give me a hand ?
« Last Edit: September 09, 2014, 12:49:32 am by aeroxr1 »