Пример #1
0
 public void ClearClickAnchors()
 {
     Native.AccessPropertyAsTransform(this, Native.Property.ShapeClickAnchors, Native.Mode.Clear, LeapTransform.Identity.ToNative());
 }
        public void OnBodyAddedCallback(Body body)// IntPtr bodyHandle)
        {
            // Create the game object
            bool       isFinger = false;
            GameObject gameObject;

            Shape.ShapeType type = body.Shape.Type;
            if (type == Shape.ShapeType.Capsule)
            {
                float capsuleRadius        = body.Shape.CapsuleRadius;
                float capsuleSegmentLength = body.Shape.CapsuleSegmentLength;

                gameObject = GameObject.Instantiate(Resources.Load(UnityUtil.ResourcesFolder + UnityUtil.FingerBoneTemplateName) as GameObject) as GameObject;

                // Adjust dimensions
                float capsuleHeight = capsuleRadius * 2f + capsuleSegmentLength;
                float yScale        = capsuleHeight / 2f;
                float zxScale       = capsuleRadius / 0.5f;
                gameObject.transform.localScale = new Vector3(zxScale, yScale, zxScale);
                gameObject.name = UnityUtil.FingerBoneName;

                LeapTransform t = new LeapTransform();
                t = new LeapTransform(Native.AccessPropertyAsTransform(body, Native.Property.BodyTransform, Native.Mode.Get, t.ToNative()));
                gameObject.transform.position = t.Position;
                gameObject.transform.rotation = t.Rotation;

                gameObject.rigidbody.maxAngularVelocity = 100.0f;

                isFinger = true;
                fingerBoneCount++;
            }
            else
            {
                gameObject      = GameObject.Instantiate(Resources.Load(UnityUtil.ResourcesFolder + UnityUtil.HandPalmTemplateName) as GameObject) as GameObject;
                gameObject.name = UnityUtil.HandPalmName;
                LeapTransform t = new LeapTransform();
                t = new LeapTransform(Native.AccessPropertyAsTransform(body, Native.Property.BodyTransform, Native.Mode.Get, t.ToNative()));
                gameObject.transform.position = t.Position;
                gameObject.transform.rotation = t.Rotation;

                gameObject.rigidbody.maxAngularVelocity = 100.0f;

                latestHandPalmAdded = gameObject;
                fingerBoneCount     = 0;
            }

            BodyMapper.Add(gameObject, body);

            GameObject container = isFinger && latestHandPalmAdded != null ? latestHandPalmAdded : GameObject.Find(UnityUtil.DynamicObjectContainerName) as GameObject;

            gameObject.transform.parent = container.transform;

            gameObject.layer = UnityUtil.LayerForHands;

            if (fingerBoneCount % 3 == 0 && fingerBoneCount > 0)
            {
                gameObject.name = UnityUtil.FingerTipBoneName;
                if (fingerBoneCount == 3)
                {
                    gameObject.name = UnityUtil.ThumbTipBoneName;
                }
            }

            if (fingerBoneCount == 15)
            {
                latestHandPalmAdded = null;
                fingerBoneCount     = 0;

                if (UnityUtil.FilterHandCollisionPerColliderExplicitly)
                {
                    DisableHandSelfCollisions(gameObject.transform.parent);
                }
            }
        }
Пример #3
0
 public void AddClickAnchor(LeapTransform t)
 {
     Native.AccessPropertyAsTransform(this, Native.Property.ShapeClickAnchors, Native.Mode.Add, t.ToNative());
 }