当前位置: 首页>>代码示例>>C#>>正文


C# KinectWrapper类代码示例

本文整理汇总了C#中KinectWrapper的典型用法代码示例。如果您正苦于以下问题:C# KinectWrapper类的具体用法?C# KinectWrapper怎么用?C# KinectWrapper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


KinectWrapper类属于命名空间,在下文中一共展示了KinectWrapper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GestureCompleted

    public bool GestureCompleted(uint userId, int userIndex, KinectGestures.Gestures gesture, 
	                              KinectWrapper.NuiSkeletonPositionIndex joint, Vector3 screenPos)
    {
        if (gesture == KinectGestures.Gestures.SwipeLeft && Cart.scene2) {
            Debug.Log("Swipe Left Completed!");
            GameObject.FindObjectOfType<Shelf>().SwipeLeft();
        }

        if (gesture == KinectGestures.Gestures.SwipeRight && Cart.scene2) {
            //Debug.Log("Swipe Left Completed!");
            GameObject.FindObjectOfType<Cart>().SwipeRight();
            Debug.Log("Swipe Right Completed!");
        }

        string sGestureText = gesture + " detected";
        if(gesture == KinectGestures.Gestures.Click)
            sGestureText += string.Format(" at ({0:F1}, {1:F1})", screenPos.x, screenPos.y);

        if(GestureInfo != null)
            GestureInfo.GetComponent<GUIText>().text = sGestureText;

        progressDisplayed = false;

        return true;
    }
开发者ID:Evi91,项目名称:menu,代码行数:25,代码来源:SimpleGestureListener.cs

示例2: CopySkeleton

    // CopySkeleton copies the data from another skeleton.
    public static void CopySkeleton(ref KinectWrapper.NuiSkeletonData source, ref KinectWrapper.NuiSkeletonData destination)
    {
        //        if (null == source)
        //        {
        //            return;
        //        }
        //
        //        if (null == destination)
        //        {
        //            destination = new Skeleton();
        //        }

        destination.eTrackingState = source.eTrackingState;
        destination.dwTrackingID = source.dwTrackingID;
        destination.Position = source.Position;
        destination.dwQualityFlags = source.dwQualityFlags;

        int jointsCount = (int)KinectWrapper.NuiSkeletonPositionIndex.Count;

        if(destination.SkeletonPositions == null)
            destination.SkeletonPositions = new Vector4[jointsCount];
        if(destination.eSkeletonPositionTrackingState == null)
            destination.eSkeletonPositionTrackingState = new KinectWrapper.NuiSkeletonPositionTrackingState[jointsCount];

        for(int jointIndex = 0; jointIndex < jointsCount; jointIndex++)
        {
            destination.SkeletonPositions[jointIndex] = source.SkeletonPositions[jointIndex];
            destination.eSkeletonPositionTrackingState[jointIndex] = source.eSkeletonPositionTrackingState[jointIndex];
        }
    }
开发者ID:vanstorm9,项目名称:KinectSwordFight,代码行数:31,代码来源:KinectHelper.cs

示例3: Init

    // Initialize the filter with a set of TransformSmoothParameters.
    public void Init(KinectWrapper.NuiTransformSmoothParameters smoothingParameters)
    {
        this.smoothParameters = smoothingParameters;

        this.Reset();
        this.init = true;
    }
开发者ID:ranguera,项目名称:Kinect-DAT,代码行数:8,代码来源:TrackingStateFilter.cs

