Пример #1
0
    private void DoCalibrating()
    {
        statusText.text = string.Format("Calibrating... {0}/{1} samples taken.", numberOfSamplesTaken, minNumberOfSamplesToTake);
        TakeSample();

        if (numberOfSamplesTaken >= minNumberOfSamplesToTake)
        {
            statusText.text = "All samples taken.\nProcessing...";
            currentState    = State.CalibrationReview;

            CalculateTransformation();

            moveController.gameObject.SetActive(true);


            float        distance        = 0;
            Vector3      error           = Vector3.zero;
            List <float> errorMagnitudes = new List <float>();
            for (int i = 0; i < calibrationSpheres.Count; i++)
            {
                //Destroy(sphere);
                GameObject sphere       = calibrationSpheres[i];
                Vector3    cubePosition = coordinateSystem.ConvertMovePosition(rawPSMoveSamples[i]);
                GameObject cube         = Instantiate(calibrationCube, cubePosition, Quaternion.identity) as GameObject;
                cube.GetComponent <RUISMoveCalibrationVisualizer>().kinectCalibrationSphere = sphere;


                distance += Vector3.Distance(sphere.transform.position, cubePosition);
                errorMagnitudes.Add(distance);
                error += cubePosition - sphere.transform.position;

                sphere.transform.parent = calibrationReviewGameObjects.transform;
                cube.transform.parent   = calibrationReviewGameObjects.transform;
            }

            totalErrorDistance = distance;
            averageError       = distance / calibrationSpheres.Count;

            SetCalibrationReviewShowing(true);

            RUISPSMoveWand controller = FindObjectOfType(typeof(RUISPSMoveWand)) as RUISPSMoveWand;
            controller.controllerId = calibratingPSMoveControllerId;

            psEyeModelObject.transform.position = coordinateSystem.ConvertMovePosition(Vector3.zero);
        }
    }
Пример #2
0
 private Vector3 TransformPosition(Vector3 value)
 {
     return(coordinateSystem.ConvertMovePosition(value));
 }