public RUISKinectFloorDataCalibrationProcess(RUISCalibrationProcessSettings calibrationSettings) 
	{
		this.calibrationPhaseObjects = calibrationSettings.calibrationPhaseObjects;
		this.calibrationResultPhaseObjects = calibrationSettings.calibrationResultPhaseObjects;
		
		this.deviceModelObjects = calibrationSettings.deviceModelObjects;
		this.depthViewObjects = calibrationSettings.depthViewObjects;
		this.iconObjects = calibrationSettings.iconObjects;
		
		this.floorPlane = GameObject.Find ("Floor");
		
		foreach (Transform child in this.deviceModelObjects.transform)
		{
			child.gameObject.SetActive(false);
		}
		
		foreach (Transform child in this.depthViewObjects.transform)
		{
			child.gameObject.SetActive(false);
		}
		
		foreach (Transform child in this.iconObjects.transform)
		{
			child.gameObject.SetActive(false);
		}
		
		if(this.calibrationPhaseObjects)
			this.calibrationPhaseObjects.SetActive(true);
		if(this.calibrationResultPhaseObjects)
			this.calibrationResultPhaseObjects.SetActive(false);
		this.xmlFilename = calibrationSettings.xmlFilename;
		coordinateSystem = MonoBehaviour.FindObjectOfType(typeof(RUISCoordinateSystem)) as RUISCoordinateSystem;
//		kinectSelection = MonoBehaviour.FindObjectOfType(typeof(NIPlayerManagerCOMSelection)) as NIPlayerManagerCOMSelection;
		settingsManager = MonoBehaviour.FindObjectOfType(typeof(OpenNISettingsManager)) as OpenNISettingsManager;
	}
예제 #2
0
    void Awake()
    {
        playerManager = GetComponent <NIPlayerManager>();


        if (coordinateSystem == null)
        {
            coordinateSystem = FindObjectOfType(typeof(RUISCoordinateSystem)) as RUISCoordinateSystem;
        }

        for (int i = 0; i < skeletons.Length; i++)
        {
            skeletons[i] = new Skeleton();
        }
    }
예제 #3
0
    void Start()
    {
        coordinateSystem = FindObjectOfType(typeof(RUISCoordinateSystem)) as RUISCoordinateSystem;
        Quaternion dictionaryFloorNormal       = coordinateSystem.RUISCalibrationResultsFloorPitchRotation[coordinateSystem.rootDevice];
        float      dictionaryDistanceFromFloor = coordinateSystem.RUISCalibrationResultsDistanceFromFloor[coordinateSystem.rootDevice];
        Vector3    normalVector = dictionaryFloorNormal * Vector3.up;

        coordinateSystem.SetFloorNormal(normalVector, coordinateSystem.rootDevice);
        coordinateSystem.SetDistanceFromFloor(dictionaryDistanceFromFloor, coordinateSystem.rootDevice);

        //check whether the kinect camera is actually connected
        if (enableKinect)
        {
            OpenNISettingsManager settingsManager = FindObjectOfType(typeof(OpenNISettingsManager)) as OpenNISettingsManager;
            if (settingsManager.UserGenrator == null || !settingsManager.UserGenrator.Valid)
            {
                Debug.LogError("Could not start OpenNI! Check your Kinect connection.");
                GetComponentInChildren <RUISKinectDisabler>().KinectNotAvailable();
            }
        }

        if (!enableKinect2)
        {
            Debug.Log("Kinect 2 is disabled from RUISInputManager.");
            BodySourceManager kinect2Manager = GetComponentInChildren <BodySourceManager>();
            if (kinect2Manager)
            {
                kinect2Manager.gameObject.SetActive(false);
            }
        }

        if ((enableKinect && kinectFloorDetection) || (enableKinect2 && kinect2FloorDetection))
        {
            StartFloorDetection();
        }

        if (enablePSMove)
        {
            RUISPSMoveWand[] controllers = GetComponentsInChildren <RUISPSMoveWand>();
            moveControllers = new RUISPSMoveWand[controllers.Length];
            foreach (RUISPSMoveWand controller in controllers)
            {
                moveControllers[controller.controllerId] = controller;
            }
        }
    }
예제 #4
0
    void Start()
    {
        coordinateSystem = FindObjectOfType(typeof(RUISCoordinateSystem)) as RUISCoordinateSystem;

        if (transform.parent)
        {
            skeletonController = transform.parent.gameObject.GetComponentInChildren(typeof(RUISSkeletonController)) as RUISSkeletonController;
            if (skeletonController)
            {
                playerId             = skeletonController.playerId;
                bodyTrackingDeviceID = skeletonController.bodyTrackingDeviceID;
            }
        }

//		if(transform.parent)
//			characterController = transform.parent.GetComponent<RUISCharacterController>();
    }
예제 #5
0
    void Start()
    {
        coordinateSystem = FindObjectOfType(typeof(RUISCoordinateSystem)) as RUISCoordinateSystem;

        if (transform.parent)
        {
            // FIXME: if skeletonControllers are nested below produces wrong results (e.g. case of pilot inside her mecha)
            skeletonController = transform.parent.gameObject.GetComponentInChildren(typeof(RUISSkeletonController)) as RUISSkeletonController;
            if (skeletonController)
            {
                playerId             = skeletonController.playerId;
                bodyTrackingDeviceID = skeletonController.bodyTrackingDeviceID;
            }
        }

//		if(transform.parent)
//			characterController = transform.parent.GetComponent<RUISCharacterController>();
    }
예제 #6
0
    void Awake()
    {
        inputManager = FindObjectOfType(typeof(RUISInputManager)) as RUISInputManager;

        playerManager   = GetComponent <NIPlayerManager>();
        RUISKinect2Data = GetComponent <RUISKinect2Data>();

        if (!inputManager.enableKinect)
        {
            playerManager.enabled = false;
        }
        if (!inputManager.enableKinect2)
        {
            RUISKinect2Data.enabled = false;
        }

        if (coordinateSystem == null)
        {
            coordinateSystem = FindObjectOfType(typeof(RUISCoordinateSystem)) as RUISCoordinateSystem;
        }

        for (int x = 0; x < 3; x++)         // Kinect 1, Kinect 2, Custom Tracker
        {
            for (int i = 0; i < 6; i++)
            {
                skeletons [x, i] = new Skeleton();

                // HACK  for filtering Kinect 2 arm rotations
                if (x == kinect2SensorID)
                {
                    for (int k = 0; k < skeletons[x, i].filterRot.Length; ++k)
                    {
                        skeletons[x, i].filterRot[k] = new KalmanFilteredRotation();
                        skeletons[x, i].filterRot[k].skipIdenticalMeasurements = true;
                        skeletons[x, i].filterRot[k].rotationNoiseCovariance   = skeletons[x, i].rotationNoiseCovariance;
                        skeletons[x, i].previousRotation[k] = Quaternion.identity;
                    }
                }
            }
        }

        isNewKinect2Frame         = false;
        timeSinceLastKinect2Frame = 0;
    }
예제 #7
0
    public void Awake()
    {
        if (psMoveWrapper == null)
        {
            psMoveWrapper = FindObjectOfType(typeof(PSMoveWrapper)) as PSMoveWrapper;
            if (!psMoveWrapper)
            {
                Debug.LogError("Could not find PSMoveWrapper");
            }
        }

        if (coordinateSystem == null)
        {
            coordinateSystem = FindObjectOfType(typeof(RUISCoordinateSystem)) as RUISCoordinateSystem;
            if (!coordinateSystem)
            {
                Debug.LogError("Could not find RUISCoordinateSystem script! It should be located in RUIS->InputManager.");
            }
        }
    }
예제 #8
0
	public void Awake ()
    {
    
        if (psMoveWrapper == null)
        {
            psMoveWrapper = FindObjectOfType(typeof(PSMoveWrapper)) as PSMoveWrapper;
            if (!psMoveWrapper)
            {
                Debug.LogError("Could not find PSMoveWrapper");
            }
        }

        if (coordinateSystem == null)
        {
            coordinateSystem = FindObjectOfType(typeof(RUISCoordinateSystem)) as RUISCoordinateSystem;
            if (!coordinateSystem)
            {
                Debug.LogError("Could not find RUISCoordinateSystem script! It should be located in RUIS->InputManager.");
            }
        }
	}
예제 #9
0
    private IEnumerator attemptUpdatingFloorNormal()
    {
        yield return(new WaitForSeconds(5.0f));

        if (kinectFloorDetection)
        {
            coordinateSystem = FindObjectOfType(typeof(RUISCoordinateSystem)) as RUISCoordinateSystem;
            if (!coordinateSystem)
            {
                Debug.LogError("Could not find coordinate system!");
            }
            else if (sceneAnalyzer == null)
            {
                Debug.LogError("Failed to access OpenNI sceneAnalyzer!");
            }
            else
            {
                Debug.Log("Updating Kinect floor normal");
                updateKinectFloorData();
            }
        }
    }
예제 #10
0
    public RUISKinectFloorDataCalibrationProcess(RUISCalibrationProcessSettings calibrationSettings)
    {
        this.calibrationPhaseObjects       = calibrationSettings.calibrationPhaseObjects;
        this.calibrationResultPhaseObjects = calibrationSettings.calibrationResultPhaseObjects;

        this.deviceModelObjects = calibrationSettings.deviceModelObjects;
        this.depthViewObjects   = calibrationSettings.depthViewObjects;
        this.iconObjects        = calibrationSettings.iconObjects;

        this.floorPlane = GameObject.Find("Floor");

        foreach (Transform child in this.deviceModelObjects.transform)
        {
            child.gameObject.SetActive(false);
        }

        foreach (Transform child in this.depthViewObjects.transform)
        {
            child.gameObject.SetActive(false);
        }

        foreach (Transform child in this.iconObjects.transform)
        {
            child.gameObject.SetActive(false);
        }

        if (this.calibrationPhaseObjects)
        {
            this.calibrationPhaseObjects.SetActive(true);
        }
        if (this.calibrationResultPhaseObjects)
        {
            this.calibrationResultPhaseObjects.SetActive(false);
        }
        this.xmlFilename = calibrationSettings.xmlFilename;
        coordinateSystem = MonoBehaviour.FindObjectOfType(typeof(RUISCoordinateSystem)) as RUISCoordinateSystem;
//		kinectSelection = MonoBehaviour.FindObjectOfType(typeof(NIPlayerManagerCOMSelection)) as NIPlayerManagerCOMSelection;
        settingsManager = MonoBehaviour.FindObjectOfType(typeof(OpenNISettingsManager)) as OpenNISettingsManager;
    }
    void Awake()
    {
        inputManager = FindObjectOfType(typeof(RUISInputManager)) as RUISInputManager;

        if (inputManager)
        {
            if (switchToAvailableKinect)
            {
                if (bodyTrackingDevice == bodyTrackingDeviceType.Kinect1 &&
                    !inputManager.enableKinect && inputManager.enableKinect2)
                {
                    bodyTrackingDevice = bodyTrackingDeviceType.Kinect2;
                }
                else if (bodyTrackingDevice == bodyTrackingDeviceType.Kinect2 &&
                         !inputManager.enableKinect2 && inputManager.enableKinect)
                {
                    bodyTrackingDevice = bodyTrackingDeviceType.Kinect1;
                }
            }
        }

        coordinateSystem = FindObjectOfType(typeof(RUISCoordinateSystem)) as RUISCoordinateSystem;

        if (bodyTrackingDevice == bodyTrackingDeviceType.Kinect1)
        {
            bodyTrackingDeviceID = RUISSkeletonManager.kinect1SensorID;
        }
        if (bodyTrackingDevice == bodyTrackingDeviceType.Kinect2)
        {
            bodyTrackingDeviceID = RUISSkeletonManager.kinect2SensorID;
        }
        if (bodyTrackingDevice == bodyTrackingDeviceType.GenericMotionTracker)
        {
            bodyTrackingDeviceID = RUISSkeletonManager.customSensorID;
        }

        positionKalman = new KalmanFilter();
        positionKalman.initialize(3, 3);
    }
