Example #1
0
        private void SetFingerJoints(ISVisualizationJoint j)
        {
            //set index joint to target index joint position
            Vector3 targetPos = getJointPosition(j.reference);
            Vector3 newOffset = j.parent.GetGlobalMatrix().inverse.MultiplyPoint3x4(targetPos);

            j.reference.position = new Vector3(j.GetGlobalMatrix().GetColumn(3).x, j.GetGlobalMatrix().GetColumn(3).y, j.GetGlobalMatrix().GetColumn(3).z);
        }
Example #2
0
        private void AlignJoint(ISVisualizationJoint start, ISVisualizationJoint end)
        {
            Vector3    source_dir = getJointPosition(end.reference) - getJointPosition(start.reference);
            Vector3    endPos     = end.GetGlobalMatrix().GetColumn(3);//end.gameJoint.transform.position;
            Vector3    target_dir = endPos - getJointPosition(start.reference);
            Quaternion q          = Quaternion.FromToRotation(source_dir, target_dir);

            start.reference.rotation = q * start.reference.rotation;

            //this.anim.GetBoneTransform (start.referenceBone).rotation = q * this.anim.GetBoneTransform(start.referenceBone).rotation;
        }
Example #3
0
        private Matrix4x4 GetGlobalMatrix()
        {
            var t = j.GetOffsetPositions().ToVector3();
            var q = j.GetOffsetRotation().ToQuaternion();
            var m = Matrix4x4.TRS(t, q, Vector3.one);

            if (parent != null)
            {
                var parentM = parent.GetGlobalMatrix();
                m = parentM * m;
            }

            return(m);
        }