Beispiel #1
0
        private IEnumerator enableGroup(string groupName)
        {
            yield return(new WaitForEndOfFrame());

            ModelGroup group = null;

            for (int i = 0; i < ModelPool.Count; i++)
            {
                //Debug.Log (ModelPool [i].GroupName);
                if (ModelPool[i].GroupName == groupName)
                {
                    group = ModelPool[i];
                    for (int hp = 0; hp < activeHandReps.Count; hp++)
                    {
                        HandProxy  handRep = activeHandReps[hp];
                        IHandModel model   = group.TryGetModel(handRep.RepChirality, handRep.RepType);
                        if (model != null)
                        {
                            handRep.AddModel(model);
                            modelToHandRepMapping.Add(model, handRep);
                        }
                    }
                    group.IsEnabled = true;
                }
            }
            if (group == null)
            {
                Debug.LogWarning("A group matching that name does not exisit in the modelPool");
            }
        }
 protected virtual void OnValidate()
 {
     if (_handModel == null)
     {
         _handModel = GetComponentInParent <IHandModel>();
     }
 }
Beispiel #3
0
        /**
         * DisableGroup finds and removes the ModelGroup's IHandModels from their HandRepresentations, returns them to their ModelGroup and sets the groups IsEnabled to false.
         * @param groupName Takes a string that matches the ModelGroup's groupName serialized in the Inspector
         */
        public void DisableGroup(string groupName)
        {
            ModelGroup group = null;

            for (int i = 0; i < ModelPool.Count; i++)
            {
                if (ModelPool[i].GroupName == groupName)
                {
                    group = ModelPool[i];
                    for (int m = 0; m < group.modelsCheckedOut.Count; m++)
                    {
                        IHandModel         model = group.modelsCheckedOut[m];
                        HandRepresentation handRep;
                        if (modelToHandRepMapping.TryGetValue(model, out handRep))
                        {
                            handRep.RemoveModel(model);
                            group.ReturnToGroup(model);
                            m--;
                        }
                    }
                    Assert.AreEqual(0, group.modelsCheckedOut.Count, group.GroupName + "'s modelsCheckedOut List has not been cleared");
                    group.IsEnabled = false;
                }
            }
            if (group == null)
            {
                Debug.LogWarning("A group matching that name does not exisit in the modelPool");
            }
        }
Beispiel #4
0
        private IEnumerator disableGroup(string groupName)
        {
            yield return(new WaitForEndOfFrame());

            ModelGroup group = null;

            for (int i = 0; i < ModelPool.Count; i++)
            {
                if (ModelPool[i].GroupName == groupName)
                {
                    group = ModelPool[i];
                    for (int m = 0; m < group.modelsCheckedOut.Count; m++)
                    {
                        IHandModel model = group.modelsCheckedOut[m];
                        HandProxy  handRep;
                        if (modelToHandRepMapping.TryGetValue(model, out handRep))
                        {
                            handRep.RemoveModel(model);
                            group.ReturnToGroup(model);
                            m--;
                        }
                    }
                    Assert.AreEqual(0, group.modelsCheckedOut.Count, group.GroupName + "'s modelsCheckedOut List has not been cleared");
                    group.IsEnabled = false;
                    Debug.Log("disable " + ModelPool[i].GroupName);
                }
            }
            if (group == null)
            {
                Debug.LogWarning("A group matching that name does not exisit in the modelPool");
            }
        }
Beispiel #5
0
 /*Looks for suitable IHandModel is the ModelGroup's modelList, if found, it is added to modelsCheckedOut.
  * If not, one can be cloned*/
 public IHandModel TryGetModel(Chirality chirality, ModelType modelType)
 {
     for (int i = 0; i < modelList.Count; i++)
     {
         if (modelList[i].HandModelType == modelType && modelList[i].Handedness == chirality)
         {
             IHandModel model = modelList[i];
             modelList.RemoveAt(i);
             modelsCheckedOut.Add(model);
             return(model);
         }
     }
     if (CanDuplicate)
     {
         for (int i = 0; i < modelsCheckedOut.Count; i++)
         {
             if (modelsCheckedOut[i].HandModelType == modelType && modelsCheckedOut[i].Handedness == chirality)
             {
                 IHandModel modelToSpawn = modelsCheckedOut[i];
                 IHandModel spawnedModel = GameObject.Instantiate(modelToSpawn);
                 spawnedModel.transform.parent = _handPool.transform;
                 _handPool.modelGroupMapping.Add(spawnedModel, this);
                 modelsCheckedOut.Add(spawnedModel);
                 return(spawnedModel);
             }
         }
     }
     return(null);
 }