예제 #12
0
//	Ovr.HmdType ovrHmdVersion; //06to08

    void Awake()
    {
        // BUTTONS
        // Phase: select and configure devices
        buttons.Add(this.transform.Find("NGUIControls/Panel/selectAndConfigureDevices/Buttons/Button - Calibration").gameObject);
        buttons.Add(this.transform.Find("NGUIControls/Panel/selectAndConfigureDevices/Buttons/Button - Display Management").gameObject);
        buttons.Add(this.transform.Find("NGUIControls/Panel/selectAndConfigureDevices/Buttons/Button - Save Config & Restart Scene").gameObject);
        buttons.Add(this.transform.Find("NGUIControls/Panel/selectAndConfigureDevices/Buttons/Button - Discard Configuration").gameObject);
        buttons.Add(this.transform.Find("NGUIControls/Panel/selectAndConfigureDevices/Buttons/Button - Quit Application").gameObject);

        // Phase: key stone configuration
        buttons.Add(this.transform.Find("NGUIControls/Panel/keyStoneConfiguration/Button - Reset Keystoning").gameObject);
        buttons.Add(this.transform.Find("NGUIControls/Panel/keyStoneConfiguration/Button - Save Configurations").gameObject);
        buttons.Add(this.transform.Find("NGUIControls/Panel/keyStoneConfiguration/Button - Load Old Configurations").gameObject);
        buttons.Add(this.transform.Find("NGUIControls/Panel/keyStoneConfiguration/Button - End Display Editing").gameObject);

        // CHECKBOXES
        checkBoxes.Add(this.transform.Find("NGUIControls/Panel/selectAndConfigureDevices/Kinect/Checkbox - Use Kinect").gameObject);
        checkBoxes.Add(this.transform.Find("NGUIControls/Panel/selectAndConfigureDevices/Kinect2/Checkbox - Use Kinect 2").gameObject);
        checkBoxes.Add(this.transform.Find("NGUIControls/Panel/selectAndConfigureDevices/Kinect/Checkbox - Use Kinect Drift Correction").gameObject);
        checkBoxes.Add(this.transform.Find("NGUIControls/Panel/selectAndConfigureDevices/PSMove/Checkbox - Use PSMove").gameObject);
        checkBoxes.Add(this.transform.Find("NGUIControls/Panel/selectAndConfigureDevices/Hydra/Checkbox - Use Hydra").gameObject);

        // TEXTFIELDS
        textFields.Add(this.transform.Find("NGUIControls/Panel/selectAndConfigureDevices/PSMove/Input - PSMove Port").gameObject);
        textFields.Add(this.transform.Find("NGUIControls/Panel/selectAndConfigureDevices/PSMove/Input - PSMove IP").gameObject);

        inputManager     = FindObjectOfType(typeof(RUISInputManager)) as RUISInputManager;
        displayManager   = FindObjectOfType(typeof(RUISDisplayManager)) as RUISDisplayManager;
        coordinateSystem = FindObjectOfType(typeof(RUISCoordinateSystem)) as RUISCoordinateSystem;

        kinectOrigGUIPos   = this.transform.Find("NGUIControls/Panel/selectAndConfigureDevices/Kinect").transform.localPosition;
        kinect2OrigGUIPos  = this.transform.Find("NGUIControls/Panel/selectAndConfigureDevices/Kinect2").transform.localPosition;
        hydraOrigGUIPos    = this.transform.Find("NGUIControls/Panel/selectAndConfigureDevices/Hydra").transform.localPosition;
        infotextOrigGUIPos = this.transform.Find("NGUIControls/Panel/selectAndConfigureDevices/Infotexts").transform.localPosition;
//		psMoveOrigGUIPos = this.transform.Find  ("NGUIControls/Panel/selectAndConfigureDevices/PSMove").transform.localPosition;
//		buttonsOrigGUIPos = this.transform.Find ("NGUIControls/Panel/selectAndConfigureDevices/Buttons").transform.localPosition;
    }
예제 #13
0
    // end // Head/Body turn gesture

    void Awake()
    {
        characterController = GetComponent <RUISCharacterController>();
        jumpGesture         = GetComponentInChildren <RUISJumpGestureRecognizer>();

        //moveWrapper = FindObjectOfType(typeof(PSMoveWrapper)) as PSMoveWrapper;
        bimanualSwingingRecognizer = FindObjectOfType(typeof(RUISBimanualSwingingRecognizer)) as RUISBimanualSwingingRecognizer;         // TODO: Shouldn't probably check whole scene
        coordinateSystem           = FindObjectOfType(typeof(RUISCoordinateSystem)) as RUISCoordinateSystem;
        skeletonManager            = FindObjectOfType(typeof(RUISSkeletonManager)) as RUISSkeletonManager;

        try
        {
            Input.GetAxis("Sprint");
        }
        catch (UnityException)
        {
            Debug.LogWarning("'Sprint' not defined in Unity Input settings");
        }

        try
        {
            Input.GetAxis("Turn");
        }
        catch (UnityException)
        {
            Debug.LogWarning("'Turn' not defined in Unity Input settings");
        }

        try
        {
            Input.GetAxis("Jump");
        }
        catch (UnityException)
        {
            Debug.LogWarning("'Jump' not defined in Unity Input settings");
        }
    }
    void Awake()
    {
		inputManager = FindObjectOfType(typeof(RUISInputManager)) as RUISInputManager;

		if(inputManager)
		{
			if(switchToAvailableKinect)
			{
				if(   bodyTrackingDevice == bodyTrackingDeviceType.Kinect1
				   && !inputManager.enableKinect && inputManager.enableKinect2)
				{
					bodyTrackingDevice = bodyTrackingDeviceType.Kinect2;
				}
				else if(   bodyTrackingDevice == bodyTrackingDeviceType.Kinect2
				   && !inputManager.enableKinect2 && inputManager.enableKinect)
				{
					bodyTrackingDevice = bodyTrackingDeviceType.Kinect1;
				}
			}
		}

		coordinateSystem = FindObjectOfType(typeof(RUISCoordinateSystem)) as RUISCoordinateSystem;
		
		if(bodyTrackingDevice == bodyTrackingDeviceType.Kinect1) bodyTrackingDeviceID = RUISSkeletonManager.kinect1SensorID;
		if(bodyTrackingDevice == bodyTrackingDeviceType.Kinect2) bodyTrackingDeviceID = RUISSkeletonManager.kinect2SensorID;
		if(bodyTrackingDevice == bodyTrackingDeviceType.GenericMotionTracker) bodyTrackingDeviceID = RUISSkeletonManager.customSensorID;

		followOculusController = false;
		followMoveController = false;
		trackedDeviceYawRotation = Quaternion.identity;
		
        jointInitialRotations = new Dictionary<Transform, Quaternion>();
        jointInitialDistances = new Dictionary<KeyValuePair<Transform, Transform>, float>();
		
		positionKalman = new KalmanFilter();
		positionKalman.initialize(3,3);

		for(int i=0; i<fourJointsKalman.Length; ++i)
		{
			fourJointsKalman[i] = new KalmanFilter();
			fourJointsKalman[i].initialize(3,3);
			fourJointPositions[i] = Vector3.zero;
		}
    }
    void Start()
    {
        colliding = false;
        grounded  = false;

        // Second substitution, because RUISKinectAndMecanimCombiner might have already erased the original one and re-created it
        skeletonController = gameObject.GetComponentInChildren <RUISSkeletonController>();
        if (skeletonController)
        {
            bodyParts.Add(skeletonController.leftFoot);
            bodyParts.Add(skeletonController.rightFoot);
            kinectPlayerId       = skeletonController.playerId;
            bodyTrackingDeviceID = skeletonController.bodyTrackingDeviceID;
        }
        else
        {
            Debug.LogError("RUISCharacterController script in game object '" + gameObject.name
                           + "' did not find RUISSkeletonController component from it's child objects!");
        }

        coordinateSystem = FindObjectOfType(typeof(RUISCoordinateSystem)) as RUISCoordinateSystem;

        if (stabilizingCollider)
        {
            colliderComponent = stabilizingCollider.gameObject.GetComponent <Collider>();
            if (colliderComponent)
            {
                if (characterPivotType == CharacterPivotType.KinectHead ||
                    characterPivotType == CharacterPivotType.KinectTorso)
                {
                    if (coordinateSystem && inputManager.enableKinect && !coordinateSystem.setKinectOriginToFloor)
                    {
                        Debug.LogWarning("It is best to enable 'setKinectOriginToFloor' from RUISCoordinateSystem " +
                                         "when using Kinect and RUISCharacterController script.");
                    }
                }

                if (colliderComponent.material)
                {
                    originalMaterial = colliderComponent.material;
                }
                else
                {
                    colliderComponent.material = new PhysicMaterial();
                    originalMaterial           = colliderComponent.material;
                }

                if (dynamicMaterial == null)
                {
                    dynamicMaterial = new PhysicMaterial();

                    dynamicMaterial.dynamicFriction = 0;
                    dynamicMaterial.staticFriction  = 0;
                    dynamicMaterial.frictionCombine = PhysicMaterialCombine.Minimum;

                    if (colliderComponent.material)
                    {
                        /*dynamicMaterial.bounceCombine = originalMaterial.bounceCombine;
                         * dynamicMaterial.bounciness = originalMaterial.bounciness;
                         * dynamicMaterial.staticFriction2 = originalMaterial.staticFriction2;
                         * dynamicMaterial.dynamicFriction2 = originalMaterial.dynamicFriction2;
                         * dynamicMaterial.frictionDirection2 = originalMaterial.frictionDirection2;*/
                    }
                }
            }
        }
        if ((characterPivotType == CharacterPivotType.KinectHead ||
             characterPivotType == CharacterPivotType.KinectTorso) &&
            (skeletonController && skeletonController.playerId != kinectPlayerId))
        {
            Debug.LogError("The 'Kinect Player Id' variable in RUISCharacterController script in gameObject '" + gameObject.name
                           + "is different from the Kinect Player Id of the RUISSkeletonController script (located in child "
                           + "object '" + skeletonController.gameObject.name + "). Make sure that these two values are "
                           + "the same.");
        }

        //#if UNITY_EDITOR
        //if(UnityEditorInternal.InternalEditorUtility.HasPro())
        //#endif
        {
            try
            {
                bool isRiftConnected = false;
                if (OVRManager.display != null)
                {
                    isRiftConnected = OVRManager.display.isPresent;
                }
                if (OVRManager.capiHmd != null)
                {
                    ovrHmdVersion = OVRManager.capiHmd.GetDesc().Type;
                }

                if (useOculusPositionalTracking && ovrHmdVersion == Ovr.HmdType.DK1 || ovrHmdVersion == Ovr.HmdType.DKHD || ovrHmdVersion == Ovr.HmdType.None)
                {
                    Debug.LogError("Can't use Oculus Rift's tracked position as a pivot with Oculus Rift " + ovrHmdVersion);
                    useOculusPositionalTracking = false;
                }

                if (useOculusPositionalTracking && !isRiftConnected)
                {
                    Debug.LogError("Can't use Oculus Rift's tracked position as a pivot because Oculus Rift is not connected.");
                    useOculusPositionalTracking = false;
                }
            }
            catch (UnityException e)
            {
                useOculusPositionalTracking = false;
                Debug.LogError(e);
            }
        }

        if (GetComponentInChildren <RUISKinectAndMecanimCombiner>())
        {
            kinectAndMecanimCombinerExists = true;
        }

        previousPosition = transform.position;
    }
