public override void OnDisconnect(Leap.Controller controller)
 {
     if (Disconnected != null)
     {
         Disconnected("Leap Motion Disconnected !");
     }
 }
 public override void OnExit(Leap.Controller controller)
 {
     if (Exited != null)
     {
         Exited("Leap Motion Exited.");
     }
 }
Ejemplo n.º 3
0
 //public static Vector3 LeapToUnity_Position( Leap.Vector v )
 //{
 //   return new Vector3 ( v.x, v.y, -v.z );
 //}
 public static Vector3 LeapToUnityWorld(Leap.Vector v)
 {
     //return new Vector3(v.x, v.y, v.z);
     Vector3 unityPosition = v.ToUnityScaled(false);
     Vector3 worldPosition = hand_controller.transform.TransformPoint(unityPosition);
     return worldPosition;
 }
 void SystemWipeInfoCallback(Leap.Util.SystemWipeInfo info)
 {
   //Debug.Log("Swipe " + info.Status + " " + info.Direction + " " + info.Progress);
   lock(wipeInfoLock) {
     m_wipeInfoDirty = true;
     m_latestWipeInfo = info;
   }
 }
        public override void OnConnect(Leap.Controller controller)
        {
            controller.EnableGesture(Leap.Gesture.GestureType.TYPECIRCLE);
            controller.EnableGesture(Leap.Gesture.GestureType.TYPEKEYTAP);
            controller.EnableGesture(Leap.Gesture.GestureType.TYPESCREENTAP);
            controller.EnableGesture(Leap.Gesture.GestureType.TYPESWIPE);

            if (Connected != null)
            {
                Connected("Leap Motion Connected !");
            }
        }
Ejemplo n.º 6
0
    void HandUpdatedHandler(Leap.Hand hand)
    {
        Debug.Log(hand.PalmPosition.ToString());

        Leap.Vector newPos = hand.PalmPosition;
        transform.position = new Vector3(newPos.x * 0.05f, newPos.y * 0.05f - 10.0f);

        float Pitch = hand.PalmNormal.Pitch + Mathf.Deg2Rad*90;
        float Roll = hand.PalmNormal.Roll;

        Debug.Log(Pitch.ToString());
        Pitch = Mathf.Clamp(Pitch, -45 * Mathf.Deg2Rad, 45 * Mathf.Deg2Rad);

        transform.rotation = new Quaternion(-Pitch, 0, Roll, 1);
    }
Ejemplo n.º 7
0
 public LEAP_VECTOR(Leap.Vector leap)
 {
     x = leap.x;
       y = leap.y;
       z = leap.z;
 }
        private Leap.Vector[] GetFingerPositionForRawImage( Leap.Image image, Leap.FingerList fingers )
        {
            List<Leap.Vector> fingerPositions = new List<Leap.Vector>();

            foreach ( var finger in fingers ) {
                fingerPositions.Add( GetFingerPositionForRawImage( image, finger.TipPosition ) );
            }

            return fingerPositions.ToArray();
        }
        /// <summary>
        /// 円を書く
        /// </summary>
        /// <param name="image"></param>
        /// <param name="position"></param>
        /// <param name="R"></param>
        void AddEllipse( Leap.Image image, Leap.Vector position, int R )
        {
            var ellipse = new Ellipse()
            {
                Width = R,
                Height = R,
                Fill = Brushes.Red,
            };

            Canvas.SetLeft( ellipse, position.x );
            Canvas.SetTop( ellipse, position.y );

            CanvasFinger.Children.Add( ellipse );
        }
Ejemplo n.º 10
0
 public void IsLeapYear_NotGivenALeapYear_ReturnsFalse(int year)
 {
     Assert.IsFalse(Leap.IsLeapYear(year));
 }
Ejemplo n.º 11
0
 public void Year_not_divisible_by_4_is_common_year()
 {
     Assert.False(Leap.IsLeapYear(2015));
 }
Ejemplo n.º 12
0
 private bool PalmIsHorizontal(Leap.Hand hand)
 {
     return hand.PalmNormal.AngleTo(Leap.Vector.Down)*Mathf.Rad2Deg < EasyLeapGesture.MaxAnglePalm &&
         Mathf.Abs (hand.StabilizedPalmPosition.x) < EasyLeapGesture.MaxFieldPalm &&
         Mathf.Abs (hand.StabilizedPalmPosition.z) < EasyLeapGesture.MaxFieldPalm;
 }
Ejemplo n.º 13
0
 public void Turn_of_the_20th_century_is_not_a_leap_year()
 {
     Assert.That(Leap.IsLeap(1900), Is.False);
 }
Ejemplo n.º 14
0
 public void Invalid_leap_year()
 {
     Assert.That(Leap.IsLeap(1997), Is.False);
 }
