示例#1
0
        public HVRPosableBoneData GetBoneData()
        {
            var bone = new HVRPosableBoneData();

            bone.Position = Transform.localPosition;
            bone.Rotation = Transform.localRotation;
            return(bone);
        }
示例#2
0
        private HVRPosableFingerData MirrorFinger(HVRPosableFinger finger, HVRJointMirrorSetting mirrorOverride, List <HVRJointMirrorSetting> settings)
        {
            var fingerData = new HVRPosableFingerData();

            for (var i = 0; i < finger.Bones.Count; i++)
            {
                var bone     = finger.Bones[i];
                var boneData = new HVRPosableBoneData();



                HVRJointMirrorSetting mirror = null;


                if (settings != null && i < settings.Count)
                {
                    mirror = settings[i];
                }
                else if (mirrorOverride != null)
                {
                    mirror = mirrorOverride;
                }

                if (mirror != null)
                {
                    var euler = bone.Transform.localRotation.eulerAngles;

                    var xAngle = euler.x;
                    var yAngle = euler.y;
                    var zAngle = euler.z;

                    MirrorRotation(mirror.XRotation, ref xAngle);
                    MirrorRotation(mirror.YRotation, ref yAngle);
                    MirrorRotation(mirror.ZRotation, ref zAngle);

                    boneData.Position = bone.Transform.localPosition;
                    boneData.Rotation = Quaternion.Euler(xAngle, yAngle, zAngle);

                    if (mirror.XPosition == FingerMirrorPosition.Opposite)
                    {
                        boneData.Position.x *= -1f;
                    }

                    if (mirror.YPosition == FingerMirrorPosition.Opposite)
                    {
                        boneData.Position.y *= -1f;
                    }

                    if (mirror.ZPosition == FingerMirrorPosition.Opposite)
                    {
                        boneData.Position.z *= -1f;
                    }
                }
                else
                {
                    boneData.Position = bone.Transform.localPosition * -1;
                    boneData.Rotation = bone.Transform.localRotation;
                }

                fingerData.Bones.Add(boneData);
            }

            return(fingerData);
        }