Beispiel #6
0
        /**
         * MakeHandRepresentation receives a Hand and combines that with an IHandModel to create a HandRepresentation
         * @param hand The Leap Hand data to be drive an IHandModel
         * @param modelType Filters for a type of hand model, for example, physics or graphics hands.
         */

        public HandRepresentation MakeHandRepresentation(Hand hand, ModelType modelType)
        {
            Chirality          handChirality = hand.IsRight ? Chirality.Right : Chirality.Left;
            HandRepresentation handRep       = new HandRepresentation(this, hand, handChirality, modelType);

            for (int i = 0; i < ModelPool.Count; i++)
            {
                ModelGroup group = ModelPool[i];
                if (group.IsEnabled)
                {
                    IHandModel model = group.TryGetModel(handChirality, modelType);
                    if (model != null)
                    {
                        handRep.AddModel(model);
                        if (!modelToHandRepMapping.ContainsKey(model))
                        {
                            model.group = group;
                            modelToHandRepMapping.Add(model, handRep);
                        }
                    }
                }
            }
            activeHandReps.Add(handRep);
            return(handRep);
        }
        /**
         * MakeHandRepresentation receives a Hand and combines that with an IHandModel to create a HandRepresentation
         * @param hand The Leap Hand data to be drive an IHandModel
         * @param modelType Filters for a type of hand model, for example, physics or graphics hands.
         */
        public override HandRepresentation MakeHandRepresentation(Hand hand, ModelType modelType)
        {
            HandRepresentation handRep = null;

            for (int i = 0; i < ModelPool.Count; i++)
            {
                IHandModel model = ModelPool[i];
                bool       isCorrectHandedness;
                Chirality  handChirality = hand.IsRight ? Chirality.Right : Chirality.Left;
                isCorrectHandedness = model.Handedness == handChirality;
                if (!EnforceHandedness || model.Handedness == Chirality.Either)
                {
                    isCorrectHandedness = true;
                }
                bool isCorrectModelType;
                isCorrectModelType = model.HandModelType == modelType;
                if (isCorrectModelType && isCorrectHandedness)
                {
                    ModelPool.RemoveAt(i);
                    handRep = new HandProxy(this, model, hand);
                    break;
                }
            }
            return(handRep);
        }
 void ValidateIHandModelPrefab(IHandModel iHandModel)
 {
     if (PrefabUtility.GetPrefabType(iHandModel) == PrefabType.Prefab)
     {
         EditorUtility.DisplayDialog("Warning", "This slot needs to have an instance of a prefab from your scene. Make your hand prefab a child of the LeapHanadContrller in your scene,  then drag here", "OK");
     }
 }
Beispiel #9
0
 public void ReturnToPool(IHandModel model)
 {
     ModelGroup modelGroup;
       bool groupFound = modelGroupMapping.TryGetValue(model, out modelGroup);
       modelGroup.ReturnToGroup(model);
       Assert.IsTrue(groupFound);
 }
