예제 #1
0
        public IEnumerator Calibrate()
        {
            var settings = new RootMotion.FinalIK.VRIKCalibrator.Settings();

            //トラッカー
            //xをプラス方向に動かすとトラッカーの左(LEDを上に見たとき)に進む
            //yをプラス方向に動かすとトラッカーの上(LED方向)に進む
            //zをマイナス方向に動かすとトラッカーの底面に向かって進む

            //角度補正(左手なら右のトラッカーに向けた)後
            //xを+方向は体の正面に向かって進む
            //yを+方向は体の上(天井方向)に向かって進む
            //zを+方向は体中心(左手なら右手の方向)に向かって進む
            var leftHandOffset = new Vector3(1.0f, leftHandTrackerOffsetToBottom, leftHandTrackerOffsetToBodySide);  // Vector3 (IsEnable, ToTrackerBottom, ToBodySide)
            //}
            //if (CurrentSettings.RightHand.Item1 == ETrackedDeviceClass.GenericTracker) {
            //角度補正(左手なら右のトラッカーに向けた)後
            //xを-方向は体の正面に向かって進む
            //yを+方向は体の上(天井方向)に向かって進む
            //zを+方向は体中心(左手なら右手の方向)に向かって進む
            var rightHandOffset = new Vector3(1.0f, rightHandTrackerOffsetToBottom, rightHandTrackerOffsetToBodySide);  // Vector3 (IsEnable, ToTrackerBottom, ToBodySide)

            //}
            //if (calibrateType == PipeCommands.CalibrateType.Default) {

            if (calibrationType == CalibrationType.VirtualMotionCaptureScaled)
            {
                yield return(Calibrator.CalibrateScaled(_refs.RealTrackerRoot, _refs.HandTrackerRoot, _refs.HeadTrackerRoot, _refs.PelvisTrackerRoot,
                                                        dummyVrik, settings, leftHandOffset, rightHandOffset, pelvisTrackerAdjustmentToBottom,
                                                        _data.headTracker, _data.bodyTracker, _data.leftHandTracker, _data.rightHandTracker, _data.leftFootTracker, _data.rightFootTracker, _data.leftElbowTracker, _data.rightElbowTracker, _data.leftKneeTracker, _data.rightKneeTracker));
            }
            else
            {
                yield return(Calibrator.Calibrate(_refs.RealTrackerRoot, _refs.HandTrackerRoot, _refs.HeadTrackerRoot, _refs.PelvisTrackerRoot,
                                                  dummyVrik, settings, leftHandOffset, rightHandOffset, pelvisTrackerAdjustmentToBottom,
                                                  _data.headTracker, _data.bodyTracker, _data.leftHandTracker, _data.rightHandTracker, _data.leftFootTracker, _data.rightFootTracker, _data.leftElbowTracker, _data.rightElbowTracker, _data.leftKneeTracker, _data.rightKneeTracker));
            }

            dummyVrik.solver.IKPositionWeight = 1.0f;
            if (_refs.handler.Trackers.Count == 1)
            {
                dummyVrik.solver.plantFeet         = true;
                dummyVrik.solver.locomotion.weight = 1.0f;
                var rootController = dummyVrik.references.root.GetComponent <RootMotion.FinalIK.VRIKRootController> ();
                if (rootController != null)
                {
                    GameObject.Destroy(rootController);
                }
            }

            dummyVrik.solver.locomotion.footDistance   = 0.06f;
            dummyVrik.solver.locomotion.stepThreshold  = 0.2f;
            dummyVrik.solver.locomotion.angleThreshold = 45f;
            dummyVrik.solver.locomotion.maxVelocity    = 0.04f;
            dummyVrik.solver.locomotion.velocityFactor = 0.04f;
            dummyVrik.solver.locomotion.rootSpeed      = 40;
            dummyVrik.solver.locomotion.stepSpeed      = 2;

            //トラッカー位置の非表示
            _refs.RealTrackerRoot.gameObject.SetActive(false);

            _UpdateHandRotation();
        }