/** * Constructs a Frame object. * * Frame instances created with this constructor are invalid. * Get valid Frame objects by calling the Controller::frame() function. * * \include Frame_Frame.txt * * The only time you should use this constructor is before deserializing * serialized frame data. Call ``Frame::deserialize(string)`` to recreate * a saved Frame. * * @since 1.0 */ public Frame() { Hands = new List <Hand> (); InteractionBox = new InteractionBox( new Vector(0, 200, 0), new Vector(200, 200, 200) ); }
/** * Constructs a new Frame. * * @param id The id of this frame. * @param timestamp The creation time of this frame in microseconds. * @param fps The current data frame rate of the service when this frame was created. * @param interactionBox The InteractionBox object for this frame. * @since 3.0 */ public Frame(long id, long timestamp, float fps, InteractionBox interactionBox, List <Hand> hands) { Id = id; Timestamp = timestamp; CurrentFramesPerSecond = fps; InteractionBox = interactionBox; Hands = hands; }
void Update() { Leap.Frame leapFrame = IVISession.LeapProvider.CurrentFrame; Leap.InteractionBox interactionBox = leapFrame.InteractionBox; Transform transform = GetComponent <Transform>(); transform.rotation = new Quaternion(); transform.position = interactionBox.Center.ToVector3() / 1000; transform.localScale = interactionBox.Size.ToVector3() / 1000; }
public Frame(long id, long timestamp, float fps, InteractionBox interactionBox) { _id = id; _timestamp = timestamp; _fps = fps; _isValid = true; _fingers = new FingerList(15); _hands = new HandList(3); _trackedQuad = new TrackedQuad(); InteractionBox = interactionBox; }
// // Right Hand is right hand coordiate //if(handType == "right") //{ // rotation[0, 2] = -basis[2][0]; // rotation[1, 2] = -basis[2][1]; // rotation[2, 2] = -basis[2][2]; //} //// Left Hand is Left hand coordiate for Unity is Left Hand corrdiate //else //{ // rotation[0, 2] = basis[2][0]; // rotation[1, 2] = basis[2][1]; // rotation[2, 2] = basis[2][2]; //} public Leap.InteractionBox GetRemoteInteractionBox(FrameData Jframe) { if (Jframe.interactionBox == null) { Leap.InteractionBox RemoteBox = new Leap.InteractionBox(); return(RemoteBox); } Leap.InteractionBox RemoteBox1 = new Leap.InteractionBox (toVec3(Jframe.interactionBox.center), toVec3(Jframe.interactionBox.size)); return(RemoteBox1); }
void Update() { frame = controller.Frame(); interactionBox = frame.InteractionBox; Hand hand = frame.Hands[0]; plamCount = frame.Hands.Count; debugFingerCount = frame.Fingers.Count; Vector plamPos = interactionBox.NormalizePoint(hand.PalmPosition); int scale = 4;//感知する領域を広げる x = scale * (plamPos.x - 0.5f); y = scale * plamPos.y; z = scale * (plamPos.z - 0.5f); if (plamCount <= 1)//片手の場合 { if (hand.IsValid == false && existPlamFlag) { existPlamFlag = false; Destroy(plam); } if (!existPlamFlag) { if (hand.IsValid) { existPlamFlag = true; plam = (GameObject)Instantiate(Resources.Load("Title/Plam"), ToVector3(new Vector(x, y, -z)), Quaternion.identity); plam.transform.SetParent(GameObject.Find("MainCamera/LeapPos").transform); plam.GetComponent<Renderer>().enabled = hand.IsValid; plam.GetComponent<Collider>().enabled = hand.IsValid; } } else { plam.transform.localPosition = ToVector3(new Vector(x, y, -z)); } HoldDecision(hand); } else if (plamCount >= 2)//両手の場合 { existPlamFlag = false; Destroy(plam); BothHandsGesture(); } }
//Member Function: Update//////////////////////////////////////////////////// public void Update() { //Update the listener. listener.refresh(); //Reset the fingers array. if (fingers != null) { fingers.Clear(); } //Retrieve coordinates for any fingers that are present, but only if the menus are visible. if (listener.fingers > 0 && Core.getInstance().paused) { //Loop over all fingers. for (int i = 0; i < listener.fingers; i++) { //Set up it's position. Vector3 tipPosition = new Vector3(0, 0, 0); //Get a normalized box. normalizedBox = listener.frame.InteractionBox; //Finger coordinates. tipPosition.x = normalizedBox.NormalizePoint(listener.frame.Fingers[i].TipPosition).x; tipPosition.y = normalizedBox.NormalizePoint(listener.frame.Fingers[i].TipPosition).y; //Modify coordinates to equal screen resolution. tipPosition.x = tipPosition.x * Screen.width; tipPosition.y = tipPosition.y * Screen.height; //Flip Y axis. tipPosition.y = tipPosition.y * -1; tipPosition.y += Screen.height; fingers.Add(new Rect(tipPosition.x, tipPosition.y, 16, 16)); } } }
public SerializableInteractionBox(InteractionBox b) { center = new SerializableVector(b.Center); size = new SerializableVector(b.Size); }
/** * Compare InteractionBox object equality. * * \include InteractionBox_operator_equals.txt * * Two InteractionBox objects are equal if and only if both InteractionBox objects * are the same size, in the same position and both InteractionBoxes are valid. * @since 1.0 */ public bool Equals(InteractionBox other) { return(this.IsValid && other.IsValid && (this.Center == other.Center) && (this.Size == other.Size)); }
//Update///////////////////////////////////////////////////////////////////// public void Update() { if (listener == null) { listener = new LeapListener(); } //Update the listener. listener.refresh(); //Get a normalized box. normalizedBox = listener.frame.InteractionBox; //First, get any hands that are present. if (listener.hands > 0) { //Reset the hands array. if (hands != null) { for (int i = 0; i < hands.Length; i++) { Destroy(hands[i]); } } //Initialize our hands. hands = new GameObject[listener.hands]; //Loop over all hands. for (int i = 0; i < listener.hands; i++) { try { //Create a new hand. hands[i] = (GameObject)Instantiate(palm); //Set its properties. hands[i].transform.parent = camera.transform; hands[i].name = "Palm:" + i; //Set up it's position. Vector3 palmPosition = new Vector3(0, 0, 0); palmPosition.x += listener.frame.Hands[i].PalmPosition.x / 10; palmPosition.y += verticalOffset; palmPosition.y += listener.frame.Hands[i].PalmPosition.y / 10; palmPosition.z += depth; palmPosition.z += (listener.frame.Hands[i].PalmPosition.z * -1) / 10; //Move the hand. hands[i].transform.localPosition = palmPosition; //Set the hands rotation to neutral. Quaternion lr = hands[i].transform.rotation; Vector3 leap = listener.rotation(listener.frame.Hands[i]); lr.eulerAngles = new Vector3(leap.x * -1, leap.y, leap.z); hands[i].transform.localRotation = lr; } //Watch out for those pesky "index out of bounds" errors. catch (System.IndexOutOfRangeException e) { Debug.LogException(e); } } } //If there aren't any. delete any active palms. else if (hands != null) { for (int i = 0; i < hands.Length; i++) { Destroy(hands[i]); } } //Get any fingers that are present. if (listener.fingers > 0 && listener.hands > 0) { //Reset the fingers array. if (fingers != null && listener.fingers != fingers.Length) { for (int i = 0; i < fingers.Length; i++) { Destroy(fingers[i]); } } //Initialize our fingers. if (fingers == null || listener.fingers != fingers.Length) { fingers = new GameObject[listener.fingers]; } //Loop over all fingers. for (int i = 0; i < listener.fingers; i++) { try { //Create a new finger. if (fingers[i] == null) { fingers[i] = (GameObject)Instantiate(fingerTip); } //Set its properties. fingers[i].name = "Finger:" + i; fingers[i].transform.parent = camera.transform; //Set up it's position. Vector3 tipPosition = new Vector3(0, 0, 0); tipPosition.x += listener.frame.Fingers[i].TipPosition.x / 10; tipPosition.y += verticalOffset; tipPosition.y += listener.frame.Fingers[i].TipPosition.y / 10; tipPosition.z += depth; tipPosition.z += (listener.frame.Fingers[i].TipPosition.z * -1) / 10; //Move the finger to where it belongs. fingers[i].transform.localPosition = tipPosition; //Set the fingers rotation to neutral. Quaternion lr = fingers[i].transform.rotation; lr.eulerAngles = Vector3.zero; fingers[i].transform.localRotation = lr; } //Watch out for those pesky "index out of bounds" errors. catch (System.IndexOutOfRangeException e) { Debug.LogException(e); } } } //If not, delete any active fingers. else if (fingers != null) { for (int i = 0; i < fingers.Length; i++) { Destroy(fingers[i]); } } }
//Update is called once per frame void Update() { if (m_controller != null) { lastFrame = m_Frame == null ? Frame.Invalid : m_Frame; m_Frame = m_controller.Frame(); } //Get interaction box for this frame interactionBox = m_Frame.InteractionBox; //Deal with hands addHands(); updateHands(); removeHands(); //Deal with fingers addFingers(); updateFingers(); removeFingers(); //Deal with gestures addGestures(); }
//Update is called once per frame void Update() { if (m_controller != null) { //If the controller is not null... last_frame = (m_frame == null) ? Frame.Invalid : m_frame; //If the existing frame is null, set last_frame to an invalid frame, otherwise set it to the current (now old) frame m_frame = m_controller.Frame(); //Set the current frame to the latest frame from the controller } normalise_box = m_frame.InteractionBox; //Set the interaction box to the current frame's interaction box AddHands(); //Add any new hands UpdateHands(); //Update any existing hands RemoveHands(); //Remove any old hands }
/** * Compare InteractionBox object equality. * * \include InteractionBox_operator_equals.txt * * Two InteractionBox objects are equal if and only if both InteractionBox objects * are the same size, in the same position and both InteractionBoxes are valid. * @since 1.0 */ public bool Equals(InteractionBox other) { return this.IsValid && other.IsValid && (this.Center == other.Center) && (this.Size == other.Size); }
public MainWindow() { InitializeComponent(); this.controller = new Controller(); this.listener = new LeapEventListener(this); this.iBox = controller.Frame().InteractionBox; controller.AddListener(listener); controller.SetPolicy(Controller.PolicyFlag.POLICY_BACKGROUND_FRAMES); Console.WriteLine("hi"); }