Ejemplo n.º 15
0
    // Update a Unity GameObject that represents a Leap Pointable.
    void updatePointable( Leap.Pointable pointable, GameObject fingerObject )
    {
        // Update the parent object (the hand) of the pointable.
        updateParent( fingerObject, pointable.Hand.Id );

        // Change the pointable's visibility based on whether
        // or not the parent hand is valid.
        SetVisible(fingerObject, pointable.IsValid);
        // Do the same for the collidable property.
        SetCollidable(fingerObject, pointable.IsValid);

        // If the parent hand is valid:
        if ( pointable.IsValid )
        {
            point = pointable;
            // Create vectors for the finger's direction and position with the new
            // direction and position from the Leap, but only after scaling/ofsetting
            // with LeapUnityExtensions.
            Vector3 vFingerDir = pointable.Direction.ToUnity();
            Vector3 vFingerPos = pointable.TipPosition.ToUnityTranslated();

            // Apply the position vector to the Unity finger object.
            fingerObject.transform.localPosition = vFingerPos;
            // Apply the direction vector to the Unity finger object.
            // A Quaternion represents a rotation. For more information, see here:
            // http://docs.unity3d.com/Documentation/ScriptReference/Quaternion.FromToRotation.html
            fingerObject.transform.localRotation = Quaternion.FromToRotation( Vector3.forward, vFingerDir );
            // LIU: get the offset from the forward (pitch) and right (yaw) vectors
        //			if (LeapUnitySelectionController.ActiveMode == "Rotating") {
        //				float offsetY = Vector3.Angle(Vector3.up, vFingerDir);
        //				float offsetX = Vector3.Angle(Vector3.right, vFingerDir);
        //				float pitch = offsetY.ToUnityPitch();
        //				float yaw = offsetX.ToUnityYaw();
                //fingerObject.GetComponent<SpotLight1>().OnLeapRotation(pitch, yaw);
        //				Debug.Log ("Pitch: "+pitch+"  Yaw: "+yaw);
        //				Vector2 rotation = new Vector2 (pitch,yaw);
        //				LeapUnitySelectionController.DoRotation(rotation);
                //fingerObject.transform.RotateAroundLocal(new Vector3(0,1,0),yaw);
                //fingerObject.gameObject.SendMessage(OnLeapRotation, yaw,SendMessageOptions.DontRequireReceiver);
        //			}
        }
    }
Ejemplo n.º 16
0
    // Update a palm.
    void updatePalm( Leap.Hand leapHand, GameObject palmObject )
    {
        // Update the palm's parent (the hand).
        updateParent( palmObject, leapHand.Id);

        // Change the palm's visibility based on whether
        // or not the parent hand is valid.
        SetVisible(palmObject, leapHand.IsValid);
        // Do the same for the collidable property.
        SetCollidable(palmObject, leapHand.IsValid);

        // If the parent hand is valid.
        if( leapHand.IsValid )
        {
            // Update the transform of the palm to match the incoming palm position from
            // the Leap (after scaling/offsetting it in LeapUnityExtensions).
            palmObject.transform.localPosition = leapHand.PalmPosition.ToUnityTranslated();
            // NEW: updates the rotation of the palm based on the incoming palm rotation
        //			Debug.Log(leapHand.Direction.ToUnityRotated());
        //			Debug.Log(leapHand.Direction);
            Vector3 vPalmDir = leapHand.Direction.ToUnity(); //leapHand.Direction.ToUnityRotated();
            palmObject.transform.localRotation = Quaternion.FromToRotation( Vector3.forward, vPalmDir );
        }
    }
