Beispiel #1
0
    protected override void InitBoneMapTable()
    {
        foreach (var boneIdx in Enum.GetValues(typeof(SrcBoneName)))
        {
            Keypose pose = new Keypose();
            boneID2SrcPose.Add((int)boneIdx, pose);
            boneID2SrcBoneName.Add((int)boneIdx, Enum.GetName(typeof(SrcBoneName), boneIdx));
            srcBoneName2BoneID.Add(Enum.GetName(typeof(SrcBoneName), boneIdx), (int)boneIdx);
        }

        foreach (var boneIdx in Enum.GetValues(typeof(DstBoneName)))
        {
            string    dstBoneName = Enum.GetName(typeof(DstBoneName), boneIdx);
            Transform tf          = this.shapeObject.transform.FindLoop(dstBoneName);
            if (tf == null)
            {
                Debug.LogErrorFormat("Cant find bone:{0}", dstBoneName);
                var tmp = new GameObject(dstBoneName);
                tf = tmp.transform;
            }

            Bone bone = new Bone();
            bone.trfBone = tf;
            bone.pos     = tf.localPosition;
            bone.rot     = tf.localRotation.eulerAngles;
            bone.scale   = tf.localScale;

            boneID2DstPose.Add((int)boneIdx, bone);
            dstBoneName2BoneID.Add(dstBoneName, (int)boneIdx);
        }
    }
Beispiel #2
0
    void ParseShapeKeyposes()
    {
        var ta = Resources.Load <TextAsset>(this.keyposeConfig);

        if (ta == null)
        {
            return;
        }

        string txt = ta.text.Replace("\r", "");

        string[] lines = txt.Split('\n');
        foreach (var line in lines)
        {
            var            vals        = line.Split('\t');
            List <Keypose> poses       = new List <Keypose>();
            int            pos         = 0;
            string         srcBoneName = vals[pos++];
            if (string.IsNullOrEmpty(srcBoneName))
            {
                continue;
            }
            for (int i = 0; i < 25; ++i)
            {
                int     idx   = int.Parse(vals[pos++]);
                Keypose frame = new Keypose();
                frame.pos.x   = float.Parse(vals[pos++]);
                frame.pos.y   = float.Parse(vals[pos++]);
                frame.pos.z   = float.Parse(vals[pos++]);
                frame.rot.x   = float.Parse(vals[pos++]);
                frame.rot.y   = float.Parse(vals[pos++]);
                frame.rot.z   = float.Parse(vals[pos++]);
                frame.scale.x = float.Parse(vals[pos++]);
                frame.scale.y = float.Parse(vals[pos++]);
                frame.scale.z = float.Parse(vals[pos++]);
                poses.Add(frame);
            }
            keyposes.Add(srcBoneName, poses);
        }
    }