예제 #16
0
    public void Awake()
    {
        coordinateSystem = FindObjectOfType(typeof(RUISCoordinateSystem)) as RUISCoordinateSystem;

        if (!Application.isEditor || loadFromTextFileInEditor)
        {
            if (!Import(filename))
            {
                Debug.LogError("Could not load input configuration file. Creating file based on current settings.");
                Export(filename);
            }
        }

        // Check if we are in calibration scene
        if (RUISCalibrationProcessSettings.isCalibrating)
        {
            this.enablePSMove       = RUISCalibrationProcessSettings.enablePSMove;
            this.enableKinect       = RUISCalibrationProcessSettings.enableKinect;
            this.enableKinect2      = RUISCalibrationProcessSettings.enableKinect2;
            this.jumpGestureEnabled = RUISCalibrationProcessSettings.jumpGestureEnabled;
            this.enableRazerHydra   = RUISCalibrationProcessSettings.enableRazerHydra;
            this.PSMoveIP           = RUISCalibrationProcessSettings.PSMoveIP;
            this.PSMovePort         = RUISCalibrationProcessSettings.PSMovePort;
//			this.kinectDriftCorrectionPreferred = ruisNGUIMenu.originalKinectDriftCorrection;

            RUISCalibrationProcessSettings.isCalibrating = false;
        }

        wandDelayed = new bool[4] {
            moveWand0, moveWand1, moveWand2, moveWand3
        };
        disabledWands = new List <GameObject>();


        if (!enableKinect)
        {
            Debug.Log("Kinect is disabled from RUISInputManager.");
            GetComponentInChildren <RUISKinectDisabler>().KinectNotAvailable();
        }
        else
        {
            GetComponentInChildren <NIPlayerManagerCOMSelection>().m_MaxNumberOfPlayers = maxNumberOfKinectPlayers;
        }

        //     psMoveWrapper = GetComponentInChildren<PSMoveWrapper>();
        //     if (enablePSMove)
        //     {

        //         if (psMoveWrapper && connectToPSMoveOnStartup)
        //         {
        //             StartCoroutine("CheckForMoveConnection");

        //             psMoveWrapper.Connect(PSMoveIP, PSMovePort);

        //             psMoveWrapper.enableDefaultInGameCalibrate = enableMoveCalibrationDuringPlay;

        //	if(delayedWandActivation)
        //	{
        //		string names = "";
        //		foreach (RUISPSMoveWand moveController in FindObjectsOfType(typeof(RUISPSMoveWand)) as RUISPSMoveWand[])
        //        {
        //            if(		moveController != null && moveController.controllerId < 4
        //				&&	moveController.controllerId >= 0 && wandDelayed[moveController.controllerId] )
        //			{
        //				// Make sure that the found RUISPSMoveWand is not under InputManager->MoveControllers GameObject
        //				if(		moveController.gameObject.transform.parent == null
        //					||	moveController.gameObject.transform.parent.parent == null
        //					||	(	moveController.gameObject.transform.parent.GetComponent<RUISInputManager>() == null
        //						 &&	moveController.gameObject.transform.parent.parent.GetComponent<RUISInputManager>() == null))
        //				{
        //					moveController.gameObject.SetActive(false);
        //					disabledWands.Add(moveController.gameObject);
        //					if(names.Length > 0)
        //						names += ", ";
        //					names += moveController.gameObject.name;
        //				}
        //			}
        //        }
        //		if(disabledWands.Count > 0)
        //		{
        //			Debug.Log(	  "DELAYED CONTROLLER ACTIVATION INITIALIZATION: Following objects are disabled: "
        //						+ names + ". If their input devices are found, they will be re-activated in "
        //						+ delayTime + " seconds, as configured in RUISInputManager.");
        //			StartCoroutine("DelayedWandActivation");
        //		}
        //	}
        //         }
        //     }
        //     else
        //     {
        //Debug.Log("PS Move is disabled from RUISInputManager.");
        //         //psMoveWrapper.gameObject.SetActiveRecursively(false);
        //     }


//		sixense = FindObjectOfType(typeof(SixenseInput)) as SixenseInput;
//		if(enableRazerHydra)
//		{
//			if(sixense == null)
//				Debug.LogError(		"Could not connect with Razer Hydra! Your RUIS InputManager settings indicate "
//								+   "that you want to use Razer Hydra, but this scene does not have a gameobject "
//								+	"with SixenseInput script, which is required. Add SixenseInput prefab "
//								+	"into the scene.");
//			// IsBaseConnected() seems to crash Unity at least when called here
////			else if(!SixenseInput.IsBaseConnected(0)) // TODO: *** Apparently there can be multiple bases
////				Debug.LogError(		"Could not connect with Razer Hydra! Check the USB connection.");
//		}
//		else
//		{
//			if(sixense != null)
//			{
//				sixense.gameObject.SetActive(false);
//				Debug.Log(	"Razer Hydra is disabled from RUISInputManager. Disabling object " + sixense.name
//						  + " that has the SixenseInput script.");
//			}
//		}

        DisableUnneededMoveWands();

        DisableUnneededRazerHydraWands();
    }
	void Awake () {
		Cursor.visible = true; // Incase cursor was hidden in previous scene
		
		// Check if calibration settings were chosen on previous scene
		ruisNGUIMenu = FindObjectOfType(typeof(RUISMenuNGUI)) as RUISMenuNGUI;
		
		if(ruisNGUIMenu != null) 
		{
			if(ruisNGUIMenu.currentMenuState == RUISMenuNGUI.RUISMenuStates.calibration) 
			{
				numberOfSamplesToTake = 50;
				samplesPerSecond = 5;
				switch(ruisNGUIMenu.calibrationDropDownSelection)  
				{
					case "Kinect - Kinect2":
						firstDevice = RUISDevice.Kinect_1;
						secondDevice = RUISDevice.Kinect_2;
					break;
					case "Kinect - PSMove":
						firstDevice = RUISDevice.Kinect_1;
						secondDevice = RUISDevice.PS_Move;
					break;
					case "Kinect 2 - PSMove":
						firstDevice = RUISDevice.Kinect_2;
						secondDevice = RUISDevice.PS_Move;
					break;
					case "Kinect 2 - Oculus DK2":
						firstDevice = RUISDevice.Kinect_2;
						secondDevice = RUISDevice.Oculus_DK2;
					break;
					case "Kinect - Oculus DK2":
						firstDevice = RUISDevice.Kinect_1;
						secondDevice = RUISDevice.Oculus_DK2;
					break;
					case "PSMove - Oculus DK2":
						firstDevice = RUISDevice.PS_Move;
						secondDevice = RUISDevice.Oculus_DK2;
					break;
					case "Kinect floor data":
						firstDevice = RUISDevice.Kinect_1;
						secondDevice = RUISDevice.Kinect_1;
					break;
					case "Kinect 2 floor data":
						firstDevice = RUISDevice.Kinect_2;
						secondDevice = RUISDevice.Kinect_2;
					break;
					default:
						firstDevice = RUISDevice.Null;
						secondDevice = RUISDevice.Null;
					break;
				}
			}
		}
	
		// Init scene objects
		this.floorPlane = GameObject.Find ("Floor");
		this.calibrationPhaseObjects = GameObject.Find("CalibrationPhase");
		this.calibrationResultPhaseObjects = GameObject.Find("ResultPhase");
		this.depthViews = GameObject.Find ("Depth views");
		this.deviceModels = GameObject.Find ("Device models");
		this.icons = GameObject.Find ("Icons");
		
		upperText = GameObject.Find ("Upper Text").GetComponent<GUIText>();
		lowerText = GameObject.Find ("Lower Text").GetComponent<GUIText>();
		
		skeletonController = FindObjectOfType(typeof(RUISSkeletonController)) as RUISSkeletonController;
		coordinateSystem  = FindObjectOfType(typeof(RUISCoordinateSystem)) as RUISCoordinateSystem;
		
		// Pass variables and objects to calibrationProcess
		calibrationProcessSettings = new RUISCalibrationProcessSettings();
		calibrationProcessSettings.xmlFilename = xmlFilename;
		calibrationProcessSettings.numberOfSamplesToTake = numberOfSamplesToTake;
		calibrationProcessSettings.numberOfSamplesPerSecond = samplesPerSecond;
		calibrationProcessSettings.calibrationCubePrefab = this.sampleCube;
		calibrationProcessSettings.calibrationSpherePrefab = this.sampleSphere;
		calibrationProcessSettings.calibrationPhaseObjects = this.calibrationPhaseObjects;
		calibrationProcessSettings.calibrationResultPhaseObjects = this.calibrationResultPhaseObjects;
		calibrationProcessSettings.deviceModelObjects = deviceModels;
		calibrationProcessSettings.depthViewObjects = depthViews;
		calibrationProcessSettings.iconObjects = icons;
	}
	public RUISKinect2ToKinectCalibrationProcess(RUISCalibrationProcessSettings calibrationSettings) {
		
		this.inputDevice1 = RUISDevice.Kinect_2;
		this.inputDevice2 = RUISDevice.Kinect_1;
		
		this.numberOfSamplesToTake = calibrationSettings.numberOfSamplesToTake;
		this.numberOfSamplesPerSecond = calibrationSettings.numberOfSamplesPerSecond;
		
		trackingIDs = new trackedBody[6]; 
		for(int y = 0; y < trackingIDs.Length; y++) {
			trackingIDs[y] = new trackedBody(-1, false, 1);
		}
		
		kinectSelection = MonoBehaviour.FindObjectOfType(typeof(NIPlayerManagerCOMSelection)) as NIPlayerManagerCOMSelection;
		settingsManager = MonoBehaviour.FindObjectOfType(typeof(OpenNISettingsManager)) as OpenNISettingsManager;
		inputManager = MonoBehaviour.FindObjectOfType(typeof(RUISInputManager)) as RUISInputManager;
		coordinateSystem = MonoBehaviour.FindObjectOfType(typeof(RUISCoordinateSystem)) as RUISCoordinateSystem;
		kinect2SourceManager = MonoBehaviour.FindObjectOfType(typeof(Kinect2SourceManager)) as Kinect2SourceManager;
		
		this.timeSinceScriptStart = 0;
		this.timeBetweenSamples = 1 / (float)numberOfSamplesPerSecond;
		
		// Limit sample rate
		if(this.timeBetweenSamples < 0.1f) {
			this.timeBetweenSamples = 0.1f;
		}
		
		calibrationSpheres = new List<GameObject>();
		
		samples_Kinect1 = new List<Vector3>();
		samples_Kinect2 = new List<Vector3>();
		
		this.calibrationCube = calibrationSettings.calibrationCubePrefab;
		this.calibrationSphere = calibrationSettings.calibrationSpherePrefab;
		this.calibrationPhaseObjects = calibrationSettings.calibrationPhaseObjects;
		this.calibrationResultPhaseObjects = calibrationSettings.calibrationResultPhaseObjects;
		
		this.deviceModelObjects = calibrationSettings.deviceModelObjects;
		this.depthViewObjects = calibrationSettings.depthViewObjects;
		this.iconObjects = calibrationSettings.iconObjects;
		
		if(GameObject.Find ("PSMoveWand") != null)
			GameObject.Find ("PSMoveWand").SetActive(false);
		
		// Models
		this.kinect1ModelObject = GameObject.Find ("KinectCamera");
		this.kinect2ModelObject = GameObject.Find ("Kinect2Camera");
		
		RUISSkeletonController skeletonController = Component.FindObjectOfType<RUISSkeletonController>();
		Transform rightHand = null;
		if(skeletonController)
			rightHand = skeletonController.rightHand;
		FixedFollowTransform followTransform = Component.FindObjectOfType<FixedFollowTransform>();
		if(followTransform && rightHand)
			followTransform.transformToFollow = rightHand;
		
		// Depth view
		this.depthView = GameObject.Find ("KinectDepthView");
		this.depthView2 = GameObject.Find ("Kinect2DepthView");
		// Icons
		this.Kinect1Icon = GameObject.Find ("Kinect Icon");
		this.Kinect2Icon = GameObject.Find ("Kinect2 Icon");

		this.floorPlane = GameObject.Find ("Floor");

		if(this.Kinect1Icon && this.Kinect1Icon.GetComponent<GUITexture>())
			this.Kinect1Icon.GetComponent<GUITexture>().pixelInset = new Rect(5.1f, 10.0f, 70.0f, 70.0f);
		
		foreach (Transform child in this.deviceModelObjects.transform)
		{
			child.gameObject.SetActive(false);
		}
		
		foreach (Transform child in this.depthViewObjects.transform)
		{
			child.gameObject.SetActive(false);
		}
		
		foreach (Transform child in this.iconObjects.transform)
		{
			child.gameObject.SetActive(false);
		}
		
		if(this.kinect1ModelObject)
			this.kinect1ModelObject.SetActive(true);
		if(this.kinect2ModelObject)
			this.kinect2ModelObject.SetActive(true);
		if(this.Kinect1Icon)
			this.Kinect1Icon.SetActive(true);
		if(this.Kinect2Icon)
			this.Kinect2Icon.SetActive(true);
		if(this.calibrationPhaseObjects)
			this.calibrationPhaseObjects.SetActive(true);
		if(this.calibrationResultPhaseObjects)
			this.calibrationResultPhaseObjects.SetActive(false);
		if(this.depthView)
			this.depthView.SetActive(true);
		if(this.depthView2)
			this.depthView2.SetActive(true);
		this.xmlFilename = calibrationSettings.xmlFilename;
	}