Ejemplo n.º 17
0
        /// <summary>
        /// Parses TimeZones and Rules from the files in the provided
        /// Olson/TZ Database directory. The directory provided must be a valid TZ Database.
        /// </summary>
        /// <param name="directory">The valid directory to parse Rules and TimeZones from.</param>
        public void ReadTZDirectory()
        {
            try
            {
                // Mapping from TZname to: id, Ccode, Cname.
                var tzNameToInfo = ReadTabFiles();

                TimeZones.BeginLoadData();
                Rules.BeginLoadData();
                Leaps.BeginLoadData();

                foreach (OlsonFileInfo file in _olsonFiles.GetConsumingEnumerable())
                {
                    if (!file.IsTabFile)
                    {
                        RaiseFileParsing(file);
                        string[] lines = File.ReadAllLines(file.FullName);

                        // Process items.
                        for (int i = 0; i < lines.Length; i++)
                        {
                            string line = lines[i].TrimStart();

                            if (!isCommentNullOrWhiteSpace(line))
                            {
                                string[] fields = ParseFields(line);

                                switch (fields[0])
                                {
                                case Rule.RULE_NAME:
                                {
                                    short from = Rule.ParseStartYear(fields[Rule.FromIndex]);
                                    short to   = Rule.ParseEndYear(fields[Rule.ToIndex], from);

                                    if (from > _curYear || to < _curYear)
                                    {
                                        continue;
                                    }

                                    // No parsing necessary.
                                    string name = fields[Rule.NameIndex];

                                    var rule = Rules.NewRow();
                                    rule[1] = name;
                                    rule[2] = Rule.ParseBias(fields[Rule.SaveIndex]);
                                    rule[3] = from;
                                    rule[4] = to;
                                    rule[5] = Rule.ParseMonth(fields[Rule.InIndex]);
                                    rule[6] = fields[Rule.OnIndex];
                                    rule[7] = Rule.ParseTime(fields[Rule.AtIndex]);
                                    rule[8] = Rule.ParseTimeType(ref fields[Rule.AtIndex]);
                                    rule[9] = Rule.ParseAbrev(fields[Rule.LetterIndex]) ?? (object)System.DBNull.Value;

                                    _ruleRows.Add(rule);
                                    RaiseEntryParsed(null);
                                    break;
                                }

                                case TimeZone.ZONE_NAME:
                                {
                                    // First TZ.
                                    int init = i;
                                    // Count to last
                                    do
                                    {
                                        i++;
                                    } while (i < lines.Length && TimeZone.IsContinuation(lines[i]));

                                    // If first was not the only...
                                    if (i - init != 1)
                                    {
                                        string[] continuation = ParseFields(lines[--i].Trim());

                                        // Continuation has a non-tab delimited date...
                                        if (continuation.Length > 4 && int.Parse(continuation[3]) < _curYear)
                                        {
                                            continue;
                                        }
                                        System.Array.Copy(continuation, 0, fields, 2, continuation.Length);
                                    }
                                    else
                                    {
                                        if (fields.Length > 5 && int.Parse(fields[5]) < _curYear)
                                        {
                                            continue;
                                        }
                                    }

                                    string   name        = TimeZone.ParseName(fields[TimeZone.NameIndex]);
                                    string   countryCode = null;
                                    string   countryName = null;
                                    string   coord       = null;
                                    string   comments    = null;
                                    int      id          = 0;
                                    string[] tokens;
                                    if (tzNameToInfo.TryGetValue(name, out tokens))
                                    {
                                        id          = System.Convert.ToInt32(tokens[0]);
                                        countryCode = tokens[1];
                                        countryName = tokens[2];
                                        coord       = tokens[3];
                                        comments    = tokens[4];
                                    }
                                    else
                                    {
                                        App.ExceptionLogger.LogLow(new System.Exception("OlsonParser.cs Ln 390:"
                                                                                        + "Error attempting to get a TimeZone's iso/tab info."));
                                        continue;
                                    }
                                    short  bias     = TimeZone.ParseBias(fields[TimeZone.GMTOffsetIndex]);
                                    string ruleName = TimeZone.ParseRuleName(fields[TimeZone.RuleIndex]);
                                    string tzAbrev  = TimeZone.ParseTzAbrev(fields[TimeZone.FormatIndex]);

                                    var timeZone = TimeZones.NewRow();
                                    timeZone[0] = id;
                                    timeZone[1] = name;
                                    timeZone[2] = bias;
                                    timeZone[3] = ruleName;
                                    timeZone[4] = tzAbrev;
                                    timeZone[5] = countryCode;
                                    timeZone[6] = countryName;
                                    timeZone[7] = comments;
                                    timeZone[8] = coord;

                                    TimeZoneLookupTable[name] = timeZone;
                                    _timeZoneRows.Add(timeZone);
                                    RaiseEntryParsed(null);
                                    break;
                                }

                                case Link.LINK_NAME:
                                {
                                    var link = new string[] { fields[Link.FromZoneNameIndex], fields[Link.ToZoneNameIndex] };
                                    _links.Add(link);
                                    RaiseEntryParsed(null);
                                    break;
                                }

                                case Leap.LEAP_NAME:
                                {
                                    var leap = Leaps.NewRow();
                                    leap[1] = Leap.ParseYear(fields[Leap.YearIndex]);
                                    leap[2] = fields[Leap.MonthIndex];
                                    leap[3] = Leap.ParseDay(fields[Leap.DayIndex]);
                                    leap[4] = Leap.ParseTime(fields[Leap.TimeIndex]);
                                    leap[5] = Leap.ParseCorrection(fields[Leap.CorrectionIndex]);
                                    leap[6] = Leap.ParseRs(fields[Leap.RsIndex]);

                                    _leapRows.Add(leap);
                                    RaiseEntryParsed(null);
                                    break;
                                }
                                }
                                ParsedEntries++;
                            }
                        }
                        RaiseFileParsed(file);
                    }
                }
                // Adding all links to list of TimeZones.
                foreach (string[] link in _links)
                {
                    System.Data.DataRow from;
                    if (!TimeZoneLookupTable.TryGetValue(link[Link.FromZoneNameIndex], out from))
                    {
                        App.ExceptionLogger.LogLow(new System.Exception("OlsonParser.cs Ln 364: Error attempting to find the \"From\" TimeZone for the link:"
                                                                        + link[0].ToString()));
                        continue;
                    }

                    string toName          = link[Link.ToZoneNameIndex];
                    System.Data.DataRow to = TimeZones.NewRow();
                    to[0] = ++_lastUID;
                    to[1] = toName;
                    to[2] = from[2];
                    to[3] = from[3];
                    to[4] = from[4];
                    to[5] = from[5];
                    to[6] = from[6];
                    to[7] = from[7];
                    to[8] = from[8];

                    if (!TimeZoneLookupTable.TryAdd(toName, to))
                    {
                        App.ExceptionLogger.LogLow(new System.Exception("OlsonParser.cs Ln 373: Error attempting to add the TimeZone for the link:"
                                                                        + link.ToString()));
                        continue;
                    }
                    try
                    {
                        _timeZoneRows.Add(to);
                        RaiseEntryParsed(null);
                        ParsedEntries++;
                    }
                    catch (System.Exception e)
                    {
                        App.ExceptionLogger.LogLow(e);
                        continue;
                    }
                }

                RaiseDirectoryParsed(Directory);
            }
            finally
            {
                TimeZones.EndLoadData();
                Rules.EndLoadData();
                Leaps.EndLoadData();
            }
        }
