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

        moveWrapper = FindObjectOfType(typeof(PSMoveWrapper)) as PSMoveWrapper;

        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");
		}
    }
Esempio n. 2
0
 // Use this for initialization
 void Start()
 {
     rigidbody.centerOfMass += CenterOfMassOffset;         //this.CenterOfMass.position;
     psMoveWrapper           = FindObjectOfType(typeof(PSMoveWrapper)) as PSMoveWrapper;
     this.initPos            = transform.position;
     this.initRot            = transform.rotation;
 }
Esempio n. 3
0
    void Awake()
    {
        characterController = GetComponent <RUISCharacterController>();
        jumpGesture         = GetComponentInChildren <RUISJumpGestureRecognizer>();

        moveWrapper = FindObjectOfType(typeof(PSMoveWrapper)) as PSMoveWrapper;

        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()
    {
        RUISM2KCalibration calibration = FindObjectOfType(typeof(RUISM2KCalibration)) as RUISM2KCalibration;
        if (!calibration.usePSMove)
            gameObject.SetActive(false);

        psMoveWrapper = FindObjectOfType(typeof(PSMoveWrapper)) as PSMoveWrapper;
        texture = new Texture2D(640, 480, TextureFormat.ARGB32, false);
    }
Esempio n. 5
0
 public void Disconnect(bool isCleanUp)
 {
     if (isCleanUp)
     {
         CameraFramePause();
         ResetAll();
     }
     PSMoveWrapper.client_disconnect();
     isConnected = false;
     Debug.Log("Disconnect");
 }
Esempio n. 6
0
 public void Connect(string address, int port)
 {
     if (!onlineMode)
     {
         Debug.LogWarning("onlineMode == false, running in offline mode!");
         return;
     }
     PSMoveWrapper.client_connect(address, port);
     isConnected = PSMoveWrapper.client_connected;
     Debug.Log("Connect");
 }
Esempio n. 7
0
    void Awake()
    {
        RUISM2KCalibration calibration = FindObjectOfType(typeof(RUISM2KCalibration)) as RUISM2KCalibration;

        if (!calibration.usePSMove)
        {
            gameObject.SetActive(false);
        }

        psMoveWrapper = FindObjectOfType(typeof(PSMoveWrapper)) as PSMoveWrapper;
        texture       = new Texture2D(640, 480, TextureFormat.ARGB32, false);
    }
Esempio n. 8
0
    void Awake()
    {
        currentState    = State.Start;
        psMoveWrapper   = GetComponent <PSMoveWrapper>();
        kinectSelection = FindObjectOfType(typeof(NIPlayerManagerCOMSelection)) as NIPlayerManagerCOMSelection;
        statusText      = GetComponentInChildren <GUIText>();

        rawPSMoveSamples = new List <Vector3>();
        psMoveSamples    = new List <Vector3>();
        kinectSamples    = new List <Vector3>();

        Screen.SetResolution(resolutionX, resolutionY, Screen.fullScreen);
    }
Esempio n. 9
0
	void Awake () {
		gameController = GameObject.FindGameObjectWithTag("GameController").GetComponent<GameController>();
		gameController.onGameLose += MoveLock;
		gameController.onGameWin += MoveLock;
		gameController.onGameRestart += Start;
		soundmanager = GameObject.Find ("SoundManager").GetComponent<SoundClip>();

		psMoveWrapper = gameObject.GetComponent<PSMoveWrapper>();
		psMoveWrapper.Connect();

		// TODO: activate this line if the player can't stop reaching the monster
		//gameController.onGamePlayStart += MoveLockThenUnlock;
	}
Esempio n. 10
0
    void Awake()
    {
        gameController                = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameController>();
        gameController.onGameLose    += MoveLock;
        gameController.onGameWin     += MoveLock;
        gameController.onGameRestart += Start;
        soundmanager = GameObject.Find("SoundManager").GetComponent <SoundClip>();

        psMoveWrapper = gameObject.GetComponent <PSMoveWrapper>();
        psMoveWrapper.Connect();

        // TODO: activate this line if the player can't stop reaching the monster
        //gameController.onGamePlayStart += MoveLockThenUnlock;
    }
Esempio n. 11
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.");
            }
        }
    }
Esempio n. 12
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.");
            }
        }
	}
 void Awake()
 {
     psMoveWrapper = FindObjectOfType(typeof(PSMoveWrapper)) as PSMoveWrapper;
     texture = new Texture2D(640, 480, TextureFormat.ARGB32, false);
 }
Esempio n. 14
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;
	}
