Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - ani.tumanyan

Pages: [1]
1
Bones / Re: Bone length
« on: April 04, 2013, 09:35:12 pm »
Thanks raft so much! This is wonderful :).

Another question popped up. When I'm galling getTranslation() function, in which units are those numbers? Are they meters, centimeters or even worse pixels?

Thanks again for your help!

2
Bones / Bone length
« on: April 03, 2013, 11:30:16 pm »
Hi raft,

Is there a way to get the length of different bones in Bones API?


Ani

3
Thanks raft!!! It saved me lots of time and effort.

This is eventually what I ended up doing, in case someone else would be wondering:

Code: [Select]
private void rotateJoint(SkeletonPose pose, Matrix rotation, int jointIndex, SimpleVector bindPoseDirection, float angle, final float targetStrength) {
    final int parentIndex = pose.getSkeleton().getJoint(jointIndex).getParentIndex();

        // neckBindGlobalTransform is the neck bone -> model space transform. essentially, it is the world transform of
        // the neck bone in bind pose.
        final Matrix jointInverseBindPose = pose.getSkeleton().getJoint(jointIndex).getInverseBindPose();
        final Matrix jointBindPose = jointInverseBindPose.invert();
       
        // 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);

        // Calculate a rotation to go from one direction to the other and set that rotation on a blank transform.
        Quaternion quat = new Quaternion();
    rotation.rotateAxis(bindPoseDirection, angle);
    quat.rotate(rotation);

        final Matrix subGlobal = quat.getRotationMatrix();
       
        // now remove the global/world transform of the neck's parent bone, leaving us with just the local transform of
        // neck + rotation.
        subGlobal.matMul(jointBindPose);
        subGlobal.matMul(pose.getSkeleton().getJoint(parentIndex).getInverseBindPose());

        // set that as the neck's transform
        pose.getLocal(jointIndex).setTo(subGlobal);
    }

4
Now I'm really confused :(. I know that my questions might be very basic but please bear with me. In your first reply you told me that those modifications are not cumulative. What I really want to know is how to add the previous position of the neck joint to the rotation matrix before doing this action
Code: [Select]
pose.getLocal(jointIndex).setTo(subGlobal);, so instead of resetting the joint to it's original position it will continue to rotate around ANOTHER axis.

5
Thanks raft!! But is it somehow feasible to combine the rotation modifications ?

6
Hi raft,

I'm using JPCT-AE to display my ninja object on an Android phone. What I'm trying to do it to rotate different joints of the ninja. Because of the human structure people can rotate their neck around different axis (twist, bend, flexion and extension). But because all the rotations are with the same joint, I'm getting a weird problem. Once I have twisted the neck by some angle, and I'm trying to add some blending rotation the neck gets to it's original position and everything starts from scratch. I'm not sure what I'm doing wrong here, as I don't have a lot of experience in this field. Here is the section of performing rotation:

Code: [Select]
private void rotateJoint(SkeletonPose pose, int jointIndex, SimpleVector bindPoseDirection, float angle, final float targetStrength) {
   
        final int parentIndex = pose.getSkeleton().getJoint(jointIndex).getParentIndex();

        final Matrix jointInverseBindPose = pose.getSkeleton().getJoint(jointIndex).getInverseBindPose();
        final Matrix jointBindPose = jointInverseBindPose.invert();
       
        // 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);

        // Calculate a rotation to go from one direction to the other and set that rotation on a blank transform.
        Quaternion quat = new Quaternion();       
        quat.fromAngleAxis(angle, forwardDirection);
        quat.slerp(Quaternion.IDENTITY, quat, targetStrength);

        final Matrix subGlobal = quat.getRotationMatrix();
       
        subGlobal.matMul(jointBindPose);
        subGlobal.matMul(pose.getSkeleton().getJoint(parentIndex).getInverseBindPose());
       
        // set that as the neck's transform
        pose.getLocal(jointIndex).setTo(subGlobal);
    }




Ani

7
Support / Re: Pick a specific part of Ninja
« on: March 05, 2013, 09:33:23 pm »
Hey Egon! I have a quick question here. As you mentioned it might be possible to get the closest bone to the collision point. I can get the collision position relative to the world space. Is that possible to find that position relative to the object (Ninja)? Because I can get joint's location relative to the object or relative to it's parent.


Thanks!

8
Support / Re: Pick a specific part of Ninja
« on: March 05, 2013, 08:15:05 pm »
Thanks Egon! I've posted this question in Bones section as well. Could not find a way to move instead of creating another one. Anyway, thanks for your quick reply :)!

9
Bones / Pick a specific part of Ninja
« on: March 05, 2013, 08:13:45 pm »
Hi everybody,

I'm trying to rotate specific parts of Ninja object. So I need to determine the specific bone the user has picked by touching on some part of the screen. Using collision detection technique I can understand which object was picked, but that's not enough as this returns only the whole object (the Ninja).

So my question here is,  how to know which bone was selected by a touch event?


Thanks in advance!
Ani

10
Support / Pick a specific part of Ninja
« on: March 05, 2013, 05:38:42 pm »
Hi everybody,

I'm trying to rotate specific parts of Ninja object. So I need to determine the specific bone the user has picked by touching on some part of the screen. Using collision detection technique I can understand which object was picked, but that's not enough as this returns only the whole object (the Ninja).

So my question here is,  how to know which bone was selected by a touch event?


Thanks in advance!
Ani

Pages: [1]