示例#1
0
    // Use this for initialization
    void Start()
    {
        sliderController = handModels.GetComponent <SliderController>();
        toggleController = handModels.GetComponent <ToggleController>();

        leftPinch = leftPhysicsHand.GetComponent <GestureDetection>();
        foreach (ExtendedFingerDetector detector in leftHand.GetComponents <ExtendedFingerDetector>())
        {
            if (detector.Focus == "Slider")
            {
                leftSlider = detector;
            }
            else if (detector.Focus == "Buttons")
            {
                leftButton = detector;
            }
        }

        rightPinch = rightPhysicsHand.GetComponent <GestureDetection>();
        foreach (ExtendedFingerDetector detector in rightHand.GetComponents <ExtendedFingerDetector>())
        {
            if (detector.Focus == "Slider")
            {
                rightSlider = detector;
            }
            else if (detector.Focus == "Buttons")
            {
                rightButton = detector;
            }
        }
    }
示例#2
0
 //FIXME: Temporary solution to compensate for broken settings
 private void repairSettings(ExtendedFingerDetector detector)
 {
     if (!detector.enabled)
     {
         detector.Thumb   = PointingState.Either;
         detector.Index   = PointingState.Either;
         detector.Middle  = PointingState.Either;
         detector.Ring    = PointingState.Either;
         detector.Pinky   = PointingState.Either;
         detector.enabled = true;
     }
 }
示例#3
0
        void SetUpDetectors()
        {
            var detectorHolder = UnityHelper.CreateGameObjectAsChild("Warp Detector Holder", transform).gameObject;

            _OpenPalmDownwardsDetector = detectorHolder.AddComponent <DetectorLogicGate>();

            _PalmDownwardsDetector                   = detectorHolder.AddComponent <PalmDirectionDetector>();
            _PalmDownwardsDetector.HandModel         = _Hand;
            _PalmDownwardsDetector.PointingDirection = new Vector3(0, -1, 0.5f).normalized;
            _PalmDownwardsDetector.OnAngle           = 10;
            //_PalmDownwardsDetector.OffAngle = 60;


            _ExtendedFingerDetector           = UnityHelper.CreateGameObjectAsChild("_ExtendedFingerDetector", detectorHolder.transform).gameObject.AddComponent <ExtendedFingerDetector>();
            _ExtendedFingerDetector.HandModel = _Hand;
            _ExtendedFingerDetector.Thumb     = PointingState.Extended;
            _ExtendedFingerDetector.Index     = PointingState.Extended;
            _ExtendedFingerDetector.Middle    = PointingState.Extended;
            _ExtendedFingerDetector.Ring      = PointingState.Extended;
            _ExtendedFingerDetector.Pinky     = PointingState.Extended;

            _Fistdetector           = UnityHelper.CreateGameObjectAsChild("_Fistdetector", detectorHolder.transform).gameObject.AddComponent <ExtendedFingerDetector>();
            _Fistdetector.HandModel = _Hand;
            _Fistdetector.Thumb     = PointingState.Either;
            _Fistdetector.Index     = PointingState.NotExtended;
            _Fistdetector.Middle    = PointingState.NotExtended;
            _Fistdetector.Ring      = PointingState.NotExtended;
            _Fistdetector.Pinky     = PointingState.NotExtended;


            _OpenPalmDownwardsDetector.AddDetector(_PalmDownwardsDetector);
            _OpenPalmDownwardsDetector.AddDetector(_ExtendedFingerDetector);
            _OpenPalmDownwardsDetector.OnActivate.AddListener(OnOpenPalmDownwardStart);
            _OpenPalmDownwardsDetector.OnDeactivate.AddListener(OnOpenPalmDownwardEnd);

            _Fistdetector.OnActivate.AddListener(OnFist);
        }
