コード例 #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()
    {
        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.");
        }
    }
コード例 #2
0
    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
    }
コード例 #3
0
    private IEnumerator attemptStartingSceneAnalyzer()
    {
        if (kinectFloorDetection)
        {
            yield return(new WaitForSeconds(2.0f));

            if (sceneAnalyzer == null)
            {
                Debug.Log("Using existing sceneAnalyzer");
                sceneAnalyzer = moveKinectCalibration.sceneAnalyzer;
                //usingExistingSceneAnalyzer = true;
                //if(!sceneAnalyzer.IsGenerating) // Seems to be always on
                //	sceneAnalyzer.StartGenerating();
            }
        }
    }
コード例 #4
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");
        }
        //attemptUpdatingFloorNormal();
        else
        {
            Debug.LogError("Kinect is not enabled! You can enable it from RUIS InputManager.");
        }
    }
コード例 #5
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
    }
コード例 #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()
	{
		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.");
	}
コード例 #7
0
ファイル: Context.cs プロジェクト: penyatree/openni
        private ProductionNode CreateProductionNodeObject(IntPtr nodeHandle, NodeType? type)
        {
            lock (this)
            {
                if (!this.allNodes.ContainsKey(nodeHandle))
                {
                    if (type == null)
                    {
                        IntPtr pNodeInfo = SafeNativeMethods.xnGetNodeInfo(nodeHandle);
                        type = NodeInfo.FromNative(pNodeInfo).Description.Type;
                    }

                    ProductionNode node;

                    switch (type)
                    {
                        case NodeType.Device:
                            node = new Device(this, nodeHandle, true);
                            break;
                        case NodeType.Depth:
                            node = new DepthGenerator(this, nodeHandle, true);
                            break;
                        case NodeType.Image:
                            node = new ImageGenerator(this, nodeHandle, true);
                            break;
                        case NodeType.Audio:
                            node = new AudioGenerator(this, nodeHandle, true);
                            break;
                        case NodeType.IR:
                            node = new IRGenerator(this, nodeHandle, true);
                            break;
                        case NodeType.User:
                            node = new UserGenerator(this, nodeHandle, true);
                            break;
                        case NodeType.Recorder:
                            node = new Recorder(this, nodeHandle, true);
                            break;
                        case NodeType.Player:
                            node = new Player(this, nodeHandle, true);
                            break;
                        case NodeType.Gesture:
                            node = new GestureGenerator(this, nodeHandle, true);
                            break;
                        case NodeType.Scene:
                            node = new SceneAnalyzer(this, nodeHandle, true);
                            break;
                        case NodeType.Hands:
                            node = new HandsGenerator(this, nodeHandle, true);
                            break;
                        case NodeType.Codec:
                            node = new Codec(this, nodeHandle, true);
                            break;
                        case NodeType.ProductionNode:
                            node = new ProductionNode(this, nodeHandle, true);
                            break;
                        case NodeType.Generator:
                            node = new Generator(this, nodeHandle, true);
                            break;
                        case NodeType.MapGenerator:
                            node = new MapGenerator(this, nodeHandle, true);
                            break;
                        case NodeType.ScriptNode:
                            node = new ScriptNode(this, nodeHandle, true);
                            break;
                        default:
                            throw new NotImplementedException("C# wrapper: Unknown generator type!");
                    }
                    this.allNodes[nodeHandle] = node;
                }

                return this.allNodes[nodeHandle];
            } // lock
        }
	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
	}
コード例 #9
0
ファイル: Context.cs プロジェクト: FreeMiles/OpenNI
		private ProductionNode CreateProductionNodeObject(IntPtr nodeHandle, NodeType? type)
		{
			lock (this)
			{
				if (!this.allNodes.ContainsKey(nodeHandle))
				{
					if (type == null)
					{
						IntPtr pNodeInfo = SafeNativeMethods.xnGetNodeInfo(nodeHandle);
                        type = NodeInfo.FromNative(pNodeInfo).Description.Type;
					}

					ProductionNode node;

                   	// start with concrete types
                    if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.Device))
                    {
                        node = new Device(this, nodeHandle, true);
                    }
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.Depth))
                    {
                        node = new DepthGenerator(this, nodeHandle, true);
                    }
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.Image))
                    {
                        node = new ImageGenerator(this, nodeHandle, true);
                    }
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.Audio))
                    {
                        node = new AudioGenerator(this, nodeHandle, true);
                    }
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.IR))
                    {
                        node = new IRGenerator(this, nodeHandle, true);
                    }
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.User))
                    {
                        node = new UserGenerator(this, nodeHandle, true);
                    }
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.Recorder))
                    {
                        node = new Recorder(this, nodeHandle, true);
                    }
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.Player))
                    {
                        node = new Player(this, nodeHandle, true);
                    }
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.Gesture))
                    {
                        node = new GestureGenerator(this, nodeHandle, true);
                    }
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.Scene))
                    {
                        node = new SceneAnalyzer(this, nodeHandle, true);
                    }
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.Hands))
                    {
                        node = new HandsGenerator(this, nodeHandle, true);
                    }
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.Codec))
                    {
                        node = new Codec(this, nodeHandle, true);
                    }
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.ScriptNode))
                    {
                        node = new ScriptNode(this, nodeHandle, true);
                    }
                    // move on to abstract types
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.MapGenerator))
                    {
                        node = new MapGenerator(this, nodeHandle, true);
                    }
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.Generator))
                    {
                        node = new Generator(this, nodeHandle, true);
                    }
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.ProductionNode))
                    {
                        node = new ProductionNode(this, nodeHandle, true);
                    }
                    else
                    {
                        throw new NotImplementedException("C# wrapper: Unknown generator type!");
                    }

					this.allNodes[nodeHandle] = node;
				}

				return this.allNodes[nodeHandle];
			} // lock
		}
