Пример #1
0
    // Doesn't seem to matter whether floor normal and point is constantly improved or just once in the beginning
//	void Update()
//	{
//		if(enableKinect && kinectFloorDetection && !enablePSMove)
//		{
//			updateKinectFloorData();
//		}
//	}

    public void StartFloorDetection()
    {
        bool startDetection = false;

        if (enableKinect)
        {
            kinectFloorDetection = true;

            if (sceneAnalyzer == null)
            {
                try
                {
                    OpenNISettingsManager niSettings = FindObjectOfType(typeof(OpenNISettingsManager)) as OpenNISettingsManager;
                    if (niSettings != null && niSettings.CurrentContext != null && niSettings.CurrentContext.BasicContext != null)
                    {
                        sceneAnalyzer = new OpenNI.SceneAnalyzer(niSettings.CurrentContext.BasicContext);
                    }
                    if (sceneAnalyzer != null)
                    {
                        sceneAnalyzer.StartGenerating();
                    }
                }
                catch (System.Exception e)
                {
                    Debug.LogError(e.Message);
                }
                Debug.Log("OpenNI: Starting sceneAnalyzer for floor detection purposes.");
            }
            startDetection = true;
        }

        if (enableKinect2)
        {
            startDetection = true;
        }

        if (startDetection)
        {
            StartCoroutine("attemptUpdatingFloorNormal");
        }
        else
        {
            Debug.LogError("Kinect is not enabled! You can enable it from RUIS InputManager.");
        }
    }