예제 #19
0
//	Quaternion kinect1PitchRotation = Quaternion.identity;

    public RUISPSMoveToOculusDK2CalibrationProcess(RUISCalibrationProcessSettings calibrationSettings)
    {
        this.inputDevice1 = RUISDevice.Oculus_DK2;
        this.inputDevice2 = RUISDevice.PS_Move;

        this.numberOfSamplesToTake    = calibrationSettings.numberOfSamplesToTake;
        this.numberOfSamplesPerSecond = calibrationSettings.numberOfSamplesPerSecond;

        psMoveWrapper    = MonoBehaviour.FindObjectOfType(typeof(PSMoveWrapper)) as PSMoveWrapper;
        inputManager     = MonoBehaviour.FindObjectOfType(typeof(RUISInputManager)) as RUISInputManager;
        coordinateSystem = MonoBehaviour.FindObjectOfType(typeof(RUISCoordinateSystem)) as RUISCoordinateSystem;


        this.timeSinceScriptStart = 0;
        this.timeBetweenSamples   = 1 / (float)numberOfSamplesPerSecond;

        // Limit sample rate
        if (this.timeBetweenSamples < 0.1f)
        {
            this.timeBetweenSamples = 0.1f;
        }

        calibrationSpheres = new List <GameObject>();

        samples_PSMove    = new List <Vector3>();
        samples_OculusDK2 = new List <Vector3>();

        this.calibrationCube               = calibrationSettings.calibrationCubePrefab;
        this.calibrationSphere             = calibrationSettings.calibrationSpherePrefab;
        this.calibrationPhaseObjects       = calibrationSettings.calibrationPhaseObjects;
        this.calibrationResultPhaseObjects = calibrationSettings.calibrationResultPhaseObjects;

        this.deviceModelObjects = calibrationSettings.deviceModelObjects;
        this.depthViewObjects   = calibrationSettings.depthViewObjects;
        this.iconObjects        = calibrationSettings.iconObjects;

        this.PSMoveWandObject = GameObject.Find("PSMoveWand");
        this.mannequin        = GameObject.Find("Mannequin");

        // Models
        this.psEyeModelObject      = GameObject.Find("PS Eye");
        this.oculusDK2CameraObject = GameObject.Find("OculusDK2Camera");
        this.oculusRiftModel       = GameObject.Find("OculusRift");

        // Icons
        this.psMoveIcon    = GameObject.Find("PS Move Icon");
        this.oculusDK2Icon = GameObject.Find("OculusDK2 Icon");

//		this.floorPlane = GameObject.Find ("Floor");

        foreach (Transform child in this.deviceModelObjects.transform)
        {
            child.gameObject.SetActive(false);
        }

        foreach (Transform child in this.depthViewObjects.transform)
        {
            child.gameObject.SetActive(false);
        }

        foreach (Transform child in this.iconObjects.transform)
        {
            child.gameObject.SetActive(false);
        }

        if (this.mannequin)
        {
            this.mannequin.SetActive(false);
        }
        if (this.psEyeModelObject)
        {
            this.psEyeModelObject.SetActive(true);
        }
        if (this.PSMoveWandObject)
        {
            this.PSMoveWandObject.SetActive(true);
        }
        if (this.oculusRiftModel)
        {
            this.oculusRiftModel.SetActive(true);
        }
        if (this.oculusDK2CameraObject)
        {
            this.oculusDK2CameraObject.SetActive(true);
        }
        if (this.psMoveIcon)
        {
            this.psMoveIcon.SetActive(true);
        }
        if (this.oculusDK2Icon)
        {
            this.oculusDK2Icon.SetActive(true);
        }
        if (this.calibrationPhaseObjects)
        {
            this.calibrationPhaseObjects.SetActive(true);
        }
        if (this.calibrationResultPhaseObjects)
        {
            this.calibrationResultPhaseObjects.SetActive(false);
        }
        this.xmlFilename = calibrationSettings.xmlFilename;
    }
예제 #20
0
    void Awake()
    {
		inputManager = FindObjectOfType(typeof(RUISInputManager)) as RUISInputManager;

		playerManager = GetComponent<NIPlayerManager>();
		RUISKinect2Data = GetComponent<RUISKinect2Data>();

		if (!inputManager.enableKinect) playerManager.enabled = false;
		if (!inputManager.enableKinect2) RUISKinect2Data.enabled = false;

        if (coordinateSystem == null)
        {
            coordinateSystem = FindObjectOfType(typeof(RUISCoordinateSystem)) as RUISCoordinateSystem;
        }

		for (int x = 0; x < 3; x++) // Kinect 1, Kinect 2, Custom Tracker
		{
			for (int i = 0; i < 6; i++) 
			{
				skeletons [x, i] = new Skeleton ();

				// HACK  for filtering Kinect 2 arm rotations
				if(x == kinect2SensorID)
				{
					for(int k = 0; k < skeletons[x, i].filterRot.Length; ++k)
					{
						skeletons[x, i].filterRot[k] = new KalmanFilteredRotation();
						skeletons[x, i].filterRot[k].skipIdenticalMeasurements = true;
						skeletons[x, i].filterRot[k].rotationNoiseCovariance = skeletons[x, i].rotationNoiseCovariance;
						skeletons[x, i].previousRotation[k] = Quaternion.identity;
					}
				}
			}
		}
		
		isNewKinect2Frame = false;
		timeSinceLastKinect2Frame = 0;
    }
 void Start()
 {
     coordinateSystem = FindObjectOfType(typeof(RUISCoordinateSystem)) as RUISCoordinateSystem;
 }
예제 #22
0
 void Start()
 {
     coordinateSystem = MonoBehaviour.FindObjectOfType(typeof(RUISCoordinateSystem)) as RUISCoordinateSystem;
 }