示例4: Constrain

    // ConstrainSelfIntersection collides joints with the skeleton to keep the skeleton's hands and wrists from puncturing its body
    // A cylinder is created to represent the torso. Intersecting joints have their positions changed to push them outside the torso.
    public void Constrain(ref KinectWrapper.NuiSkeletonData skeleton)
    {
//        if (null == skeleton)
//        {
//            return;
//        }

		int shoulderCenterIndex = (int)KinectWrapper.NuiSkeletonPositionIndex.ShoulderCenter;
		int hipCenterIndex = (int)KinectWrapper.NuiSkeletonPositionIndex.HipCenter;

        if (skeleton.eSkeletonPositionTrackingState[shoulderCenterIndex] != KinectWrapper.NuiSkeletonPositionTrackingState.NotTracked &&
            skeleton.eSkeletonPositionTrackingState[hipCenterIndex] != KinectWrapper.NuiSkeletonPositionTrackingState.NotTracked)
        {
            Vector3 shoulderDiffLeft = KinectHelper.VectorBetween(ref skeleton, shoulderCenterIndex, (int)KinectWrapper.NuiSkeletonPositionIndex.ShoulderLeft);
            Vector3 shoulderDiffRight = KinectHelper.VectorBetween(ref skeleton, shoulderCenterIndex, (int)KinectWrapper.NuiSkeletonPositionIndex.ShoulderRight);
            float shoulderLengthLeft = shoulderDiffLeft.magnitude;
            float shoulderLengthRight = shoulderDiffRight.magnitude;

            // The distance between shoulders is averaged for the radius
            float cylinderRadius = (shoulderLengthLeft + shoulderLengthRight) * 0.5f;
    
            // Calculate the shoulder center and the hip center.  Extend them up and down respectively.
            Vector3 shoulderCenter = (Vector3)skeleton.SkeletonPositions[shoulderCenterIndex];
            Vector3 hipCenter = (Vector3)skeleton.SkeletonPositions[hipCenterIndex];
            Vector3 hipShoulder = hipCenter - shoulderCenter;
            hipShoulder.Normalize();

            shoulderCenter = shoulderCenter - (hipShoulder * (ShoulderExtend * cylinderRadius));
            hipCenter = hipCenter + (hipShoulder * (HipExtend * cylinderRadius));
    
            // Optionally increase radius to account for bulky avatars
            cylinderRadius *= RadiusMultiplier;
   
            // joints to collide
            int[] collisionIndices = 
			{ 
				(int)KinectWrapper.NuiSkeletonPositionIndex.WristLeft, 
				(int)KinectWrapper.NuiSkeletonPositionIndex.HandLeft, 
				(int)KinectWrapper.NuiSkeletonPositionIndex.WristRight, 
				(int)KinectWrapper.NuiSkeletonPositionIndex.HandRight 
			};
    
            foreach (int j in collisionIndices)
            {
                Vector3 collisionJoint = (Vector3)skeleton.SkeletonPositions[j];
                
                Vector4 distanceNormal = KinectHelper.DistanceToLineSegment(shoulderCenter, hipCenter, collisionJoint);

                Vector3 normal = new Vector3(distanceNormal.x, distanceNormal.y, distanceNormal.z);

                // if distance is within the cylinder then push the joint out and away from the cylinder
                if (distanceNormal.w < cylinderRadius)
                {
                    collisionJoint += normal * ((cylinderRadius - distanceNormal.w) * CollisionTolerance);

                    skeleton.SkeletonPositions[j] = (Vector4)collisionJoint;
                }
            }
        }
    }
开发者ID:ReaperCZ,项目名称:UnityTemp,代码行数:62,代码来源:SelfIntersectionConstraint.cs

示例5: GestureCompleted

    public bool GestureCompleted(uint userId, int userIndex, KinectGestures.Gestures gesture, 
	                              KinectWrapper.NuiSkeletonPositionIndex joint, Vector3 screenPos)
    {
        string sGestureText = gesture + " detected";
        if (gesture == KinectGestures.Gestures.Click) {
            sGestureText += string.Format (" at ({0:F1}, {1:F1})", screenPos.x, screenPos.y);
            print ("CLICKED DOWN???!?!?!?!?!");	//reverse units
            print ("SCREEN POS: " + screenPos);
            clickedPos.x = screenPos.x;
            clickedPos.y = screenPos.y;
            GetComponent<LineGame> ().kinectClickedOn = true;
            GetComponent<LineGame> ().clickedPos = clickedPos;
            GetComponent<Main> ().kinectClickedOn = true;
            GetComponent<Main> ().clickedPos = clickedPos;
            GetComponent<GrowingTeamGame> ().kinectClickedOn = true;
            GetComponent<GrowingTeamGame> ().clickedPos = clickedPos;
            GetComponent<AquariumGame> ().kinectClickedOn = true;
            GetComponent<AquariumGame> ().clickedPos = clickedPos;
        }

        if(GestureInfo != null)
            GestureInfo.GetComponent<GUIText>().text = sGestureText;

        progressDisplayed = false;

        return true;
    }
开发者ID:EECS481AquaTeam,项目名称:Aquarium,代码行数:27,代码来源:SimpleGestureListener.cs