Пример #2
0
    public override RUISCalibrationPhase InitialPhase(float deltaTime)
    {
        timeSinceScriptStart += deltaTime;

        if (timeSinceScriptStart < 3)
        {
            this.guiTextLowerLocal = "Calibration of Kinect 1 floor data\n\n Starting up...";
            return(RUISCalibrationPhase.Initial);
        }

        if (timeSinceScriptStart < 4)
        {
            this.guiTextLowerLocal = "Connecting to Kinect 1. \n\n Please wait...";
            return(RUISCalibrationPhase.Initial);
        }

        if (!kinectChecked && timeSinceScriptStart < 5)
        {
            if (settingsManager == null)
            {
                this.guiTextLowerLocal = "Connecting to Kinect. \n\n Error: Could not start OpenNI";
                return(RUISCalibrationPhase.Invalid);
            }
            else if (settingsManager.UserGenrator == null)
            {
                this.guiTextLowerLocal = "Connecting to Kinect. \n\n Error: Could not start OpenNI";
                return(RUISCalibrationPhase.Invalid);
            }
            else if (!settingsManager.UserGenrator.Valid)
            {
                this.guiTextLowerLocal = "Connecting to Kinect. \n\n Error: Could not start OpenNI";
                return(RUISCalibrationPhase.Invalid);
            }
            else
            {
                sceneAnalyzer = new OpenNI.SceneAnalyzer((MonoBehaviour.FindObjectOfType(typeof(OpenNISettingsManager)) as OpenNISettingsManager).CurrentContext.BasicContext);
                sceneAnalyzer.StartGenerating();
                return(RUISCalibrationPhase.Preparation);
            }
        }

        return(RUISCalibrationPhase.Invalid);        // Loop should not get this far
    }
	public override RUISCalibrationPhase InitialPhase(float deltaTime) {
		
		timeSinceScriptStart += deltaTime;
		
		if(timeSinceScriptStart < 3) {
			this.guiTextLowerLocal = "Calibration of Kinect 1 and Kinect 2\n\n Starting up...";
			return RUISCalibrationPhase.Initial;
		}
		
		if(timeSinceScriptStart < 4) {
			this.guiTextLowerLocal = "Connecting to Kinect 1. \n\n Please wait...";
			return RUISCalibrationPhase.Initial;
		}
		 
		if(!kinectChecked && timeSinceScriptStart > 4) {
			if (settingsManager == null) {
				this.guiTextLowerLocal = "Connecting to Kinect 1. \n\n Error: Could not start OpenNI";
				return RUISCalibrationPhase.Invalid;
			}
			else if(settingsManager.UserGenrator == null) {
				this.guiTextLowerLocal = "Connecting to Kinect 1. \n\n Error: Could not start OpenNI";
				return RUISCalibrationPhase.Invalid;
			}
			else if(!settingsManager.UserGenrator.Valid) {
				this.guiTextLowerLocal = "Connecting to Kinect 1. \n\n Error: Could not start OpenNI";
				return RUISCalibrationPhase.Invalid;
			}
			else {
				sceneAnalyzer = new OpenNI.SceneAnalyzer((MonoBehaviour.FindObjectOfType(typeof(OpenNISettingsManager)) as OpenNISettingsManager).CurrentContext.BasicContext);
				sceneAnalyzer.StartGenerating();
			}
			kinectChecked = true;	
		}	
		
		if(timeSinceScriptStart < 5) {
			this.guiTextLowerLocal = "Connecting to Kinect 2. \n\n Please wait...";
			return RUISCalibrationPhase.Initial;
		}
		
		if(!kinect2Checked && timeSinceScriptStart > 5) {
			kinect2Checked = true;	
			if (!kinect2SourceManager.GetSensor().IsOpen || !kinect2SourceManager.GetSensor().IsAvailable) {
				this.guiTextLowerLocal = "Connecting to Kinect 2. \n\n Error: Could not connect to Kinect 2.";
				return RUISCalibrationPhase.Invalid;
			}
			else {
				return RUISCalibrationPhase.Preparation;
			}
			
		}	
		
		return RUISCalibrationPhase.Invalid; // Loop should not get this far
	}
	public override RUISCalibrationPhase InitialPhase(float deltaTime) {
		
		timeSinceScriptStart += deltaTime;
		
		if(timeSinceScriptStart < 3) {
			this.guiTextLowerLocal = "Calibration of Kinect 1 and Oculus DK2\n\n Starting up...";
			return RUISCalibrationPhase.Initial;
		}
		
		if(timeSinceScriptStart < 4) {
			this.guiTextLowerLocal = "Connecting to Oculus Rift DK2. \n\n Please wait...";
			return RUISCalibrationPhase.Initial;
		}
		
		if(!oculusChecked && timeSinceScriptStart > 4) {
			oculusChecked = true;	
			if ((RUISOVRManager.ovrHmd.GetTrackingState().StatusFlags & (uint)StatusBits.HmdConnected) == 0) { // Code from OVRManager.cs
				this.guiTextLowerLocal = "Connecting to Oculus Rift DK2. \n\n Error: Could not connect to Oculus Rift DK2.";
				return RUISCalibrationPhase.Invalid;
			}
		}	
		
		if(!kinectChecked && timeSinceScriptStart < 5) {
			if (settingsManager == null) {
				this.guiTextLowerLocal = "Connecting to Kinect. \n\n Error: Could not start OpenNI";
				return RUISCalibrationPhase.Invalid;
			}
			else if(settingsManager.UserGenrator == null) {
				this.guiTextLowerLocal = "Connecting to Kinect. \n\n Error: Could not start OpenNI";
				return RUISCalibrationPhase.Invalid;
			}
			else if(!settingsManager.UserGenrator.Valid) {
				this.guiTextLowerLocal = "Connecting to Kinect. \n\n Error: Could not start OpenNI";
				return RUISCalibrationPhase.Invalid;
			}
			else {
				sceneAnalyzer = new OpenNI.SceneAnalyzer((MonoBehaviour.FindObjectOfType(typeof(OpenNISettingsManager)) as OpenNISettingsManager).CurrentContext.BasicContext);
				sceneAnalyzer.StartGenerating();
				return RUISCalibrationPhase.Preparation;
			}
		}	
		
		return RUISCalibrationPhase.Invalid; // Loop should not get this far
	}
Пример #5
0
    void Start()
    {
        OpenNISettingsManager settingsManager = FindObjectOfType(typeof(OpenNISettingsManager)) as OpenNISettingsManager;
        if (settingsManager.UserGenrator == null || !settingsManager.UserGenrator.Valid)
        {
            Debug.LogError("Could not start OpenNI! Check your Kinect connection.");
            kinectAvailable = false;
            settingsManager.transform.parent.gameObject.SetActive(false);

            userViewer.gameObject.SetActive(false);
        }
        else
        {

            sceneAnalyzer = new OpenNI.SceneAnalyzer((FindObjectOfType(typeof(OpenNISettingsManager)) as OpenNISettingsManager).CurrentContext.BasicContext);
            sceneAnalyzer.StartGenerating();
        }

        RUISMenu ruisMenu = FindObjectOfType(typeof(RUISMenu)) as RUISMenu;
        if (ruisMenu)
        {
            usePSMove = ruisMenu.enablePSMove;
            psMoveIP = ruisMenu.psMoveIP;
            psMovePort = ruisMenu.psMovePort;
        }

        if (usePSMove)
        {

            StartCoroutine("CheckForMoveConnection");
            psMoveWrapper.ipAddress = psMoveIP;
            psMoveWrapper.port = psMovePort;
            psMoveWrapper.Connect(psMoveIP, psMovePort);

            psMoveWrapper.CameraFrameResume(4);
        }
        else
        {
            (FindObjectOfType(typeof(CameraTiltTextUpdater)) as CameraTiltTextUpdater).gameObject.SetActive(false);
        }

        //moveController.gameObject.SetActiveRecursively(false);

        /*psEyeTexture = new Texture2D(640, 480, TextureFormat.ARGB32, false);

        psEyeGUITexture.texture = psEyeTexture;

        psMoveWrapper.CameraFrameResume();*/

        calibrationSpheres = new List<GameObject>();

        SetCalibrationReviewShowing(false);

        /*List<Vector3> testList = new List<Vector3>();
        testList.Add(Vector3.right * 1.5f);
        testList.Add(new Vector3(0.5f, 1f, 0.5f));
        testList.Add(Vector3.forward * 2.0f);
        Orthonormalize(ref testList);
        foreach (Vector3 v in testList)
        {
            Debug.Log(v);
        }*/
    }
