public void InitLeap() { m_instance = this; if (Scene == null) { Scene = new Scene(); } BodyMapper = new Dictionary<GameObject, Body>(); AddRemoveBodyUtil.Instance = new AddRemoveBodyUtil(Scene, BodyMapper); HandViewer.Instance = new HandViewer(Scene, BodyMapper); // Add listener to show Leap Interaction hands Scene.OnBodyAdded += new Scene.BodyNotification(HandViewer.Instance.OnBodyAddedCallback); Scene.OnBodyRemoved += new Scene.BodyNotification(HandViewer.Instance.OnBodyRemovedCallback); Scene.OnBodyScaled += new Scene.BodyNotification(OnBodyScaledCallback); // Create a container for the dynamic objects. GameObject dynamicObjectContainer = new GameObject(); dynamicObjectContainer.name = DynamicObjectContainerName; if (!FilterHandCollisionPerColliderExplicitly) { SetLayerCollisions(); } }
/// <summary> /// Performs initialization of Leap Interaction. /// </summary> public void Initialize() { // clientUnitLengthInMillimeters = MM_PER_M / transform.localScale.x; ReferenceObject = GetComponent<HandController>(); m_scene = new Scene (); Scene.ClientUnitLengthInMillimeters = clientUnitLengthInMillimeters; PositionCamera(); m_scene.RunCollisionDetection = EnableInteractionCollisions; m_scene.ResolveCollisions = true; //EnableInteractionCollisions; m_scene.AlwaysRunCollisionForHandsVsHeldObjects = true; m_scene.HandDistanceMultiplier = 1.0f; m_scene.DestroyClustersWhileNotHolding = true; // Don't create update the hand from the interact dll m_scene.UseBodyCallbacks = ShowInteractionHands; m_scene.UseHoldingCallbacks = true; // Start internal visualizer if (ShowVisualizer) { m_scene.OpenVisualDebgger (); } m_scene.AllowPinchWithAnyFinger = AllowPinchWithAnyFinger; m_scene.DisableHoldingOnPointingIndexFinger = DisableHoldingOnPointingIndexFinger; m_unityUtil = new UnityUtil (m_scene); m_unityUtil.InitLeap (); UnityUtil.LayerForHands = LayerForHands; UnityUtil.LayerForHeldObjects = LayerForHeldObjects; UnityUtil.LayerForReleasedObjects = LayerForReleasedObjects; // Optional: Initializatio of holding callbacks. // m_scene.OnHoldingHoverOver += OnHoldingHovers; // m_scene.OnHoldingStarts += OnHoldingStarts; m_scene.OnHoldingUpdates += DisableHandCollisions; m_scene.OnHoldingEnds += EnableHandCollisions; }