예제 #23
0
    void Awake()
    {
        playerManager = GetComponent<NIPlayerManager>();

        if (coordinateSystem == null)
        {
            coordinateSystem = FindObjectOfType(typeof(RUISCoordinateSystem)) as RUISCoordinateSystem;
        }

        for (int i = 0; i < skeletons.Length; i++)
        {
            skeletons[i] = new Skeleton();
        }
    }
	public RUISKinectToPSMoveCalibrationProcess(RUISCalibrationProcessSettings calibrationSettings) {
		
		
		this.inputDevice1 = RUISDevice.Kinect_1;
		this.inputDevice2 = RUISDevice.PS_Move;
		
		this.numberOfSamplesToTake = calibrationSettings.numberOfSamplesToTake;
		this.numberOfSamplesPerSecond = calibrationSettings.numberOfSamplesPerSecond;
		
		
		kinectSelection = MonoBehaviour.FindObjectOfType(typeof(NIPlayerManagerCOMSelection)) as NIPlayerManagerCOMSelection;
		settingsManager = MonoBehaviour.FindObjectOfType(typeof(OpenNISettingsManager)) as OpenNISettingsManager;
		psMoveWrapper = MonoBehaviour.FindObjectOfType(typeof(PSMoveWrapper)) as PSMoveWrapper;
		inputManager = MonoBehaviour.FindObjectOfType(typeof(RUISInputManager)) as RUISInputManager;
		coordinateSystem = MonoBehaviour.FindObjectOfType(typeof(RUISCoordinateSystem)) as RUISCoordinateSystem;
		
		this.timeSinceScriptStart = 0;
		this.timeBetweenSamples = 1 / (float)numberOfSamplesPerSecond;
		
		// Limit sample rate
		if(this.timeBetweenSamples < 0.1f) {
			this.timeBetweenSamples = 0.1f;
		}
		
		calibrationSpheres = new List<GameObject>();
		
		samples_PSMove = new List<Vector3>();
		samples_Kinect = new List<Vector3>();
		
		this.calibrationCube = calibrationSettings.calibrationCubePrefab;
		this.calibrationSphere = calibrationSettings.calibrationSpherePrefab;
		this.calibrationPhaseObjects = calibrationSettings.calibrationPhaseObjects;
		this.calibrationResultPhaseObjects = calibrationSettings.calibrationResultPhaseObjects;
		
		this.deviceModelObjects = calibrationSettings.deviceModelObjects;
		this.depthViewObjects = calibrationSettings.depthViewObjects;
		this.iconObjects = calibrationSettings.iconObjects;
		
		this.PSMoveWandObject = GameObject.Find ("PSMoveWand");
				
		// Models
		this.psEyeModelObject = GameObject.Find ("PS Eye");
		this.kinect1ModelObject = GameObject.Find ("KinectCamera");
		
		// Depth view
		this.depthView = GameObject.Find ("KinectDepthView");
		
		// Icons
		this.psMoveIcon = GameObject.Find ("PS Move Icon");
		this.KinectIcon = GameObject.Find ("Kinect Icon");
		
		this.floorPlane = GameObject.Find ("Floor");
		
		foreach (Transform child in this.deviceModelObjects.transform)
		{
			child.gameObject.SetActive(false);
		}
		
		foreach (Transform child in this.depthViewObjects.transform)
		{
			child.gameObject.SetActive(false);
		}
		
		foreach (Transform child in this.iconObjects.transform)
		{
			child.gameObject.SetActive(false);
		}
		
		if(this.psEyeModelObject)
			this.psEyeModelObject.SetActive(true);
		if(this.PSMoveWandObject)
			this.PSMoveWandObject.SetActive(true);
		if(this.kinect1ModelObject)
			this.kinect1ModelObject.SetActive(true);
		if(this.psMoveIcon)
			this.psMoveIcon.SetActive(true);
		if(this.KinectIcon)
			this.KinectIcon.SetActive(true);
		if(this.calibrationPhaseObjects)
			this.calibrationPhaseObjects.SetActive(true);
		if(this.calibrationResultPhaseObjects)
			this.calibrationResultPhaseObjects.SetActive(false);
		if(this.depthView)
			this.depthView.SetActive(true);
		this.xmlFilename = calibrationSettings.xmlFilename;
	}
예제 #25
0
	void Awake()
	{
		coordinateSystem = MonoBehaviour.FindObjectOfType(typeof(RUISCoordinateSystem)) as RUISCoordinateSystem;
		localPosition = Vector3.zero;
		localRotation = Quaternion.identity;
		rawRotation = Quaternion.identity;
		
		filterPos = new KalmanFilter();
		filterPos.initialize(3,3);
		filterPos.skipIdenticalMeasurements = true;
		//		filterRot = new KalmanFilter();
		//		filterRot.initialize(4,4);
		
		// Mobile Razer Hydra base filtering
		hydraBaseFilterPos = new KalmanFilter();
		hydraBaseFilterPos.initialize(3,3);
		hydraBaseFilterPos.skipIdenticalMeasurements = true;
		//		hydraBaseFilterRot = new KalmanFilter();
		//		hydraBaseFilterRot.initialize(4,4);
		
		filterRot.skipIdenticalMeasurements = true;
		
		// Yaw Drift Corrector invocations in Awake()
		filterDrift = new KalmanFilter();
		filterDrift.initialize(2,2);
		
		transform.localPosition = defaultPosition;
		eyeCenterPosition = defaultPosition;
		measuredHeadPosition = defaultPosition;
		
		hydraBasePosition = new Vector3(0, 0, 0);
		hydraBaseRotation = Quaternion.identity;
		
		ovrCameraRig = GetComponentInChildren<OVRCameraRig>();
		if(ovrCameraRig != null && OVRManager.display != null && OVRManager.display.isPresent)
		{
			useOculusRiftRotation = true;
		}
		else
		{
			useOculusRiftRotation = false;
		}
		
		// Enforce rotation settings if rotation source is set to be same as position source
		if (!pickRotationSource) 
		{
			switch (headPositionInput)
			{	
			case HeadPositionSource.Kinect1:
			{
				headRotationInput = HeadRotationSource.Kinect1;
				rotationPlayerID = positionPlayerID;
				rotationJoint = positionJoint;
				break;
			}
			case HeadPositionSource.Kinect2:
			{
				headRotationInput = HeadRotationSource.Kinect2;
				rotationPlayerID = positionPlayerID;
				rotationJoint = positionJoint;
				break;
			}
			case HeadPositionSource.PSMove:
			{
				headRotationInput = HeadRotationSource.PSMove;
				rotationPSMoveID = positionPSMoveID;
				break;
			}
			case HeadPositionSource.RazerHydra:
			{
				headRotationInput = HeadRotationSource.RazerHydra;
				rotationRazerID = positionRazerID;
				break;
			}
			case HeadPositionSource.InputTransform:
			{
				headRotationInput = HeadRotationSource.InputTransform;
				rotationInput = positionInput;
				break;
			}
			case HeadPositionSource.None:
			{
				headRotationInput = HeadRotationSource.None;
				break;
			}
			}
		}
		
		filterPosition = false;
	}
예제 #26
0
	void Start() 
	{
		coordinateSystem = MonoBehaviour.FindObjectOfType(typeof(RUISCoordinateSystem)) as RUISCoordinateSystem;
	}
    public RUISKinect2ToPSMoveCalibrationProcess(RUISCalibrationProcessSettings calibrationSettings)
    {
        this.inputDevice1 = RUISDevice.Kinect_2;
        this.inputDevice2 = RUISDevice.PS_Move;

        this.numberOfSamplesToTake = calibrationSettings.numberOfSamplesToTake;
        this.numberOfSamplesPerSecond = calibrationSettings.numberOfSamplesPerSecond;

        trackingIDs = new trackedBody[6];
        for(int y = 0; y < trackingIDs.Length; y++) {
            trackingIDs[y] = new trackedBody(-1, false, 1);
        }

        psMoveWrapper = MonoBehaviour.FindObjectOfType(typeof(PSMoveWrapper)) as PSMoveWrapper;
        inputManager = MonoBehaviour.FindObjectOfType(typeof(RUISInputManager)) as RUISInputManager;
        coordinateSystem = MonoBehaviour.FindObjectOfType(typeof(RUISCoordinateSystem)) as RUISCoordinateSystem;
        kinect2SourceManager = MonoBehaviour.FindObjectOfType(typeof(Kinect2SourceManager)) as Kinect2SourceManager;

        this.timeSinceScriptStart = 0;
        this.timeBetweenSamples = 1 / (float)numberOfSamplesPerSecond;

        // Limit sample rate
        if(this.timeBetweenSamples < 0.1f) {
            this.timeBetweenSamples = 0.1f;
        }

        calibrationSpheres = new List<GameObject>();

        samples_PSMove = new List<Vector3>();
        samples_Kinect2 = new List<Vector3>();

        this.calibrationCube = calibrationSettings.calibrationCubePrefab;
        this.calibrationSphere = calibrationSettings.calibrationSpherePrefab;
        this.calibrationPhaseObjects = calibrationSettings.calibrationPhaseObjects;
        this.calibrationResultPhaseObjects = calibrationSettings.calibrationResultPhaseObjects;

        this.deviceModelObjects = calibrationSettings.deviceModelObjects;
        this.depthViewObjects = calibrationSettings.depthViewObjects;
        this.iconObjects = calibrationSettings.iconObjects;

        this.PSMoveWandObject = GameObject.Find ("PSMoveWand");

        // Models
        this.psEyeModelObject = GameObject.Find ("PS Eye");
        this.kinect2ModelObject = GameObject.Find ("Kinect2Camera");

        // Depth view
        this.depthView = GameObject.Find ("Kinect2DepthView");

        // Icons
        this.psMoveIcon = GameObject.Find ("PS Move Icon");
        this.KinectIcon = GameObject.Find ("Kinect2 Icon");

        this.floorPlane = GameObject.Find ("Floor");

        foreach (Transform child in this.deviceModelObjects.transform)
        {
            child.gameObject.SetActive(false);
        }

        foreach (Transform child in this.depthViewObjects.transform)
        {
            child.gameObject.SetActive(false);
        }

        foreach (Transform child in this.iconObjects.transform)
        {
            child.gameObject.SetActive(false);
        }

        if(this.psEyeModelObject)
            this.psEyeModelObject.SetActive(true);
        if(this.PSMoveWandObject)
            this.PSMoveWandObject.SetActive(true);
        if(this.kinect2ModelObject)
            this.kinect2ModelObject.SetActive(true);
        if(this.psMoveIcon)
            this.psMoveIcon.SetActive(true);
        if(this.KinectIcon)
            this.KinectIcon.SetActive(true);
        if(this.calibrationPhaseObjects)
            this.calibrationPhaseObjects.SetActive(true);
        if(this.calibrationResultPhaseObjects)
            this.calibrationResultPhaseObjects.SetActive(false);
        if(this.depthView)
            this.depthView.SetActive(true);
        this.xmlFilename = calibrationSettings.xmlFilename;
    }