示例#4
0
        // Update is called once per frame
        void Update()
        {
            if (!initializedMenu)
            {
                //Connects to the menu
                cMenu = GameObject.Find("Palm UI L").GetComponent <CurrentMenu>();
                if (cMenu != null)
                {
                    //Debug.Log("IL EST INITIALISEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE");
                    initializedMenu = true;
                }
            }

            if (!initializedLeft)
            {
                Left = GameObject.Find("Capsule Hand Left");
                if (Left != null)
                {
                    //Debug.Log("ALLO");
                    scriptPDL  = Left.GetComponent <PinchDetector>();
                    scriptEFDL = Left.GetComponent <ExtendedFingerDetector>();
                    //Debug.Log(scriptEFDL, scriptPDL);
                    scriptPDL.OnActivate.AddListener(PinchLeftDetected);
                    scriptPDL.OnDeactivate.AddListener(PinchLeftEnded);
                    scriptEFDL.OnActivate.AddListener(ExtendedFingerDetected);
                    scriptEFDL.OnDeactivate.AddListener(ExtendedFingerEnded);
                    initializedLeft = true;
                }
            }
            if (!initializedRight)
            {
                Right = GameObject.Find("Capsule Hand Right");
                if (Right != null)
                {
                    //Debug.Log("ALLO");
                    scriptPDR  = Right.GetComponent <PinchDetector>();
                    scriptEFDR = Right.GetComponent <ExtendedFingerDetector>();
                    //Debug.Log(scriptEFDR, scriptPDR);
                    scriptPDR.OnActivate.AddListener(PinchRightDetected);
                    scriptPDR.OnDeactivate.AddListener(PinchRightEnded);
                    scriptEFDR.OnActivate.AddListener(ExtendedFingerDetected);
                    scriptEFDR.OnDeactivate.AddListener(ExtendedFingerEnded);
                    initializedRight = true;
                }
            }


            if (initializedLeft && initializedRight && initializedMenu)
            {
                switch (cMenu.GetCurrentMenu())
                {
                case CurrentMenu.Menu.NoMenuSelected:
                    break;

                case CurrentMenu.Menu.Creation:     //CREATION
                    LeapCreation.creationMain(ref nb_pinch, ref creating, scriptPDL, scriptPDR, ref currentSelection, cam,
                                              ref lastPosition, ref lastPositionR, ref lastPositionL, referenceWait, ref wait);
                    break;

                case CurrentMenu.Menu.Selection:     //SELECTION (!!! ptet avec un modulo pour gérer les différents sous-cas de la sélection)
                    switch (cMenu.GetCurrentMenuSelection())
                    {
                    case CurrentMenu.Selection.SetOperation:

                        break;

                    case CurrentMenu.Selection.Modification:
                        LeapDeformation.Update();
                        break;

                    default:
                        break;
                    }
                    Vector3 PointingDirection = new Vector3(0, 0, 0);
                    Vector3 Fingertip         = new Vector3(0, 0, 0);
                    //if (currentSelection != null)
                    //Debug.Log("CURRENT OBJECT:", currentSelection);
                    Finger f  = null;
                    Hand   hl = Left.GetComponent <HandModelBase>().GetLeapHand();
                    Hand   hr = Right.GetComponent <HandModelBase>().GetLeapHand();
                    if (Pointing > 0)
                    {
                        if (hl.Fingers[1].IsExtended)
                        {
                            f = hl.GetIndex();
                        }
                        else
                        {
                            f = hr.GetIndex();
                        }
                        PointingDirection = f.Direction.ToVector3();
                        Fingertip         = f.TipPosition.ToVector3();
                    }
                    Collider tempo = LeapSelection.selectionMain((Pointing > 0), PointingDirection, Fingertip, ref nb_pinch, ref creating, scriptPDL, scriptPDR, ref currentSelection, cam,
                                                                 ref lastPosition, ref lastPositionR, ref lastPositionL);
                    if (tempo != null)
                    {
                        if (currentSelection != null)
                        {
                            currentSelection.GetComponent <Renderer>().material.color = Color.white;
                        }
                        currentSelection = tempo.gameObject;
                        currentSelection.GetComponent <Renderer>().material.color = Color.red;
                    }
                    else
                    {
                        if (currentSelection != null)
                        {
                            currentSelection.GetComponent <Renderer>().material.color = Color.white;
                        }
                        currentSelection = null;
                    }

                    break;
                }
                lastPositionL = scriptPDL.Position;
                lastPositionR = scriptPDR.Position;
            }
        }
