private Rect tempRect; ///< @brief Temporary rectangle which sets the position of items (defined here to avoid creating on the fly). /// @brief mono-behavior start for initialization void Start() { m_mode = SkeletonGUIModes.SkeletonMode; // initialize all the external links if (m_input == null) { m_input = FindObjectOfType(typeof(NIInput)) as NIInput; if (m_input == null) { throw new System.Exception("Please add an NIInput object to the scene"); } } if (m_settings == null) { m_settings = FindObjectOfType(typeof(OpenNISettingsManager)) as OpenNISettingsManager; if (m_settings == null) { throw new System.Exception("Please add an OpenNISettingsManager object to the scene"); } } // a rect used later, this is mainly an initialization tempRect = new Rect(); tempRect.x = Screen.width / 2 - 60; tempRect.y = Screen.height / 2 - 20; tempRect.width = 120; tempRect.height = 40; m_controllers = FindObjectsOfType(typeof(NISkeletonController)) as NISkeletonController[]; NIGUI.SetActive(false); // we don't want to see the cursor yet so we deactivate NIGUI }
void Start () { // Below is only for Kinect 1 settingsManager = FindObjectOfType(typeof(OpenNISettingsManager)) as OpenNISettingsManager; if (settingsManager == null || !settingsManager.UserGenrator.Valid || settingsManager.CurrentContext.Depth == null) { Kinect1Update = false; return; } depthGenerator = new OpenNI.DepthGenerator(settingsManager.CurrentContext.BasicContext); OpenNI.MapOutputMode mapOutputMode = settingsManager.CurrentContext.Depth.MapOutputMode; width = mapOutputMode.XRes / factor; height = mapOutputMode.YRes / factor; texture = new Texture2D(width, height); depthMap = new short[(int)(mapOutputMode.XRes * mapOutputMode.YRes)]; depthHistogramMap = new float[settingsManager.CurrentContext.Depth.DeviceMaxDepth]; NIOpenNICheckVersion.Instance.ValidatePrerequisite(); metaData = new OpenNI.DepthMetaData(); mapPixels = new Color[width * height]; }
void Start() { settingsManager = FindObjectOfType(typeof(OpenNISettingsManager)) as OpenNISettingsManager; if (!settingsManager.UserGenrator.Valid || settingsManager.CurrentContext.Depth == null) { update = false; return; } depthGenerator = new OpenNI.DepthGenerator(settingsManager.CurrentContext.BasicContext); OpenNI.MapOutputMode mapOutputMode = settingsManager.CurrentContext.Depth.MapOutputMode; width = mapOutputMode.XRes / factor; height = mapOutputMode.YRes / factor; texture = new Texture2D(width, height); depthMap = new short[(int)(mapOutputMode.XRes * mapOutputMode.YRes)]; depthHistogramMap = new float[settingsManager.CurrentContext.Depth.DeviceMaxDepth]; NIOpenNICheckVersion.Instance.ValidatePrerequisite(); metaData = new OpenNI.DepthMetaData(); mapPixels = new Color[width * height]; }
/// mono-behavior start (called on initialization) public void Awake () { m_players = new List<InternalSkeleton>(); if (m_contextManager == null) m_contextManager = FindObjectOfType(typeof(OpenNISettingsManager)) as OpenNISettingsManager; }
/// A method for initialization. It is called from the mono-behavior start method. /// @note if an extending class overwrite start, they should either call base.Start or simply call this /// method! protected virtual void InternalStart() { if (m_context == null) { m_context = FindObjectOfType(typeof(OpenNISettingsManager)) as OpenNISettingsManager; } if (m_context == null || m_context.Valid == false) { string str = "Context is invalid"; if (m_context == null) { str = "Context is null"; } Debug.Log(str); m_valid = false; return; } if (InitTexture(out m_mapTexture, out XRes, out YRes) == false || m_mapTexture == null) { m_context.m_Logger.Log("Failed to init texture", NIEventLogger.Categories.Errors, NIEventLogger.Sources.BaseObjects); m_valid = false; return; } m_mapPixels = new Color[XRes * YRes]; m_valid = true; }
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; }
/// editor OnInspectorGUI to control the NIEventLogger properties override public void OnInspectorGUI() { EditorGUI.indentLevel = 0; EditorGUIUtility.LookLikeInspector(); NIUserPoseGestureFactory detector = target as NIUserPoseGestureFactory; string[] legalPoses = NIUserAndSkeleton.GetLegalPoses(); if (legalPoses != null) { int selectedIndex; if (detector.m_poseName == null) { selectedIndex = 0; } else { for (selectedIndex = 0; selectedIndex < legalPoses.Length; selectedIndex++) { if (detector.m_poseName.CompareTo(legalPoses[selectedIndex]) == 0) { break; } } } if (selectedIndex >= legalPoses.Length) { selectedIndex = 0; } selectedIndex = EditorGUILayout.Popup("pose to detect", selectedIndex, legalPoses); detector.m_poseName = legalPoses[selectedIndex]; } else { EditorGUILayout.LabelField("Pose to detect", detector.m_poseName); } detector.m_timeToHoldPose = EditorGUILayout.FloatField("Time to hold pose", detector.m_timeToHoldPose); if (detector.m_timeToHoldPose < 0) { detector.m_timeToHoldPose = 0; } detector.m_Context = EditorGUILayout.ObjectField("Context", detector.m_Context, typeof(OpenNISettingsManager), true) as OpenNISettingsManager; if (EditorApplication.isPlaying == false) { if (GUILayout.Button("Update legal poses (might take some time)")) { OpenNISettingsManager.InspectorReloadAnInstance(); } } if (GUI.changed) { EditorUtility.SetDirty(target); } }
/// this method does initialization when the Awake method is called. It should be overriden instead /// of Awake... protected virtual void InternalAwake() { m_valid = false; if (m_context == null) { m_context = FindObjectOfType(typeof(OpenNISettingsManager)) as OpenNISettingsManager; } }
private Texture2D m_texture; ///< @brief Internal texture to draw a specific color /// mono-behavior initialization void Start() { m_style = new GUIStyle(); m_texture = new Texture2D(1, 1); if (m_context == null) m_context = FindObjectOfType(typeof(OpenNISettingsManager)) as OpenNISettingsManager; }
protected float m_timePlayerSelected; ///< @brief The time (Time.Time) when the player was SELECTED #endregion Fields #region Constructors // end implement interface /// @brief Constructor /// /// @param settingsManager The settings manager to use /// @param userID The user id of the user this relates to. public NIPlayerCandidateObject(OpenNISettingsManager settingsManager, int userID) { m_settingsManager = settingsManager; settingsManager.UserGenrator.Skeleton.CalibrationComplete += new EventHandler<CalibrationProgressEventArgs>(CalibrationEndCallback); m_openNIUserID = userID; m_referenceSkeletonJointTransform=new Dictionary<SkeletonJoint,SkeletonJointTransformation>(); Reset(); }
/// base constructor /// @param timeToHoldPose The time the user is required to hold the pose. /// @param poseName The name of the pose to detect /// @param context The OpenNISettingsManager to use to get the basic OpenNI nodes public NIUserPoseDetector(float timeToHoldPose, string poseName, OpenNISettingsManager context) { m_timeToHoldPose = timeToHoldPose; if (m_timeToHoldPose < 0) m_timeToHoldPose = 0; m_firedEvent=false; m_context = context; m_poseName = poseName; }
/// this creates the correct object implementation of the tracker /// @return the tracker object. protected override NIGestureTracker GetNewTrackerObject() { if (m_Context == null) { m_Context = FindObjectOfType(typeof(OpenNISettingsManager)) as OpenNISettingsManager; } NIUserPoseDetector gestureTracker = new NIUserPoseDetector(m_timeToHoldPose,m_poseName,m_Context); return gestureTracker; }
// end implement interface /// @brief Constructor /// /// @param settingsManager The settings manager to use /// @param userID The user id of the user this relates to. public NIPlayerCandidateObject(OpenNISettingsManager settingsManager, int userID) { m_settingsManager = settingsManager; settingsManager.UserGenrator.Skeleton.CalibrationComplete += new EventHandler <CalibrationProgressEventArgs>(CalibrationEndCallback); m_openNIUserID = userID; m_referenceSkeletonJointTransform = new Dictionary <SkeletonJoint, SkeletonJointTransformation>(); Reset(); }
/// mono-behavior initialization void Start() { m_style = new GUIStyle(); m_texture = new Texture2D(1, 1); if (m_context == null) { m_context = FindObjectOfType(typeof(OpenNISettingsManager)) as OpenNISettingsManager; } }
/// mono-behavior Start for initialization public void Start() { if (m_context == null) m_context = FindObjectOfType(typeof(OpenNISettingsManager)) as OpenNISettingsManager; if (m_manager == null) m_manager = FindObjectOfType(typeof(OpenNISettingsManager)) as OpenNISettingsManager; if (m_manager == null) throw new System.Exception("Cannot do anything without an OpenNISettingsManager object"); }
/// mono-behavior awake (initialization) public void Awake() { if (m_context == null) m_context = FindObjectOfType(typeof(OpenNISettingsManager)) as OpenNISettingsManager; if (m_trackers.Length <= 0) return; // nothing to do, there are no trackers m_references=new int[m_trackers.Length]; for(int i=0; i<m_trackers.Length; i++) m_references[i]=0; }
/// this creates the correct object implementation of the tracker /// @return the tracker object. protected override UNIGestureTracker GetNewTrackerObject() { if (m_Context == null) { m_Context = FindObjectOfType(typeof(OpenNISettingsManager)) as OpenNISettingsManager; } UNIUserPoseDetector gestureTracker = new UNIUserPoseDetector(m_timeToHoldPose, m_poseName, m_Context); return(gestureTracker); }
// protected methods /// an internal method to initialize the context. /// @param newContext the context to initialize /// @return true on success (which also initializes the context) and false on failure /// (releasing is the responsibility of the caller) protected virtual bool InitContext(OpenNISettingsManager newContext) { // checks we have a context and hands. if (newContext.Valid == false) { newContext.Log("received invalid context!", NIEventLogger.Categories.Initialization, NIEventLogger.Sources.Hands, NIEventLogger.VerboseLevel.Errors); return(false); } m_context = newContext; return(true); }
/// base constructor /// @param timeToHoldPose The time the user is required to hold the pose. /// @param poseName The name of the pose to detect /// @param context The OpenNISettingsManager to use to get the basic OpenNI nodes public NIUserPoseDetector(float timeToHoldPose, string poseName, OpenNISettingsManager context) { m_timeToHoldPose = timeToHoldPose; if (m_timeToHoldPose < 0) { m_timeToHoldPose = 0; } m_firedEvent = false; m_context = context; m_poseName = poseName; }
/// @brief Internal method to initialize the player manager /// /// @note InternalInit is called from the mono behavior @ref Start method. It assumes the players /// (see @ref InitPlayers) were initialized before (during @ref Awake); protected virtual void InternalInit() { if (m_contextManager == null) { m_contextManager = FindObjectOfType(typeof(OpenNISettingsManager)) as OpenNISettingsManager; } if (m_contextManager == null) { throw new NullReferenceException("No context manager in NIPlayerManager"); } m_contextManager.UserGenrator.UserNode.NewUser += new EventHandler <NewUserEventArgs>(NewUserCallback); m_contextManager.UserGenrator.UserNode.LostUser += new EventHandler <UserLostEventArgs>(LostUserCallback); m_users = new List <NIPlayerCandidateObject>(); }
/// mono-behavior awake (initialization) public void Awake() { if (m_context == null) { m_context = FindObjectOfType(typeof(OpenNISettingsManager)) as OpenNISettingsManager; } if (m_trackers.Length <= 0) { return; // nothing to do, there are no trackers } m_references = new int[m_trackers.Length]; for (int i = 0; i < m_trackers.Length; i++) { m_references[i] = 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; } } }
/// @brief performs the initialization /// /// This method performs the initialization of the hand to a specific context. /// @note in most cases child classes should NOT override this method but rather instead /// override InitInternalStructures /// @param newContext the context to use. /// @return true on success, false on failure. public virtual bool InitTracking(OpenNISettingsManager newContext) { StopTracking(); // to make sure it is released. if (InitContext(newContext) == false) { StopTracking(); return(false); } if (InitInternalStructures() == false) { StopTracking(); return(false); } m_valid = true; return(true); }
// 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."); } }
/// this method makes sure we are initialized when we reach protected virtual void InternalInit() { if (m_context == null) { m_context = FindObjectOfType(typeof(OpenNISettingsManager)) as OpenNISettingsManager; if (m_context == null) { throw new System.Exception("Hands manager needs a valid NIConfigurableContextManager to work"); } } if (m_context.Valid == false) { throw new System.Exception("Hands manager needs a valid NIConfigurableContextManager to work"); } m_handsControl = NIHandControl.Instance; m_handsControl.Init(m_context.m_Logger, m_context.CurrentContext, m_focusGesture, m_refocusGesture); m_initializedHands = true; }
/// @brief Method to reload all nodes /// /// This method is used by inspectors to load and unload the relevant nodes when those are currently /// not loaded. public static void InspectorReloadAnInstance() { NIEventLogger loggerInstance = FindObjectOfType(typeof(NIEventLogger)) as NIEventLogger; bool awakenLogger = false; NIQuery queryInstance = FindObjectOfType(typeof(NIQuery)) as NIQuery; bool awakenQuery = false; OpenNISettingsManager managerInstance = FindObjectOfType(typeof(OpenNISettingsManager)) as OpenNISettingsManager; if (managerInstance == null) { Debug.LogError("Please Add an OpenNISettingsManager object to the scene"); return; } if (managerInstance.Valid) { return; // it is already up, nothing to do... } if (loggerInstance != null && loggerInstance.Initialized == false) { loggerInstance.Awake(); awakenLogger = true; } if (queryInstance != null && queryInstance.Initialized == false) { queryInstance.Awake(); awakenQuery = true; } managerInstance.Awake(); if (managerInstance.UserSkeletonValid == false) { Debug.LogError("No user generator available. Please make sure the user generator is active"); } managerInstance.OnDestroy(); if (awakenQuery) { queryInstance.OnDestroy(); } if (awakenLogger) { queryInstance.OnDestroy(); } }
protected void InitInspector() { OpenNISettingsManager openNISettings = target as OpenNISettingsManager; openNISettings.m_initMirroring = EditorGUILayout.Toggle("Mirror behavior", openNISettings.m_initMirroring); openNISettings.m_useImageGenerator = EditorGUILayout.Toggle("Use image generator?", openNISettings.m_useImageGenerator); openNISettings.m_useSkeleton = EditorGUILayout.Toggle("Use skeleton generator?", openNISettings.m_useSkeleton); if (openNISettings.m_useSkeleton && openNISettings.m_useSkeleton) { EditorGUI.indentLevel += 2; openNISettings.m_smoothingFactor = EditorGUILayout.FloatField("Smoothing factor:", openNISettings.m_smoothingFactor); EditorGUI.indentLevel -= 2; } //initialize the logger and query objects openNISettings.m_logger = EditorGUILayout.ObjectField("Logger object", openNISettings.m_logger, typeof(UNIEventLogger), true) as UNIEventLogger; openNISettings.m_query = EditorGUILayout.ObjectField("Query object", openNISettings.m_query, typeof(UNIQuery), true) as UNIQuery; m_myContent.text = "XML file"; m_myContent.tooltip = "Initialize from XML file."; openNISettings.m_XMLFileName = EditorGUILayout.TextField(m_myContent, openNISettings.m_XMLFileName); m_myContent.text = "Playback filename"; m_myContent.tooltip = "If this is not empty,it will hold the filename of a recording. NOTE: if XML is defing,this is ignored."; //m_myContent.image = openNISettings.m_texture; openNISettings.m_recordingFileName = EditorGUILayout.TextField(m_myContent, openNISettings.m_recordingFileName); m_myContent.text = "Reset floor normal"; m_myContent.tooltip = "If floor normal is updated in the game, it remains between game.If a new normal should be calculated,reset it between games.Note: this is only relevant while playing again and again in the editor as the normal will automationally be reset whenever the program is started again."; if (GUILayout.Button(m_myContent)) { //resetFloorNormal UNIConvertCoordinates.ResetFloorNormal(); } if (GUI.changed) { EditorUtility.SetDirty(target); } }
/// This method creates the inspector when the program is NOT running. In this mode we /// allow initialization but do not show any running information protected void InitInspector() { // for easy access to the object OpenNISettingsManager OpenNISettings = target as OpenNISettingsManager; // set the default mirroring. OpenNISettings.m_initMirroring = EditorGUILayout.Toggle("Mirror behavior ", OpenNISettings.m_initMirroring); // chooses the xml file. In most implementations this should be empty! OpenNISettings.m_XMLFileName = EditorGUILayout.TextField("XML file", OpenNISettings.m_XMLFileName); // set image generator use. OpenNISettings.m_useImageGenerator = EditorGUILayout.Toggle("Use image generator?", OpenNISettings.m_useImageGenerator); // set skeleton generator use. // show user and skeleton control status OpenNISettings.m_useSkeleton = EditorGUILayout.Toggle("Use user and skeleton?", OpenNISettings.m_useSkeleton); if (OpenNISettings.m_useSkeleton && OpenNISettings.m_useSkeleton) { EditorGUI.indentLevel += 2; OpenNISettings.m_smoothingFactor = EditorGUILayout.FloatField("Smoothing factor:", OpenNISettings.m_smoothingFactor); EditorGUI.indentLevel -= 2; } // initialize the logger and query objects OpenNISettings.m_Logger = EditorGUILayout.ObjectField("Logger object", OpenNISettings.m_Logger, typeof(NIEventLogger), true) as NIEventLogger; OpenNISettings.m_query = EditorGUILayout.ObjectField("Query object", OpenNISettings.m_query, typeof(NIQuery), true) as NIQuery; m_myContent.text = "Use Playback mode"; m_myContent.tooltip = "If this is checked then the game will use playback mode playing back sensor data from a recording. Please remember to set the XML file accordingly. See the documentation for more info"; OpenNISettings.m_playerbackMode = EditorGUILayout.Toggle(m_myContent, OpenNISettings.m_playerbackMode); m_myContent.text = "Reset floor normal"; m_myContent.tooltip = "If floor normal is updated in the game, it remains between games. If a new normal should be calculated, reset it between games. Note: this is only relevant while playing again and again in the editor as the normal will automatically be reset whenever the program is started again"; if (GUILayout.Button(m_myContent)) { NIConvertCoordinates.ResetFloorNormal(); } if (GUI.changed) { EditorUtility.SetDirty(target); } }
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; }
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; }
/// A method for initialization. It is called from the mono-behavior start method. /// @note if an extending class overwrite start, they should either call base.Start or simply call this /// method! protected virtual void InternalStart() { if (m_context == null) m_context = FindObjectOfType(typeof(OpenNISettingsManager)) as OpenNISettingsManager; if (m_context==null || m_context.Valid == false) { string str = "Context is invalid"; if (m_context == null) str = "Context is null"; Debug.Log(str); m_valid = false; return; } if(InitTexture(out m_mapTexture, out XRes, out YRes)==false || m_mapTexture==null) { m_context.m_Logger.Log("Failed to init texture", NIEventLogger.Categories.Initialization, NIEventLogger.Sources.BaseObjects, NIEventLogger.VerboseLevel.Errors); m_valid=false; return; } m_mapPixels = new Color[XRes * YRes]; m_valid = true; }
void Start() { 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); } } else { bool kinect2FoundBySystem = false; try { Kinect2SourceManager kinect2SourceManager = FindObjectOfType(typeof(Kinect2SourceManager)) as Kinect2SourceManager; if (kinect2SourceManager != null && kinect2SourceManager.GetSensor() != null && kinect2SourceManager.GetSensor().IsOpen) { // IsOpen seems to return false mostly if Kinect 2 drivers are not installed? // Debug.Log("Kinect 2 was detected by the system."); kinect2FoundBySystem = true; } else { Debug.LogError("Kinect 2 was NOT detected by the system. Disabling Kinect 2 in RUISInputManager."); } } catch (System.Exception e) { Debug.LogError("Kinect 2 was NOT detected by the system. Disabling Kinect 2 in RUISInputManager.\n" + e.Message); } if (!kinect2FoundBySystem) { enableKinect2 = 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; // } // } }
/// @brief Constructor /// /// @param settingsManager The settings manager to use /// @param userID The user id of the user this relates to. public NIPlayerCOMCandidateObject(OpenNISettingsManager settingsManager, int userID) : base(settingsManager, userID) { }
/// @brief mono-behavior start for initialization void Start() { m_mode = SkeletonGUIModes.SkeletonMode; // initialize all the external links if(m_input==null) { m_input = FindObjectOfType(typeof(NIInput)) as NIInput; if (m_input == null) throw new System.Exception("Please add an NIInput object to the scene"); } if (m_settings == null) { m_settings = FindObjectOfType(typeof(OpenNISettingsManager)) as OpenNISettingsManager; if (m_settings == null) throw new System.Exception("Please add an OpenNISettingsManager object to the scene"); } // a rect used later, this is mainly an initialization tempRect = new Rect(); tempRect.x = Screen.width / 2 - 60; tempRect.y = Screen.height / 2 - 20; tempRect.width = 120; tempRect.height = 40; m_controllers = FindObjectsOfType(typeof(NISkeletonController)) as NISkeletonController[]; NIGUI.SetActive(false); // we don't want to see the cursor yet so we deactivate NIGUI }
/// @brief Constructor /// /// @param settingsManager The settings manager to use /// @param userID The user id of the user this relates to. public NIPlayerPoseCandidateObject(OpenNISettingsManager settingsManager, int userID) : base(settingsManager, userID) { m_selectionOutOfPoseTime = float.MaxValue; // we put max value to make sure that this time will never arrive m_unselectionOutOfPoseTime = float.MinValue; // we put min value to make sure that even subtracting a couple of seconds we will always be in the past }
/// @brief Constructor /// /// @param settingsManager The settings manager to use /// @param userID The user id of the user this relates to. public NIPlayerCOMCandidateObject(OpenNISettingsManager settingsManager, int userID) : base(settingsManager, userID) { }
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; }
/// Release the gesture public override void ReleaseGesture() { if (m_context != null && m_context.UserSkeletonValid) { NISkeletonTracker tracker = m_pointTracker as NISkeletonTracker; if(tracker.Valid) { NISelectedPlayer player = tracker.GetTrackedPlayer(); if (player != null && player.Valid && validRequestedPoseDetection) { m_context.UserGenrator.ReleasePoseDetection(m_poseName, player.OpenNIUserID); } } } m_context = null; m_poseName = ""; m_pointTracker = null; }
/// @brief Constructor /// /// @param settingsManager The settings manager to use /// @param userID The user id of the user this relates to. public NIPlayerPoseCandidateObject(OpenNISettingsManager settingsManager, int userID) : base(settingsManager, userID) { m_selectionOutOfPoseTime = float.MaxValue; // we put max value to make sure that this time will never arrive m_unselectionOutOfPoseTime = float.MinValue; // we put min value to make sure that even subtracting a couple of seconds we will always be in the past }
/// @brief Internal method to initialize the player manager /// /// @note InternalInit is called from the mono behavior @ref Start method. It assumes the players /// (see @ref InitPlayers) were initialized before (during @ref Awake); protected virtual void InternalInit() { if (m_contextManager == null) m_contextManager = FindObjectOfType(typeof(OpenNISettingsManager)) as OpenNISettingsManager; if (m_contextManager == null) throw new NullReferenceException("No context manager in NIPlayerManager"); m_contextManager.UserGenrator.UserNode.NewUser += new EventHandler<NewUserEventArgs>(NewUserCallback); m_contextManager.UserGenrator.UserNode.LostUser += new EventHandler<UserLostEventArgs>(LostUserCallback); m_users = new List<NIPlayerCandidateObject>(); }
/// This method creates the inspector when the program is running. In this mode we /// only show information on what is initialized, valid etc. but allow no changes. protected void RunInspector() { // for easy access to the object OpenNISettingsManager OpenNISettings = target as OpenNISettingsManager; // basic test. If the object is invalid, nothing else matters. if (OpenNISettings.Valid == false) { EditorGUILayout.LabelField("NI was not initialized and therefore everything is invalid!", ""); return; } // show the mirror capability (global one from the context). Note, we can change the mirroring (To // allow showing mirrored/unmirrored viewers in realtime) but this should NOT be used except for that // purpose OpenNISettings.Mirror = EditorGUILayout.Toggle("Mirror behavior ", OpenNISettings.Mirror); // show image generator status string str = "Not used"; if (OpenNISettings.m_useImageGenerator) { str = OpenNISettings.ImageValid ? "Valid" : "Invalid"; } EditorGUILayout.LabelField("Image Generator:", str); EditorGUILayout.Space(); // show user and skeleton control status if (OpenNISettings.m_useSkeleton) { str = OpenNISettings.UserSkeletonValid ? "user and skeleton control is Valid" : "user and skeleton control is Invalid"; m_userAndSkeletonControlFoldout = EditorGUILayout.Foldout(m_userAndSkeletonControlFoldout, str); if (m_userAndSkeletonControlFoldout && OpenNISettings.UserSkeletonValid) { EditorGUI.indentLevel += 2; IList <int> users = OpenNISettings.UserGenrator.Users; EditorGUILayout.LabelField("Identified " + users.Count + " users", ""); for (int i = 0; i < users.Count; i++) { int userID = OpenNISettings.UserGenrator.GetNIUserId(users[i]); NIUserAndSkeleton.CalibrationState state = OpenNISettings.UserGenrator.GetUserCalibrationState(userID); Vector3 center = OpenNISettings.UserGenrator.GetUserCenterOfMass(userID); EditorGUILayout.LabelField("User:"******"" + i); EditorGUI.indentLevel += 2; EditorGUILayout.LabelField("user id:", "" + userID); EditorGUILayout.LabelField("unique id:", "" + users[i]); EditorGUILayout.LabelField("calibration state:", "" + state); EditorGUILayout.LabelField("center of mass:", "" + center); EditorGUI.indentLevel -= 2; } EditorGUILayout.Space(); OpenNISettings.SmoothFactor = EditorGUILayout.FloatField("Smoothing factor:", OpenNISettings.SmoothFactor); EditorGUI.indentLevel -= 2; } } else { EditorGUILayout.LabelField("user and skeleton control:", "Not used"); } EditorGUILayout.Space(); }
/// editor OnInspectorGUI to control the NIEventLogger properties override public void OnInspectorGUI() { EditorGUI.indentLevel = 0; EditorGUIUtility.LookLikeInspector(); NIQuery query = target as NIQuery; if (query.Valid == false) { query.ForceInit(); } if (query.m_queryDescriptions != null) { if (m_queryFoldout == null || m_queryFoldout.Length != query.m_queryDescriptions.Length) { m_queryFoldout = new bool[query.m_queryDescriptions.Length]; for (int i = 0; i < m_queryFoldout.Length; i++) { m_queryFoldout[i] = false; } } GUILayout.Label("Queries supported for " + query.m_queryDescriptions.Length + " nodes "); for (int i = 0; i < query.m_queryDescriptions.Length; i++) { m_queryFoldout[i] = EditorGUILayout.Foldout(m_queryFoldout[i], "" + query.m_queryDescriptions[i].m_nodeType + " nodes query"); if (m_queryFoldout[i]) { EditorGUI.indentLevel += 2; QueryDescription desc = query.m_queryDescriptions[i]; if (EditorApplication.isPlaying == false) { desc.m_nodeName = EditorGUILayout.TextField("Node name", desc.m_nodeName); desc.m_vendorName = EditorGUILayout.TextField("Vendor name", desc.m_vendorName); EditorGUILayout.LabelField("Min version: ", desc.RequiresMinVersion() ? "Limited" : "no limitation"); desc.GetMinVersionArr(ref m_Version); EditorGUILayout.BeginHorizontal(); EditorGUILayout.Space(); for (int j = 0; j < m_Version.Length; j++) { if (j != 0) { GUILayout.Label(".", GUILayout.MaxWidth(5)); } m_Version[j] = EditorGUILayout.IntField(m_Version[j], GUILayout.MaxWidth(25)); } EditorGUILayout.EndHorizontal(); desc.SetMinVersion(m_Version); EditorGUILayout.LabelField("Max version: ", desc.RequiresMaxVersion() ? "Limited" : "no limitation"); desc.GetMaxVersionArr(ref m_Version); EditorGUILayout.BeginHorizontal(); EditorGUILayout.Space(); for (int j = 0; j < m_Version.Length; j++) { if (j != 0) { GUILayout.Label(".", GUILayout.MaxWidth(5)); } m_Version[j] = EditorGUILayout.IntField(m_Version[j], GUILayout.MaxWidth(25)); } EditorGUILayout.EndHorizontal(); desc.SetMaxVersion(m_Version); } ProductionNodeDescription curNodeDesc; if (OpenNISettingsManager.GetProductionNodeInformation(desc.m_nodeType, out curNodeDesc)) { EditorGUILayout.LabelField("Last node loaded was:", ""); EditorGUI.indentLevel += 2; EditorGUILayout.LabelField("Node name", curNodeDesc.Name); EditorGUILayout.LabelField("Vendor name", curNodeDesc.Vendor); EditorGUILayout.LabelField("Version:", "" + curNodeDesc.Version.Major + "." + curNodeDesc.Version.Minor + "." + curNodeDesc.Version.Maintenance + "." + curNodeDesc.Version.Build); EditorGUI.indentLevel -= 2; } else { GUILayout.Label(" Load node to see its info"); } EditorGUI.indentLevel -= 2; query.m_queryDescriptions[i] = desc; } } } if (GUI.changed) { EditorUtility.SetDirty(target); } }
/// @brief Releases all internal objects. /// /// Release all internal objects in a reverse order to initialization. /// @note after releasing this object becomes uninitialized!!! /// @note any who plan to override this must call the base at the END of the method (as /// InitTracking changes the context to null!). public virtual void StopTracking() { m_valid = false; m_context = null; }
/// @brief Releases all internal objects. /// /// Release all internal objects in a reverse order to initialization. /// @note after releasing this object becomes uninitialized!!! /// @note any who plan to override this must call the base at the END of the method (as /// InitTracking changes the context to null!). public virtual void StopTracking() { m_valid = false; m_context = null; }
/// @brief performs the initialization /// /// This method performs the initialization of the hand to a specific context. /// @note in most cases child classes should NOT override this method but rather instead /// override InitInternalStructures /// @param newContext the context to use. /// @return true on success, false on failure. public virtual bool InitTracking(OpenNISettingsManager newContext) { StopTracking(); // to make sure it is released. if (InitContext(newContext) == false) { StopTracking(); return false; } if (InitInternalStructures() == false) { StopTracking(); return false; } m_valid=true; return true; }
/// this method does initialization when the Awake method is called. It should be overriden instead /// of Awake... protected virtual void InternalAwake() { m_valid = false; if (m_context == null) m_context = FindObjectOfType(typeof(OpenNISettingsManager)) as OpenNISettingsManager; }
protected override void DrawPlayerManager() { base.DrawPlayerManager(); AS_UNIPlayerManagerPoseSelection manager = target as AS_UNIPlayerManagerPoseSelection; string[] legalPose = UNIUserAndSkeleton.GetLegalPoses(); if (legalPose != null) { int selectedIndex; if (manager.m_PoseToSelect == null) { selectedIndex = 0; } else { for (selectedIndex = 0; selectedIndex < legalPose.Length; selectedIndex++) { if (manager.m_PoseToSelect.CompareTo(legalPose[selectedIndex]) == 0) { break; } } } if (selectedIndex >= legalPose.Length) { selectedIndex = 0; } selectedIndex = EditorGUILayout.Popup("Pose to select", selectedIndex, legalPose); manager.m_PoseToSelect = legalPose[selectedIndex]; bool useUnselectionPose = manager.m_PoseToUnselect != null && manager.m_PoseToUnselect.CompareTo("") != 0; useUnselectionPose = EditorGUILayout.Toggle("Use unselection pose", useUnselectionPose); if (useUnselectionPose == false) { manager.m_PoseToUnselect = ""; } else { if (manager.m_PoseToUnselect == null) { selectedIndex = 0; } else { for (selectedIndex = 0; selectedIndex < legalPose.Length; selectedIndex++) { if (legalPose[selectedIndex] == manager.m_PoseToUnselect) { break; } } } if (selectedIndex >= legalPose.Length) { selectedIndex = 0; } selectedIndex = EditorGUILayout.Popup("Pose to unselect", selectedIndex, legalPose); manager.m_PoseToUnselect = legalPose[selectedIndex]; } } else { EditorGUILayout.LabelField("Pose to select", manager.m_PoseToSelect); EditorGUILayout.LabelField("pose to unselect", manager.m_PoseToUnselect); } manager.m_timeToSwitch = EditorGUILayout.FloatField("Time between switching", manager.m_timeToSwitch); if (manager.m_timeToSwitch < 0) { manager.m_timeToSwitch = 0; } if (EditorApplication.isPlaying == false) { if (GUILayout.Button("Update legal pose")) { OpenNISettingsManager.InspectorReloadAnInstance(); } } }
// protected methods /// an internal method to initialize the context. /// @param newContext the context to initialize /// @return true on success (which also initializes the context) and false on failure /// (releasing is the responsibility of the caller) protected virtual bool InitContext(OpenNISettingsManager newContext) { // checks we have a context and hands. if (newContext.Valid == false) { newContext.Log("received invalid context!", NIEventLogger.Categories.Initialization, NIEventLogger.Sources.Hands, NIEventLogger.VerboseLevel.Errors); return false; } m_context = newContext; return true; }
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 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; }