Beispiel #10
0
 public void ReturnToPool(IHandModel model) {
   ModelGroup modelGroup;
   bool groupFound = modelGroupMapping.TryGetValue(model, out modelGroup);
   Assert.IsTrue(groupFound);
   //First see if there is another active representation that can use this model
   for (int i = 0; i < activeHandReps.Count; i++) {
     HandProxy rep = activeHandReps[i];
     if (rep.RepChirality == model.Handedness && rep.RepType == model.HandModelType) {
       bool modelFromGroupFound = false;
       if (rep.handModels != null) {
         //And that represention does not contain a model from this model's modelGroup
         for (int j = 0; j < modelGroup.modelsCheckedOut.Count; j++) {
           IHandModel modelToCompare = modelGroup.modelsCheckedOut[j];
           for (int k = 0; k < rep.handModels.Count; k++) {
             if (rep.handModels[k] == modelToCompare) {
               modelFromGroupFound = true;
             }
           }
         }
       }
       if (!modelFromGroupFound) {
         rep.AddModel(model);
         modelToHandRepMapping[model] = rep;
         return;
       }
     }
   }
   //Otherwise return to pool
   modelGroup.ReturnToGroup(model);
 }
 void Awake()
 {
     watcherCoroutine = extendedFingerWatcher();
       if(HandModel == null){
     HandModel = gameObject.GetComponentInParent<IHandModel>();
       }
 }
Beispiel #12
0
        /**
         * EnableGroup finds suitable HandRepresentations and adds IHandModels from the ModelGroup, returns them to their ModelGroup and sets the groups IsEnabled to true.
         * @param groupName Takes a string that matches the ModelGroup's groupName serialized in the Inspector
         */
        public void EnableGroup(string groupName)
        {
            ModelGroup group = null;

            for (int i = 0; i < ModelPool.Count; i++)
            {
                if (ModelPool[i].GroupName == groupName)
                {
                    group = ModelPool[i];
                    for (int hp = 0; hp < activeHandReps.Count; hp++)
                    {
                        HandRepresentation handRep = activeHandReps[hp];
                        IHandModel         model   = group.TryGetModel(handRep.RepChirality, handRep.RepType);
                        if (model != null)
                        {
                            handRep.AddModel(model);
                            modelToHandRepMapping.Add(model, handRep);
                        }
                    }
                    group.IsEnabled = true;
                }
            }
            if (group == null)
            {
                Debug.LogWarning("A group matching that name does not exisit in the modelPool");
            }
        }
Beispiel #13
0
        public override void AddModel(IHandModel model)
        {
            // Check is Remote or not
            if (model.isRemote != this.IsRemote_)
            {
                return;
            }

            if (handModels == null)
            {
                handModels = new List <IHandModel>();
                // 有Bug????
            }
            handModels.Add(model);
            if (model.GetLeapHand() == null)
            {
                model.SetLeapHand(MostRecentHand);
                model.InitHand();
                model.BeginHand();
                model.UpdateHand();
            }
            else
            {
                model.SetLeapHand(MostRecentHand);
                model.BeginHand();
            }
        }
Beispiel #14
0
 public override void RemoveModel(IHandModel model)
 {
     if (handModels != null)
     {
         model.FinishHand();
         handModels.Remove(model);
     }
 }
Beispiel #15
0
 void Awake()
 {
     watcherCoroutine = extendedFingerWatcher();
     if (HandModel == null)
     {
         HandModel = gameObject.GetComponentInParent <IHandModel>();
     }
 }
 private void Awake()
 {
     watcherCoroutine = fingerPointingWatcher();
     if (HandModel == null)
     {
         HandModel = gameObject.GetComponentInParent <IHandModel>();
     }
 }
Beispiel #17
0
        public void ReturnToPool(IHandModel model)
        {
            ModelGroup modelGroup;
            bool       groupFound = modelGroupMapping.TryGetValue(model, out modelGroup);

            modelGroup.ReturnToGroup(model);
            //Assert.IsTrue(groupFound);
        }
 protected virtual void Awake(){
   iHandModel = GetComponent<IHandModel>();
   if (iHandModel == null) {
     Debug.LogWarning("HandTransitionBehavior components require an IHandModel component attached to the same GameObject");
     return;
   }
   iHandModel.OnBegin += HandReset;
   iHandModel.OnFinish += HandFinish;
 }
Beispiel #19
0
 private void Awake()
 {
     Debug.Log("Yolo");
     Debug.Log(OnAngle);
     watcherCoroutine = palmWatcher();
     if (HandModel == null)
     {
         HandModel = gameObject.GetComponentInParent <IHandModel>();
     }
 }