예제 #28
0
    public RUISKinectToOculusDK2CalibrationProcess(RUISCalibrationProcessSettings calibrationSettings)
    {
        this.inputDevice1 = RUISDevice.Oculus_DK2;
        this.inputDevice2 = RUISDevice.Kinect_1;

        this.numberOfSamplesToTake    = calibrationSettings.numberOfSamplesToTake;
        this.numberOfSamplesPerSecond = calibrationSettings.numberOfSamplesPerSecond;

        trackingIDs = new trackedBody[6];
        for (int y = 0; y < trackingIDs.Length; y++)
        {
            trackingIDs[y] = new trackedBody(-1, false, 1);
        }

        inputManager     = MonoBehaviour.FindObjectOfType(typeof(RUISInputManager)) as RUISInputManager;
        coordinateSystem = MonoBehaviour.FindObjectOfType(typeof(RUISCoordinateSystem)) as RUISCoordinateSystem;
        kinectSelection  = MonoBehaviour.FindObjectOfType(typeof(NIPlayerManagerCOMSelection)) as NIPlayerManagerCOMSelection;
        settingsManager  = MonoBehaviour.FindObjectOfType(typeof(OpenNISettingsManager)) as OpenNISettingsManager;

        this.timeSinceScriptStart = 0;
        this.timeBetweenSamples   = 1 / (float)numberOfSamplesPerSecond;

        // Limit sample rate
        if (this.timeBetweenSamples < 0.1f)
        {
            this.timeBetweenSamples = 0.1f;
        }

        calibrationSpheres = new List <GameObject>();

        samples_Kinect1   = new List <Vector3>();
        samples_OculusDK2 = new List <Vector3>();

        this.calibrationCube               = calibrationSettings.calibrationCubePrefab;
        this.calibrationSphere             = calibrationSettings.calibrationSpherePrefab;
        this.calibrationPhaseObjects       = calibrationSettings.calibrationPhaseObjects;
        this.calibrationResultPhaseObjects = calibrationSettings.calibrationResultPhaseObjects;

        this.deviceModelObjects = calibrationSettings.deviceModelObjects;
        this.depthViewObjects   = calibrationSettings.depthViewObjects;
        this.iconObjects        = calibrationSettings.iconObjects;


        if (GameObject.Find("PSMoveWand") != null)
        {
            GameObject.Find("PSMoveWand").SetActive(false);
        }

        // Models
        this.oculusDK2CameraObject = GameObject.Find("OculusDK2Camera");
        this.kinect1ModelObject    = GameObject.Find("KinectCamera");
        this.oculusRiftModel       = GameObject.Find("OculusRift");

        FixedFollowTransform followTransform = Component.FindObjectOfType <FixedFollowTransform>();

        if (followTransform && this.oculusRiftModel)
        {
            followTransform.transformToFollow = this.oculusRiftModel.transform;
        }

        // Depth view
        this.depthView = GameObject.Find("KinectDepthView");

        // Icons
        this.oculusDK2Icon = GameObject.Find("OculusDK2 Icon");
        this.kinectIcon    = GameObject.Find("Kinect Icon");

        this.floorPlane = GameObject.Find("Floor");

        if (this.oculusDK2Icon && this.oculusDK2Icon.GetComponent <GUITexture>())
        {
            this.oculusDK2Icon.GetComponent <GUITexture>().pixelInset = new Rect(5.1f, 10.0f, 70.0f, 70.0f);
        }

        foreach (Transform child in this.deviceModelObjects.transform)
        {
            child.gameObject.SetActive(false);
        }

        foreach (Transform child in this.depthViewObjects.transform)
        {
            child.gameObject.SetActive(false);
        }

        foreach (Transform child in this.iconObjects.transform)
        {
            child.gameObject.SetActive(false);
        }

        if (this.oculusDK2CameraObject)
        {
            this.oculusDK2CameraObject.SetActive(true);
        }
        if (this.kinect1ModelObject)
        {
            this.kinect1ModelObject.SetActive(true);
        }
        if (this.oculusRiftModel)
        {
            this.oculusRiftModel.SetActive(true);
        }
        if (this.oculusDK2Icon)
        {
            this.oculusDK2Icon.SetActive(true);
        }
        if (this.kinectIcon)
        {
            this.kinectIcon.SetActive(true);
        }
        if (this.calibrationPhaseObjects)
        {
            this.calibrationPhaseObjects.SetActive(true);
        }
        if (this.calibrationResultPhaseObjects)
        {
            this.calibrationResultPhaseObjects.SetActive(false);
        }
        if (this.depthView)
        {
            this.depthView.SetActive(true);
        }
        this.xmlFilename = calibrationSettings.xmlFilename;
    }
    public RUISKinectToPSMoveCalibrationProcess(RUISCalibrationProcessSettings calibrationSettings)
    {
        this.inputDevice1 = RUISDevice.Kinect_1;
        this.inputDevice2 = RUISDevice.PS_Move;

        this.numberOfSamplesToTake    = calibrationSettings.numberOfSamplesToTake;
        this.numberOfSamplesPerSecond = calibrationSettings.numberOfSamplesPerSecond;


        kinectSelection  = MonoBehaviour.FindObjectOfType(typeof(NIPlayerManagerCOMSelection)) as NIPlayerManagerCOMSelection;
        settingsManager  = MonoBehaviour.FindObjectOfType(typeof(OpenNISettingsManager)) as OpenNISettingsManager;
        psMoveWrapper    = MonoBehaviour.FindObjectOfType(typeof(PSMoveWrapper)) as PSMoveWrapper;
        inputManager     = MonoBehaviour.FindObjectOfType(typeof(RUISInputManager)) as RUISInputManager;
        coordinateSystem = MonoBehaviour.FindObjectOfType(typeof(RUISCoordinateSystem)) as RUISCoordinateSystem;

        this.timeSinceScriptStart = 0;
        this.timeBetweenSamples   = 1 / (float)numberOfSamplesPerSecond;

        // Limit sample rate
        if (this.timeBetweenSamples < 0.1f)
        {
            this.timeBetweenSamples = 0.1f;
        }

        calibrationSpheres = new List <GameObject>();

        samples_PSMove = new List <Vector3>();
        samples_Kinect = new List <Vector3>();

        this.calibrationCube               = calibrationSettings.calibrationCubePrefab;
        this.calibrationSphere             = calibrationSettings.calibrationSpherePrefab;
        this.calibrationPhaseObjects       = calibrationSettings.calibrationPhaseObjects;
        this.calibrationResultPhaseObjects = calibrationSettings.calibrationResultPhaseObjects;

        this.deviceModelObjects = calibrationSettings.deviceModelObjects;
        this.depthViewObjects   = calibrationSettings.depthViewObjects;
        this.iconObjects        = calibrationSettings.iconObjects;

        this.PSMoveWandObject = GameObject.Find("PSMoveWand");

        // Models
        this.psEyeModelObject   = GameObject.Find("PS Eye");
        this.kinect1ModelObject = GameObject.Find("KinectCamera");

        // Depth view
        this.depthView = GameObject.Find("KinectDepthView");

        // Icons
        this.psMoveIcon = GameObject.Find("PS Move Icon");
        this.KinectIcon = GameObject.Find("Kinect Icon");

        this.floorPlane = GameObject.Find("Floor");

        foreach (Transform child in this.deviceModelObjects.transform)
        {
            child.gameObject.SetActive(false);
        }

        foreach (Transform child in this.depthViewObjects.transform)
        {
            child.gameObject.SetActive(false);
        }

        foreach (Transform child in this.iconObjects.transform)
        {
            child.gameObject.SetActive(false);
        }

        if (this.psEyeModelObject)
        {
            this.psEyeModelObject.SetActive(true);
        }
        if (this.PSMoveWandObject)
        {
            this.PSMoveWandObject.SetActive(true);
        }
        if (this.kinect1ModelObject)
        {
            this.kinect1ModelObject.SetActive(true);
        }
        if (this.psMoveIcon)
        {
            this.psMoveIcon.SetActive(true);
        }
        if (this.KinectIcon)
        {
            this.KinectIcon.SetActive(true);
        }
        if (this.calibrationPhaseObjects)
        {
            this.calibrationPhaseObjects.SetActive(true);
        }
        if (this.calibrationResultPhaseObjects)
        {
            this.calibrationResultPhaseObjects.SetActive(false);
        }
        if (this.depthView)
        {
            this.depthView.SetActive(true);
        }
        this.xmlFilename = calibrationSettings.xmlFilename;
    }
예제 #30
0
    public static bool ImportInputManager(RUISInputManager inputManager, RUISCoordinateSystem coordinateSystem, string filename, TextAsset xmlSchema)
    {
        XmlDocument xmlDoc = XMLUtil.LoadAndValidateXml(filename, xmlSchema);

        if (xmlDoc == null)
        {
            return(false);
        }

        XmlNode psMoveNode = xmlDoc.GetElementsByTagName("PSMoveSettings").Item(0);

        inputManager.enablePSMove                    = bool.Parse(psMoveNode.SelectSingleNode("enabled").Attributes["value"].Value);
        inputManager.PSMoveIP                        = psMoveNode.SelectSingleNode("ip").Attributes["value"].Value;
        inputManager.PSMovePort                      = int.Parse(psMoveNode.SelectSingleNode("port").Attributes["value"].Value);
        inputManager.connectToPSMoveOnStartup        = bool.Parse(psMoveNode.SelectSingleNode("autoConnect").Attributes["value"].Value);
        inputManager.enableMoveCalibrationDuringPlay = bool.Parse(psMoveNode.SelectSingleNode("enableInGameCalibration").Attributes["value"].Value);
        inputManager.amountOfPSMoveControllers       = int.Parse(psMoveNode.SelectSingleNode("maxControllers").Attributes["value"].Value);

        XmlNode kinectNode = xmlDoc.GetElementsByTagName("KinectSettings").Item(0);

        inputManager.enableKinect             = bool.Parse(kinectNode.SelectSingleNode("enabled").Attributes["value"].Value);
        inputManager.maxNumberOfKinectPlayers = int.Parse(kinectNode.SelectSingleNode("maxPlayers").Attributes["value"].Value);
        inputManager.kinectFloorDetection     = bool.Parse(kinectNode.SelectSingleNode("floorDetection").Attributes["value"].Value);
        inputManager.jumpGestureEnabled       = bool.Parse(kinectNode.SelectSingleNode("jumpGestureEnabled").Attributes["value"].Value);

        XmlNode kinect2Node = xmlDoc.GetElementsByTagName("Kinect2Settings").Item(0);

        inputManager.enableKinect2 = bool.Parse(kinect2Node.SelectSingleNode("enabled").Attributes["value"].Value);

        XmlNode razerNode = xmlDoc.GetElementsByTagName("RazerSettings").Item(0);

        inputManager.enableRazerHydra = bool.Parse(razerNode.SelectSingleNode("enabled").Attributes["value"].Value);

//		XmlNode riftDriftNode = xmlDoc.GetElementsByTagName("OculusDriftSettings").Item(0);
//		string magnetometerMode = riftDriftNode.SelectSingleNode("magnetometerDriftCorrection").Attributes["value"].Value;
//		inputManager.riftMagnetometerMode = (RUISInputManager.RiftMagnetometer)System.Enum.Parse(typeof(RUISInputManager.RiftMagnetometer), magnetometerMode);
//		inputManager.kinectDriftCorrectionPreferred = bool.Parse(riftDriftNode.SelectSingleNode("kinectDriftCorrectionIfAvailable").Attributes["value"].Value);

        XmlNode coordinateSystemNode = xmlDoc.GetElementsByTagName("CoordinateSystemSettings").Item(0);

        if (coordinateSystemNode != null)
        {
            if (coordinateSystemNode.SelectSingleNode("useMasterCoordinateSystem") != null)
            {
                coordinateSystem.applyToRootCoordinates = bool.Parse(coordinateSystemNode.SelectSingleNode("useMasterCoordinateSystem").Attributes["value"].Value);
            }
            if (coordinateSystemNode.SelectSingleNode("masterCoordinateSystemSensor") != null)
            {
                string masterDevice = coordinateSystemNode.SelectSingleNode("masterCoordinateSystemSensor").Attributes["value"].Value;
                coordinateSystem.rootDevice = (RUISDevice)System.Enum.Parse(typeof(RUISDevice), masterDevice);
            }
            if (coordinateSystemNode.SelectSingleNode("switchMasterToAvailableSensor") != null)
            {
                coordinateSystem.switchToAvailableDevice = bool.Parse(coordinateSystemNode.SelectSingleNode("switchMasterToAvailableSensor").Attributes["value"].Value);
            }
            if (coordinateSystemNode.SelectSingleNode("setKinectOriginToFloor") != null)
            {
                coordinateSystem.setKinectOriginToFloor = bool.Parse(coordinateSystemNode.SelectSingleNode("setKinectOriginToFloor").Attributes["value"].Value);
            }
            if (coordinateSystemNode.SelectSingleNode("coordinateSystemYRotationOffset") != null)
            {
                coordinateSystem.yawOffset = float.Parse(coordinateSystemNode.SelectSingleNode("coordinateSystemYRotationOffset").Attributes["value"].Value);
            }

            if (coordinateSystemNode.SelectSingleNode("coordinateSystemLocationOffset") != null)
            {
                XmlNode translationElement = coordinateSystemNode.SelectSingleNode("coordinateSystemLocationOffset");
                float   x = float.Parse(translationElement.Attributes["x"].Value);
                float   y = float.Parse(translationElement.Attributes["y"].Value);
                float   z = float.Parse(translationElement.Attributes["z"].Value);
                coordinateSystem.positionOffset = new Vector3(x, y, z);
            }
        }

        return(true);
    }