Ejemplo n.º 18
0
 public void TestPersonal()
 {
     Assert.True(Leap.IsLeapYear(2020));
 }
Ejemplo n.º 19
0
 // converts leap vector to unity vector
 private Vector3 LeapToUnity(Leap.Vector leapVector, bool bScaled)
 {
     if(bScaled)
         return new Vector3(leapVector.x, leapVector.y, -leapVector.z) * .001f;
     else
         return new Vector3(leapVector.x, leapVector.y, -leapVector.z);
 }
Ejemplo n.º 20
0
 public void Turn_of_the_25th_century_is_a_leap_year()
 {
     Assert.That(Leap.IsLeap(2400), Is.True);
 }
Ejemplo n.º 21
0
 private void BuiltInImprovedGestureRecognised(Leap.Gesture gesture, EasyLeapGestureType type)
 {
     if(!gestureList.ContainsKey(-(int)type)) {
         RecordNewGesture(-(int)type,
             EasyLeapGestureState.STATESTOP,
             EasyLeapGestureState.STATEUPDATE,
             type,
             -1,
             gesture.Hands[0].StabilizedPalmPosition);
     }
 }
Ejemplo n.º 22
0
 public void Year_divisible_by_4_not_divisible_by_100_is_leap_year()
 {
     Assert.True(Leap.IsLeapYear(1996));
 }
    void updatePalm( Leap.Hand leapHand, GameObject palmObject )
    {
        updateParent( palmObject, leapHand.Id);

        SetVisible(palmObject, leapHand.IsValid);
        SetCollidable(palmObject, leapHand.IsValid);

        if( leapHand.IsValid )
        {
            palmObject.transform.localPosition = leapHand.PalmPosition.ToUnityTranslated();
        }
    }
Ejemplo n.º 24
0
 public void Year_divisible_by_400_is_leap_year()
 {
     Assert.True(Leap.IsLeapYear(2000));
 }
Ejemplo n.º 25
0
	void updatePointable( Leap.Pointable pointable, GameObject fingerObject )
	{
		updateParent( fingerObject, pointable.Hand.Id );
		
		SetVisible(fingerObject, pointable.IsValid);
		SetCollidable(fingerObject, pointable.IsValid);
		
		if ( pointable.IsValid )
		{
			Vector3 localFingerPos = pointable.TipPosition.ToUnityTranslated();
			
			float fingerRadius = fingerObject.GetComponent<SphereCollider>().radius - 0.3f;
			RaycastHit target;
			
			// need to convert it to a vec4 for it to take translation into account when converting to world space.
			Vector4 localFingerPt = new Vector4(localFingerPos.x, localFingerPos.y, localFingerPos.z, 1.0f);
			Vector3 worldTargetPos = fingerObject.transform.parent.localToWorldMatrix * localFingerPt;

			Vector3 worldMovementDir = worldTargetPos - fingerObject.transform.position;
			worldMovementDir.Normalize();
		
			Vector3 worldRayTarget = worldTargetPos + worldMovementDir * fingerRadius;
			
			/*if (Physics.Linecast(fingerObject.transform.position, worldRayTarget, out target)) {
				Vector4 targetPoint = new Vector4(target.point.x, target.point.y, target.point.z, 1.0f);
				Vector3 localTargetPoint = fingerObject.transform.parent.worldToLocalMatrix * targetPoint;
				Vector3 localMovementDir = localFingerPos - fingerObject.transform.localPosition;
				localMovementDir.Normalize();
				fingerObject.transform.localPosition = localTargetPoint - localMovementDir * fingerRadius; */
			//} else {
				fingerObject.transform.localPosition = localFingerPos;
			//}
			
			Vector3 vFingerDir = pointable.Direction.ToUnity();
			fingerObject.transform.localRotation = Quaternion.FromToRotation( Vector3.forward, vFingerDir );
			fingerObject.GetComponent<LeapFinger>().m_hand = pointable.Hand;
			fingerObject.rigidbody.velocity = pointable.TipVelocity.ToUnityScaled();
		}
	}
        /// <summary>
        /// ピンチの処理
        /// </summary>
        /// <param name="fingerPosition"></param>
        private void ProcessPinch( Leap.Vector fingerPosition )
        {
            // 指が画像に接しているか調べる
            var element = HitTest( CanvasPhoto, new Point( fingerPosition.x, fingerPosition.y ) );
            if ( (element  == null) ) {
                isPinch = false;
                return;
            }

            // ピンチ開始
            if ( !isPinch ) {
                Trace.WriteLine( "Pinch Start" );

                isPinch  = true;
                return;
            }

            Trace.WriteLine( "Pinch Move" );

            // エレメントを動かす
            MoveElement( element, fingerPosition - prevPosition );
        }
