示例#1
0
        public void TweenTransform(Pose from, Pose to, float alpha, bool easing = false)
        {
            alpha = Mathf.Clamp01(alpha);

            if (easing)
            {
                alpha = CubicEaseInOut(alpha);
            }

            Transform personRoot = atom.mainController.transform;

            from.transforms.Keys.ToList().ForEach(id =>
            {
                if (from.transforms.ContainsKey(id) == false)
                {
                    return;
                }
                if (to.transforms.ContainsKey(id) == false)
                {
                    return;
                }

                PoseTransform fromT = from.transforms[id];
                PoseTransform toT   = to.transforms[id];
                if (fromT == null || toT == null)
                {
                    return;
                }

                JSONStorable storable            = atom.GetStorableByID(id);
                storable.transform.localPosition = Vector3.Lerp(fromT.localPosition, toT.localPosition, alpha);
                storable.transform.localRotation = Quaternion.Lerp(fromT.localRotation, toT.localRotation, alpha);
            });
        }
示例#2
0
        public Pose(Atom atom, JSONNode atomJSON)
        {
            var obj       = atomJSON.AsObject;
            var storables = obj["storables"].AsArray;
            Dictionary <string, JSONClass> storablesDict = new Dictionary <string, JSONClass>();

            storables.Childs.ToList().ForEach(node =>
            {
                var asClass = node.AsObject;
                storablesDict[asClass["id"]] = node.AsObject;
            });

            atom.freeControllers.ToList().ForEach(controller =>
            {
                string id = controller.storeId;
                if (id == "control")
                {
                    return;
                }

                if (storablesDict.ContainsKey(id) == false)
                {
                    return;
                }
                var storable        = storablesDict[id];
                Vector3 position    = GetLocalPosition(storable);
                Quaternion rotation = GetLocalRotation(storable);
                PoseTransform pt    = new PoseTransform()
                {
                    localPosition = position, localRotation = rotation
                };
                transforms[id] = pt;
            });
        }