public virtual void removeLayer(LayerMetaphor layer)
 {
     if (!layers.Contains(layer))
     {
         return;
     }
     try
     {
         if (_oldVersion)
         {
             layer.reScaleOrginal();
         }
         GameObject layerObject = layer.getMetaphorObject();
         if (layer.Handle == this)
         {
             layerObject.transform.parent = worldObject.transform.parent;
             layer.setHandle(null);
         }
     }
     catch
     {
         Debug.Log("Fail to set layer parent");
         return;
     }
     layers.Remove(layer);
     if (!_oldVersion)
     {
         if (layers.Count > maxNormalLayerNum)
         {
             generalGap = entireHeight / layers.Count;
         }
     }
 }
    public virtual void updateObjectsOrder()
    {
        List <LayerMetaphor> newLayers = new List <LayerMetaphor>();

        for (int i = 0; i < layers.Count - 1
             ; i++)
        {
            for (int j = i + 1; j < layers.Count; j++)
            {
                if (layers[j].getMetaphorObject().transform.position.y < layers[i].getMetaphorObject().transform.position.y)
                {
                    LayerMetaphor temp = layers[j];
                    layers[j] = layers[i];
                    layers[i] = temp;
                    if (centerIndex == i)
                    {
                        centerIndex = j;
                    }
                    else if (centerIndex == j)
                    {
                        centerIndex = i;
                    }
                }
            }
        }
    }
 public virtual void addLayer(LayerMetaphor layer)
 {
     if (layers.Contains(layer))
     {
         return;
     }
     try
     {
         GameObject layerObject = layer.getMetaphorObject();
         layerObject.transform.parent   = baseObject.transform.parent;
         layerObject.transform.rotation = new Quaternion();
     }
     catch
     {
         Debug.Log("Fail to set layer parent");
         return;
     }
     layer.setHandle(this);
     layers.Add(layer);
     if (!_oldVersion)
     {
         if (layers.Count > maxNormalLayerNum)
         {
             generalGap = entireHeight / layers.Count;
         }
     }
 }
Пример #4
0
    /*
     * private void OnDrawGizmos()
     * {
     *  Controller controller = new Controller();
     *  Frame frame = controller.Frame();
     *  List<Hand> hands = frame.Hands;
     *  foreach (Hand h in hands)
     *  {
     *      Gizmos.DrawSphere(UnityVectorExtension.ToVector3(h.Fingers[1].TipPosition), 0.1f);
     *  }
     * }*/

    private void MapLayerInit()
    {
        foreach (GameObject gameObj in GameObject.FindObjectsOfType <GameObject>())
        {
            if (gameObj.name == "Map")
            {
                mapObj = gameObj;
            }
        }

        if (mapObj != null)
        {
            mapToEdit = mapObj.GetComponent <AbstractMap>();
            List <VectorSubLayerProperties> mapLayerProperties = (List <VectorSubLayerProperties>)mapToEdit.VectorData.GetAllFeatureSubLayers();
            foreach (VectorSubLayerProperties vsp in mapLayerProperties)
            {
                MapARLayer newLayer = new MapARLayer(vsp);
                if (vsp.coreOptions.isActive)
                {
                    LayerMetaphor newMetaphor = new LayerMetaphor(newLayer, oldVersion);
                    newMetaphor.oldVersion = oldVersion;
                    layerMetaphorsActived.Add(newMetaphor);
                }
            }
        }
    }