Ejemplo n.º 27
0
 public void Valid_leap_year()
 {
     Assert.That(Leap.IsLeap(1996), Is.True);
 }
Ejemplo n.º 28
0
 public void IsLeapYear_GivenALeapYear_ReturnsTrue(int year)
 {
     Assert.IsTrue(Leap.IsLeapYear(year));
 }
Ejemplo n.º 29
0
 public void Year_divisible_by_100_not_divisible_by_400_is_common_year()
 {
     Assert.False(Leap.IsLeapYear(2100));
 }
Ejemplo n.º 30
0
 // Compares two positions using an error margin
 bool positionsAreEqualWithinError(Leap.Vector pos1, Leap.Vector pos2, float error)
 {
     return Mathf.Abs(pos1.x - pos2.x) < error &&
            Mathf.Abs(pos1.y - pos2.y) < error &&
            Mathf.Abs(pos1.z - pos2.z) < error;
 }
        /// <summary>
        /// グラブの処理
        /// </summary>
        /// <param name="handPosition"></param>
        private void ProcessGrab( Leap.Vector handPosition )
        {
            // 手の座標が画像に接しているか調べる
            var element = HitTest( CanvasPhoto, new Point( handPosition.x, handPosition.y ) );
            if ( (element == null) ) {
                isGrab = false;
                return;
            }

            // Grab開始
            if ( !isGrab ) {
                isGrab = true;

                Trace.WriteLine( "Grab Start" );
                return;
            }

            Trace.WriteLine( "Grab Move : " + handPosition.z.ToString() );

            // 前フレームとの差分を取得
            var delta = handPosition - prevPosition;

            // エレメントを動かす
            MoveElement( element, delta );

            // ZIndexをZ位置によって動かす
            Canvas.SetZIndex( element, Canvas.GetZIndex( element ) + (int)(delta.z * 100) );

            // Z位置によって、画像の拡大率を変更する
            var scaleTransform = element.RenderTransform as ScaleTransform;
            if ( scaleTransform != null ) {
                var scale = delta.z / 30;
                if ( (scaleTransform.ScaleX + scale) >= 1.0 ) {
                    scaleTransform.ScaleX += scale;
                    scaleTransform.ScaleY += scale;
                }
            }

        }
Ejemplo n.º 32
0
 Vector3 unityVector(Leap.Vector v)
 {
     return new Vector3(v.x, v.y, v.z);
 }
 /// <summary>
 /// エレメントを動かす
 /// </summary>
 /// <param name="element"></param>
 /// <param name="delta"></param>
 private static void MoveElement( FrameworkElement element, Leap.Vector delta )
 {
     Canvas.SetLeft( element, Canvas.GetLeft( element ) + delta.x );
     Canvas.SetTop( element, Canvas.GetTop( element ) + delta.y );
 }
Ejemplo n.º 34
0
        private Leap CreateALeap(Leaper currentLeaper, HostRepository hostRepository, EventRepository eventRepository)
        {
            var createdLeap = new Leap(currentLeaper, hostRepository.GetRandomHost(), eventRepository.GetRandomEvent());

            return(createdLeap);
        }
        Leap.Vector GetFingerPositionForRawImage( Leap.Image image, Leap.Vector position )
        {
            // 3次元の指の位置を、2次元のカメラ画像に合わせる
            float hSlope = -(position.x + cameraOffset * (2 * image.Id - 1))/position.y;
            float vSlope = position.z/position.y;
            var pos = image.Warp( new Leap.Vector( hSlope, vSlope, 0 ) );

            // カメラ画像の拡大率を取得する
            var scaleX = ImageLeap.ActualWidth / image.Width;
            var scaleY = ImageLeap.ActualHeight / image.Height;

            // 座標を拡大する
            pos.x = (float)(ImageLeap.ActualWidth - (pos.x * scaleX));
            pos.y = (float)(pos.y * scaleY);
            pos.z = position.z;

            return pos;
        }
    void updatePalm( Leap.Hand leapHand, GameObject palmObject )
    {
        updateParent( palmObject, leapHand.Id);

        SetVisible(palmObject, leapHand.IsValid);
        SetCollidable(palmObject, leapHand.IsValid);

        if( leapHand.IsValid )
        {
            palmObject.transform.localPosition = leapHand.PalmPosition.ToUnityTranslated();
            palmObject.transform.localRotation = Quaternion.LookRotation(leapHand.Direction.ToUnity(), leapHand.PalmNormal.ToUnity());
        }
    }
