Author Topic: Pick part of bones to rotate  (Read 2382 times)

Offline faridrakh

  • byte
  • *
  • Posts: 11
    • View Profile
Pick part of bones to rotate
« on: February 27, 2015, 12:26:02 pm »
i have bones file. i want to select 1 part of my file to rotate.
how i can get access to my bones joint?
how can  i cast animated group to animated 3d?

Offline raft

  • Moderator
  • quad
  • *****
  • Posts: 1966
    • View Profile
    • http://www.aptalkarga.com
Re: Pick part of bones to rotate
« Reply #1 on: February 27, 2015, 12:40:20 pm »
have a look at ProceduralAnimationSample sample.

you cant cast AnimatedGroup to Animated3D but can access Animated3D's in the group by get(index/name) methods.

Offline faridrakh

  • byte
  • *
  • Posts: 11
    • View Profile
Re: Pick part of bones to rotate
« Reply #2 on: February 28, 2015, 02:43:24 am »
thank you. i followed ProseduralAnimationSample.java.
but my skeleton  and my mesh model not in same position.
my skeleton a bit lower form my mesh model.
in blender my model and my armature is okay.


Offline raft

  • Moderator
  • quad
  • *****
  • Posts: 1966
    • View Profile
    • http://www.aptalkarga.com
Re: Pick part of bones to rotate
« Reply #3 on: February 28, 2015, 05:09:27 am »
i dont know why. i remember sometimes in 3d max when you move model during rigging, such strange things was happening. it has a reset xform modifier or something like, which mostly solves the situation. no idea what to do in blender.

Offline faridrakh

  • byte
  • *
  • Posts: 11
    • View Profile
Re: Pick part of bones to rotate
« Reply #4 on: February 28, 2015, 02:38:27 pm »
i already solved the model . And now i can tranlate and rotate the skeleton with this code.

Code: [Select]
Joint pointing  = currentPose.getSkeleton().getJoint(15);
final Joint parentJoint = currentPose.getSkeleton().getJoint(pointing.getParentIndex());
final Matrix global= new Matrix(pointing.getBindPose());
global.translate(10,10,10)
global.matMul(parentJoint.getInverseBindPose());
currentPose.getLocal(pointing.getIndex()).setTo(global);
currentPose.updateTransforms();
skeletonDebugger.update(currentPose);

the joint at index 15 stretch. but my mesh not. i want the parent joint following, like seymour neck in ProceduralAnimationSample.
how i can do like that? i don't know where the mistake, in the program or my model.
« Last Edit: February 28, 2015, 02:42:04 pm by faridrakh »

Offline raft

  • Moderator
  • quad
  • *****
  • Posts: 1966
    • View Profile
    • http://www.aptalkarga.com
Re: Pick part of bones to rotate
« Reply #5 on: February 28, 2015, 03:11:19 pm »
well to tell the truth, i'm not proficient at those calculations too :/

did you see this post, it may help:
http://www.jpct.net/forum2/index.php/topic,3300.0.html

Offline faridrakh

  • byte
  • *
  • Posts: 11
    • View Profile
Re: Pick part of bones to rotate
« Reply #6 on: March 01, 2015, 11:58:56 am »
is matrix translate different form object 3d translate?
when i used matrix translate and object3d translate with same value, giving different output.
can i cast matrix to object 3d? because i want to make augmented reality, that my object translate where my marker position.

in the picture my marker is the white circle. if i use matrix translate, i cant move to the white circle.
but if i use .obj file with object3d translate , i can move to white circle.

any idea?
« Last Edit: March 01, 2015, 02:11:10 pm by faridrakh »

Offline raft

  • Moderator
  • quad
  • *****
  • Posts: 1966
    • View Profile
    • http://www.aptalkarga.com
Re: Pick part of bones to rotate
« Reply #7 on: March 01, 2015, 03:12:45 pm »
which matrix are you talking about? Object3D.getTranslationMatrix().translate(..) and Object3D.translate(..) should give the same result.

no, you cant cast Matrix to Object3D. you can find many posts about AR in the forums.

Offline faridrakh

  • byte
  • *
  • Posts: 11
    • View Profile
Re: Pick part of bones to rotate
« Reply #8 on: March 01, 2015, 03:19:53 pm »
Code: [Select]
   Joint pointing  = currentPose.getSkeleton().getJoint(15);
final Joint parentJoint = currentPose.getSkeleton().getJoint(pointing.getParentIndex());
final Matrix global= new Matrix(pointing.getBindPose());
global.translate(x,y,z);
global.matMul(parentJoint.getInverseBindPose());
currentPose.getLocal(pointing.getIndex()).setTo(global);
currentPose.updateTransforms();
skeletonDebugger.update(currentPose);

global.translate giving different position from object3d.translate()

Offline raft

  • Moderator
  • quad
  • *****
  • Posts: 1966
    • View Profile
    • http://www.aptalkarga.com
Re: Pick part of bones to rotate
« Reply #9 on: March 01, 2015, 03:25:11 pm »
you are modifying a joint's translation. that has nothing to do with the Object3d's (Animatd3D indeed) translation.

Offline faridrakh

  • byte
  • *
  • Posts: 11
    • View Profile
Re: Pick part of bones to rotate
« Reply #10 on: March 01, 2015, 03:29:33 pm »
So how i can move the joint? Ex: i want to move my joint to (240,200,10) this is my marker position.

Offline raft

  • Moderator
  • quad
  • *****
  • Posts: 1966
    • View Profile
    • http://www.aptalkarga.com
Re: Pick part of bones to rotate
« Reply #11 on: March 01, 2015, 03:34:56 pm »
what do you mean by moving the joint? if you mean you want your model's finger (or whatever) point to that direction, you should first calculate the direction and apply to joint.

again ProseduralAnimationSample may help. Chase's helper class may also help:

Offline faridrakh

  • byte
  • *
  • Posts: 11
    • View Profile
Re: Pick part of bones to rotate
« Reply #12 on: March 12, 2015, 12:39:21 pm »
thank you. i already can move my finger to my desire location. Can but parent mesh not follow the object rotation. how can i calculate the rotation to make the parent mesh like follow the child? and is the skeleton helper can move the joint and follow by the parent joint?

Offline raft

  • Moderator
  • quad
  • *****
  • Posts: 1966
    • View Profile
    • http://www.aptalkarga.com
Re: Pick part of bones to rotate
« Reply #13 on: March 12, 2015, 02:00:36 pm »
and is the skeleton helper can move the joint and follow by the parent joint?
i guess so. Chase may give more detail about that

Can but parent mesh not follow the object rotation. how can i calculate the rotation to make the parent mesh like follow the child?
in jPCT you can add an object as child of another. so when parent is moved/rotated child follow same move/rotation.

Offline faridrakh

  • byte
  • *
  • Posts: 11
    • View Profile
Re: Pick part of bones to rotate
« Reply #14 on: March 12, 2015, 02:12:07 pm »
what mat to fill in transformJointOnPivot(Joint joint, Matrix mat)? i only know simplevector to translate