示例#1
0
 public static Collider selectionMain(bool Pointing, Vector3 PointingDirection, Vector3 Fingertip, ref int nb_pinch, ref bool creating, PinchDetector scriptPDL, PinchDetector scriptPDR, ref GameObject currentSelection, Camera cam,
                                      ref Vector3 lastPosition, ref Vector3 lastPositionR, ref Vector3 lastPositionL) // si le doigt pointe, un Vector3 (direction de raycast), le bout du doigt
 {
     if (nb_pinch == 1 && currentSelection != null)
     {
         Debug.Log("1 pinch");
         LeapCommon.deplacementMode(ref currentSelection, scriptPDL, scriptPDR, ref lastPosition, ref lastPositionR, ref lastPositionL);
     }
     else if (nb_pinch == 2 && currentSelection != null)
     {
         Debug.Log("2 pinch");
         LeapCommon.sizingMode(ref currentSelection, scriptPDL, scriptPDR, ref lastPosition, cam, ref lastPositionR, ref lastPositionL);
     }
     //LineRenderer lr = new LineRenderer();
     //lr.positionCount = 2;
     if (Pointing) //si je pointe avec mon doigt
     {
         //lr.SetPosition(0, Fingertip);
         //lr.SetPosition(1, Fingertip + PointingDirection * 10);
         if (currentCollider == null || timer >= timerDelay) //dans le cas où j'arrive pour la première fois ou que je peux changer de couche
         {
             timer = 0;
             Ray r = new Ray(Fingertip, PointingDirection);
             SphereArray = Physics.RaycastAll(r); // PTET FAIRE GAFFE AU MASK UTILISE POUR PAS SELECTIONNER LES POINTS
             Debug.Log(SphereArray.Length);
             return(chooseSphere());
         }
         else // le cas où je dois attendre avant de changer de couche
         {
             timer += Time.deltaTime;
             return(currentCollider);
         }
     }
     else
     {
         timer = timerDelay;
         return(currentCollider);
     }
 }
示例#2
0
        public static void creationMain(ref int nb_pinch, ref bool creating, PinchDetector scriptPDL, PinchDetector scriptPDR, ref GameObject currentSelection, Camera cam,
                                        ref Vector3 lastPosition, ref Vector3 lastPositionR, ref Vector3 lastPositionL, float referenceWait, ref float wait)
        {
            if (creating)
            {
                if (nb_pinch == 1)
                {
                    //Debug.Log(" DEPLACEMENT MODE");
                    wait = 0;
                    LeapCommon.deplacementMode(ref currentSelection, scriptPDL, scriptPDR, ref lastPosition, ref lastPositionR, ref lastPositionL);
                }
                else if (nb_pinch == 2)
                {
                    //Debug.Log(" SIZING MODE");
                    // wait, currentSelection, scriptPDL, scriptPDR (à remplacer par des "scripts" ou direct les objets),  lastPosition[,L,R], cam,
                    wait = 0;
                    Debug.Log(currentSelection != null);
                    LeapCommon.sizingMode(ref currentSelection, scriptPDL, scriptPDR, ref lastPosition, cam, ref lastPositionR, ref lastPositionL);
                }
                else
                {
                    // Debug.Log(" FINISHED MODE");
                    wait += Time.deltaTime;
                    if (wait >= referenceWait)
                    {
                        creating = false;
                    }
                }
            }
            else if (!creating)
            {
                if (nb_pinch == 2)
                {
                    /*
                     * //Debug.Log(" CREATION MODE");
                     * creating = true;
                     * currentSelection = GameObject.CreatePrimitive(PrimitiveType.Sphere);
                     * currentSelection.transform.position = (scriptPDL.Position + scriptPDR.Position) / 2;
                     * float tmp = (Vector3.Distance(scriptPDL.Position, scriptPDR.Position));
                     * currentSelection.transform.localScale = new Vector3(tmp, tmp, tmp);
                     */

                    /*
                     * The following code is supposed to do the exat same thing but with
                     * the prefab sphereMesh instead of standard sphere
                     */

                    creating = true;
                    // Gets the prefab
                    GameObject volumesNode = GameObject.Find("Volumes");
                    currentSelection = Instantiate(Resources.Load("Prefab/sphereMesh", typeof(GameObject))) as GameObject;
                    if (volumesNode != null)
                    {
                        currentSelection.transform.parent = volumesNode.transform;
                    }
                    //Modifies the position and scale
                    currentSelection.transform.position = (scriptPDL.Position + scriptPDR.Position) / 2;
                    float tmp = (Vector3.Distance(scriptPDL.Position, scriptPDR.Position));
                    currentSelection.transform.localScale = new Vector3(tmp, tmp, tmp);
                    /* End here*/

                    lastPosition = currentSelection.transform.position;
                }
            }
        }