本文整理汇总了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;
}
示例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);
}
示例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);
}
示例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);
}
}