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


C# Body.FirstOrDefault方法代码示例

本文整理汇总了C#中Body.FirstOrDefault方法的典型用法代码示例。如果您正苦于以下问题:C# Body.FirstOrDefault方法的具体用法?C# Body.FirstOrDefault怎么用?C# Body.FirstOrDefault使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Body的用法示例。


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

示例1: Select

        public Body Select(BodyFrame frame)
        {
            if (frame == null || frame.BodyCount == 0)
            {
                this.trackingId = 0;
                return null;
            }

            var bodies = new Body[frame.BodyCount];
            frame.GetAndRefreshBodyData(bodies);

            var trackedBody = bodies.FirstOrDefault(b =>
                b.TrackingId == this.trackingId &&
                b.Joints[JointType.HandLeft].Position.Y > b.Joints[JointType.HipLeft].Position.Y + 0.05);

            if (trackedBody != null)
            {
                return trackedBody;
            }

            var activeBody = bodies.FirstOrDefault(b =>
                b.IsTracked &&
                b.HandLeftState == HandState.Open &&
                b.Joints[JointType.HandLeft].Position.Y > b.Joints[JointType.ShoulderLeft].Position.Y);

            if (activeBody != null)
            {
                this.trackingId = activeBody.TrackingId;
                return activeBody;
            }

            this.trackingId = 0;
            return null;
        }
开发者ID:primarilysoftware,项目名称:kinect-cursor,代码行数:34,代码来源:SimpleActiveBodySelector.cs

示例2: ProcessMove

        private void ProcessMove(object sender, MultiSourceFrameArrivedEventArgs e)
        {
            unchecked { _frameCount++; }
            Body[] bodys = null;
            var mFrame = e.FrameReference.AcquireFrame();
            Vector4 kinectHeight;

            using (var bodyframe = mFrame.BodyFrameReference.AcquireFrame())
            {
                if (bodyframe == null)
                {
                    return;
                }
                kinectHeight = bodyframe.FloorClipPlane;
                bodys = new Body[bodyframe.BodyCount];
                bodyframe.GetAndRefreshBodyData(bodys);
            }

            var body = bodys.FirstOrDefault(b=>b.IsTracked);

            if (body == null)
            {
                return;
            }

            var head = body.Joints[JointType.Head];
            var handLeft = body.Joints[JointType.HandLeft];
            var handRight = body.Joints[JointType.HandRight];

            if (head.TrackingState == TrackingState.NotTracked ||
                handLeft.TrackingState == TrackingState.NotTracked ||
                handRight.TrackingState == TrackingState.NotTracked)
            {
                return;
            }

            TrackForeMove(body, head, handLeft, handRight);
        }
开发者ID:RomaRudyak,项目名称:start-wars-move-the-sphero,代码行数:38,代码来源:JediGestureRecognizer.cs

示例3: Release

        private void Release(ICvarcEngine engine, Body Body)
        {
            var latestGripped = Body.FirstOrDefault(z => z.Type.StartsWith("D") && z.Type.Length == 2);
            if (latestGripped == null) return;

            var absoluteLocation = latestGripped.GetAbsoluteLocation();
            Body.Remove(latestGripped);

            latestGripped.FrictionCoefficient = frictionCoefficientsById.SafeGet(latestGripped.Id);
            var targetColor = latestGripped.Type[1].ToString();

            latestGripped.Location = absoluteLocation;
            latestGripped.Velocity = Body.Velocity;
            var toAtt = Body.TreeRoot.GetSubtreeChildrenFirst()
                            .Where(a =>
                                    (a.Type == "VW" + targetColor || a.Type == "HW" + targetColor) &&
                                    Distance(latestGripped, a) < 30)
                            .OfType<Box>()
                            .FirstOrDefault();

            if (toAtt != null)
            {
                Body.TreeRoot.Remove(toAtt);
                var wall = new Box
                {
                    Type = toAtt.Type.Substring(0, 2),
                    XSize = toAtt.XSize,
                    YSize = toAtt.YSize,
                    ZSize = toAtt.ZSize,
                    Location = toAtt.Location,
                    DefaultColor = SRCompetitions.WallColor,
                    IsStatic = true,
                    IsMaterial = true
                };
                Body.TreeRoot.Add(wall);
                engine.RaiseOnCollision(Body.Id.ToString(), toAtt.Id.ToString(), GetCollisionType(targetColor));
            }
            else
                Body.TreeRoot.Add(latestGripped);
            //  gripped.RemoveRange(0, gripped.Count);
        }
开发者ID:DmitryZyr,项目名称:CVARC,代码行数:41,代码来源:CvarcEngine.cs

示例4: MultiSourceFrameArrived

        private void MultiSourceFrameArrived(object sender, MultiSourceFrameArrivedEventArgs e)
        {
            using (var bodyFrame = e.FrameReference.AcquireFrame().BodyFrameReference.AcquireFrame())
            {
                var bodys = new Body[6];

                if (bodyFrame == null)
                {
                    return;
                }

                bodyFrame.GetAndRefreshBodyData(bodys);

                var b = bodys.FirstOrDefault(body => body.IsTracked);
                if (b == null)
                {
                    return;
                }

                var head = b.Joints[JointType.Head];
                var hand = b.Joints[JointType.HandRight];

                SetpointXZ(this.headXZ, head);
                SetpointXZ(this.heandXZ, hand);

                SetpointZY(headZY, head);
                SetpointZY(heand1ZY, hand);
            }
        }
开发者ID:RomaRudyak,项目名称:start-wars-move-the-sphero,代码行数:29,代码来源:MainWindow.xaml.cs


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