示例6: GestureCompleted

    public bool GestureCompleted(uint userId, int userIndex, KinectGestures.Gestures gesture, 
		KinectWrapper.SkeletonJoint joint, Vector3 screenPos)
    {
        KinectManager manager = KinectManager.Instance;
        string sGestureText = gesture + " detected";
        if(GestureInfo != null)
        {
            GestureInfo.guiText.text = sGestureText;
        }

        if (gesture == KinectGestures.Gestures.SwipeLeft)
            swipeLeft = true;
        else if (gesture == KinectGestures.Gestures.SwipeRight)
            swipeRight = true;
        //else if(gesture == KinectGestures.Gestures.RaiseLeftHand)
        //    RaiseLeftHand = true;
        //else if(gesture == KinectGestures.Gestures.RaiseRightHand)
        //    RaiseRightHand = true;
        else if (gesture == KinectGestures.Gestures.Push)
            Push = true;
        else if (gesture == KinectGestures.Gestures.Psi)
            PSI = true;
        else if (gesture == KinectGestures.Gestures.Wave)
            Wave = true;
        return true;
    }
开发者ID:jsnulla,项目名称:IFX,代码行数:26,代码来源:GestureListener.cs

示例7: GestureInProgress

    public void GestureInProgress(uint userId, int userIndex, KinectGestures.Gestures gesture, 
	                              float progress, KinectWrapper.NuiSkeletonPositionIndex joint, Vector3 screenPos)
    {
        //GestureInfo.guiText.text = string.Format("{0} Progress: {1:F1}%", gesture, (progress * 100));
        if(gesture == KinectGestures.Gestures.Click && progress > 0.3f)
        {
            string sGestureText = string.Format ("{0} {1:F1}% complete", gesture, progress * 100);
            if(GestureInfo != null)
                GestureInfo.GetComponent<GUIText>().text = sGestureText;

            progressDisplayed = true;
        }
        else if((gesture == KinectGestures.Gestures.ZoomOut || gesture == KinectGestures.Gestures.ZoomIn) && progress > 0.5f)
        {
            string sGestureText = string.Format ("{0} detected, zoom={1:F1}%", gesture, screenPos.z * 100);
            if(GestureInfo != null)
                GestureInfo.GetComponent<GUIText>().text = sGestureText;

            progressDisplayed = true;
        }
        else if(gesture == KinectGestures.Gestures.Wheel && progress > 0.5f)
        {
            string sGestureText = string.Format ("{0} detected, angle={1:F1} deg", gesture, screenPos.z);
            if(GestureInfo != null)
                GestureInfo.GetComponent<GUIText>().text = sGestureText;

            progressDisplayed = true;
        }
    }
开发者ID:PC-Yolger,项目名称:Tesis-de-Grado---Unity-and-Kinect,代码行数:29,代码来源:SimpleGestureListener.cs

示例8: GestureCompleted

    public bool GestureCompleted(uint userId, int userIndex, KinectGestures.Gestures gesture,
								 KinectWrapper.NuiSkeletonPositionIndex joint, Vector3 screenPos)
    {
        string sGestureText = gesture + " detected";
        if(GestureInfo != null)
        {
            GestureInfo.guiText.text = sGestureText;
        }
          	if(gesture == KinectGestures.Gestures.SwipeLeft)
          	{
            swipeLeft = true;
          	}
        if(gesture == KinectGestures.Gestures.SwipeRight)
        {
            swipeRight = true;
        }
        if(gesture == KinectGestures.Gestures.SwipeUp)
        {
          swipeUp = true;
        }
        if(gesture == KinectGestures.Gestures.SwipeDown)
        {
          swipeDown = true;
        }
        if(gesture == KinectGestures.Gestures.Push)
        {
          push = true;
        }
        if(gesture == KinectGestures.Gestures.Pull)
        {
          pull = true;
        }

          return true;
    }
开发者ID:songwanfu,项目名称:MotionSensing3DSolarSystem,代码行数:35,代码来源:GestureListener1.cs

示例9: PoseAngle

    public PoseAngle(KinectWrapper.NuiSkeletonPositionIndex centerJoint, KinectWrapper.NuiSkeletonPositionIndex angleJoint,
		double angle, double threshold)
    {
        CenterJoint = centerJoint;
        AngleJoint = angleJoint;
        Angle = angle;
        Threshold = threshold;
    }
