// // resets the last valid right hand event // public void ResetRightHandEvent() // { // lastRightHandEvent = InteractionWrapper.InteractionHandEventType.None; // } //----------------------------------- end of public functions --------------------------------------// void Awake() { // ensure the needed dlls are in place if (WrapperTools.EnsureKinectWrapperPresence()) { // reload the same level WrapperTools.RestartLevel(gameObject, "IM"); } }
//----------------------------------- end of public functions --------------------------------------// void Awake() { // ensure the needed dlls are in place if (WrapperTools.EnsureKinectWrapperPresence()) { // reload the same level WrapperTools.RestartLevel(gameObject, "SM"); } // copy the grammar file from the resources, if not found if ((grammarFileName != "") && !File.Exists(grammarFileName)) { TextAsset textRes = Resources.Load(grammarFileName, typeof(TextAsset)) as TextAsset; if (textRes != null) { string sResText = textRes.text; File.WriteAllText(grammarFileName, sResText); } } }
void Awake() { WrapperTools.EnsureKinectWrapperPresence(); int hr = 0; try { hr = KinectWrapper.NuiInitialize(KinectWrapper.NuiInitializeFlags.UsesSkeleton | KinectWrapper.NuiInitializeFlags.UsesDepthAndPlayerIndex); if (hr != 0) { throw new Exception("NuiInitialize Failed"); } hr = KinectWrapper.NuiSkeletonTrackingEnable(IntPtr.Zero, 8); // 0, 12,8 if (hr != 0) { throw new Exception("Cannot initialize Skeleton Data"); } depthStreamHandle = IntPtr.Zero; // set kinect elevation angle KinectWrapper.NuiCameraElevationSetAngle(SensorAngle); // init skeleton structures skeletonFrame = new KinectWrapper.NuiSkeletonFrame() { SkeletonData = new KinectWrapper.NuiSkeletonData[KinectWrapper.Constants.NuiSkeletonCount] }; // values used to pass to smoothing function smoothParameters = new KinectWrapper.NuiTransformSmoothParameters(); switch (smoothing) { case Smoothing.Default: smoothParameters.fSmoothing = 0.5f; smoothParameters.fCorrection = 0.5f; smoothParameters.fPrediction = 0.5f; smoothParameters.fJitterRadius = 0.05f; smoothParameters.fMaxDeviationRadius = 0.04f; break; case Smoothing.Medium: smoothParameters.fSmoothing = 0.5f; smoothParameters.fCorrection = 0.1f; smoothParameters.fPrediction = 0.5f; smoothParameters.fJitterRadius = 0.1f; smoothParameters.fMaxDeviationRadius = 0.1f; break; case Smoothing.Aggressive: smoothParameters.fSmoothing = 0.7f; smoothParameters.fCorrection = 0.3f; smoothParameters.fPrediction = 1.0f; smoothParameters.fJitterRadius = 1.0f; smoothParameters.fMaxDeviationRadius = 1.0f; break; } // init the tracking state filter trackingStateFilter = new TrackingStateFilter[KinectWrapper.Constants.NuiSkeletonMaxTracked]; for (int i = 0; i < trackingStateFilter.Length; i++) { trackingStateFilter[i] = new TrackingStateFilter(); trackingStateFilter[i].Init(); } // init the bone orientation filter boneOrientationFilter = new BoneOrientationsFilter[KinectWrapper.Constants.NuiSkeletonMaxTracked]; for (int i = 0; i < boneOrientationFilter.Length; i++) { boneOrientationFilter[i] = new BoneOrientationsFilter(); boneOrientationFilter[i].Init(); } // init the clipped legs filter clippedLegsFilter = new ClippedLegsFilter[KinectWrapper.Constants.NuiSkeletonMaxTracked]; for (int i = 0; i < clippedLegsFilter.Length; i++) { clippedLegsFilter[i] = new ClippedLegsFilter(); } // init the bone orientation constraints boneConstraintsFilter = new BoneOrientationsConstraint(); boneConstraintsFilter.AddDefaultConstraints(); // init the self intersection constraints selfIntersectionConstraint = new SelfIntersectionConstraint(); // create arrays for joint positions and joint orientations int skeletonJointsCount = (int)KinectWrapper.NuiSkeletonPositionIndex.Count; player1JointsTracked = new bool[skeletonJointsCount]; player1PrevTracked = new bool[skeletonJointsCount]; player1JointsPos = new Vector3[skeletonJointsCount]; player1JointsOri = new Matrix4x4[skeletonJointsCount]; gestureTrackingAtTime = new float[KinectWrapper.Constants.NuiSkeletonMaxTracked]; //create the transform matrix that converts from kinect-space to world-space Quaternion quatTiltAngle = new Quaternion(); quatTiltAngle.eulerAngles = new Vector3(-SensorAngle, 0.0f, 0.0f); //float heightAboveHips = SensorHeight - 1.0f; // transform matrix - kinect to world kinectToWorld.SetTRS(new Vector3(0.0f, SensorHeight, 0.0f), quatTiltAngle, Vector3.one); flipMatrix = Matrix4x4.identity; flipMatrix[2, 2] = -1; } catch (DllNotFoundException e) { string message = "Please check the Kinect SDK installation."; Debug.LogError(message); Debug.LogError(e.ToString()); return; } catch (Exception e) { string message = e.Message + " - " + KinectWrapper.GetNuiErrorString(hr); Debug.LogError(message); Debug.LogError(e.ToString()); return; } // Initialize user list to contain ALL users. allUsers = new List <uint>(); KinectInitialized = true; }