Beispiel #20
0
 protected virtual void Awake()
 {
     iHandModel = GetComponent <IHandModel>();
     if (iHandModel == null)
     {
         Debug.LogWarning("HandTransitionBehavior components require an IHandModel component attached to the same GameObject");
         return;
     }
     iHandModel.OnBegin  += HandReset;
     iHandModel.OnFinish += HandFinish;
 }
Beispiel #21
0
        public void AddNewGroup(string groupName, IHandModel leftModel, IHandModel rightModel)
        {
            ModelGroup newGroup = new ModelGroup();

            newGroup.LeftModel    = leftModel;
            newGroup.RightModel   = rightModel;
            newGroup.GroupName    = groupName;
            newGroup.CanDuplicate = false;
            newGroup.IsEnabled    = true;
            ModelPool.Add(newGroup);
        }
 protected virtual void Awake() {
   if (GetComponent<IHandModel>() != null && ControlsTransform == true) {
     Debug.LogWarning("Detector should not be control the IHandModel's transform. Either attach it to its own transform or set ControlsTransform to false.");
   }
   if (_handModel == null) {
     _handModel = GetComponentInParent<IHandModel>();
     if (_handModel == null) {
       Debug.LogWarning("The HandModel field of Detector was unassigned and the detector has been disabled.");
       enabled = false;
     }
   }
 }
    public HandProxy(HandPool parent, IHandModel handModel, Hand hand) :
      base(hand.Id)
    {
      this.parent = parent;
      this.handModel = handModel;

      // Check to see if the hand model has been initialized yet
      if (handModel.GetLeapHand() == null) {
        handModel.SetLeapHand(hand);
        handModel.InitHand();
      } else {
        handModel.SetLeapHand(hand);
      }
      handModel.BeginHand();
    }
Beispiel #24
0
        /** Popuates the ModelPool with the contents of the ModelCollection */
        void Start()
        {
            if (ModelsParent == null)
            {
                Debug.LogWarning("HandPool.ModelsParent needs to reference the parent transform of the hand models.  This transform should be a child of the LMHeadMountedRig transform.");
            }

            for (int i = 0; i < ModelPool.Count; i++)
            {
                var collectionGroup = ModelPool[i];
                collectionGroup._handPool = this;
                IHandModel leftModel;
                IHandModel rightModel;
                if (collectionGroup.IsLeftToBeSpawned)
                {
                    IHandModel modelToSpawn = collectionGroup.LeftModel;
                    GameObject spawnedGO    = GameObject.Instantiate(modelToSpawn.gameObject);
                    leftModel = spawnedGO.GetComponent <IHandModel>();
                    leftModel.transform.parent = ModelsParent;
                }
                else
                {
                    leftModel = collectionGroup.LeftModel;
                }
                if (leftModel != null)
                {
                    collectionGroup.modelList.Add(leftModel);
                    modelGroupMapping.Add(leftModel, collectionGroup);
                }

                if (collectionGroup.IsRightToBeSpawned)
                {
                    IHandModel modelToSpawn = collectionGroup.RightModel;
                    GameObject spawnedGO    = GameObject.Instantiate(modelToSpawn.gameObject);
                    rightModel = spawnedGO.GetComponent <IHandModel>();
                    rightModel.transform.parent = ModelsParent;
                }
                else
                {
                    rightModel = collectionGroup.RightModel;
                }
                if (rightModel != null)
                {
                    collectionGroup.modelList.Add(rightModel);
                    modelGroupMapping.Add(rightModel, collectionGroup);
                }
            }
        }
Beispiel #25
0
 protected virtual void Awake()
 {
     if (GetComponent <IHandModel>() != null && ControlsTransform == true)
     {
         Debug.LogWarning("Detector should not be control the IHandModel's transform. Either attach it to its own transform or set ControlsTransform to false.");
     }
     if (_handModel == null)
     {
         _handModel = GetComponentInParent <IHandModel>();
         if (_handModel == null)
         {
             Debug.LogWarning("The HandModel field of Detector was unassigned and the detector has been disabled.");
             enabled = false;
         }
     }
 }