Пример #5
0
    private void InfoUpdate()
    {
        string          info = "";
        GestureHovering gp   = (GestureHovering)gestureHoveringRH;
        LayerMetaphor   lm   = layerMetaphorsActived[0];

        if (goSelected == null)
        {
            info += "goSelected: null";
        }
        else
        {
            info += "goSelected: " + goSelected.getLayer().getLayerName();
        }
        info += "lm: " + lm.getLayer().getLayerName();
        info += "disToCenter: " + lm.distanceToCenter(gp.LastPalmPos);
        //info += "RH Hovering State" + (gp.DetectingState == LeapGestureModel.State.InProcess);
        //info += "\nRH HoveringPos: " + gp.LastTipPos;
        //info += "\nRH HoveringPos: " + gp.LastPalmPos;
        //OneHandHovering(1);
        //handle.updateIndex(gp.LastPalmPos);
        //handle.updateObjectsPositions();

        /*
         * if (goPinchedRH == null)
         * {
         * info += "goPinchedRH: null";
         * }
         * else
         * {
         * info += "goPinchedRH: " + goPinchedRH.getMetaphorObject().name;
         * }
         * if (goSelected == null)
         * {
         * info += "\ngoSelected: null";
         * }
         * else
         * {
         * info += "\ngoSelected: " + goSelected.getMetaphorObject().name;
         * }
         * try
         * {
         * GestureTapping gesture = (GestureTapping)gestureTappingRH;
         * Vector3 tappingPos = gesture.LastTipPos;
         * foreach (LayerMetaphor lm in layerMetaphorsActived)
         * {
         *  GameObject worldObject = lm.getMetaphorObject();
         *  Collider coll = worldObject.GetComponent<Collider>();
         *  Vector3 closestPoint = coll.ClosestPointOnBounds(tappingPos);
         *  float distance = Vector3.Distance(closestPoint, tappingPos);
         *  //info += "\n" + lm.getMetaphorObject().name + " distance: " + distance.ToString();
         *  info += "\n" + lm.getMetaphorObject().name + " selected:: " + lm.IsSelected;
         * }
         * }
         * catch
         * {
         *
         * }*/
        infoPanel.GetComponent <Text>().text = info;
    }