コード例 #10
0
        private ProductionNode CreateProductionNodeObject(IntPtr nodeHandle, NodeType?type)
        {
            lock (this)
            {
                if (!this.allNodes.ContainsKey(nodeHandle))
                {
                    if (type == null)
                    {
                        IntPtr pNodeInfo = SafeNativeMethods.xnGetNodeInfo(nodeHandle);
                        type = NodeInfo.FromNative(pNodeInfo).Description.Type;
                    }

                    ProductionNode node;

                    // start with concrete types
                    if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.Device))
                    {
                        node = new Device(this, nodeHandle, true);
                    }
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.Depth))
                    {
                        node = new DepthGenerator(this, nodeHandle, true);
                    }
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.Image))
                    {
                        node = new ImageGenerator(this, nodeHandle, true);
                    }
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.Audio))
                    {
                        node = new AudioGenerator(this, nodeHandle, true);
                    }
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.IR))
                    {
                        node = new IRGenerator(this, nodeHandle, true);
                    }
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.User))
                    {
                        node = new UserGenerator(this, nodeHandle, true);
                    }
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.Recorder))
                    {
                        node = new Recorder(this, nodeHandle, true);
                    }
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.Player))
                    {
                        node = new Player(this, nodeHandle, true);
                    }
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.Gesture))
                    {
                        node = new GestureGenerator(this, nodeHandle, true);
                    }
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.Scene))
                    {
                        node = new SceneAnalyzer(this, nodeHandle, true);
                    }
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.Hands))
                    {
                        node = new HandsGenerator(this, nodeHandle, true);
                    }
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.Codec))
                    {
                        node = new Codec(this, nodeHandle, true);
                    }
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.ScriptNode))
                    {
                        node = new ScriptNode(this, nodeHandle, true);
                    }
                    // move on to abstract types
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.MapGenerator))
                    {
                        node = new MapGenerator(this, nodeHandle, true);
                    }
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.Generator))
                    {
                        node = new Generator(this, nodeHandle, true);
                    }
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.ProductionNode))
                    {
                        node = new ProductionNode(this, nodeHandle, true);
                    }
                    else
                    {
                        throw new NotImplementedException("C# wrapper: Unknown generator type!");
                    }

                    this.allNodes[nodeHandle] = node;
                }

                return(this.allNodes[nodeHandle]);
            }             // lock
        }
	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
	}
コード例 #12
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);
        }*/
    }
コード例 #13
0
    private IEnumerator attemptStartingSceneAnalyzer()
    {
        if(kinectFloorDetection)
        {
            yield return new WaitForSeconds(2.0f);

            if(sceneAnalyzer == null)
            {
                Debug.Log ("Using existing sceneAnalyzer");
                sceneAnalyzer = moveKinectCalibration.sceneAnalyzer;
                //usingExistingSceneAnalyzer = true;
                //if(!sceneAnalyzer.IsGenerating) // Seems to be always on
                //	sceneAnalyzer.StartGenerating();
            }
        }
    }
コード例 #14
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.");
    }
コード例 #15
0
ファイル: Context.cs プロジェクト: moeseth/OpenNI
        private ProductionNode CreateProductionNodeObject(IntPtr nodeHandle, NodeType?type)
        {
            lock (this)
            {
                if (!this.allNodes.ContainsKey(nodeHandle))
                {
                    if (type == null)
                    {
                        IntPtr pNodeInfo = SafeNativeMethods.xnGetNodeInfo(nodeHandle);
                        type = SafeNativeMethods.xnNodeInfoGetDescription(pNodeInfo).Type;
                    }

                    ProductionNode node;

                    switch (type)
                    {
                    case NodeType.Device:
                        node = new Device(this, nodeHandle, true);
                        break;

                    case NodeType.Depth:
                        node = new DepthGenerator(this, nodeHandle, true);
                        break;

                    case NodeType.Image:
                        node = new ImageGenerator(this, nodeHandle, true);
                        break;

                    case NodeType.Audio:
                        node = new AudioGenerator(this, nodeHandle, true);
                        break;

                    case NodeType.IR:
                        node = new IRGenerator(this, nodeHandle, true);
                        break;

                    case NodeType.User:
                        node = new UserGenerator(this, nodeHandle, true);
                        break;

                    case NodeType.Recorder:
                        node = new Recorder(this, nodeHandle, true);
                        break;

                    case NodeType.Player:
                        node = new Player(this, nodeHandle, true);
                        break;

                    case NodeType.Gesture:
                        node = new GestureGenerator(this, nodeHandle, true);
                        break;

                    case NodeType.Scene:
                        node = new SceneAnalyzer(this, nodeHandle, true);
                        break;

                    case NodeType.Hands:
                        node = new HandsGenerator(this, nodeHandle, true);
                        break;

                    case NodeType.Codec:
                        node = new Codec(this, nodeHandle, true);
                        break;

                    case NodeType.ProductionNode:
                        node = new ProductionNode(this, nodeHandle, true);
                        break;

                    case NodeType.Generator:
                        node = new Generator(this, nodeHandle, true);
                        break;

                    case NodeType.MapGenerator:
                        node = new MapGenerator(this, nodeHandle, true);
                        break;

                    case NodeType.ScriptNode:
                        node = new ScriptNode(this, nodeHandle, true);
                        break;

                    default:
                        throw new NotImplementedException("C# wrapper: Unknown generator type!");
                    }
                    this.allNodes[nodeHandle] = node;
                }

                return(this.allNodes[nodeHandle]);
            }             // lock
        }
コード例 #16
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);
         * }*/
    }