示例#5
0
        public void setupDetectors()
        {
            //setup line maker detectors
            for (int idx = 0; idx < 3; idx++)
            {
                ExtendedFingerDetector fingerDetector = fingerDetectors[idx];

                if (fingerDetector == null)
                {
                    return;
                }

                float period = .25f;

                switch (handedness)
                {
                case Chirality.Left:
                    fingerDetector.HandModel = leapHandDataLogger.ins.currHands.Lhand_rigged;
                    break;

                case Chirality.Right:
                    fingerDetector.HandModel = leapHandDataLogger.ins.currHands.RHand_rigged;
                    break;

                default:
                    break;
                }
                fingerDetector.Period = period;

                switch (idx)
                {
                case 0:
                    fingerDetector.OnActivate.AddListener(setActiveOneFinger);
                    fingerDetector.Thumb  = PointingState.NotExtended;
                    fingerDetector.Index  = PointingState.Extended;
                    fingerDetector.Middle = PointingState.NotExtended;
                    fingerDetector.Ring   = PointingState.NotExtended;
                    fingerDetector.Pinky  = PointingState.NotExtended;
                    fingerDetector.MinimumExtendedCount = 1;
                    fingerDetector.MaximumExtendedCount = 1;
                    break;

                case 1:
                    fingerDetector.OnActivate.AddListener(setActiveTwoFinger);
                    fingerDetector.Thumb  = PointingState.Extended;
                    fingerDetector.Index  = PointingState.Extended;
                    fingerDetector.Middle = PointingState.Either;
                    fingerDetector.Ring   = PointingState.NotExtended;
                    fingerDetector.Pinky  = PointingState.NotExtended;
                    fingerDetector.MinimumExtendedCount = 2;
                    fingerDetector.MaximumExtendedCount = 3;
                    break;

                case 2:
                    if (eraserEnabled)
                    {
                        fingerDetector.OnActivate.AddListener(setActiveFourFinger);
                    }
                    fingerDetector.Thumb  = PointingState.Either;
                    fingerDetector.Index  = PointingState.Extended;
                    fingerDetector.Middle = PointingState.Extended;
                    fingerDetector.Ring   = PointingState.Extended;
                    fingerDetector.Pinky  = PointingState.Extended;
                    fingerDetector.MinimumExtendedCount = 4;
                    fingerDetector.MaximumExtendedCount = 5;
                    break;

                default:
                    break;
                }
                //why does this have an error?
                fingerDetector.OnDeactivate.AddListener(setUnactive);
            }
        }
        internal void Start()
        {
            shearingLabManager labMan = FindObjectOfType <shearingLabManager>();

            labMan.measurementDisplays.Add(surfaceAreaModel.transform);
            labMan.measurementDisplays.Add(volumeModel.transform);
            //labMan.measurementDisplays.Add(crossSectionModel.transform);
            labMan.disableDisplays();

            surfaceAreaModel.GetComponent <MeshRenderer>().materials[0].color  = mgoColor;
            volumeModel.GetComponent <MeshRenderer>().materials[0].color       = mgoColor;
            crossSectionModel.GetComponent <MeshRenderer>().materials[0].color = mgoColor;
            //copy into base scene on Load.
            //this.transform.parent = SceneManager.GetSceneByName("HandWaverBase").GetRootGameObjects()[0].transform.parent;

            //construct parallel planes

            flatface1 = flatlandSurface.Constructor();
            flatface2 = flatlandSurface.Constructor();

            flatface1.otherFlatlandSurface = flatface2;
            flatface2.otherFlatlandSurface = flatface1;

            flatface1.transform.localScale = new Vector3(3f, .0001f, 3f);
            flatface2.transform.localScale = new Vector3(3f, .0001f, 3f);

            AbstractPoint   apexPoint = GeoObjConstruction.iPoint(Vector3.ProjectOnPlane(this.transform.position, Vector3.up) + Vector3.up * height2);
            AbstractPolygon basePoly  = GeoObjConstruction.rPoly(nSides, .3f, Vector3.ProjectOnPlane(this.transform.position, Vector3.up) + Vector3.up * height1);

            myPyramid = GeoObjConstruction.dPyramid(basePoly, apexPoint);

            foreach (AbstractLineSegment line in myPyramid.allEdges)
            {
                line.LeapInteraction = false;
            }
            foreach (AbstractPoint point in basePoly.pointList)
            {
                point.LeapInteraction = false;
                flatface1.attachedObjs.Add(point);
            }
            foreach (AbstractPolygon face in myPyramid.allfaces)
            {
                face.LeapInteraction = false;
            }
            flatface2.attachedObjs.Add(apexPoint);
            flatface2.attachedObjs.Add(basePoly);

            myPyramid.GetComponent <InteractionBehaviour>().enabled = false;

            mf.transform.position   = Vector3.zero;
            mf.transform.localScale = Vector3.one;
            mf.transform.rotation   = Quaternion.identity;

            palmDetectors = GetComponentsInChildren <PalmDirectionDetector>();

            //NATHAN HELP ME HERE
            for (int i = 0; i < palmDetectors.Length; i++)
            {
                PalmDirectionDetector palm = palmDetectors[i];

                palm.OnActivate.AddListener(startUpdateMesh);
                palm.OnDeactivate.AddListener(endUpdateMesh);

                ExtendedFingerDetector finger = palm.GetComponent <ExtendedFingerDetector>();

                finger.OnDeactivate.AddListener(endUpdateMesh);
                //the extended finger detectors are set to enable/disable the respective PalmDirectionDetectors.

                switch (i)
                {
                case 0:
                    palm.HandModel   = leapHandDataLogger.ins.currHands.Lhand_rigged;
                    finger.HandModel = leapHandDataLogger.ins.currHands.Lhand_rigged;
                    break;

                case 1:
                    palm.HandModel   = leapHandDataLogger.ins.currHands.RHand_rigged;
                    finger.HandModel = leapHandDataLogger.ins.currHands.RHand_rigged;
                    break;

                default:
                    break;
                }
            }

            updateMesh = updateMeshRoutine();
            if (overrideHandInput)
            {
                startUpdateMesh();
            }

            foreach (AbstractPolygon face in myPyramid.allfaces)
            {
                face.figColor = mgoColor;
            }

            myPyramid.apex.GetComponent <InteractionBehaviour>().OnGraspEnd += constantVelOutOfRange;
            labMan.addApexToList(myPyramid.apex);
        }