Ejemplo n.º 37
0
 public LEAP_QUATERNION(Leap.LeapQuaternion q)
 {
     x = q.x;
       y = q.y;
       z = q.z;
       w = q.w;
 }
 public LeapGestureTemplateViewModel(Leap.Gesture.GestureType gesture)
 {
     _Type = gesture;
 }
    void updatePointable( Leap.Pointable pointable, GameObject fingerObject )
    {
        updateParent( fingerObject, pointable.Hand.Id );

        SetVisible(fingerObject, pointable.IsValid);
        SetCollidable(fingerObject, pointable.IsValid);

        if ( pointable.IsValid )
        {
            Vector3 vFingerPos = pointable.TipPosition.ToUnityTranslated();

            // perform a cast between where it is and where it wants to be.
            //float fingerRadius = fingerObject.GetComponent<SphereCollider>().radius;
            //RaycastHit target;

            // the movement vector of the finger.
            /*Vector3 movementDir = vFingerPos - fingerObject.transform.position;
            movementDir.Normalize();

            Vector3 end = vFingerPos + movementDir * fingerRadius;

            if (Physics.Linecast(fingerObject.transform.position, end, out target, LayerMask.NameToLayer("Buttons"))) {
                //fingerObject.transform.position = target.point + -movementDir * fingerRadius;
            } else {
                //fingerObject.transform.position = vFingerPos;
            }
            */
            fingerObject.transform.position = vFingerPos;
            Vector3 vFingerDir = pointable.Direction.ToUnity();

            fingerObject.transform.localRotation = Quaternion.FromToRotation( Vector3.forward, vFingerDir );
        }
    }
Ejemplo n.º 40
0
 public void Year_divisible_by_2_not_divisible_by_4_in_common_year()
 {
     Assert.False(Leap.IsLeapYear(1970));
 }
Ejemplo n.º 41
0
 private void BuiltInGestureRecognised(Leap.Gesture gesture, EasyLeapGestureType type)
 {
     RecordNewGesture(gesture.Id,ConvertGestureState(gesture.State),ConvertGestureState(gesture.State),type,gesture.Duration,gesture.Hands[0].StabilizedPalmPosition);
 }
Ejemplo n.º 42
0
 public void Year_divisible_by_4_and_5_is_still_a_leap_year()
 {
     Assert.True(Leap.IsLeapYear(1960));
 }
Ejemplo n.º 43
0
 private EasyLeapGestureState ConvertGestureState(Leap.Gesture.GestureState state)
 {
     switch(state) {
         case Leap.Gesture.GestureState.STATESTART:
             return EasyLeapGestureState.STATESTART;
         case Leap.Gesture.GestureState.STATEUPDATE:
             return EasyLeapGestureState.STATEUPDATE;
         case Leap.Gesture.GestureState.STATESTOP:
             return EasyLeapGestureState.STATESTOP;
     }
     return EasyLeapGestureState.STATEINVALID;
 }
Ejemplo n.º 44
0
 public void Year_divisible_by_100_but_not_by_3_is_still_not_a_leap_year()
 {
     Assert.False(Leap.IsLeapYear(1900));
 }
Ejemplo n.º 45
0
 // Store the recognised gesture on the gesture List
 private void RecordNewGesture(int id, EasyLeapGestureState startState, EasyLeapGestureState updateState, EasyLeapGestureType type, long duration, Leap.Vector position)
 {
     if(gestureList.ContainsKey(id)) {
         EasyLeapGesture g = gestureList[id];
         g.State = updateState;
         g.Duration = duration < 0 ? (long)(1000000*Time.deltaTime)+g.Duration : duration;
         gestureList[id] = g;
     } else {
         EasyLeapGesture gest = new EasyLeapGesture();
         gest.Duration = 0;
         gest.Id = id;
         gest.State = startState;
         gest.Type = type;
         gest.Frame = mFrame;
         gest.Position = position;
         gestureList.Add(id,gest);
     }
 }
