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"); } }
/** * 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); }
/** * 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) { Chirality handChirality = hand.IsRight ? Chirality.Right : Chirality.Left; HandRepresentation handRep = new HandProxy(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); modelToHandRepMapping.Add(model, handRep); } } } activeHandReps.Add(handRep); return(handRep); }
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); }
/** * 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); }
/** * 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); }
public void RemoveHandRepresentation(HandProxy handRep) { activeHandReps.Remove(handRep); }