Beispiel #26
0
        private void FixModelPool()
        {
            HandPool handPool = factory as HandPool;

            for (int i = 0; i < handPool.ModelPool.Count; i++)
            {
                if (handPool.ModelPool[i].modelsCheckedOut.Count != 0)
                {
                    for (int j = 0; j < handPool.ModelPool[i].modelsCheckedOut.Count; j++)
                    {
                        IHandModel model = handPool.ModelPool[i].modelsCheckedOut[j];
                        handPool.ModelPool[i].ReturnToGroup(model);
                    }
                }
            }
        }
Beispiel #27
0
        protected virtual void OnValidate()
        {
            if (_handModel == null)
            {
                _handModel = GetComponentInParent <IHandModel>();
            }

            _activatePinchDist   = Mathf.Max(0, _activatePinchDist);
            _deactivatePinchDist = Mathf.Max(0, _deactivatePinchDist);

            //Activate distance cannot be greater than deactivate distance
            if (_activatePinchDist > _deactivatePinchDist)
            {
                _deactivatePinchDist = _activatePinchDist;
            }
        }
Beispiel #28
0
        private void InitializeModelGroup(ModelGroup collectionGroup)
        {
            // Prevent the ModelGroup be initialized by multiple times
            if (modelGroupMapping.ContainsValue(collectionGroup))
            {
                return;
            }

            collectionGroup._handPool = this;
            IHandModel leftModel;
            IHandModel rightModel;

            if (collectionGroup.IsLeftToBeSpawned)
            {
                IHandModel modelToSpawn = collectionGroup.LeftModel;
                GameObject spawnedGO    = Instantiate(modelToSpawn.gameObject);
                leftModel = spawnedGO.GetComponent <IHandModel>();
                leftModel.transform.parent = modelsParent;
            }
            else
            {
                leftModel = collectionGroup.LeftModel;
            }
            if (leftModel != null)
            {
                collectionGroup.modelList.Add(leftModel);
                modelGroupMapping.Add(leftModel, collectionGroup);
            }

            if (collectionGroup.IsRightToBeSpawned)
            {
                IHandModel modelToSpawn = collectionGroup.RightModel;
                GameObject spawnedGO    = Instantiate(modelToSpawn.gameObject);
                rightModel = spawnedGO.GetComponent <IHandModel>();
                rightModel.transform.parent = modelsParent;
            }
            else
            {
                rightModel = collectionGroup.RightModel;
            }
            if (rightModel != null)
            {
                collectionGroup.modelList.Add(rightModel);
                modelGroupMapping.Add(rightModel, collectionGroup);
            }
        }
Beispiel #29
0
    public override void AddModel(IHandModel model) {
      if (handModels == null) {
        handModels = new List<IHandModel>();
      }
      handModels.Add(model);
      if (model.GetLeapHand() == null) {
        model.SetLeapHand(MostRecentHand);
        model.InitHand();
        model.BeginHand();
        model.UpdateHand();
      }
      else {
        model.SetLeapHand(MostRecentHand);
        model.BeginHand();

      }
    }
        public HandProxy(HandPool parent, IHandModel handModel, Hand hand) :
            base(hand.Id)
        {
            this.parent    = parent;
            this.handModel = handModel;

            // Check to see if the hand model has been initialized yet
            if (handModel.GetLeapHand() == null)
            {
                handModel.SetLeapHand(hand);
                handModel.InitHand();
            }
            else
            {
                handModel.SetLeapHand(hand);
            }
            handModel.BeginHand();
        }
Beispiel #31
0
 public override void AddModel(IHandModel model)
 {
     if (handModels == null)
     {
         handModels = new List <IHandModel>();
     }
     handModels.Add(model);
     if (model.GetLeapHand() == null)
     {
         model.SetLeapHand(MostRecentHand);
         model.InitHand();
         model.BeginHand();
         model.UpdateHand();
     }
     else
     {
         model.SetLeapHand(MostRecentHand);
         model.BeginHand();
     }
 }
 public void EnableGroup(string groupName)
 {
     for (int i = 0; i < ModelPool.Count; i++)
     {
         if (ModelPool[i].GroupName == groupName)
         {
             ModelGroup group = ModelPool[i];
             for (int hp = 0; hp < activeHandReps.Count; hp++)
             {
                 HandRepresentation handRep = activeHandReps[hp];
                 IHandModel         model   = group.TryGetModel(handRep.RepChirality, handRep.RepType);
                 if (model != null)
                 {
                     handRep.AddModel(model);
                     modelToHandRepMapping.Add(model, handRep);
                 }
             }
             group.IsEnabled = true;
         }
     }
 }