Пример #6
0
    // Doesn't seem to matter whether floor normal and point is constantly improved or just once in the beginning
    //    void Update()
    //    {
    //        if(enableKinect && kinectFloorDetection && !enablePSMove)
    //        {
    //            updateKinectFloorData();
    //        }
    //    }
    public void StartFloorDetection()
    {
        if (enableKinect)
        {
            kinectFloorDetection = true;

            moveKinectCalibration = FindObjectOfType(typeof(RUISM2KCalibration)) as RUISM2KCalibration;
            if(!moveKinectCalibration)
            {
                if(sceneAnalyzer == null)
                {
                    sceneAnalyzer = new OpenNI.SceneAnalyzer((FindObjectOfType(typeof(OpenNISettingsManager))
                                                            as OpenNISettingsManager).CurrentContext.BasicContext);
                    sceneAnalyzer.StartGenerating();
                    Debug.Log ("Creating sceneAnalyzer");
                }
            }
            else
                StartCoroutine("attemptStartingSceneAnalyzer");

            StartCoroutine("attemptUpdatingFloorNormal");
        }
        else
            Debug.LogError("Kinect is not enabled! You can enable it from RUIS InputManager.");
    }
Пример #7
0
    void Start()
    {
        OpenNISettingsManager settingsManager = FindObjectOfType(typeof(OpenNISettingsManager)) as OpenNISettingsManager;

        if (settingsManager.UserGenrator == null || !settingsManager.UserGenrator.Valid)
        {
            Debug.LogError("Could not start OpenNI! Check your Kinect connection.");
            kinectAvailable = false;
            settingsManager.transform.parent.gameObject.SetActive(false);

            userViewer.gameObject.SetActive(false);
        }
        else
        {
            sceneAnalyzer = new OpenNI.SceneAnalyzer((FindObjectOfType(typeof(OpenNISettingsManager)) as OpenNISettingsManager).CurrentContext.BasicContext);
            sceneAnalyzer.StartGenerating();
        }

        RUISMenu ruisMenu = FindObjectOfType(typeof(RUISMenu)) as RUISMenu;

        if (ruisMenu)
        {
            usePSMove  = ruisMenu.enablePSMove;
            psMoveIP   = ruisMenu.psMoveIP;
            psMovePort = ruisMenu.psMovePort;
        }

        if (usePSMove)
        {
            StartCoroutine("CheckForMoveConnection");
            psMoveWrapper.ipAddress = psMoveIP;
            psMoveWrapper.port      = psMovePort;
            psMoveWrapper.Connect(psMoveIP, psMovePort);

            psMoveWrapper.CameraFrameResume(4);
        }
        else
        {
            (FindObjectOfType(typeof(CameraTiltTextUpdater)) as CameraTiltTextUpdater).gameObject.SetActive(false);
        }


        //moveController.gameObject.SetActiveRecursively(false);

        /*psEyeTexture = new Texture2D(640, 480, TextureFormat.ARGB32, false);
         *
         * psEyeGUITexture.texture = psEyeTexture;
         *
         * psMoveWrapper.CameraFrameResume();*/


        calibrationSpheres = new List <GameObject>();

        SetCalibrationReviewShowing(false);

        /*List<Vector3> testList = new List<Vector3>();
         * testList.Add(Vector3.right * 1.5f);
         * testList.Add(new Vector3(0.5f, 1f, 0.5f));
         * testList.Add(Vector3.forward * 2.0f);
         * Orthonormalize(ref testList);
         * foreach (Vector3 v in testList)
         * {
         *  Debug.Log(v);
         * }*/
    }