本文整理汇总了C#中Controller.Frame方法的典型用法代码示例。如果您正苦于以下问题:C# Controller.Frame方法的具体用法?C# Controller.Frame怎么用?C# Controller.Frame使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Controller
的用法示例。
在下文中一共展示了Controller.Frame方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: fingerCheck
public void fingerCheck(Controller ctrl)
{
Frame frame = ctrl.Frame();
Frame previousFrame = ctrl.Frame(5);
float pinch = decimaal.TwoDecimal(frame.Hands[0].PinchStrength);
float previousPinch = decimaal.TwoDecimal(previousFrame.Hands[0].PinchStrength);
if(pinch > 0.1){
if(pinch > previousPinch){
Shrink();
}else if (pinch < previousPinch){
Debug.Log("Fuck you");
EnLarge();
}
}
//Debug.Log("Pinch = " + pinch + " Previous Pinch = " + previousPinch);
/*Finger leftFingr = frame.Fingers[0];
Finger rightFingr = frame.Fingers[1];
float LeftFinger = decimaal.TwoDecimal(leftFingr.Direction.y);
float rightFinger = decimaal.TwoDecimal(rightFingr.Direction.y);
float difference = LeftFinger -= rightFinger;
if(difference < 0.4f && difference > 0f){
Debug.Log("Rocuted");
}
Debug.Log ("Linker Finger = " + LeftFinger + "Rechter finger = " + rightFinger);
}*/
}
示例2: UpdateLeapMotionPosition
// HACK who needs a mouse when you can have leap doo'h
// void UpdateMicePosition (){
//
// Transform tmpPos = shipTransform;
//
// miceMoveY += Input.GetAxis("Mouse Y") * sensitivityY;
// if (Input.GetAxis("Mouse Y") > 0){
// tmpPos.Translate(Vector3.up * miceMoveY);
// }
// if (Input.GetAxis("Mouse Y") < 0){
// tmpPos.Translate(Vector3.up * miceMoveY);
// }
//
// miceMoveX += Input.GetAxis("Mouse X") * sensitivityX;
// if (Input.GetAxis("Mouse X") > 0){
// tmpPos.Translate(Vector3.right * miceMoveX);
// }
// if (Input.GetAxis("Mouse X") < 0){
// tmpPos.Translate(Vector3.right * miceMoveX);
// }
//
// shipTransform.position = tmpPos.position;
// }
//
void UpdateLeapMotionPosition()
{
controller = new Controller ();
Frame frame = controller.Frame ();
HandList hands = frame.Hands;
Hand leapHand = hands[0];
PointableList pointables = frame.Pointables;
FingerList fingers = frame.Fingers;
ToolList tools = frame.Tools;
if (leapHand == null){
platformTransform.localPosition = lastPosition;
}
else
{
Quaternion direction = leapHand.Fingers[1].Bone(Bone.BoneType.TYPE_DISTAL).Basis.Rotation();
Quaternion directionCorrected = direction * Quaternion.Euler(35, 0, 0);
platformTransform.localPosition = platformController.transform.TransformPoint(leapHand.PalmPosition.ToUnityScaled());
directionCorrected.x = 0f;
directionCorrected.y = 0f;
platformTransform.rotation = directionCorrected;
lastPosition = platformTransform.localPosition;
}
}
示例3: OnFrame
public override void OnFrame(Controller controller)
{
// Get the most recent frame and report some basic information
Frame frame = controller.Frame();
if (!Glb.player.dashing) {
//++a;
//if (a > 40) {
// a = 0;
foreach (Hand hand in frame.Hands) {
//Debug.Log("Hand id: " + hand.Id
// + ", palm position: " + hand.PalmPosition);
// Get the hand's normal vector and direction
Vector normal = hand.PalmNormal;
Vector direction = hand.Direction;
// Calculate the hand's pitch, roll, and yaw angles
float r = Mathf.Clamp(normal.Roll / Math.RADIAN, -45, 45) / (45.0f / Player.ROTA_ACCEL_SPEED);
Glb.player.angle_accel += r / 4.0f;
float p = normal.Pitch / Math.RADIAN;
if (p >= 0 && p <= 45) Glb.player.dash();
if (hand.PalmPosition.z < 50) Glb.player.light_off = true; else Glb.player.light_off = false;
}
//}
}
}
示例4: OnFrame
public override void OnFrame(Controller controller)
{
// Get the most recent frame
Frame frame = controller.Frame();
if (!frame.Hands.IsEmpty)
{
for (int g = 0; g < frame.Gestures().Count; g++)
{
switch (frame.Gestures()[g].Type)
{
case Gesture.GestureType.TYPE_CIRCLE:
handleScroll(frame, new CircleGesture(frame.Gestures()[g]));
return;
case Gesture.GestureType.TYPE_KEY_TAP:
handleTap(frame, new KeyTapGesture(frame.Gestures()[g]));
return;
case Gesture.GestureType.TYPE_SWIPE:
handleSwipe(frame, new SwipeGesture(frame.Gestures()[g]));
return;
}
}
}
}
示例5: OnFrame
public override void OnFrame(Controller controller)
{
// Get the most recent frame and report some basic information
Frame frame = controller.Frame();
if (!frame.Hands.IsEmpty)
{
if ((DateTime.Now - checkedTime) > new TimeSpan(0, 0, 0, 0, 500))
{
// 500ミリ秒ごとに前回位置との差分を求める
// 移動量がしきい値を超えていたらイベントとして認識するする
if (this.checkedFrame != null)
{
Vector diff = frame.Hands[0].Translation(this.checkedFrame);
//SafeWriteLine("X移動量: " + diff.x);
if (diff.x > 150)
{
SafeWriteLine("右フリックしました! :" + diff.x);
}
if (diff.x < -150)
{
SafeWriteLine("左フリックしました! :" + diff.x);
}
}
this.checkedTime = DateTime.Now;
this.checkedFrame = frame;
}
}
}
示例6: HandCheck
// Update is called once per frame
public void HandCheck(Controller ctrl)
{
Frame frame = ctrl.Frame();
int fingrCount = frame.Fingers.Count;
//----als er een vuist word gemaakt---//
if(fingrCount == 0){
Global.fist = true;
}else{
Global.fist = false;
}
//----als je wijst-------------------//
if(fingrCount == 1){
Global.point = true;
}else{
Global.point = false;
}
//----als je met 2 vingers erop staat---//
if(fingrCount == 2){
Global.rezise = true;
}else{
Global.rezise = false;
}
}
示例7: Update
void Update()
{
HandModel hand_model = GetComponent<HandModel>();
Controller controller = new Controller ();
Frame frame = controller.Frame ();
HandList hands = frame.Hands;
Hand leap_hand = hands[0];
if (leap_hand == null)
return;
Vector leap_thumb_tip = leap_hand.Fingers[0].TipPosition;
Vector leap_index_tip = leap_hand.Fingers[1].TipPosition;
float trigger_distance = (leap_thumb_tip - leap_index_tip).Magnitude;
// Debug.Log(trigger_distance);
if (trigger_distance != 0 && trigger_distance < 60) {
playerShoot.StartShooting();
} else {
playerShoot.StopShooting();
}
}
示例8: Update
void Update() {
Controller controller = new Controller();
Frame frame = controller.Frame();
HandList hands = frame.Hands;
hand = hands[0];
otherHand = hands[1];
}
示例9: Mouse
public float sideFieldMinY = -15f ; //- Player.transform.position.y;
#endregion Fields
#region Methods
public void Mouse(Controller ctrl)
{
float MovementY;
float MovementX;
Frame frame = ctrl.Frame();
HandList h = frame.Hands;
foreach(Hand hand in h){
if(frame.Hands.Count > 1){
Debug.Log("PLZ 1 hand");
}
MovementY = hand.PalmPosition.y;
MovementX = hand.PalmPosition.x;
if(hand.PalmPosition.z < 0 && !Global.fist){
if(Global.turnWorld == 0){
Vector3 MovPosition = new Vector3(MovementX / 150 ,MovementY / 250,0);
transform.Translate(0,NegativeSpeed,0);
transform.Translate(MovPosition);
}
if(Global.turnWorld == 1){
Vector3 MovPosition = new Vector3(-MovementY / 250,MovementX / 150,0);
transform.Translate(PositiveSpeed,0,0);
transform.Translate(MovPosition);
}
if(Global.turnWorld == 2){
Vector3 MovPosition = new Vector3(-MovementX / 150,-MovementY / 250,0);
transform.Translate(0,PositiveSpeed,0);
transform.Translate(MovPosition);
}
if(Global.turnWorld == 3){
Vector3 MovPosition = new Vector3(MovementY / 250,-MovementX / 150,0);
transform.Translate(NegativeSpeed,0,0);
transform.Translate(MovPosition);
}
}
}
if(transform.position.x < sideFieldMinX){
transform.position = new Vector3(sideFieldMinX,transform.position.y,0);
}
if(transform.position.x > sideFieldMaxX){
transform.position = new Vector3(sideFieldMaxX,transform.position.y,0);
}
if(transform.position.y < sideFieldMinY){
transform.position = new Vector3(transform.position.x,sideFieldMinY,0);
}
if(transform.position.y > sideFieldMaxY){
transform.position = new Vector3(transform.position.x,sideFieldMaxY,0);
}
}
示例10: OnFrame
public override void OnFrame(Controller controller)
{
Frame currentFrame = controller.Frame();
currentTime = currentFrame.Timestamp;
changeTime = currentTime - prevTime;
if (changeTime > 5000)
{
Hand hand = currentFrame.Hands[0];
FingerList fingers = hand.Fingers;
Pointable pointable = currentFrame.Pointables[0];
Leap.Screen screen = controller.CalibratedScreens.ClosestScreenHit(pointable);
Frame prevFrame = controller.Frame(10);
Hand prevhand = prevFrame.Hands[0];
FingerList prevfingers = prevhand.Fingers;
Pointable prevpointable = prevFrame.Pointables[0];
ScreenList screenList = controller.CalibratedScreens;
Leap.Screen prevscreen = screenList.ClosestScreenHit(prevpointable);
if (!fingers.Empty)
{
float prevwidth = prevscreen.Intersect(prevpointable, true, 1.0F).x * prevscreen.WidthPixels;
float prevheight = prevscreen.Intersect(prevpointable, true, 1.0F).y * prevscreen.HeightPixels;
float width = screen.Intersect(pointable, true, 1.0F).x * screen.WidthPixels;
float height = screen.Intersect(pointable, true, 1.0F).y * screen.HeightPixels;
float tranX = currentFrame.Translation(prevFrame).x;
float tranY = currentFrame.Translation(prevFrame).y;
int fwidth = (int)((width * 0.2) + (prevwidth * (1.0 - 0.2)));
int fheight = (int)((height * 0.2) + (prevheight * (1.0 - 0.2)));
fheight = screen.HeightPixels - fheight;
if (fingers.Count == 2 || fingers.Count == 3)
{
if (changeTime > 5000)
{
if (fingers.Count == 2)
{
mouse_event(0x0002 | 0x0004, 0, fwidth, fheight, 0);
}
else
{
mouse_event(0x0008 | 0x0010, 0, fwidth, fheight, 0);
}
Console.Write("Clicked At " + fwidth + " " + fheight);
}
}
else
{
if (fingers.Count == 1)
{
Console.Write("TipPosition: " + fingers[0].TipPosition + " Width: " + width + " height: " + height + " tranX: " + tranX + " tranY: " + tranY + "\n");
SetCursorPos(fwidth, fheight);
}
}
}
prevTime = currentTime;
}
}
示例11: Start
// Use this for initialization
void Start()
{
hc = new Controller();
hc.EnableGesture(Gesture.GestureType.TYPE_SWIPE);
hc.Config.SetFloat("Gesture.Swipe.MinLength", 150.0f);
hc.Config.SetFloat("Gesture.Swipe.MinVelocity", 250f);
hc.Config.Save();
cur = hc.Frame();
}
示例12: Start
void Start()
{
Controller controller = new Controller ();
// wait until Controller.isConnected() evaluates to true
//...
Frame frame = controller.Frame ();
HandList hands = frame.Hands;
PointableList pointables = frame.Pointables;
FingerList fingers = frame.Fingers;
ToolList tools = frame.Tools;
}
示例13: Changed
//public delegate void ChangedEventHandler(object sender, EventArgs e);
//public event ChangedEventHandler Changed;
/* protected virtual void OnChanged(EventArgs e) {
if(Changed != null)
Changed(this, e);
}*/
public override void OnFrame(Controller controller)
{
Frame a = controller.Frame();
Debug.Log("newFrame");
foreach(Gesture g in a.Gestures()) {
if(g.Type == Gesture.GestureType.TYPE_KEY_TAP) {
Debug.Log("working");
Vector3 positionOfTap = new Vector3(((KeyTapGesture)g).Position.x,((KeyTapGesture)g).Position.y,((KeyTapGesture)g).Position.z);
// PositionOfTapEventArgs positionOfTapEventArgs = new PositionOfTapEventArgs();
// positionOfTapEventArgs.PositionOfTap = positionOfTap;
// OnChanged(positionOfTapEventArgs);
}
}
}
示例14: OnFrame
public override void OnFrame(Controller controller)
{
// Get the most recent frame and report some basic information
Frame frame = controller.Frame();
SafeWriteLine("Frame id: " + frame.Id
+ ", timestamp: " + frame.Timestamp
+ ", hands: " + frame.Hands.Count
+ ", fingers: " + frame.Fingers.Count
+ ", tools: " + frame.Tools.Count);
if (!frame.Hands.Empty)
{
// Get the first hand
Hand hand = frame.Hands[0];
// Check if the hand has any fingers
FingerList fingers = hand.Fingers;
if (!fingers.Empty)
{
// Calculate the hand's average finger tip position
Vector avgPos = Vector.Zero;
foreach (Finger finger in fingers)
{
avgPos += finger.TipPosition;
}
avgPos /= fingers.Count;
SafeWriteLine("Hand has " + fingers.Count
+ " fingers, average finger tip position: " + avgPos);
}
// Get the hand's sphere radius and palm position
SafeWriteLine("Hand sphere radius: " + hand.SphereRadius.ToString("n2")
+ " mm, palm position: " + hand.PalmPosition);
// Get the hand's normal vector and direction
Vector normal = hand.PalmNormal;
Vector direction = hand.Direction;
// Calculate the hand's pitch, roll, and yaw angles
SafeWriteLine("Hand pitch: " + direction.Pitch * 180.0f / (float)Math.PI + " degrees, "
+ "roll: " + normal.Roll * 180.0f / (float)Math.PI + " degrees, "
+ "yaw: " + direction.Yaw * 180.0f / (float)Math.PI + " degrees\n");
}
}
示例15: Main
public static void Main()
{
// Create a sample listener and controller
SampleListener listener = new SampleListener();
Controller controller = new Controller();
listener.prevTime = controller.Frame().Timestamp;
// Have the sample listener receive events from the controller
controller.AddListener(listener);
// Keep this process running until Enter is pressed
Console.WriteLine("Press Enter to quit...");
Console.ReadLine();
// Remove the sample listener when done
controller.RemoveListener(listener);
controller.Dispose();
}