示例#7
0
 private Vector3 PalmNormal(ExtendedFingerDetector value)
 {
     return(value.HandModel.GetComponent <RigidHand>().GetPalmNormal());
 }
示例#8
0
        internal void Start()
        {
            shearingLabManager labMan = FindObjectOfType <shearingLabManager>();

            labMan.measurementDisplays.Add(areaModel.transform);
            labMan.measurementDisplays.Add(perimeterModel.transform);
            //labMan.measurementDisplays.Add(crossSectionModel.transform);
            labMan.disableDisplays();

            areaModel.GetComponent <MeshRenderer>().materials[0].color         = mgoColor;
            perimeterModel.GetComponent <LineRenderer>().materials[0].color    = mgoColor;
            crossSectionModel.GetComponent <LineRenderer>().materials[0].color = mgoColor;


            line1 = parallelLines.Constructor();
            parallelLines line2 = parallelLines.Constructor();

            line1.Position3 = Vector3.ProjectOnPlane(this.transform.position, Vector3.up) + Vector3.up * height2;
            line2.Position3 = Vector3.ProjectOnPlane(this.transform.position, Vector3.up) + Vector3.up * height1;

            line1.otherLine = line2;
            line2.otherLine = line1;

            AbstractPoint p1 = GeoObjConstruction.iPoint(line1.Position3);
            AbstractPoint p2 = GeoObjConstruction.iPoint(line2.Position3);
            AbstractPoint p3 = GeoObjConstruction.iPoint(line2.Position3 + line2.normalDir * 0.3f);

            p1.GetComponent <InteractionBehaviour>().OnGraspedMovement += checkOutOfRange;
            p1.GetComponent <InteractionBehaviour>().OnGraspEnd        += constantVelOutOfRange;

            labMan.addApexToList(p1);
            //line not on Parallel
            l1 = GeoObjConstruction.dLineSegment(p1, p2);
            //line not on parallel
            l2 = GeoObjConstruction.dLineSegment(p1, p3);
            //line on parallel
            AbstractLineSegment l3 = GeoObjConstruction.dLineSegment(p3, p2);

            line1.attachedObjs.Add(p1);
            line2.attachedObjs.Add(p2);
            line2.attachedObjs.Add(p3);

            points.Add(p1);
            points.Add(p2);
            points.Add(p3);

            lines.Add(l1);
            lines.Add(l2);
            lines.Add(l3);

            triangle = GeoObjConstruction.dPolygon(lines, points);

            foreach (AbstractLineSegment line in lines)
            {
                line.GetComponent <InteractionBehaviour>().enabled = false;
            }

            triangle.GetComponent <InteractionBehaviour>().enabled = false;

            myLR = GetComponent <LineRenderer>();

            palmDetectors = GetComponentsInChildren <PalmDirectionDetector>();

            for (int i = 0; i < palmDetectors.Length; i++)
            {
                PalmDirectionDetector palm = palmDetectors[i];
                palm.OnActivate.AddListener(startUpdateMesh);
                palm.OnDeactivate.AddListener(endUpdateMesh);

                ExtendedFingerDetector finger = palm.GetComponent <ExtendedFingerDetector>();
                finger.OnDeactivate.AddListener(endUpdateMesh);

                switch (i)
                {
                case 0:
                    palm.HandModel   = leapHandDataLogger.ins.currHands.Lhand_rigged;
                    finger.HandModel = leapHandDataLogger.ins.currHands.Lhand_rigged;
                    break;

                case 1:
                    palm.HandModel   = leapHandDataLogger.ins.currHands.RHand_rigged;
                    finger.HandModel = leapHandDataLogger.ins.currHands.RHand_rigged;
                    break;

                default:
                    break;
                }
                //the extended finger detectors are set to enable/disable the respective PalmDirectionDetectors.
            }

            updateLR = updateLR_Routine();

            if (overridePalmDetector)
            {
                startUpdateMesh();
            }

            triangle.figColor = mgoColor;

            movePointOnLine = animatePoint(points[0]);
        }