Esempio n. 15
0
 public void Connect(string address, int port)
 {
     PSMoveWrapper.client_connect(address, port);
     isConnected = PSMoveWrapper.client_connected;
     Debug.Log("Connect");
 }
Esempio n. 16
0
	void Awake () {
        psMoveWrapper = FindObjectOfType(typeof(PSMoveWrapper)) as PSMoveWrapper;	
	}
//	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;
	}
	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;
	}
    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;
    }
Esempio n. 20
0
 void Awake()
 {
     psMoveWrapper = FindObjectOfType(typeof(PSMoveWrapper)) as PSMoveWrapper;
 }
Esempio n. 21
0
    void Awake()
    {
        currentState = State.Start;
        psMoveWrapper = GetComponent<PSMoveWrapper>();
        kinectSelection = FindObjectOfType(typeof(NIPlayerManagerCOMSelection)) as NIPlayerManagerCOMSelection;
        statusText = GetComponentInChildren<GUIText>();

        rawPSMoveSamples = new List<Vector3>();
        psMoveSamples = new List<Vector3>();
        kinectSamples = new List<Vector3>();

        Screen.SetResolution(resolutionX, resolutionY, Screen.fullScreen);
    }
Esempio n. 22
0
    public void Awake()
    {
        // Check if we are in calibration scene
        ruisNGUIMenu = FindObjectOfType(typeof(RUISMenuNGUI)) as RUISMenuNGUI;

        if (ruisNGUIMenu != null)
        {
            if (ruisNGUIMenu.currentMenuState == RUISMenuNGUI.RUISMenuStates.calibration)
            {
                this.enablePSMove                   = ruisNGUIMenu.originalEnablePSMove;
                this.enableKinect                   = ruisNGUIMenu.originalEnableKinect;
                this.enableKinect2                  = ruisNGUIMenu.originalEnableKinect2;
                this.jumpGestureEnabled             = ruisNGUIMenu.originalEnableJumpGesture;
                this.enableRazerHydra               = ruisNGUIMenu.originalEnableHydra;
                this.kinectDriftCorrectionPreferred = ruisNGUIMenu.originalKinectDriftCorrection;
                this.PSMoveIP   = ruisNGUIMenu.originalPSMoveIP;
                this.PSMovePort = ruisNGUIMenu.originalPSMovePort;
            }
        }

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

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

        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();
    }
    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;
    }
Esempio n. 24
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;
    }
 void Awake()
 {
     psMoveWrapper = FindObjectOfType(typeof(PSMoveWrapper)) as PSMoveWrapper;
     psMoveWrapper.CameraFrameResume();
 }
 void Awake()
 {
     psMoveWrapper = FindObjectOfType(typeof(PSMoveWrapper)) as PSMoveWrapper;
     psMoveWrapper.CameraFrameResume();
 }
Esempio n. 27
0
    public void Awake()
    {
    	// Check if we are in calibration scene
		ruisNGUIMenu = FindObjectOfType(typeof(RUISMenuNGUI)) as RUISMenuNGUI;
		if(ruisNGUIMenu != null) 
		{
			if(ruisNGUIMenu.currentMenuState == RUISMenuNGUI.RUISMenuStates.calibration) 
			{
				this.enablePSMove = ruisNGUIMenu.originalEnablePSMove;
				this.enableKinect = ruisNGUIMenu.originalEnableKinect;
				this.enableKinect2 = ruisNGUIMenu.originalEnableKinect2;
				this.jumpGestureEnabled = ruisNGUIMenu.originalEnableJumpGesture;
				this.enableRazerHydra = ruisNGUIMenu.originalEnableHydra;
				this.kinectDriftCorrectionPreferred = ruisNGUIMenu.originalKinectDriftCorrection;
				this.PSMoveIP = ruisNGUIMenu.originalPSMoveIP;
				this.PSMovePort = ruisNGUIMenu.originalPSMovePort;
			}
		}
    	
		wandDelayed = new bool[4] {moveWand0, moveWand1, moveWand2, moveWand3};
		disabledWands = new List<GameObject>();
		
        if (!Application.isEditor || loadFromTextFileInEditor)
        {
            if (!Import(filename))
            {
                Debug.LogError("Could not load input configuration file. Creating file based on current settings.");
                Export(filename);
            }
        }

        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()
 {
     psMoveWrapper = FindObjectOfType(typeof(PSMoveWrapper)) as PSMoveWrapper;
     texture       = new Texture2D(640, 480, TextureFormat.ARGB32, false);
 }