예제 #31
0
 private IEnumerator attemptUpdatingFloorNormal()
 {
     yield return new WaitForSeconds(5.0f);
     if(kinectFloorDetection)
     {
         coordinateSystem = FindObjectOfType(typeof(RUISCoordinateSystem)) as RUISCoordinateSystem;
         if (!coordinateSystem)
         {
             Debug.LogError("Could not find coordinate system!");
         }
         else if(sceneAnalyzer == null)
             Debug.LogError("Failed to access OpenNI sceneAnalyzer!");
         else
         {
             Debug.Log ("Updating Kinect floor normal");
             updateKinectFloorData();
         }
     }
 }
    void Start()
    {
        colliding = false;
        grounded = false;

        // Second substitution, because RUISKinectAndMecanimCombiner might have already erased the original one and re-created it
        skeletonController = gameObject.GetComponentInChildren<RUISSkeletonController>();
        if(skeletonController)
        {
            bodyParts.Add(skeletonController.leftFoot);
            bodyParts.Add(skeletonController.rightFoot);
            kinectPlayerId = skeletonController.playerId;
            bodyTrackingDeviceID = skeletonController.bodyTrackingDeviceID;
        }
        else
        {
            Debug.LogError(  "RUISCharacterController script in game object '" + gameObject.name
                           + "' did not find RUISSkeletonController component from it's child objects!");
        }

        coordinateSystem = FindObjectOfType(typeof(RUISCoordinateSystem)) as RUISCoordinateSystem;

        if(stabilizingCollider)
        {
            colliderComponent = stabilizingCollider.gameObject.GetComponent<Collider>();
            if(colliderComponent)
            {
                if(    characterPivotType == CharacterPivotType.KinectHead
                    || characterPivotType == CharacterPivotType.KinectTorso)
                {
                    if(coordinateSystem && inputManager.enableKinect && !coordinateSystem.setKinectOriginToFloor)
                        Debug.LogWarning("It is best to enable 'setKinectOriginToFloor' from RUISCoordinateSystem " +
                                         "when using Kinect and RUISCharacterController script.");
                }

                if(colliderComponent.material)
                    originalMaterial = colliderComponent.material;
                else
                {
                    colliderComponent.material = new PhysicMaterial();
                    originalMaterial = colliderComponent.material;
                }

                if(dynamicMaterial == null)
                {
                    dynamicMaterial = new PhysicMaterial();

                    dynamicMaterial.dynamicFriction = 0;
                    dynamicMaterial.staticFriction = 0;
                    dynamicMaterial.frictionCombine = PhysicMaterialCombine.Minimum;

                    if(colliderComponent.material)
                    {
                        dynamicMaterial.bounceCombine = originalMaterial.bounceCombine;
                        dynamicMaterial.bounciness = originalMaterial.bounciness;
        //						dynamicMaterial.staticFriction2 = originalMaterial.staticFriction2;
        //						dynamicMaterial.dynamicFriction2 = originalMaterial.dynamicFriction2;
        //						dynamicMaterial.frictionDirection2 = originalMaterial.frictionDirection2;
                    }
                }
            }
        }
        if((   characterPivotType == CharacterPivotType.KinectHead
            || characterPivotType == CharacterPivotType.KinectTorso)
            && (skeletonController && skeletonController.playerId != kinectPlayerId))
            Debug.LogError(  "The 'Kinect Player Id' variable in RUISCharacterController script in gameObject '" + gameObject.name
                           + "is different from the Kinect Player Id of the RUISSkeletonController script (located in child "
                           + "object '" + skeletonController.gameObject.name + "). Make sure that these two values are "
                           + "the same.");

        //#if UNITY_EDITOR
        //if(UnityEditorInternal.InternalEditorUtility.HasPro())
        //#endif
        {
            try
            {
                bool isRiftConnected = false;
                if(OVRManager.display != null)
                    isRiftConnected = OVRManager.display.isPresent;
                if(OVRManager.capiHmd != null)
                    ovrHmdVersion = OVRManager.capiHmd.GetDesc().Type;

                if(useOculusPositionalTracking && ovrHmdVersion == Ovr.HmdType.DK1 || ovrHmdVersion == Ovr.HmdType.DKHD || ovrHmdVersion == Ovr.HmdType.None)
                {
                    Debug.LogError("Can't use Oculus Rift's tracked position as a pivot with Oculus Rift " + ovrHmdVersion);
                    useOculusPositionalTracking = false;
                }

                if(useOculusPositionalTracking && !isRiftConnected)
                {
                    Debug.LogError("Can't use Oculus Rift's tracked position as a pivot because Oculus Rift is not connected.");
                    useOculusPositionalTracking = false;
                }

            }
            catch(UnityException e)
            {
                useOculusPositionalTracking = false;
                Debug.LogError(e);
            }
        }

        if(GetComponentInChildren<RUISKinectAndMecanimCombiner>())
            kinectAndMecanimCombinerExists = true;

        previousPosition = transform.position;
    }
	void Start()
	{
		coordinateSystem = FindObjectOfType(typeof(RUISCoordinateSystem)) as RUISCoordinateSystem;

		if(transform.parent)
		{
			skeletonController = transform.parent.gameObject.GetComponentInChildren(typeof(RUISSkeletonController)) as RUISSkeletonController;
			if(skeletonController)
			{
				playerId = skeletonController.playerId;
				bodyTrackingDeviceID = skeletonController.bodyTrackingDeviceID;
			}
		}

//		if(transform.parent)
//			characterController = transform.parent.GetComponent<RUISCharacterController>();

	}
예제 #34
0
    void Awake()
    {
        Cursor.visible = true;         // Incase cursor was hidden in previous scene

        // Check if calibration settings were chosen on previous scene
        ruisNGUIMenu = FindObjectOfType(typeof(RUISMenuNGUI)) as RUISMenuNGUI;

        if (ruisNGUIMenu != null)
        {
            if (ruisNGUIMenu.currentMenuState == RUISMenuNGUI.RUISMenuStates.calibration)
            {
                numberOfSamplesToTake = 50;
                samplesPerSecond      = 5;
                switch (ruisNGUIMenu.calibrationDropDownSelection)
                {
                case "Kinect - Kinect2":
                    firstDevice  = RUISDevice.Kinect_1;
                    secondDevice = RUISDevice.Kinect_2;
                    break;

                case "Kinect - PSMove":
                    firstDevice  = RUISDevice.Kinect_1;
                    secondDevice = RUISDevice.PS_Move;
                    break;

                case "Kinect 2 - PSMove":
                    firstDevice  = RUISDevice.Kinect_2;
                    secondDevice = RUISDevice.PS_Move;
                    break;

                case "Kinect 2 - Oculus DK2":
                    firstDevice  = RUISDevice.Kinect_2;
                    secondDevice = RUISDevice.Oculus_DK2;
                    break;

                case "Kinect - Oculus DK2":
                    firstDevice  = RUISDevice.Kinect_1;
                    secondDevice = RUISDevice.Oculus_DK2;
                    break;

                case "PSMove - Oculus DK2":
                    firstDevice  = RUISDevice.PS_Move;
                    secondDevice = RUISDevice.Oculus_DK2;
                    break;

                case "Kinect floor data":
                    firstDevice  = RUISDevice.Kinect_1;
                    secondDevice = RUISDevice.Kinect_1;
                    break;

                case "Kinect 2 floor data":
                    firstDevice  = RUISDevice.Kinect_2;
                    secondDevice = RUISDevice.Kinect_2;
                    break;

                default:
                    firstDevice  = RUISDevice.Null;
                    secondDevice = RUISDevice.Null;
                    break;
                }
            }
        }

        // Init scene objects
        this.floorPlane = GameObject.Find("Floor");
        this.calibrationPhaseObjects       = GameObject.Find("CalibrationPhase");
        this.calibrationResultPhaseObjects = GameObject.Find("ResultPhase");
        this.depthViews   = GameObject.Find("Depth views");
        this.deviceModels = GameObject.Find("Device models");
        this.icons        = GameObject.Find("Icons");

        upperText = GameObject.Find("Upper Text").GetComponent <GUIText>();
        lowerText = GameObject.Find("Lower Text").GetComponent <GUIText>();

        skeletonController = FindObjectOfType(typeof(RUISSkeletonController)) as RUISSkeletonController;
        coordinateSystem   = FindObjectOfType(typeof(RUISCoordinateSystem)) as RUISCoordinateSystem;

        // Pass variables and objects to calibrationProcess
        calibrationProcessSettings                               = new RUISCalibrationProcessSettings();
        calibrationProcessSettings.xmlFilename                   = xmlFilename;
        calibrationProcessSettings.numberOfSamplesToTake         = numberOfSamplesToTake;
        calibrationProcessSettings.numberOfSamplesPerSecond      = samplesPerSecond;
        calibrationProcessSettings.calibrationCubePrefab         = this.sampleCube;
        calibrationProcessSettings.calibrationSpherePrefab       = this.sampleSphere;
        calibrationProcessSettings.calibrationPhaseObjects       = this.calibrationPhaseObjects;
        calibrationProcessSettings.calibrationResultPhaseObjects = this.calibrationResultPhaseObjects;
        calibrationProcessSettings.deviceModelObjects            = deviceModels;
        calibrationProcessSettings.depthViewObjects              = depthViews;
        calibrationProcessSettings.iconObjects                   = icons;
    }