Пример #6
0
    /*
     * private void OneHandEndGrabbing(int mode)
     * {
     *  switch (mode)
     *  {
     *      case 0:
     *          if (goGrabbedLH != null)
     *          {
     *              goGrabbedLH.endGrab();
     *          }
     *          goGrabbedLH = null;
     *          return;
     *      case 1:
     *          if (goGrabbedRH != null)
     *          {
     *              goGrabbedRH.endGrab();
     *          }
     *          goGrabbedRH = null;
     *          return;
     *  }
     * }*/
    /*
     * private void OneHandEndPinching(int mode)
     * {
     *  GesturePinching gesture;
     *  switch (mode)
     *  {
     *      case 0:
     *          gesture = (GesturePinching)gesturePinchingLH;
     *          if (goPinchedLH != null)
     *          {
     *              goPinchedLH.endPinch();
     *              if (gesture.CountTime < pinchingTimeMin)
     *              {
     *                  goPinchedLH.changeSelectState();
     *                  if (goPinchedLH.IsSelected)
     *                  {
     *                      goPinchedLH.reColorWorldObj(Color.red);
     *                      goPinchedLH.highLightDup();
     *                      goPinchedLH.createSelections();
     *                      if (goSelected == null)
     *                      {
     *                          goSelected = goPinchedLH;
     *                      }
     *                      else if (goSelected != goPinchedLH)
     *                      {
     *                          goSelected.reColorWorldObj(Color.white);
     *                          goSelected.cancelHighLightDup();
     *                          goSelected.removeSelections();
     *                          goSelected.endSelectState();
     *                          goSelected = goPinchedLH;
     *                      }
     *                  }
     *                  else
     *                  {
     *                      goPinchedLH.reColorWorldObj(Color.white);
     *                      goPinchedLH.cancelHighLightDup();
     *                      goPinchedLH.removeSelections();
     *                      goSelected = null;
     *                  }
     *              }
     *              goPinchedLH = null;
     *              handle.updateObjectsPositions(gesture.LastPalmPos);
     *          }
     *          return;
     *      case 1:
     *          gesture = (GesturePinching)gesturePinchingRH;
     *          if (goPinchedRH != null)
     *          {
     *              goPinchedRH.endPinch();
     *              if (gesture.CountTime < pinchingTimeMin)
     *              {
     *                  goPinchedRH.changeSelectState();
     *                  if (goPinchedRH.IsSelected)
     *                  {
     *                      goPinchedRH.reColorWorldObj(Color.red);
     *                      goPinchedRH.highLightDup();
     *                      goPinchedRH.createSelections();
     *                      if (goSelected == null)
     *                      {
     *                          goSelected = goPinchedRH;
     *                      }
     *                      else if (goSelected != goPinchedRH)
     *                      {
     *                          goSelected.reColorWorldObj(Color.white);
     *                          goSelected.cancelHighLightDup();
     *                          goSelected.removeSelections();
     *                          goSelected.endSelectState();
     *                          goSelected = goPinchedRH;
     *                      }
     *                  }
     *                  else
     *                  {
     *                      goPinchedRH.reColorWorldObj(Color.white);
     *                      goPinchedRH.cancelHighLightDup();
     *                      goPinchedRH.removeSelections();
     *                      goSelected = null;
     *                  }
     *              }
     *              goPinchedRH = null;
     *              handle.updateObjectsPositions(gesture.LastPalmPos);
     *          }
     *          return;
     *  }
     * }
     */
    /*
     * private void OneHandEndTapping(int mode)
     * {
     *  switch (mode)
     *  {
     *      case 0:
     *          if (goTappedLH != null)
     *          {
     *              goTappedLH.endTap();
     *              goTappedLH.reScaleWorldObj(0.8f, 0.8f, 0.8f);
     *          }
     *          goTappedLH = null;
     *          return;
     *      case 1:
     *          switch (controlMode)
     *          {
     *              case ControlMode.tapMenu:
     *                  return;
     *              case ControlMode.tappingRotation:
     *                  if (goTappedRH != null)
     *                  {
     *                      goTappedRH.endTap();
     *                      goTappedRH.reScaleWorldObj(0.8f, 0.8f, 0.8f);
     *                  }
     *                  goTappedRH = null;
     *                  return;
     *          }
     *          return;
     *  }
     * }*/
    private void DeletingLayersForTest()
    {
        if (this.Lock)
        {
            return;
        }
        int count = 0;

        while (layerMetaphorsActived.Count > 14)
        {
            count++;
            layerMetaphorsActived[0].moveObjectBy(new Vector3(.5f, 0.06f * count, 0));
            layerMetaphorsActived[0].enableActivedGraspActions();
            layerMetaphorsActived[0].enableGraspMovement();
            LayerMetaphor lm      = layerMetaphorsActived[0];
            bool          inRange = handle.updateLayerExisted(lm);
            if (inRange)
            {
                Debug.Log("Not successfully removed.");
                return;
            }
            else
            {
                layerMetaphorsActived.Remove(lm);
                lm.getLayer().hide();
                layerMetaphorsDisActived.Add(lm);
                if (!oldVersion)
                {
                    lm.getLayer().getDuplication().hideSelf();
                    lm.getMetaphorObject().GetComponent <MeshRenderer>().enabled = true;
                    bin.addLayer(lm);
                }
            }
            handle.updateIndex(handle.safeUpdatePos);
            handle.updateObjectsPositions(handle.safeUpdatePos);
            if (!oldVersion)
            {
                bin.updateIndex(bin.safeUpdatePos);
                bin.updateObjectsPositions(bin.safeUpdatePos);
            }
            deleteBefore = false;

            /*
             * else
             * {
             *  if (inRange)
             *  {
             *      layerMetaphorsActived.Add(lm);
             *      lm.getLayer().show();
             *      layerMetaphorsDisActived.Remove(lm);
             *  }
             * }*/
        }
    }
