/// <summary> /// Update the logic for the window. /// </summary> protected void Update() { if (isNUIOn && ZigEditorInput.Instance.ReaderInited) { // Update Device ZigEditorInput.Instance.Update(); // Get the tracked user ZigTrackedUser user = null; foreach (KeyValuePair <int, ZigTrackedUser> trackedUser in ZigEditorInput.Instance.TrackedUsers) { user = trackedUser.Value; } // Update viewers if (viewerType == NUIViewerType.DepthViewer) { depthViewer.Update(ZigEditorInput.Depth, user, viewNodes); } else if (viewerType == NUIViewerType.ImageViewer) { imageViewer.Update(ZigEditorInput.Image, kinectCaptureResolution, user, viewNodes); } //else if (viewerType == NUIViewerType.DepthAndImageViewer) //{ // mixedViewer.Update(ZigEditorInput.Image, ZigEditorInput.Depth, kinectCaptureResolution); //} // Check if in pre-recording state if (captureState == RecordingState.PreRecording) { long timeLeft = (delaySeconds * 1000) - stopwatch.ElapsedMilliseconds; if (timeLeft <= 0) { // Begin recording data BeginRecording(); } } // Add a keyframe if in recording state if (user != null && captureData != null && user.SkeletonTracked && captureState == RecordingState.Recording) { captureData.AddKeyframe(user.Skeleton, stopwatch.ElapsedMilliseconds); } // Pose the preview model if (inputMapper != null && cinema_mocap_humanoid_instance != null && user != null && user.SkeletonTracked) { RealtimeHumanoidPosing poser = cinema_mocap_humanoid_instance.GetComponent <RealtimeHumanoidPosing>(); poser.SetRotations(inputMapper.GetRotations(user.Skeleton)); poser.SetWorldPosition(inputMapper.GetHipPosition(user.Skeleton)); } Repaint(); } }
/// <summary> /// Destroy the zig editor input. /// </summary> private void turnOffNUIDevice() { ZigEditorInput.Instance.ShutdownReader(); isNUIOn = ZigEditorInput.Instance.ReaderInited; if (captureState != RecordingState.NotRecording) { StopRecording(); } if (cinema_mocap_humanoid_instance != null && inputMapper != null) { RealtimeHumanoidPosing poser = cinema_mocap_humanoid_instance.GetComponent <RealtimeHumanoidPosing>(); poser.SetRotations(inputMapper.GetBaseRotations()); } }