예제 #35
0
	public RUISKinect2ToPSMoveCalibrationProcess(RUISCalibrationProcessSettings calibrationSettings) {
		
		this.inputDevice1 = RUISDevice.Kinect_2;
		this.inputDevice2 = RUISDevice.PS_Move;
		
		this.numberOfSamplesToTake = calibrationSettings.numberOfSamplesToTake;
		this.numberOfSamplesPerSecond = calibrationSettings.numberOfSamplesPerSecond;
		
		trackingIDs = new trackedBody[6]; 
		for(int y = 0; y < trackingIDs.Length; y++) {
			trackingIDs[y] = new trackedBody(-1, false, 1);
		}
		
		psMoveWrapper = MonoBehaviour.FindObjectOfType(typeof(PSMoveWrapper)) as PSMoveWrapper;
		inputManager = MonoBehaviour.FindObjectOfType(typeof(RUISInputManager)) as RUISInputManager;
		coordinateSystem = MonoBehaviour.FindObjectOfType(typeof(RUISCoordinateSystem)) as RUISCoordinateSystem;
		kinect2SourceManager = MonoBehaviour.FindObjectOfType(typeof(Kinect2SourceManager)) as Kinect2SourceManager;
		
		this.timeSinceScriptStart = 0;
		this.timeBetweenSamples = 1 / (float)numberOfSamplesPerSecond;
		
		// Limit sample rate
		if(this.timeBetweenSamples < 0.1f) {
			this.timeBetweenSamples = 0.1f;
		}
		
		calibrationSpheres = new List<GameObject>();
		
		samples_PSMove = new List<Vector3>();
		samples_Kinect2 = new List<Vector3>();
		
		this.calibrationCube = calibrationSettings.calibrationCubePrefab;
		this.calibrationSphere = calibrationSettings.calibrationSpherePrefab;
		this.calibrationPhaseObjects = calibrationSettings.calibrationPhaseObjects;
		this.calibrationResultPhaseObjects = calibrationSettings.calibrationResultPhaseObjects;
		
		this.deviceModelObjects = calibrationSettings.deviceModelObjects;
		this.depthViewObjects = calibrationSettings.depthViewObjects;
		this.iconObjects = calibrationSettings.iconObjects;
		
		this.PSMoveWandObject = GameObject.Find ("PSMoveWand");
		
		// Models
		this.psEyeModelObject = GameObject.Find ("PS Eye");
		this.kinect2ModelObject = GameObject.Find ("Kinect2Camera");
		
		// Depth view
		this.depthView = GameObject.Find ("Kinect2DepthView");
		
		// Icons
		this.psMoveIcon = GameObject.Find ("PS Move Icon");
		this.KinectIcon = GameObject.Find ("Kinect2 Icon");
		
		this.floorPlane = GameObject.Find ("Floor");
		
		foreach (Transform child in this.deviceModelObjects.transform)
		{
			child.gameObject.SetActive(false);
		}
		
		foreach (Transform child in this.depthViewObjects.transform)
		{
			child.gameObject.SetActive(false);
		}
		
		foreach (Transform child in this.iconObjects.transform)
		{
			child.gameObject.SetActive(false);
		}
		
		if(this.psEyeModelObject)
			this.psEyeModelObject.SetActive(true);
		if(this.PSMoveWandObject)
			this.PSMoveWandObject.SetActive(true);
		if(this.kinect2ModelObject)
			this.kinect2ModelObject.SetActive(true);
		if(this.psMoveIcon)
			this.psMoveIcon.SetActive(true);
		if(this.KinectIcon)
			this.KinectIcon.SetActive(true);
		if(this.calibrationPhaseObjects)
			this.calibrationPhaseObjects.SetActive(true);
		if(this.calibrationResultPhaseObjects)
			this.calibrationResultPhaseObjects.SetActive(false);
		if(this.depthView)
			this.depthView.SetActive(true);
		this.xmlFilename = calibrationSettings.xmlFilename;
	}
예제 #36
0
    void Start()
    {
		coordinateSystem = FindObjectOfType(typeof(RUISCoordinateSystem)) as RUISCoordinateSystem;
		Quaternion dictionaryFloorNormal = coordinateSystem.RUISCalibrationResultsFloorPitchRotation[coordinateSystem.rootDevice];
		float dictionaryDistanceFromFloor = coordinateSystem.RUISCalibrationResultsDistanceFromFloor[coordinateSystem.rootDevice];
		Vector3 normalVector = dictionaryFloorNormal * Vector3.up;
		coordinateSystem.SetFloorNormal(normalVector, coordinateSystem.rootDevice);
		coordinateSystem.SetDistanceFromFloor(dictionaryDistanceFromFloor, coordinateSystem.rootDevice);
			
		//check whether the kinect camera is actually connected
        if (enableKinect)
        {
            OpenNISettingsManager settingsManager = FindObjectOfType(typeof(OpenNISettingsManager)) as OpenNISettingsManager;
            if (settingsManager.UserGenrator == null || !settingsManager.UserGenrator.Valid)
            {
                Debug.LogError("Could not start OpenNI! Check your Kinect connection.");
                GetComponentInChildren<RUISKinectDisabler>().KinectNotAvailable();
            }
        }

		if (!enableKinect2)
		{
			Debug.Log("Kinect 2 is disabled from RUISInputManager.");
			BodySourceManager kinect2Manager = GetComponentInChildren<BodySourceManager>();
			if(kinect2Manager)
				kinect2Manager.gameObject.SetActive(false);
		}

		if((enableKinect && kinectFloorDetection) || (enableKinect2 && kinect2FloorDetection))
			StartFloorDetection();
		
		if (enablePSMove)
        {
            RUISPSMoveWand[] controllers = GetComponentsInChildren<RUISPSMoveWand>();
            moveControllers = new RUISPSMoveWand[controllers.Length];
            foreach (RUISPSMoveWand controller in controllers)
            {
                moveControllers[controller.controllerId] = controller;
            }
        }
    }
//	Quaternion kinect1PitchRotation = Quaternion.identity;
	
	public RUISPSMoveToOculusDK2CalibrationProcess(RUISCalibrationProcessSettings calibrationSettings) {
		
		
		this.inputDevice1 = RUISDevice.Oculus_DK2;
		this.inputDevice2 = RUISDevice.PS_Move;
		
		this.numberOfSamplesToTake = calibrationSettings.numberOfSamplesToTake;
		this.numberOfSamplesPerSecond = calibrationSettings.numberOfSamplesPerSecond;
		
		psMoveWrapper = MonoBehaviour.FindObjectOfType(typeof(PSMoveWrapper)) as PSMoveWrapper;
		inputManager = MonoBehaviour.FindObjectOfType(typeof(RUISInputManager)) as RUISInputManager;
		coordinateSystem = MonoBehaviour.FindObjectOfType(typeof(RUISCoordinateSystem)) as RUISCoordinateSystem;
		
		
		this.timeSinceScriptStart = 0;
		this.timeBetweenSamples = 1 / (float)numberOfSamplesPerSecond;
		
		// Limit sample rate
		if(this.timeBetweenSamples < 0.1f) {
			this.timeBetweenSamples = 0.1f;
		}
		
		calibrationSpheres = new List<GameObject>();
		
		samples_PSMove = new List<Vector3>();
		samples_OculusDK2 = new List<Vector3>();
		
		this.calibrationCube = calibrationSettings.calibrationCubePrefab;
		this.calibrationSphere = calibrationSettings.calibrationSpherePrefab;
		this.calibrationPhaseObjects = calibrationSettings.calibrationPhaseObjects;
		this.calibrationResultPhaseObjects = calibrationSettings.calibrationResultPhaseObjects;
		
		this.deviceModelObjects = calibrationSettings.deviceModelObjects;
		this.depthViewObjects = calibrationSettings.depthViewObjects;
		this.iconObjects = calibrationSettings.iconObjects;
		
		this.PSMoveWandObject = GameObject.Find ("PSMoveWand");
		this.mannequin = GameObject.Find ("Mannequin");		
		
		// Models
		this.psEyeModelObject = GameObject.Find ("PS Eye");
		this.oculusDK2CameraObject = GameObject.Find ("OculusDK2Camera");
		this.oculusRiftModel = GameObject.Find ("OculusRift");
		
		// Icons
		this.psMoveIcon = GameObject.Find ("PS Move Icon");
		this.oculusDK2Icon = GameObject.Find ("OculusDK2 Icon");
		
//		this.floorPlane = GameObject.Find ("Floor");
		
		foreach (Transform child in this.deviceModelObjects.transform)
		{
			child.gameObject.SetActive(false);
		}
		
		foreach (Transform child in this.depthViewObjects.transform)
		{
			child.gameObject.SetActive(false);
		}
		
		foreach (Transform child in this.iconObjects.transform)
		{
			child.gameObject.SetActive(false);
		}
		
		if(this.mannequin)
			this.mannequin.SetActive(false);
		if(this.psEyeModelObject)
			this.psEyeModelObject.SetActive(true);
		if(this.PSMoveWandObject)
			this.PSMoveWandObject.SetActive(true);
		if(this.oculusRiftModel)
			this.oculusRiftModel.SetActive(true);
		if(this.oculusDK2CameraObject)
			this.oculusDK2CameraObject.SetActive(true);
		if(this.psMoveIcon)
			this.psMoveIcon.SetActive(true);
		if(this.oculusDK2Icon)
			this.oculusDK2Icon.SetActive(true);
		if(this.calibrationPhaseObjects)
			this.calibrationPhaseObjects.SetActive(true);
		if(this.calibrationResultPhaseObjects)
			this.calibrationResultPhaseObjects.SetActive(false);
		this.xmlFilename = calibrationSettings.xmlFilename;
	}