Beispiel #33
0
        public void ReturnToPool(IHandModel model)
        {
            ModelGroup modelGroup;
            bool       groupFound = modelGroupMapping.TryGetValue(model, out modelGroup);

            Assert.IsTrue(groupFound);
            //First see if there is another active representation that can use this model
            for (int i = 0; i < activeHandReps.Count; i++)
            {
                HandProxy rep = activeHandReps[i];
                if (rep.RepChirality == model.Handedness && rep.RepType == model.HandModelType)
                {
                    bool modelFromGroupFound = false;
                    if (rep.handModels != null)
                    {
                        //And that represention does not contain a model from this model's modelGroup
                        for (int j = 0; j < modelGroup.modelsCheckedOut.Count; j++)
                        {
                            IHandModel modelToCompare = modelGroup.modelsCheckedOut[j];
                            for (int k = 0; k < rep.handModels.Count; k++)
                            {
                                if (rep.handModels[k] == modelToCompare)
                                {
                                    modelFromGroupFound = true;
                                }
                            }
                        }
                    }
                    if (!modelFromGroupFound)
                    {
                        rep.AddModel(model);
                        modelToHandRepMapping[model] = rep;
                        return;
                    }
                }
            }
            //Otherwise return to pool
            modelGroup.ReturnToGroup(model);
        }
Beispiel #34
0
        /**
         * MakeHandRepresentation receives a Hand and combines that with an IHandModel to create a HandRepresentation
         * @param hand The Leap Hand data to be drive an IHandModel
         * @param modelType Filters for a type of hand model, for example, physics or graphics hands.
         */

        public override HandRepresentation MakeHandRepresentation(Hand hand, ModelType modelType)
        {
            VRGIN.Core.VRLog.Info("Make hand representation: {0}", modelType);

            Chirality          handChirality = hand.IsRight ? Chirality.Right : Chirality.Left;
            HandRepresentation handRep       = new HandProxy(this, hand, handChirality, modelType);

            for (int i = 0; i < ModelPool.Count; i++)
            {
                VRGIN.Core.VRLog.Info("Try group {0}", i);

                ModelGroup group = ModelPool[i];
                if (group.IsEnabled)
                {
                    VRGIN.Core.VRLog.Info("Enabled!");
                    try
                    {
                        IHandModel model = group.TryGetModel(handChirality, modelType);
                        if (model != null)
                        {
                            VRGIN.Core.VRLog.Info("Model found");
                            handRep.AddModel(model);

                            modelToHandRepMapping.Add(model, handRep);
                        }
                        else
                        {
                            VRGIN.Core.VRLog.Info("Model is null");
                        }
                    } catch (System.Exception e)
                    {
                        VRGIN.Core.VRLog.Error(e);
                    }
                }
            }
            activeHandReps.Add(handRep);
            return(handRep);
        }
Beispiel #35
0
        /**
         * MakeHandRepresentation receives a Hand and combines that with an IHandModel to create a HandProxy
         * @param hand The Leap Hand data to be drive an IHandModel
         * @param modelType Filters for a type of hand model, for example, physics or graphics hands.
         */

        public override HandRepresentation MakeHandRepresentation(Hand hand, ModelType modelType, bool IsRemote)
        {
            Chirality handChirality = hand.IsRight ? Chirality.Right : Chirality.Left;
            HandProxy handRep       = new HandProxy(this, hand, handChirality, modelType, IsRemote);

            for (int i = 0; i < ModelPool.Count; i++)
            {
                ModelGroup group = ModelPool[i];
                if (group.IsEnabled && IsRemote == group.IsRemote)                              // Make Sure Remote for remote  and  unremote for unremote
                {
                    IHandModel model = group.TryGetModel(handChirality, modelType);
                    if (model != null)
                    {
                        handRep.AddModel(model);
                        if (!modelToHandRepMapping.ContainsKey(model))
                        {
                            modelToHandRepMapping.Add(model, handRep);
                        }
                    }
                }
            }
            activeHandReps.Add(handRep);
            return(handRep);
        }