Ejemplo n.º 46
0
 public void Year_divisible_by_400_but_not_by_125_is_still_a_leap_year()
 {
     Assert.True(Leap.IsLeapYear(2400));
 }
    void updatePointable( Leap.Pointable pointable, GameObject fingerObject )
    {
        updateParent( fingerObject, pointable.Hand.Id );

        SetVisible(fingerObject, pointable.IsValid);
        SetCollidable(fingerObject, pointable.IsValid);

        if ( pointable.IsValid )
        {
            Vector3 vFingerDir = pointable.Direction.ToUnity();
            Vector3 vFingerPos = pointable.TipPosition.ToUnityTranslated();

            fingerObject.transform.localPosition = vFingerPos;
            fingerObject.transform.localRotation = Quaternion.FromToRotation( Vector3.forward, vFingerDir );
        }
    }
Ejemplo n.º 48
0
        //======================================================
        #region Event Methods
        private void SpecialForm_Load(object sender, EventArgs e)
        {
            //Until I find a better way, this list is typed manually.

            //Rules attached to this ability should be added first, for editing.
            if (ability.SpecialRules != null)
            {
                foreach (SpecialRule rule in ability.SpecialRules)
                {
                    clbSpecials.Items.Add(rule, true);
                }
            }

            //Add the rest of the rules, but don't add ones already added from the ability.
            SpecialRule nRule = new Acid();

            if (!ability.SpecialRules.Contains(nRule))
            {
                clbSpecials.Items.Add(nRule);
            }
            nRule = new ArmorBuster();
            if (!ability.SpecialRules.Contains(nRule))
            {
                clbSpecials.Items.Add(nRule);
            }
            nRule = new Blast();
            if (!ability.SpecialRules.Contains(nRule))
            {
                clbSpecials.Items.Add(nRule);
            }
            nRule = new Blind();
            if (!ability.SpecialRules.Contains(nRule))
            {
                clbSpecials.Items.Add(nRule);
            }
            nRule = new ChangeSpeed();
            if (!ability.SpecialRules.Contains(nRule))
            {
                clbSpecials.Items.Add(nRule);
            }
            nRule = new ChangeStrength();
            if (!ability.SpecialRules.Contains(nRule))
            {
                clbSpecials.Items.Add(nRule);
            }
            nRule = new ChangeMarksmanship();
            if (!ability.SpecialRules.Contains(nRule))
            {
                clbSpecials.Items.Add(nRule);
            }
            nRule = new ChangeTech();
            if (!ability.SpecialRules.Contains(nRule))
            {
                clbSpecials.Items.Add(nRule);
            }
            nRule = new CounterAttack();
            if (!ability.SpecialRules.Contains(nRule))
            {
                clbSpecials.Items.Add(nRule);
            }
            nRule = new Deafen();
            if (!ability.SpecialRules.Contains(nRule))
            {
                clbSpecials.Items.Add(nRule);
            }
            nRule = new DrainTime();
            if (!ability.SpecialRules.Contains(nRule))
            {
                clbSpecials.Items.Add(nRule);
            }
            nRule = new Encase();
            if (!ability.SpecialRules.Contains(nRule))
            {
                clbSpecials.Items.Add(nRule);
            }
            nRule = new Explosion();
            if (!ability.SpecialRules.Contains(nRule))
            {
                clbSpecials.Items.Add(nRule);
            }
            nRule = new Fear();
            if (!ability.SpecialRules.Contains(nRule))
            {
                clbSpecials.Items.Add(nRule);
            }
            nRule = new GreaterAcid();
            if (!ability.SpecialRules.Contains(nRule))
            {
                clbSpecials.Items.Add(nRule);
            }
            nRule = new GreaterCounterAttack();
            if (!ability.SpecialRules.Contains(nRule))
            {
                clbSpecials.Items.Add(nRule);
            }
            nRule = new GreaterIndirect();
            if (!ability.SpecialRules.Contains(nRule))
            {
                clbSpecials.Items.Add(nRule);
            }
            nRule = new GreaterNoDeflect();
            if (!ability.SpecialRules.Contains(nRule))
            {
                clbSpecials.Items.Add(nRule);
            }
            nRule = new GreaterNoDodge();
            if (!ability.SpecialRules.Contains(nRule))
            {
                clbSpecials.Items.Add(nRule);
            }
            nRule = new Heal();
            if (!ability.SpecialRules.Contains(nRule))
            {
                clbSpecials.Items.Add(nRule);
            }
            nRule = new IdentifyFriendFoe();
            if (!ability.SpecialRules.Contains(nRule))
            {
                clbSpecials.Items.Add(nRule);
            }
            nRule = new Indirect();
            if (!ability.SpecialRules.Contains(nRule))
            {
                clbSpecials.Items.Add(nRule);
            }
            nRule = new Leap();
            if (!ability.SpecialRules.Contains(nRule))
            {
                clbSpecials.Items.Add(nRule);
            }
            nRule = new NoArmorReduction();
            if (!ability.SpecialRules.Contains(nRule))
            {
                clbSpecials.Items.Add(nRule);
            }
            nRule = new NoDeflect();
            if (!ability.SpecialRules.Contains(nRule))
            {
                clbSpecials.Items.Add(nRule);
            }
            nRule = new NoDodge();
            if (!ability.SpecialRules.Contains(nRule))
            {
                clbSpecials.Items.Add(nRule);
            }
            nRule = new Paralyze();
            if (!ability.SpecialRules.Contains(nRule))
            {
                clbSpecials.Items.Add(nRule);
            }
            nRule = new PoisonMalignant();
            if (!ability.SpecialRules.Contains(nRule))
            {
                clbSpecials.Items.Add(nRule);
            }
            nRule = new PoisonResilient();
            if (!ability.SpecialRules.Contains(nRule))
            {
                clbSpecials.Items.Add(nRule);
            }
            nRule = new Pull();
            if (!ability.SpecialRules.Contains(nRule))
            {
                clbSpecials.Items.Add(nRule);
            }
            nRule = new Range();
            if (!ability.SpecialRules.Contains(nRule))
            {
                clbSpecials.Items.Add(nRule);
            }
            nRule = new CharacterCreator.Classes.SpecialRules.Radius();
            if (!ability.SpecialRules.Contains(nRule))
            {
                clbSpecials.Items.Add(nRule);
            }
            nRule = new RerollMisses();
            if (!ability.SpecialRules.Contains(nRule))
            {
                clbSpecials.Items.Add(nRule);
            }
            nRule = new RerollHits();
            if (!ability.SpecialRules.Contains(nRule))
            {
                clbSpecials.Items.Add(nRule);
            }
            nRule = new Reach();
            if (!ability.SpecialRules.Contains(nRule))
            {
                clbSpecials.Items.Add(nRule);
            }
            nRule = new Roll();
            if (!ability.SpecialRules.Contains(nRule))
            {
                clbSpecials.Items.Add(nRule);
            }
            nRule = new Slam();
            if (!ability.SpecialRules.Contains(nRule))
            {
                clbSpecials.Items.Add(nRule);
            }
            nRule = new Stream();
            if (!ability.SpecialRules.Contains(nRule))
            {
                clbSpecials.Items.Add(nRule);
            }
            nRule = new Stun();
            if (!ability.SpecialRules.Contains(nRule))
            {
                clbSpecials.Items.Add(nRule);
            }
            nRule = new SuperbAcid();
            if (!ability.SpecialRules.Contains(nRule))
            {
                clbSpecials.Items.Add(nRule);
            }
            nRule = new SuperbCounterAttack();
            if (!ability.SpecialRules.Contains(nRule))
            {
                clbSpecials.Items.Add(nRule);
            }
            nRule = new SuperbIndirect();
            if (!ability.SpecialRules.Contains(nRule))
            {
                clbSpecials.Items.Add(nRule);
            }
            nRule = new SuperbNoDeflect();
            if (!ability.SpecialRules.Contains(nRule))
            {
                clbSpecials.Items.Add(nRule);
            }
            nRule = new SuperbNoDodge();
            if (!ability.SpecialRules.Contains(nRule))
            {
                clbSpecials.Items.Add(nRule);
            }
            nRule = new TechAttack();
            if (!ability.SpecialRules.Contains(nRule))
            {
                clbSpecials.Items.Add(nRule);
            }
            nRule = new TechBlast();
            if (!ability.SpecialRules.Contains(nRule))
            {
                clbSpecials.Items.Add(nRule);
            }
            nRule = new TechBlind();
            if (!ability.SpecialRules.Contains(nRule))
            {
                clbSpecials.Items.Add(nRule);
            }
            nRule = new TechDeafen();
            if (!ability.SpecialRules.Contains(nRule))
            {
                clbSpecials.Items.Add(nRule);
            }
            nRule = new TechExplosion();
            if (!ability.SpecialRules.Contains(nRule))
            {
                clbSpecials.Items.Add(nRule);
            }
            nRule = new TechEncase();
            if (!ability.SpecialRules.Contains(nRule))
            {
                clbSpecials.Items.Add(nRule);
            }
            nRule = new TechMelee();
            if (!ability.SpecialRules.Contains(nRule))
            {
                clbSpecials.Items.Add(nRule);
            }
            nRule = new TechParalyze();
            if (!ability.SpecialRules.Contains(nRule))
            {
                clbSpecials.Items.Add(nRule);
            }
            nRule = new TechRange();
            if (!ability.SpecialRules.Contains(nRule))
            {
                clbSpecials.Items.Add(nRule);
            }
            nRule = new Teleport();
            if (!ability.SpecialRules.Contains(nRule))
            {
                clbSpecials.Items.Add(nRule);
            }
            nRule = new Throw();
            if (!ability.SpecialRules.Contains(nRule))
            {
                clbSpecials.Items.Add(nRule);
            }
            nRule = new Trip();
            if (!ability.SpecialRules.Contains(nRule))
            {
                clbSpecials.Items.Add(nRule);
            }
        }