Exemplo n.º 1
0
        private void SetChildTransform(SkeletonJoint child, AMCFrame frame, Vector4 p)
        {
            float[] data   = frame.GetValue(child.Name).Data;
            Vector3 rot3x1 = Vector3.zero;

            int idx = 0;

            for (int i = 0; data.Length != 0 && i < child.Dof.Length; i++)
            {
                if (asfReader.DOFMap.TryGetValue(child.Dof[i], out int dim))
                {
                    rot3x1[dim] = data[idx];
                    idx++;
                }
            }

            Matrix4x4 M = (rot3x1 * Mathf.Deg2Rad).Euler2Mat();

            child.L          = child.B * child.C * M * child.CInv;
            child.G          = child.Parent.G * child.L;
            child.Coordinate = child.G * p;

            if (child.Children == null)
            {
                return;
            }

            foreach (SkeletonJoint childOfChild in child.Children)
            {
                SetChildTransform(childOfChild, frame, p);
            }
        }
Exemplo n.º 2
0
        private void SetRootTransform(AMCFrame frame)
        {
            Vector4       point = MotionUtil.LastOne;
            SkeletonJoint root  = skeletonJointDict[ROOTKEY];

            float[] vals        = frame.GetValue(ROOTKEY).Data;
            float   px          = vals[0] * AcclaimSkeleton.METER_SCALE;
            float   py          = vals[1] * AcclaimSkeleton.METER_SCALE;
            float   pz          = vals[2] * AcclaimSkeleton.METER_SCALE;
            Vector3 transOffset = new Vector3(px, py, pz);

            Vector3   rot3x1 = new Vector3(vals[3], vals[4], vals[5]);
            Matrix4x4 M      = (rot3x1 * Mathf.Deg2Rad).Euler2Mat();

            //root.LocalRotation = root.C * M * root.CInv;
            root.L = root.B * root.C * M * root.CInv;
            root.G = root.L * Matrix4x4.Translate(transOffset);

            root.Coordinate = root.G * point;
            foreach (SkeletonJoint child in root.Children)
            {
                SetChildTransform(child, frame, point);
            }
        }