本文整理汇总了C#中Frame.Translation方法的典型用法代码示例。如果您正苦于以下问题:C# Frame.Translation方法的具体用法?C# Frame.Translation怎么用?C# Frame.Translation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Frame
的用法示例。
在下文中一共展示了Frame.Translation方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnFrame
public override void OnFrame(Controller controller)
{
currentFrame = controller.Frame();
prevFrame = controller.Frame(10);
currentTime = currentFrame.Timestamp;
changeTime = currentTime - prevTime;
if (changeTime > 500)
{
Hand hand = currentFrame.Hands[0];
FingerList fingers = hand.Fingers;
Hand prevHand = prevFrame.Hands[0];
FingerList prevFingers = prevHand.Fingers;
Pointable currentPointable = currentFrame.Pointables[0];
Pointable prevPointable = prevFrame.Pointables[0];
// Set Up Screen
Leap.Screen currentScreen = controller.CalibratedScreens.ClosestScreenHit(currentPointable);
Leap.Screen prevScreen = controller.CalibratedScreens.ClosestScreenHit(prevPointable);
// Set up Display
float DisplayHeight = currentScreen.HeightPixels;
float DisplayWidth = currentScreen.WidthPixels;
double scalingFactor = 1.5;
// Set up Coordinates
float CurrentLeapXCoordinate = currentScreen.Intersect(currentPointable, true, 1.0F).x;
float CurrentLeapYCoordinate = currentScreen.Intersect(currentPointable, true, 1.0F).y;
int CurrentyPixel = (int)(DisplayHeight - (DisplayHeight * (scalingFactor * CurrentLeapYCoordinate)));
int CurrentxPixel = (int)(DisplayWidth * (scalingFactor * CurrentLeapXCoordinate));
float PrevLeapXCoordinate = currentScreen.Intersect(prevPointable, true, 1.0F).x;
float PrevLeapYCoordinate = currentScreen.Intersect(prevPointable, true, 1.0F).y;
int PrevyPixel = (int)(DisplayHeight - (DisplayHeight * (scalingFactor * PrevLeapYCoordinate)));
int PrevxPixel = (int)(DisplayWidth * (scalingFactor * PrevLeapXCoordinate));
float changeyPixel = (PrevyPixel - CurrentyPixel);
float changexPixel = (PrevxPixel - CurrentxPixel);
if (changeyPixel < 0) { changeyPixel = changeyPixel * -1; }
if (changexPixel < 0) { changexPixel = changexPixel * -1; }
bool allowfalse = false;
if (changeyPixel > 10) { allowfalse = true; }
if (CurrentyPixel < 0) { CurrentyPixel = 0; }
if (CurrentxPixel < 0) { CurrentxPixel = 0; }
if (allowfalse)
{
if (prevFingers.Count != 2 || prevFingers.Count != 3)
{
if (fingers.Count == 1)
{
if (changeTime > 500)
{
Console.Write("TipPosition: " + fingers[0].TipPosition + " Width: " + CurrentxPixel + " height: " + CurrentyPixel + "\n");
SetCursorPos(CurrentxPixel, CurrentyPixel);
}
}
if (fingers.Count == 2)
{
if (changeTime > 1000)
{
mouse_event(0x0002 | 0x0004, 0, CurrentxPixel, CurrentyPixel, 0);
Console.Write("Clicked At " + CurrentxPixel + " " + CurrentyPixel + "\n");
}
}
if (fingers.Count == 4)
{
if (changeTime > 10000)
{
float Translation = currentFrame.Translation(prevFrame).y;
Console.WriteLine(Translation);
if (Translation < -50)
{
SendKeys.SendWait("{LEFT}");
System.Threading.Thread.Sleep(700);
}
if (Translation > 50)
{
SendKeys.SendWait("{Right}");
System.Threading.Thread.Sleep(700);
}
}
}
}
}
}
prevTime = currentTime;
}