开发者ID:jaredbruhn,项目名称:KinectPose,代码行数:8,代码来源:PoseAngle.cs

示例10: IsTrackedOrInferred

    // IsTrackedOrInferred checks whether the skeleton joint is tracked or inferred.
    public static bool IsTrackedOrInferred(KinectWrapper.NuiSkeletonData skeleton, int jointIndex)
    {
//            if (null == skeleton)
//            {
//                return false;
//            }

		return skeleton.eSkeletonPositionTrackingState[jointIndex] != KinectWrapper.NuiSkeletonPositionTrackingState.NotTracked;
    }
开发者ID:ReaperCZ,项目名称:UnityTemp,代码行数:10,代码来源:KinectHelper.cs

示例11: JointConstraint

    public JointConstraint( KinectWrapper.Joints joint_a,
							KinectWrapper.Joints joint_b,
							Relations relation,
							Operators operation,
							Vector3 val )
    {
        this.joint_a = joint_a;
        this.joint_b = joint_b;
        this.relation = relation;
        this.operation = operation;
        this.val = val;
    }
开发者ID:vladotrocol,项目名称:van-dyke,代码行数:12,代码来源:JointConstraint.cs

示例12: GestureInProgress

    public void GestureInProgress(uint userId, int userIndex, KinectGestures.Gestures gesture, 
	                              float progress, KinectWrapper.NuiSkeletonPositionIndex joint, Vector3 screenPos)
    {
        if (gesture == KinectGestures.Gestures.SwipeLeft)
        {
            //Debug.Log("SwipeLeft " + progress + " Screen Pos: "+ screenPos + " Gesture: " + gesture);
        }
        if (gesture == KinectGestures.Gestures.SwipeRight)
        {
            //Debug.Log("SwipeRight " + progress + " Screen Pos: "+ screenPos + " Gesture: " + gesture);
        }
    }
开发者ID:Evi91,项目名称:menu,代码行数:12,代码来源:MineGestureListener.cs

示例13: LerpAndApply

    // LerpAndApply performs a Lerp and applies the Lerped vector to the skeleton joint.
    public static void LerpAndApply(ref KinectWrapper.NuiSkeletonData skeleton, int jointIndex, Vector3 newJointPos, float lerpValue, KinectWrapper.NuiSkeletonPositionTrackingState finalTrackingState)
    {
//            if (null == skeleton)
//            {
//                return;
//            }

		Vector3 jointPos = (Vector3)skeleton.SkeletonPositions[jointIndex];
        jointPos = Vector3.Lerp(jointPos, newJointPos, lerpValue);
	
		skeleton.SkeletonPositions[jointIndex] = (Vector4)jointPos;
		skeleton.eSkeletonPositionTrackingState[jointIndex] = finalTrackingState;
    }
开发者ID:ReaperCZ,项目名称:UnityTemp,代码行数:14,代码来源:KinectHelper.cs

示例14: GestureCompleted

    public bool GestureCompleted(uint userId, int userIndex, KinectGestures.Gestures gesture, 
	                              KinectWrapper.NuiSkeletonPositionIndex joint, Vector3 screenPos)
    {
        string sGestureText = gesture + " detected";
        if(gesture == KinectGestures.Gestures.Click)
            sGestureText += string.Format(" at ({0:F1}, {1:F1})", screenPos.x, screenPos.y);

        if(GestureInfo != null)
            GestureInfo.GetComponent<GUIText>().text = sGestureText;

        progressDisplayed = false;

        return true;
    }
开发者ID:PC-Yolger,项目名称:Tesis-de-Grado---Unity-and-Kinect,代码行数:14,代码来源:SimpleGestureListener.cs

示例15: GestureCancelled

    public bool GestureCancelled(uint userId, int userIndex, KinectGestures.Gestures gesture, 
	                              KinectWrapper.NuiSkeletonPositionIndex joint)
    {
        if(progressDisplayed)
        {
            // clear the progress info
            if(GestureInfo != null)
                GestureInfo.GetComponent<GUIText>().text = String.Empty;

            progressDisplayed = false;
        }

        return true;
    }
开发者ID:PC-Yolger,项目名称:Tesis-de-Grado---Unity-and-Kinect,代码行数:14,代码来源:SimpleGestureListener.cs


注:本文中的KinectWrapper类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。