Пример #7
0
    override public void updateIndex(Vector3 handPos)
    {
        if (layers.Count == 0)
        {
            return;
        }
        Vector3 handlePos     = getMetaphorObject().transform.position;
        Vector3 firstLayerPos = postionForLayerInIndex(0);
        Vector3 lastLayerPos  = postionForLayerInIndex(layers.Count - 1);
        float   distance      = Vector2.Distance(new Vector2(handPos.x, handPos.z), new Vector2(handlePos.x, handlePos.z));
        bool    inRange       = (distance <= detectRange) && ((handPos.y - lastLayerPos.y) <= (detectRange + fixGap)) && ((firstLayerPos.y - handPos.y) <= (detectRange + fixGap));

        if (!inRange)
        {
            fixGap = 0;
            layers[centerIndex].cancelHighLightText();
            centerIndex = 0;
            return;
        }
        else
        {
            fixGap = 0.5f * (detectRange - distance);
        }
        //centerAroundIndexs.Clear();
        centerIndex = Mathf.RoundToInt((handPos.y - firstLayerPos.y) / (lastLayerPos.y - firstLayerPos.y) * (layers.Count - 1));
        if (centerIndex < 0)
        {
            centerIndex = 0;
        }
        else if (centerIndex > layers.Count - 1)
        {
            centerIndex = layers.Count - 1;
        }
        LayerMetaphor toEnableLm = layers[centerIndex];
        Color         c          = Color.black;

        foreach (LayerMetaphor lm in layers)
        {
            if (!lm.isGrasped)
            {
                lm.disableGraspMovement();
                lm.disableGraspActions();
                lm.cancelHighLightText();
            }
            else
            {
                toEnableLm = lm;
                c          = Color.red;
            }
        }
        toEnableLm.enableGraspMovement();
        toEnableLm.enableRemovedGraspActions();
        toEnableLm.highLightText(c);
    }
    protected float distanceRateForLayer(LayerMetaphor lm, Vector3 handPos)
    {
        float distance     = lm.distanceToCenter(handPos);
        float distanceRate = distance / detectRange;

        if (distanceRate < 0)
        {
            distanceRate = 0;
        }
        else if (distanceRate > 1)
        {
            distanceRate = 1;
        }
        return(distanceRate);
    }
Пример #9
0
    public SelectionMetaphor(LayerMetaphor layerMetaphor, float distance, string selectionName)
    {
        parentLayerMetaphor = layerMetaphor;

        GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);

        sphere.name = selectionName.ToUpper();
        sphere.transform.localScale = new Vector3(.03f, .03f, .03f);
        MeshCollider ms = sphere.AddComponent <MeshCollider>();

        //ms.convex = true;
        GameObject.Destroy(sphere.GetComponent <SphereCollider>());
        Material newMaterial = (Material)Resources.Load("Selection_" + selectionName, typeof(Material));

        sphere.GetComponent <Renderer>().material = newMaterial;
        sphere.transform.parent        = layerMetaphor.getMetaphorObject().transform;
        sphere.transform.localPosition = new Vector3(distance, 0, 0);
        worldObject = sphere;
    }
    public virtual bool updateLayerExisted(LayerMetaphor lm)
    {
        Vector3 lmPos     = lm.getMetaphorObject().transform.position;
        Vector3 handlePos = getMetaphorObject().transform.position;
        float   distance  = Vector2.Distance(new Vector2(lmPos.x, lmPos.z), new Vector2(handlePos.x, handlePos.z));
        //bool inRange = (distance <= pinchingRange * 2);
        bool inRange = (distance <= baseObject.transform.GetComponent <CapsuleCollider>().radius *baseObject.transform.lossyScale.x);

        if (layers.Contains(lm))
        {
            if (!inRange)
            {
                removeLayer(lm);
            }
        }
        else
        {
            if (inRange)
            {
                addLayer(lm);
            }
        }
        return(inRange);
    }
    public virtual void updateIndex(Vector3 handPos)
    {
        if (layers.Count == 0)
        {
            return;
        }
        Vector3 handlePos     = getMetaphorObject().transform.position;
        Vector3 firstLayerPos = postionForLayerInIndex(0);
        Vector3 lastLayerPos  = postionForLayerInIndex(layers.Count - 1);
        float   distance      = Vector2.Distance(new Vector2(handPos.x, handPos.z), new Vector2(handlePos.x, handlePos.z));
        bool    inRange       = (distance <= detectRange) && ((handPos.y - lastLayerPos.y) <= (detectRange + fixGap)) && ((firstLayerPos.y - handPos.y) <= (detectRange + fixGap));

        if (!inRange)
        {
            fixGap = 0;
            layers[centerIndex].cancelHighLightText();
            centerIndex = 0;
            return;
        }
        else
        {
            fixGap = Mathf.Sqrt((detectRange - distance) / detectRange) * detectRange * 0.6f;
        }
        //centerAroundIndexs.Clear();
        centerIndex = 0;
        float gap = Mathf.Abs(postionForLayerInIndex(0).y - handPos.y);

        if (_oldVersion)
        {
            for (int i = 0; i < layers.Count; i++)
            {
                float gap_i = Mathf.Abs(postionForLayerInIndex(i).y - handPos.y);
                if (layers[i].isGrasped)
                {
                    gap_i = 0;
                }
                if (gap > gap_i)
                {
                    centerIndex = i;
                    gap         = gap_i;
                }
            }
        }
        else
        {
            centerIndex = Mathf.RoundToInt((handPos.y - firstLayerPos.y) / (lastLayerPos.y - firstLayerPos.y) * (layers.Count - 1));
        }
        if (centerIndex < 0)
        {
            centerIndex = 0;
        }
        else if (centerIndex > layers.Count - 1)
        {
            centerIndex = layers.Count - 1;
        }
        LayerMetaphor toEnableLm = layers[centerIndex];
        Color         c          = Color.black;

        foreach (LayerMetaphor lm in layers)
        {
            if (!lm.isGrasped)
            {
                lm.disableGraspMovement();
                lm.disableGraspActions();
                lm.cancelHighLightText();
            }
            else
            {
                toEnableLm = lm;
                c          = Color.red;
            }
        }
        toEnableLm.enableGraspMovement();
        toEnableLm.enableActivedGraspActions();
        toEnableLm.highLightText(c);

        //Debug.Log("bot:" + centerBotIndex + "center" + centerIndex + "top" + centerTopIndex);
    }