Beispiel #36
0
        /** Populates the ModelPool with the contents of the ModelCollection */
        void Start()
        {
            foreach (ModelGroup collectionGroup in ModelPool)
            {
                collectionGroup._handPool = this;
                IHandModel leftModel;
                IHandModel rightModel;
                if (collectionGroup.IsLeftToBeSpawned)
                {
                    IHandModel modelToSpawn = collectionGroup.LeftModel;
                    GameObject spawnedGO    = GameObject.Instantiate(modelToSpawn.gameObject);
                    leftModel = spawnedGO.GetComponent <IHandModel>();
                    leftModel.transform.parent = transform;
                }
                else
                {
                    leftModel = collectionGroup.LeftModel;
                }
                collectionGroup.modelList.Add(leftModel);
                modelGroupMapping.Add(leftModel, collectionGroup);

                if (collectionGroup.IsRightToBeSpawned)
                {
                    IHandModel modelToSpawn = collectionGroup.RightModel;
                    GameObject spawnedGO    = GameObject.Instantiate(modelToSpawn.gameObject);
                    rightModel = spawnedGO.GetComponent <IHandModel>();
                    rightModel.transform.parent = transform;
                }
                else
                {
                    rightModel = collectionGroup.RightModel;
                }
                collectionGroup.modelList.Add(rightModel);
                modelGroupMapping.Add(rightModel, collectionGroup);
            }
        }
 /** To be called if the HandRepresentation no longer has a Leap Hand. */
 public override void Finish() {
   handModel.FinishHand();
   parent.ModelPool.Add(handModel);
   handModel = null;
 }
Beispiel #38
0
 public override void RemoveModel(IHandModel model) {
   if (handModels != null) {
     model.FinishHand();
     handModels.Remove(model);
   }
 }
Beispiel #39
0
        protected virtual void OnValidate()
        {
            if (_handModel == null) {
            _handModel = GetComponentInParent<IHandModel>();
              }

              _activatePinchDist = Mathf.Max(0, _activatePinchDist);
              _deactivatePinchDist = Mathf.Max(0, _deactivatePinchDist);

              //Activate distance cannot be greater than deactivate distance
              if (_activatePinchDist > _deactivatePinchDist) {
            _deactivatePinchDist = _activatePinchDist;
              }
        }
Beispiel #40
0
 public void ReturnToGroup(IHandModel model)
 {
     modelsCheckedOut.Remove(model);
     modelList.Add(model);
     this._handPool.modelToHandRepMapping.Remove(model);
 }
 public abstract void AddModel(IHandModel model);
 public abstract void RemoveModel(IHandModel model);
Beispiel #43
0
 public void ReturnToGroup(IHandModel model)
 {
     modelsCheckedOut.Remove(model);
     modelList.Add(model);
     this._handPool.modelToHandRepMapping.Remove(model);
 }
Beispiel #44
0
 public void AddNewGroup(string groupName, IHandModel leftModel, IHandModel rightModel) {
   ModelGroup newGroup = new ModelGroup();
   newGroup.LeftModel = leftModel;
   newGroup.RightModel = rightModel;
   newGroup.GroupName = groupName;
   newGroup.CanDuplicate = false;
   newGroup.IsEnabled = true;
   ModelPool.Add(newGroup);
 }
 void ValidateIHandModelPrefab(IHandModel iHandModel) {
   if (PrefabUtility.GetPrefabType(iHandModel) == PrefabType.Prefab) {
     EditorUtility.DisplayDialog("Warning", "This slot needs to have an instance of a prefab from your scene. Make your hand prefab a child of the LeapHanadContrller in your scene,  then drag here", "OK");
   }
 }
 private void Awake()
 {
     watcherCoroutine = palmWatcher();
       if(HandModel == null){
     HandModel = gameObject.GetComponentInParent<IHandModel>();
       }
 }