Пример #12
0
    /*
     * private void OneHandPinching(int mode)
     * {
     *  GesturePinching gesture;
     *  Vector3 pinchingPos;
     *  Vector3 posMovement;
     *  switch (mode)
     *  {
     *      case 0:
     *          gesture = (GesturePinching)gesturePinchingLH;
     *          pinchingPos = gesture.LastTipPos;
     *          posMovement = gesture.TipMovement;
     *          if (goPinchedLH != null && gesture.CountTime >= pinchingTimeMin)
     *          {
     *              if (goPinchedLH.IsSelected)
     *              {
     *                  goPinchedLH.reColorWorldObj(Color.white);
     *                  goPinchedLH.cancelHighLightDup();
     *                  goPinchedLH.removeSelections();
     *                  goPinchedLH.endSelectState();
     *                  goSelected = null;
     *              }
     *              //goPinchedLH.moveObjectBy(posMovement);
     *              goPinchedLH.moveObjectTo(pinchingPos);
     *              LayerMetaphor lm = (LayerMetaphor)goPinchedLH;
     *              bool inRange = handle.updateLayerExisted(lm);
     *              if (layerMetaphorsActived.Contains(lm))
     *              {
     *                  if (!inRange)
     *                  {
     *                      layerMetaphorsActived.Remove(lm);
     *                      lm.getLayer().hide();
     *                      layerMetaphorsDisActived.Add(lm);
     *                  }
     *                  else
     *                  {
     *                      handle.updateIndex(pinchingPos);
     *                  }
     *              }
     *              else
     *              {
     *                  if (inRange)
     *                  {
     *                      layerMetaphorsActived.Add(lm);
     *                      lm.getLayer().show();
     *                      layerMetaphorsDisActived.Remove(lm);
     *                  }
     *              }
     *              handle.updateObjectsOrder();
     *              handle.updateObjectsPositions(gesture.LastPalmPos);
     *          }
     *          return;
     *      case 1:
     *          gesture = (GesturePinching)gesturePinchingRH;
     *          pinchingPos = gesture.LastTipPos;
     *          posMovement = gesture.TipMovement;
     *          Debug.Log(posMovement);
     *          if (goPinchedRH != null && gesture.CountTime >= pinchingTimeMin)
     *          {
     *              if (goPinchedRH.IsSelected)
     *              {
     *                  goPinchedRH.reColorWorldObj(Color.white);
     *                  goPinchedRH.cancelHighLightDup();
     *                  goPinchedRH.removeSelections();
     *                  goPinchedRH.endSelectState();
     *                  goSelected = null;
     *              }
     *              //goPinchedRH.moveObjectBy(posMovement);
     *              goPinchedRH.moveObjectTo(pinchingPos);
     *              LayerMetaphor lm = (LayerMetaphor)goPinchedRH;
     *              bool inRange = handle.updateLayerExisted(lm);
     *              if (layerMetaphorsActived.Contains(lm))
     *              {
     *                  if (!inRange)
     *                  {
     *                      layerMetaphorsActived.Remove(lm);
     *                      lm.getLayer().hide();
     *                      layerMetaphorsDisActived.Add(lm);
     *                  }
     *                  else
     *                  {
     *                      handle.updateIndex(pinchingPos);
     *                  }
     *              }
     *              else
     *              {
     *                  if (inRange)
     *                  {
     *                      layerMetaphorsActived.Add(lm);
     *                      lm.getLayer().show();
     *                      layerMetaphorsDisActived.Remove(lm);
     *                  }
     *              }
     *              handle.updateObjectsOrder();
     *              handle.updateObjectsPositions(gesture.LastPalmPos);
     *          }
     *          return;
     *  }
     * }*/
    /*
     * private void OneHandTapping(int mode)
     * {
     *  GestureTapping gesture;
     *  Vector3 tappingPos;
     *  Vector3 posMovement;
     *  List<LayerMetaphor> potentialLayers;
     *  List<SelectionMetaphor> potentialSelections;
     *  switch (controlMode)
     *  {
     *      case ControlMode.tapMenu:
     *          switch (mode)
     *          {
     *              case 0:
     *                  gesture = (GestureTapping)gestureTappingLH;
     *                  tappingPos = gesture.LastTipPos;
     *                  posMovement = gesture.TipMovement;
     *                  if (goTappedLH == null)
     *                  {
     *                      potentialLayers = new List<LayerMetaphor>();
     *                      foreach (LayerMetaphor lm in layerMetaphorsActived)
     *                      {
     *                          if (!lm.IsTapped)
     *                          {
     *                              if (lm.checkTapping(tappingPos))
     *                              {
     *                                  potentialLayers.Add(lm);
     *                              }
     *                          }
     *                      }
     *                      if (potentialLayers.Count > 0)
     *                      {
     *                          goTappedLH = potentialLayers[0];
     *                          foreach (LayerMetaphor lm in potentialLayers)
     *                          {
     *                              if (lm.checkDistance(tappingPos) < goTappedLH.checkDistance(tappingPos))
     *                              {
     *                                  goTappedLH = lm;
     *                              }
     *                          }
     *                          goTappedLH.startTap();
     *                          goTappedLH.reScaleWorldObj(1.25f, 1.25f, 1.25f);
     *                      }
     *                  }
     *                  else
     *                  {
     *                      if (goTappedLH.checkTapping(tappingPos))
     *                      {
     *                          //ratate the go
     *                      }
     *                      else
     *                      {
     *                          goTappedLH.endTap();
     *                          goTappedLH.reScaleWorldObj(0.8f, 0.8f, 0.8f);
     *                          goTappedLH = null;
     *                      }
     *                  }
     *                  return;
     *              case 1:
     *                  gesture = (GestureTapping)gestureTappingRH;
     *                  tappingPos = gesture.LastTipPos;
     *                  posMovement = gesture.TipMovement;
     *                  if (goTappedRH != null)
     *                  {
     *                      foreach (SelectionMetaphor sm in goTappedRH.getSelectionObjects())
     *                      {
     *                          if (sm.checkTapping(tappingPos))
     *                          {
     *                              goTappedRH.createSelections(sm.getMetaphorObject().name);
     *                              return;
     *                          }
     *                      }
     *                  }
     *                  if (goTappingRH == null)
     *                  {
     *                      potentialLayers = new List<LayerMetaphor>();
     *                      foreach (LayerMetaphor lm in layerMetaphorsActived)
     *                      {
     *                          if (lm.checkTapping(tappingPos))
     *                          {
     *                              potentialLayers.Add(lm);
     *                          }
     *                      }
     *                      if (potentialLayers.Count > 0)
     *                      {
     *                          goTappingRH = potentialLayers[0];
     *                          foreach (LayerMetaphor lm in potentialLayers)
     *                          {
     *                              if (lm.checkDistance(tappingPos) < goTappingRH.checkDistance(tappingPos))
     *                              {
     *                                  goTappingRH = lm;
     *                              }
     *                          }
     *                          goTappingRH.changeTap();
     *                          if (goTappingRH.IsTapped)
     *                          {
     *                              if(goTappedRH != null)
     *                              {
     *                                  goTappedRH.endTap();
     *                                  goTappedRH.reColorWorldObj(Color.white);
     *                                  goTappedRH.removeSelections();
     *                              }
     *                              goTappedRH = goTappingRH;
     *                              goTappedRH.reColorWorldObj(Color.red);
     *                              goTappedRH.createSelections();
     *                          }
     *                          else
     *                          {
     *                              goTappedRH.reColorWorldObj(Color.white);
     *                              goTappedRH.removeSelections();
     *                              goTappedRH = null;
     *                          }
     *                      }
     *                  }
     *                  else
     *                  {
     *                      if (goTappingRH.checkTapping(tappingPos))
     *                      {
     *                          //do nothing
     *                      }
     *                      else
     *                      {
     *                          //goTappedRH.endTap();
     *                          //goTappedRH.reScaleWorldObj(1.25f, 1.25f, 1.25f);
     *                          goTappingRH = null;
     *                      }
     *                  }
     *                  return;
     *          }
     *          return;
     *      case ControlMode.tappingRotation:
     *          switch (mode)
     *          {
     *              case 0:
     *                  gesture = (GestureTapping)gestureTappingLH;
     *                  tappingPos = gesture.LastTipPos;
     *                  posMovement = gesture.TipMovement;
     *                  if (goTappedLH == null)
     *                  {
     *                      potentialLayers = new List<LayerMetaphor>();
     *                      foreach (LayerMetaphor lm in layerMetaphorsActived)
     *                      {
     *                          if (!lm.IsTapped)
     *                          {
     *                              if (lm.checkTapping(tappingPos))
     *                              {
     *                                  potentialLayers.Add(lm);
     *                              }
     *                          }
     *                      }
     *                      if (potentialLayers.Count > 0)
     *                      {
     *                          goTappedLH = potentialLayers[0];
     *                          foreach (LayerMetaphor lm in potentialLayers)
     *                          {
     *                              if (lm.checkDistance(tappingPos) < goTappedLH.checkDistance(tappingPos))
     *                              {
     *                                  goTappedLH = lm;
     *                              }
     *                          }
     *                          goTappedLH.startTap();
     *                          goTappedLH.reScaleWorldObj(1.25f, 1.25f, 1.25f);
     *                      }
     *                  }
     *                  else
     *                  {
     *                      if (goTappedLH.checkTapping(tappingPos))
     *                      {
     *                          //ratate the go
     *                      }
     *                      else
     *                      {
     *                          goTappedLH.endTap();
     *                          goTappedLH.reScaleWorldObj(0.8f, 0.8f, 0.8f);
     *                          goTappedLH = null;
     *                      }
     *                  }
     *                  return;
     *              case 1:
     *                  gesture = (GestureTapping)gestureTappingRH;
     *                  tappingPos = gesture.LastTipPos;
     *                  posMovement = gesture.TipMovement;
     *                  if (goTappedRH == null)
     *                  {
     *                      potentialLayers = new List<LayerMetaphor>();
     *                      foreach (LayerMetaphor lm in layerMetaphorsActived)
     *                      {
     *                          if (!lm.IsTapped)
     *                          {
     *                              if (lm.checkTapping(tappingPos))
     *                              {
     *                                  potentialLayers.Add(lm);
     *                              }
     *                          }
     *                      }
     *                      if (potentialLayers.Count > 0)
     *                      {
     *                          goTappedRH = potentialLayers[0];
     *                          foreach (LayerMetaphor lm in potentialLayers)
     *                          {
     *                              if (lm.checkDistance(tappingPos) < goTappedRH.checkDistance(tappingPos))
     *                              {
     *                                  goTappedRH = lm;
     *                              }
     *                          }
     *                          goTappedRH.startTap();
     *                          goTappedRH.reScaleWorldObj(1.25f, 1.25f, 1.25f);
     *                      }
     *                  }
     *                  else
     *                  {
     *                      if (goTappedRH.checkTapping(tappingPos))
     *                      {
     *                          //ratate the go
     *                      }
     *                      else
     *                      {
     *                          goTappedRH.endTap();
     *                          goTappedRH.reScaleWorldObj(0.8f, 0.8f, 0.8f);
     *                          goTappedRH = null;
     *                      }
     *                  }
     *                  return;
     *          }
     *          return;
     *
     *  }
     * }
     */


    private void OneHandHovering(int mode)
    {
        if (goSelected != null)
        {
            return;
        }
        GestureHovering gesture;
        Vector3         hoveringPos;

        switch (mode)
        {
        case 0:
            gesture     = (GestureHovering)gestureHoveringLH;
            hoveringPos = (gesture.LastTipPos + gesture.LastPalmPos) / 2;
            handle.updateIndex(hoveringPos);
            handle.updateObjectsPositions(hoveringPos);
            if (!oldVersion)
            {
                bin.updateIndex(hoveringPos);
                bin.updateObjectsPositions(hoveringPos);
            }
            return;

        case 1:
            gesture     = (GestureHovering)gestureHoveringRH;
            hoveringPos = (gesture.LastTipPos + gesture.LastPalmPos) / 2;
            handle.updateIndex(hoveringPos);
            handle.updateObjectsPositions(hoveringPos);
            if (!oldVersion)
            {
                bin.updateIndex(hoveringPos);
                bin.updateObjectsPositions(hoveringPos);
            }
            return;

        case 2:
            foreach (LayerMetaphor lm in layerMetaphorsActived)
            {
                if (lm.isGrasped)
                {
                    lm.cancelAllGraspState();
                    lm.cancelAllHighLight();
                }
            }
            hoveringPos = handle.safeUpdatePos;
            handle.updateIndex(hoveringPos);
            handle.updateObjectsPositions(hoveringPos);
            if (oldVersion)
            {
                return;
            }
            foreach (LayerMetaphor lm in layerMetaphorsDisActived)
            {
                if (lm.isGrasped)
                {
                    goSelected = null;
                    lm.cancelAllGraspState();
                    lm.cancelAllHighLight();
                    lm.moveObjectTo(bin.safeUpdatePos);
                }
            }
            hoveringPos = bin.safeUpdatePos;
            bin.updateIndex(hoveringPos);
            bin.updateObjectsPositions(hoveringPos);
            return;
        }
    }
Пример #13
0
 public override void addLayer(LayerMetaphor layer)
 {
     base.addLayer(layer);
     //layer.rotateObjectBy(new Vector3(90,90,0));
 }
Пример #14
0
 public override void removeLayer(LayerMetaphor layer)
 {
     base.removeLayer(layer);
     //layer.rotateObjectBy(new Vector3(0, -90, 90));
 }