Ejemplo n.º 1
0
        HandState momentHandState()
        {
            Hand      hand           = leapManager.frontmostHand();
            ArrayList forwardFingers = LeapManager.forwardFacingFingers(hand);

            if (forwardFingers.Count == 0)
            {
                return(HandState.Fisting);
            }
            else if (forwardFingers.Count < 3)
            {
                float  minZ          = float.MaxValue;
                Finger forwardFinger = Finger.Invalid;

                foreach (Finger finger in forwardFingers)
                {
                    if (finger.TipPosition.z < minZ)
                    {
                        minZ          = finger.TipPosition.z;
                        forwardFinger = finger;
                    }
                }
                if (forwardFinger.IsValid && (forwardFinger.Type() == Finger.FingerType.TYPE_INDEX || forwardFinger.Type() == Finger.FingerType.TYPE_MIDDLE))
                {
                    return(HandState.Pointing);
                }
            }
            return(HandState.NoAction);
        }
Ejemplo n.º 2
0
    private List<Vector3> verts; //new Vector3(x,y,z)

    #endregion Fields

    #region Methods

    void awake()
    {
        util = new Vector3(0, 0, 1);
        manager = Camera.main.GetComponent<LeapManager>();
        verts=new List<Vector3>();
        groups=new int[6]{0,1,2,2,1,0,};
    }
Ejemplo n.º 3
0
 // Use this for initialization
 void Start()
 {
     controller            = new Controller();
     _leapManager          = GameObject.Find("LeapManager").GetComponent <LeapManager> ();
     _leapManager._mainCam = Camera.main;
     cursor = GameObject.Find("Cursor");
 }
Ejemplo n.º 4
0
    // Update is called once per frame
    void Update()
    {
        //First update of hand and finger positions to prevent destruction of stage
        if (firstUpdate)
        {
            manager = this.gameObject.GetComponent <LeapManager> ();
            UpdateBonePositions();
            UpdateFingerBonesPositions();
            firstUpdate = false;
        }

        if (manager.HandIsValid())
        {
            UpdateBonePositions();
            UpdateFingerBonesPositions();

            /*if (checkForWall (hand) == true) {
             *      CreateWall (hand);
             * } else{
             *      CreateHand (hand);
             * }*/
            CreateHand(manager.GetHand());
        }
        else
        {
            MakeBonesFlyUp();
        }
    }
Ejemplo n.º 5
0
    // Use this for initialization
    void Start()
    {
        m_button1 = this.transform.FindChild("button_1").GetComponent <GUIButton>();
        m_button2 = this.transform.FindChild("button_2").GetComponent <GUIButton>();

        _leapManager = (GameObject.Find("LeapManager") as GameObject).GetComponent(typeof(LeapManager)) as LeapManager;
    }
Ejemplo n.º 6
0
 // Use this for initialization
 void Start()
 {
     controller= new Controller();
     _leapManager = GameObject.Find ("LeapManager").GetComponent<LeapManager> ();
     _leapManager._mainCam = Camera.main;
     cursor=GameObject.Find("Cursor");
 }
Ejemplo n.º 7
0
				void Awake ()
				{	
						handState = HandState.NoAction;
						
						leapManager = (GameObject.Find ("LeapManager") as GameObject).GetComponent (typeof(LeapManager)) as LeapManager;
						cueStickController = (GameObject.Find ("CueStickTip") as GameObject).GetComponent (typeof(CueStickController)) as CueStickController;

						leapManager.leapController.EnableGesture (Gesture.GestureType.TYPE_SWIPE);
						leapManager.leapController.Config.SetFloat ("Gesture.Swipe.MinLength", 200.0f);
						leapManager.leapController.Config.SetFloat ("Gesture.Swipe.MinVelocity", 750f);
						leapManager.leapController.Config.Save ();

						gameStates.Add (GameState.CameraAutoAdjust);
						gameStates.Add (GameState.CameraManualAdjust);
						gameStates.Add (GameState.Aiming);
						gameStates.Add (GameState.AfterShot);
						gameStates.Add (GameState.TurnEnd);

						

						viewAdjustmentStateIcon = (GameObject.Find ("ViewAdjustmentStateIcon") as GameObject).GetComponent (typeof(RawImage)) as RawImage; 
						aimingStateIcon = (GameObject.Find ("AimingStateIcon") as GameObject).GetComponent (typeof(RawImage)) as RawImage; 
						swipeActionIcon = (GameObject.Find ("SwipeActionIcon") as GameObject).GetComponent (typeof(RawImage)) as RawImage;

						playerTurn = (GameObject.Find ("PlayerTurn") as GameObject).GetComponent (typeof(Text)) as Text; 
						cueBall = GameObject.FindGameObjectWithTag ("cueBall");

						cueBall = GameObject.FindGameObjectWithTag ("cueBall");
						camera = GameObject.FindGameObjectWithTag ("PlayerCamera");
						ballsParent = GameObject.FindGameObjectWithTag ("balls");
						foreach (Transform ball in ballsParent.transform) {
								balls.Add (ball.gameObject);				
						}
				}
Ejemplo n.º 8
0
    private LeapManager manager; //This provides access to leap data

    #endregion Fields

    #region Methods

    // Use this for initialization
    void Start()
    {
        manager = Camera.main.GetComponent<LeapManager>();							//This links to some leap data
        listener   = new Leap.Listener ();											//initializes the listener
        controller = new Leap.Controller ();										//Initializes the controler
        controller.AddListener (listener);											//Pipes the listener stream into the controler
    }
Ejemplo n.º 9
0
        void Awake()
        {
            handState = HandState.NoAction;

            leapManager        = (GameObject.Find("LeapManager") as GameObject).GetComponent(typeof(LeapManager)) as LeapManager;
            cueStickController = (GameObject.Find("CueStickTip") as GameObject).GetComponent(typeof(CueStickController)) as CueStickController;

            leapManager.leapController.EnableGesture(Gesture.GestureType.TYPE_SWIPE);
            leapManager.leapController.Config.SetFloat("Gesture.Swipe.MinLength", 200.0f);
            leapManager.leapController.Config.SetFloat("Gesture.Swipe.MinVelocity", 750f);
            leapManager.leapController.Config.Save();

            gameStates.Add(GameState.CameraAutoAdjust);
            gameStates.Add(GameState.CameraManualAdjust);
            gameStates.Add(GameState.Aiming);
            gameStates.Add(GameState.AfterShot);
            gameStates.Add(GameState.TurnEnd);



            viewAdjustmentStateIcon = (GameObject.Find("ViewAdjustmentStateIcon") as GameObject).GetComponent(typeof(RawImage)) as RawImage;
            aimingStateIcon         = (GameObject.Find("AimingStateIcon") as GameObject).GetComponent(typeof(RawImage)) as RawImage;
            swipeActionIcon         = (GameObject.Find("SwipeActionIcon") as GameObject).GetComponent(typeof(RawImage)) as RawImage;

            playerTurn = (GameObject.Find("PlayerTurn") as GameObject).GetComponent(typeof(Text)) as Text;
            cueBall    = GameObject.FindGameObjectWithTag("cueBall");

            cueBall     = GameObject.FindGameObjectWithTag("cueBall");
            camera      = GameObject.FindGameObjectWithTag("PlayerCamera");
            ballsParent = GameObject.FindGameObjectWithTag("balls");
            foreach (Transform ball in ballsParent.transform)
            {
                balls.Add(ball.gameObject);
            }
        }
Ejemplo n.º 10
0
    // Use this for initialization
    void Start()
    {
        //Create GameObject-arrays
        leapManager  = this.gameObject.GetComponent <LeapManager> ();
        audioManager = GameObject.Find("AudioManager").GetComponent <AudioManager> ();

        finger_bones = new GameObject[fingerCount, fingerBoneCount];
        palm_bones   = new GameObject[palmBoneCount];

        //Locate core and audioplayers
        core = handObject.transform.FindChild("ball").gameObject;
        audioplayerMovement          = core.transform.FindChild("audioplayerMovement").gameObject;
        audioplayerCasting           = core.transform.FindChild("audioplayerCasting").gameObject;
        audioplayerCastingSupporting = core.transform.FindChild("audioplayerCasting2").gameObject;
        audioplayerCastingGust       = core.transform.FindChild("audioplayerCasting3").gameObject;

        //Play move-loop
        audioManager.PlayLoop("handMoveLoop", audioplayerMovement);

        //Locate fingerbones
        for (int i = 0; i < fingerCount; i++)
        {
            for (int j = 0; j < fingerBoneCount; j++)
            {
                //Insert prefab fingerbone in array
                Transform fingerContainer = handObject.transform.FindChild("fingers");
                switch (i)
                {
                default:
                    finger_bones [i, j] = fingerContainer.FindChild("thumb_" + j.ToString()).gameObject; break;

                case 1:
                    finger_bones [i, j] = fingerContainer.FindChild("point_" + j.ToString()).gameObject; break;

                case 2:
                    finger_bones [i, j] = fingerContainer.FindChild("middle_" + j.ToString()).gameObject; break;

                case 3:
                    finger_bones [i, j] = fingerContainer.FindChild("ring_" + j.ToString()).gameObject; break;

                case 4:
                    finger_bones [i, j] = fingerContainer.FindChild("pinky_" + j.ToString()).gameObject; break;
                }

                finger_bones [i, j].GetComponent <BoneManager> ().scale = fingerBoneScale;
                //Debug.Log ("Found bone! " + finger_bones [i, j].ToString () + "| Scaled to "+fingerBoneScale.ToString());
            }
        }

        //Locate palm-bones
        for (int i = 0; i < palmBoneCount; i++)
        {
            Transform palmContainer = handObject.transform.FindChild("palm");
            palm_bones [i]      = palmContainer.FindChild("palm_" + (i).ToString()).gameObject;
            palmBoneOffsets [i] = palm_bones [i].transform.localPosition;
            palm_bones [i].GetComponent <BoneManager> ().scale = fingerBoneScale * 0.75f;
            //Debug.Log ("Found bone! " + palm_bones [i].ToString () + "| Offset of "+palmBoneOffsets[i].ToString());
        }
    }
Ejemplo n.º 11
0
Archivo: RClic.cs Proyecto: Krewn/LIOS
 void Start()
 {
     manager = Camera.main.GetComponent<LeapManager>();							//This links to some leap data
     a       = Camera.main.GetComponent<GetFrame> ();
     Rclic   = false;
     step    = 0;
     spector = new float[3];
 }
Ejemplo n.º 12
0
	// Use this for initialization
	void Start () {
		_backing = 	gameObject.transform.GetChild(0).gameObject;
		_fillBar = 	_backing.transform.GetChild(0).gameObject;
		_label = 	gameObject.transform.GetChild(1).gameObject;

		if(_selectionAction != "" && _nextLinkage != null) { Debug.LogWarning("Button with both selection action and linkage detected."); }
		_leapManager = (GameObject.Find("LeapManager") as GameObject).GetComponent(typeof(LeapManager)) as LeapManager;
	}
Ejemplo n.º 13
0
    // Use this for initialization
    void Start()
    {
        _leapManager = (GameObject.Find("LeapManager") as GameObject).GetComponent(typeof(LeapManager)) as LeapManager;

        //DontDestroyOnLoad(_leapManager);

        arrowTexture = GameObject.FindGameObjectsWithTag("ArrowTexture");
    }
Ejemplo n.º 14
0
 // Use this for initialization
 protected void Init()
 {
     leapManager    = this.gameObject.GetComponent <LeapManager> ();
     gestureManager = this.gameObject.GetComponent <GestureManager> ();
     handManager    = this.gameObject.GetComponent <StoneHandManager> ();
     audioManager   = GameObject.Find("AudioManager").GetComponent <AudioManager> ();
     //Debug.Log ("Base.init was called by " + this.ToString());
     //Debug.Log ("Two managers were found: " + leapManager.ToString() + " , " + gestureManager.ToString());
 }
Ejemplo n.º 15
0
    // Use this for initialization
    void Start()
    {
        //Frame frame = _leapController.Frame();
        _leapController = new Controller();
        text            = gameObject.GetComponent(typeof(TextMesh)) as TextMesh;


        _leapManager = (GameObject.Find("LeapManager") as GameObject).GetComponent(typeof(LeapManager)) as LeapManager;
    }
Ejemplo n.º 16
0
Archivo: BIDT.cs Proyecto: Krewn/LIOS
    void Start()
    {
        manager = Camera.main.GetComponent<LeapManager>();
        a       = Camera.main.GetComponent<GetFrame> ();

        k  = 0;
        km = 0;
        t  = 0;
        transform.GetChild(0).gameObject.SetActive(false);
    }
Ejemplo n.º 17
0
Archivo: IsClic.cs Proyecto: Krewn/LIOS
 void Start()
 {
     manager = Camera.main.GetComponent<LeapManager>();
     rClic = Camera.main.GetComponent<RClic>();
     lClic = Camera.main.GetComponent<LClic>();
     tol   = 2.5F;
     lk = 0;
     rk = 0;
     fix.x=1.5F;fix.y = 0F;fix.z = 3F;
 }
Ejemplo n.º 18
0
 void Update()
 {
     Glb.cam.update();
     Glb.map.update();
     Glb.player.update();
     Glb.em.update();
     Light.update_all();
     LeapManager.update();
     Glb.gui.update();
 }
Ejemplo n.º 19
0
    // Use this for initialization
    void Start()
    {
        _backing = gameObject.transform.GetChild(0).gameObject;
        _fillBar = _backing.transform.GetChild(0).gameObject;
        _label   = gameObject.transform.GetChild(1).gameObject;

        if (_selectionAction != "" && _nextLinkage != null)
        {
            Debug.LogWarning("Button with both selection action and linkage detected.");
        }
        _leapManager = (GameObject.Find("LeapManager") as GameObject).GetComponent(typeof(LeapManager)) as LeapManager;
    }
Ejemplo n.º 20
0
	// Use this for initialization
	void Start () {
		if(gameObject.transform.childCount > 0)
		{
			_minX = gameObject.transform.GetChild(0).GetChild(0).renderer.bounds.min.x;
			_maxX = gameObject.transform.GetChild(0).GetChild(0).renderer.bounds.max.x;
		}
		else
		{
			Debug.LogError("Level has no buttons.");
		}

		_leapManager = (GameObject.Find("LeapManager") as GameObject).GetComponent(typeof(LeapManager)) as LeapManager;
	}
Ejemplo n.º 21
0
    // Use this for initialization
    void Start()
    {
        leapManager    = gameObject.GetComponent <LeapManager> ();
        gestureManager = gameObject.GetComponent <GestureManager> ();

        releaseVectors = new List <Vector3>();

        //Construct layermask
        LayerMask mask1 = 1 << 13;
        LayerMask mask2 = 1 << 14;

        allowedLayers = mask1 | mask2;
    }
Ejemplo n.º 22
0
    // Update is called once per frame
    void Update()
    {
        if (_leapManager)
        {
            if (_leapManager.pointerAvailible && !LeapManager.isHandOpen(_leapManager.frontmostHand()))
            {
                Vector2 pointerPositionScreen = _leapManager.pointerPositionScreen;
                pointerPositionScreen.y = pointerPositionScreen.y + 30;

                m_button1.UpdateState(pointerPositionScreen);
                m_button2.UpdateState(pointerPositionScreen);
            }
        }
    }
Ejemplo n.º 23
0
    // Use this for initialization
    void Start()
    {
        if (gameObject.transform.childCount > 0)
        {
            _minX = gameObject.transform.GetChild(0).GetChild(0).renderer.bounds.min.x;
            _maxX = gameObject.transform.GetChild(0).GetChild(0).renderer.bounds.max.x;
        }
        else
        {
            Debug.LogError("Level has no buttons.");
        }

        _leapManager = (GameObject.Find("LeapManager") as GameObject).GetComponent(typeof(LeapManager)) as LeapManager;
    }
Ejemplo n.º 24
0
    // Use this for initialization
    void Start()
    {
        _leapManager = (GameObject.Find("LeapManager") as GameObject).GetComponent(typeof(LeapManager)) as LeapManager;
        rb           = gameObject.GetComponent <Rigidbody>();

        Transform[] transforms = GetComponentsInChildren <Transform>();
        foreach (Transform t in transforms)
        {
            if (t.gameObject.name == "direction")
            {
                direction = t.gameObject;
            }
        }
    }
Ejemplo n.º 25
0
    // Update is called once per frame
    void Update()
    {
        if (Game.currentState.Equals(Game.GameState.Aiming))
        {
            gameObject.renderer.enabled = true;
            cueStick.renderer.enabled   = true;
            Hand    hand           = Game.leapManager.frontmostHand();
            Finger  pointingFinger = LeapManager.pointingFigner(hand);
            Vector3 tip            = pointingFinger.TipPosition.ToUnityTranslated();
            tip = new Vector3(tip.z, tip.y, -1 * tip.x);
            Vector3 mid = hand.PalmPosition.ToUnityTranslated();
            mid = new Vector3(mid.z, mid.y, -1 * mid.x);

            float   globalResizeCoef = (2 * Vector3.Distance(camera.transform.position, cueBall.transform.position)) / (LeapManager.HandMaxZ - LeapManager.HandMinZ);
            Vector3 tmp = camera.transform.position + (globalResizeCoef * new Vector3(tip.x, tip.y, tip.z));



            if (hand.IsValid && pointingFinger.IsValid)
            {
                cueStickTipPosition = new Vector3(tmp.x, 0.25f, tmp.z);
                cueStickVelocity    = pointingFinger.TipVelocity.ToUnityScaled();
            }
            else
            {
                cueStickVelocity = Vector3.zero;
            }


            //Debug.Log ("tip:" + mid.x +
            //     ", " + mid.y + ", " + mid.z);
            //Vector3 vca = camera.transform.rotation.eulerAngles;
            //Vector3 dir = tip - mid;
            //float dax = Vector3.Angle (dir, Vector3.right);
            //float daz = Vector3.Angle (dir, Vector3.up);
            //float day = Vector3.Angle (dir, Vector3.forward);
            //cueStickRotation = Quaternion.Euler (new Vector3 (dax, day + vca.y, daz));
            //Vector3 cueStickPosition = cueStickTipPosition;
            //Vector3.MoveTowards (cueStickPosition, dir.normalized, 2.0f);
            //cueStickRotation = Quaternion.Euler (new Vector3 (90.0f, (day - 90) + vca.y, 0.0f));
            //Debug.Log ("vca:" + vca.x + ", " + vca.y + ", " + vca.z + " dax:" + dax + ", " + day + ", " + daz);
        }
        else
        {
            gameObject.renderer.enabled = true;
            cueStick.renderer.enabled   = true;
        }
    }
Ejemplo n.º 26
0
    // Update is called once per frame
    void Update()
    {
        if (_leapManager)
        {
            if (_leapManager.pointerAvailible && !LeapManager.isHandOpen(_leapManager.frontmostHand()) /* && !any_menu_active*/)
            {
                arrowTexture[0].SetActive(true);

                gameObject.transform.position = new Vector3(_leapManager.pointerPositionScreen.x / Camera.main.pixelWidth, _leapManager.pointerPositionScreen.y / Camera.main.pixelHeight, 0.0f);
            }
            else
            {
                arrowTexture[0].SetActive(false);
            }
        }
    }
Ejemplo n.º 27
0
    void Awake()
    {
        // get needed objects´ references
        manager = Camera.mainCamera.GetComponent<LeapManager>();
        infoGUI = GameObject.Find("HandGuiText");

        // save original materials
        objectMaterials = new Material[draggableObjects.Length];
        objectPositions = new Vector3[draggableObjects.Length];

        for(int i = 0; i < draggableObjects.Length; i++)
        {
            if(draggableObjects[i] && draggableObjects[i].renderer)
            {
                objectMaterials[i] = new Material(draggableObjects[i].renderer.material);
                objectPositions[i] = draggableObjects[i].transform.position;
            }
        }
    }
Ejemplo n.º 28
0
    // Update is called once per frame
    void Update()
    {
        if (_leapManager.frontmostHand().IsValid&& LeapManager.isHandOpen(_leapManager.frontmostHand()))
        {
            Hand    hand         = _leapManager.frontmostHand();
            Vector3 handLocation = hand.PalmPosition.ToUnityTranslated();

            if (hand.Id != _lastHandId)
            {
                _handPositionOnAquire = handLocation;
                _lastHandId           = hand.Id;
            }

            handLocation = _lastHandPositionOnLoss + (handLocation - _handPositionOnAquire);

            handLocation.y = Mathf.Clamp(handLocation.y, _controlMin.y, _controlMax.y);

            _lastHandPosition = handLocation;

            Quaternion yRotation = Quaternion.Euler(new Vector3(
                                                        0,
                                                        (((handLocation.x - _controlMin.x) / (_controlMax.x - _controlMin.x)) * 180.0f) + 90.0f,
                                                        0
                                                        ));

            Quaternion xRotation = Quaternion.Euler(new Vector3(
                                                        ((1 - ((handLocation.y - _controlMin.y) / (_controlMax.y - _controlMin.y))) * 180.0f) + 90.0f,
                                                        0,
                                                        0));

            Vector3 directionVector = yRotation * xRotation * Vector3.forward;

            float dist = ((1.0f - Mathf.Clamp((handLocation.z - _controlMin.z) / (_controlMax.z - _controlMin.x), 0.0f, 1.0f)) * (_distanceLimits.y - _distanceLimits.x)) + _distanceLimits.x;
            gameObject.transform.position = directionVector * dist;
            gameObject.transform.LookAt(_targetObject.transform);
        }
        else
        {
            _lastHandId             = -1;
            _lastHandPositionOnLoss = _lastHandPosition;
        }
    }
Ejemplo n.º 29
0
    public bool calibrationTriggered; // check if hand is within calibration area

    // Use this for initialization
    void Start()
    {
        leapManager  = this.gameObject.GetComponent <LeapManager> ();
        musicManager = GameObject.Find("AudioManager").GetComponent <MusicManager> ();
        GameObject g = GameObject.Find("LeapControllerBlockHand");

        calibrationManagerNew = g.GetComponent <CalibrationManagerNew>();
        calibrationManager    = g.GetComponent <CalibrationManager>();
        glowController        = GameObject.Find("StoneHandModel 1").GetComponentInChildren <GlowControl>();
        //Debug.Log("Found hand + glow");
        activeSpell = "none";

        calibratedDownFrame = new List <Vector3> ();
        calibratedDown      = new Vector3(0f, -1f, -0.1f);     //Default down-vector

        calibrateOnStart     = false;
        calibrationTriggered = false;

        if (calibrateOnStart)
        {
            Debug.Log("Calibrating... ");
        }
    }
Ejemplo n.º 30
0
    // Use this for initialization
    void Start()
    {
        manager = this.gameObject.GetComponent <LeapManager> ();
        Debug.Log(this.ToString() + manager.ToString());
        //Create finger bones
        finger_bones = new GameObject[NUM_FINGERS, NUM_BONES];

        for (int i = 0; i < NUM_FINGERS; i += 1)
        {
            for (int g = 0; g < NUM_BONES; g += 1)
            {
                //Debug.Log ("Creating Sphere");

                //Insert prefab fingerbone in spheres array
                //finger_bones [i, g] = Instantiate(FingerBone, new Vector3(5,20,190), Quaternion.Euler(0,0,0)) as GameObject;
                //finger_bones [i, g].GetComponent<Rigidbody> ().MovePosition (new Vector3 (5, 1, 190));
                finger_bones [i, g] = Instantiate(FingerBone) as GameObject;
                //finger_bones [i, g].GetComponent<Rigidbody> ().MovePosition (new Vector3 (5, 1, 190));

                //Change scale of fingerbone
                finger_bones[i, g].GetComponent <BoneManager>().scale    = 0.2f * fingerBoneScale;
                finger_bones[i, g].GetComponent <BoneManager>().boneMass = boneMass;


                finger_bones[i, g].GetComponent <BoneManager>().targetPosition.y = 200;

                //finger_bones[i,g].transform.position = new ;
                //spheres[i, g].transform.localScale = new Vector3 (scale, scale, scale);
            }
        }

        //Create palm bone
        palm_bone = Instantiate(FingerBone, new Vector3(5, 1, -130), Quaternion.Euler(0, 0, 0)) as GameObject;
        palm_bone.GetComponent <Rigidbody> ().MovePosition(new Vector3(5, 1, -130));
        palm_bone.GetComponent <BoneManager> ().scale    = 0.4f * fingerBoneScale;
        palm_bone.GetComponent <BoneManager> ().boneMass = boneMass;
    }
Ejemplo n.º 31
0
    /*-------------------------------------------------------------------------
     * Unity Lifecycle Functions
     * ----------------------------------------------------------------------*/
    public void Awake()
    {
        // Singleton implementation
        if (_instance != null)
        {
            Debug.LogError(this.ToString() + ": Singleton already exists. Destroying.");
            Destroy(this);
        }
        else
        {
            _instance = this;
        }

        // Set Leap Unity Extension Properties
        Leap.UnityVectorExtension.InputScale  = LeapScaling;
        Leap.UnityVectorExtension.InputOffset = LeapOffset;

        // Set up Leap Controller
        _controller = new Controller();
        _controller.EnableGesture(Leap.Gesture.GestureType.TYPECIRCLE);
        _controller.EnableGesture(Leap.Gesture.GestureType.TYPEKEYTAP);
        _controller.EnableGesture(Leap.Gesture.GestureType.TYPESCREENTAP);
        _controller.EnableGesture(Leap.Gesture.GestureType.TYPESWIPE);
    }
Ejemplo n.º 32
0
    // Update is called once per frame
    void Update()
    {
        //First update of hand and finger positions to prevent destruction of stage
        if (firstUpdate)
        {
            leapManager = this.gameObject.GetComponent <LeapManager> ();
            UpdateBonePositions();
            firstUpdate = false;
        }

        if (leapManager.HandIsValid())
        {
            UpdateBonePositions();
        }
        else
        {
            MakeBonesFlyUp();
        }

        UpdateActivity();

        //Apply activity to movement-volume
        audioManager.SetVolume(activity, audioplayerMovement);
    }
Ejemplo n.º 33
0
    // Update is called once per frame
    void Update()
    {
        if (_leapManager.frontmostHand().IsValid&& LeapManager.isHandOpen(_leapManager.frontmostHand()))
        {
            Vector3 handLocation = _leapManager.frontmostHand().PalmPosition.ToUnityTranslated();

            Quaternion yRotation = Quaternion.Euler(new Vector3(
                                                        0,
                                                        360 - (Mathf.Clamp((handLocation.x - _controlMin.x) / (_controlMax.x - _controlMin.x), 0, 1.0f) * 360.0f) + 90.0f,
                                                        0
                                                        ));

            Quaternion xRotation = Quaternion.Euler(new Vector3(
                                                        (Mathf.Clamp((handLocation.y - _controlMin.y) / (_controlMax.y - _controlMin.y), 0, 1.0f) * 180.0f) + 90.0f,
                                                        0,
                                                        0));

            Vector3 directionVector = yRotation * xRotation * Vector3.forward;

            float dist = ((1.0f - Mathf.Clamp((handLocation.z - _controlMin.z) / (_controlMax.z - _controlMin.x), 0.0f, 1.0f)) * (_distanceLimits.y - _distanceLimits.x)) + _distanceLimits.x;
            gameObject.transform.position = directionVector * dist;
            gameObject.transform.LookAt(_targetObject.transform);
        }
    }
Ejemplo n.º 34
0
 // Use this for initialization
 void Start()
 {
     _mainCam     = (GameObject.FindGameObjectWithTag("MainCamera") as GameObject).GetComponent(typeof(Camera)) as Camera;
     _leapManager = (GameObject.Find("LeapManager") as GameObject).GetComponent(typeof(LeapManager)) as LeapManager;
 }
Ejemplo n.º 35
0
 // Use this for initializationm.
 void Start()
 {
     _leapManager = GameObject.Find("LeapManager").GetComponent <LeapManager> ();
 }
Ejemplo n.º 36
0
	// Use this for initialization
	void Start () {
		finger = gameObject.transform.GetChild(0).gameObject as GameObject;
		 _leapManager = (GameObject.Find("LeapManager") as GameObject).GetComponent(typeof(LeapManager)) as LeapManager;
	}
Ejemplo n.º 37
0
    void Start()
    {
        try
        {
            leapController = new Leap.Controller();

        //			if(leapController.Devices.Count == 0)
        //				throw new Exception("Please connect the LeapMotion sensor!");

            leapController.EnableGesture(Gesture.GestureType.TYPECIRCLE);
            leapController.EnableGesture(Gesture.GestureType.TYPEKEYTAP);
            leapController.EnableGesture(Gesture.GestureType.TYPESCREENTAP);
            leapController.EnableGesture(Gesture.GestureType.TYPESWIPE);

            // add the extra gestures to detect, if any
            foreach(LeapExtraGestures.ExtraGestures gesture in ExtraGestures)
            {
                DetectGesture(gesture);
            }

            // load cursor textures once
            normalHandTexture = (Texture)Resources.Load("NormalCursor");
            touchHandTexture = (Texture)Resources.Load("TouchCursor");
            selectHandTexture = (Texture)Resources.Load("SelectCursor");

            instance = this;
            leapInitialized = true;

            DontDestroyOnLoad(gameObject);

            // show the ready-message
            string sMessage = leapController.Devices.Count > 0 ? "Ready." : "Please make sure the Leap-sensor is connected.";
            Debug.Log(sMessage);

            if(debugText != null)
                debugText.guiText.text = sMessage;
        }
        catch(System.TypeInitializationException ex)
        {
            Debug.LogError(ex.ToString());
            if(debugText != null)
                debugText.guiText.text = "Please check the LeapMotion installation.";
        }
        catch (System.Exception ex)
        {
            Debug.LogError(ex.ToString());
            if(debugText != null)
                debugText.guiText.text = ex.Message;
        }
    }
Ejemplo n.º 38
0
	// Use this for initialization
	void Start () {
		_leapManager = (GameObject.Find("LeapManager")as GameObject).GetComponent(typeof(LeapManager)) as LeapManager;
	}
Ejemplo n.º 39
0
 // Use this for initialization
 void Start()
 {
     _leapManager = (GameObject.Find("LeapManager") as GameObject).GetComponent(typeof(LeapManager)) as LeapManager;
 }
Ejemplo n.º 40
0
    void Start()
    {
        try
        {
            leapController = new Leap.Controller();

        //			if(leapController.Devices.Count == 0)
        //				throw new Exception("Please connect the LeapMotion sensor!");

            leapController.EnableGesture(Gesture.GestureType.TYPECIRCLE);
            leapController.EnableGesture(Gesture.GestureType.TYPEKEYTAP);
            leapController.EnableGesture(Gesture.GestureType.TYPESCREENTAP);
            leapController.EnableGesture(Gesture.GestureType.TYPESWIPE);

            instance = this;
            leapInitialized = true;

            DontDestroyOnLoad(gameObject);

            if(DebugCamera)
            {
                DontDestroyOnLoad(DebugCamera.gameObject);
            }

            // show the ready-message
            string sMessage = leapController.Devices.Count > 0 ? "Ready." : "Please make sure the Leap-sensor is connected.";
            Debug.Log(sMessage);

        //			if(debugText != null)
        //				debugText.guiText.text = sMessage;
        }
        catch(System.TypeInitializationException ex)
        {
            Debug.LogError(ex.ToString());
            if(debugText != null)
                debugText.guiText.text = "Please check the LeapMotion installation.";
        }
        catch (System.Exception ex)
        {
            Debug.LogError(ex.ToString());
            if(debugText != null)
                debugText.guiText.text = ex.Message;
        }
    }
Ejemplo n.º 41
0
    void Start()
    {
        // initialising reference variables
        anim = GetComponent<Animator>();
        col = GetComponent<CapsuleCollider>();
        //enemy = GameObject.Find("Enemy").transform;

        if(anim.layerCount == 2)
            anim.SetLayerWeight(1, 1);

        leapManager = GameObject.FindGameObjectWithTag("MainCamera").GetComponent<LeapManager>();
        debugText = GameObject.Find("DebugText");

        GameObject objButton = GameObject.Find("BtnJump");
        btnJump = objButton ? objButton.GetComponent<LeapGuiButton>() : null;

        objButton = GameObject.Find("BtnWave");
        btnWave = objButton ? objButton.GetComponent<LeapGuiButton>() : null;
    }
Ejemplo n.º 42
0
 void OnApplicationQuit()
 {
     LeapManager.dispose();
     quit = true;
 }
Ejemplo n.º 43
0
Archivo: LClic.cs Proyecto: Krewn/LIOS
 void Start()
 {
     manager = Camera.main.GetComponent<LeapManager>();							//This links to some leap data
     a       = Camera.main.GetComponent<GetFrame> ();
     Lclic   = false;
 }
Ejemplo n.º 44
0
 // Use this for initializationm.
 void Start()
 {
     _leapManager = GameObject.Find ("LeapManager").GetComponent<LeapManager> ();
 }
Ejemplo n.º 45
0
    /*-------------------------------------------------------------------------
     * Unity Lifecycle Functions
     * ----------------------------------------------------------------------*/
    public void Awake()
    {
        // Singleton implementation
        if (_instance != null)
        {
            Debug.LogError(this.ToString() + ": Singleton already exists. Destroying.");
            Destroy(this);
        }
        else
        {
            _instance = this;
        }

        // Set Leap Unity Extension Properties
        Leap.UnityVectorExtension.InputScale = LeapScaling;
        Leap.UnityVectorExtension.InputOffset = LeapOffset;

        // Set up Leap Controller
        _controller = new Controller();
        _controller.EnableGesture(Leap.Gesture.GestureType.TYPECIRCLE);
        _controller.EnableGesture(Leap.Gesture.GestureType.TYPEKEYTAP);
        _controller.EnableGesture(Leap.Gesture.GestureType.TYPESCREENTAP);
        _controller.EnableGesture(Leap.Gesture.GestureType.TYPESWIPE);
    }
Ejemplo n.º 46
0
    // estimate the next state and completeness of the gesture
    public static void CheckForGesture(ref ExtraGestureData gestureData, float timestamp, LeapManager leapManager)
    {
        if(gestureData.complete || !leapManager)
            return;

        switch(gestureData.gesture)
        {
            // check for Fist
            case ExtraGestures.Fist:
                switch(gestureData.state)
                {
                    case 0:  // gesture detection - phase 1
                        if(leapManager.IsHandValid() && leapManager.GetFingersCount() > 1)
                        {
                            SetGestureJoint(ref gestureData, timestamp, true, leapManager.GetHandID(), leapManager.GetHandPos());
                            gestureData.tagFloat = leapManager.GetThumbID();
                            gestureData.screenPos = leapManager.GetCursorNormalizedPos();
                            gestureData.progress = 0.3f;
                        }
                        break;

                    case 1:  // gesture phase 2 - complete
                        if(leapManager.IsHandValid())
                        {
                            // check for stay-in-place
                            Vector3 jointPos = leapManager.GetHandPos();
                            bool bHandMatch = (leapManager.GetHandID() == gestureData.jointId);
                            bool bThumbMatch = leapManager.GetFingersCount() > 0 ? (leapManager.GetThumbID() == (int)gestureData.tagFloat) : true;

                            if(bHandMatch && bThumbMatch)
                            {
                                if(leapManager.GetFingersCount() <= 1)
                                {
                                    gestureData.screenPos = leapManager.GetCursorNormalizedPos();
                                    CheckPoseComplete(ref gestureData, timestamp, jointPos, true, Constants.PoseCompleteDuration);
                                }
                            }
                            else
                            {
                                // hand or thumb don´t match
                                SetGestureCancelled(ref gestureData);
                            }

        //							Debug.Log(gestureData.complete.ToString() + " GestID: " + gestureData.jointId +
        //									" Fingers: " + leapManager.GetFingersCount() +
        //									" ThumbID: " + leapManager.GetThumbID().ToString());

                        }
                        break;
                }
                break;

            // check for Click
            case ExtraGestures.Click:
                switch(gestureData.state)
                {
                    case 0:  // gesture detection - phase 1
                        if(leapManager.IsHandValid())
                        {
                            SetGestureJoint(ref gestureData, timestamp, true, leapManager.GetHandID(), leapManager.GetHandPos());
                            gestureData.screenPos = leapManager.GetCursorNormalizedPos();
                            gestureData.progress = 0.3f;
                        }
                        break;

                    case 1:  // gesture phase 2 - complete
                        if(leapManager.IsHandValid())
                        {
                            // check for stay-in-place
                            Vector3 jointPos = leapManager.GetHandPos();
                            Vector3 distVector = jointPos - gestureData.jointPos;
                            bool isInPose = leapManager.GetHandID() == gestureData.jointId &&
                                            distVector.magnitude < 0.05f;

                            CheckPoseComplete(ref gestureData, timestamp, jointPos, isInPose, Constants.ClickStayDuration);
                        }
                        break;
                }
                break;

            // check for HandSwipe
            case ExtraGestures.HandSwipe:
                switch(gestureData.state)
                {
                    case 0:  // gesture detection - phase 1
                        if(leapManager.IsHandValid())
                        {
                            SetGestureJoint(ref gestureData, timestamp, true, leapManager.GetHandID(), leapManager.GetHandPos());
                            gestureData.screenPos = leapManager.GetCursorNormalizedPos();
                            gestureData.progress = 0.5f;
                        }
                        break;

                    case 1:  // gesture phase 2 - complete
                        if((timestamp - gestureData.timestamp) < 1.5f)
                        {
                            if(leapManager.IsHandValid())
                            {
                                Vector3 jointPos = leapManager.GetHandPos();
                                Vector3 distVector = jointPos - gestureData.jointPos;
                                bool isInPose = leapManager.GetHandID() == gestureData.jointId &&
                                                distVector.magnitude > 0.15f;

                                if(isInPose)
                                {
                                    CheckPoseComplete(ref gestureData, timestamp, jointPos, isInPose, 0f);
                                }
                            }
                        }
                        else
                        {
                            // cancel the gesture
                            SetGestureCancelled(ref gestureData);
                        }
                        break;
                }
                break;
        }

        // here come more gesture-cases
    }
Ejemplo n.º 47
0
 void OnDestroy()
 {
     // Singleton implementation
     _instance = null;
 }
Ejemplo n.º 48
0
	// Use this for initialization
	void Start () {
		text = gameObject.GetComponent(typeof(TextMesh)) as TextMesh;
		_leapManager = (GameObject.Find("LeapManager") as GameObject).GetComponent(typeof(LeapManager)) as LeapManager;
	}
 // Use this for initialization
 void Start()
 {
     _menus = GameObject.FindGameObjectsWithTag("Menu");
     _leapManager = (GameObject.Find("LeapManager") as GameObject).GetComponent(typeof(LeapManager)) as LeapManager;
 }
Ejemplo n.º 50
0
 void OnDestroy()
 {
     // Singleton implementation
     _instance = null;
 }
Ejemplo n.º 51
0
 // Use this for initialization
 void Start()
 {
     _mainCam = (GameObject.FindGameObjectWithTag("MainCamera")as GameObject).GetComponent(typeof(Camera)) as Camera;
     _leapManager = (GameObject.Find("LeapManager")as GameObject).GetComponent(typeof(LeapManager)) as LeapManager;
 }
Ejemplo n.º 52
0
 // Use this for initialization
 void Start()
 {
     mainCam     = (GameObject.FindGameObjectWithTag("MainCamera") as GameObject).GetComponent(typeof(Camera)) as Camera;
     leapManager = (GameObject.Find("LeapManager") as GameObject).GetComponent(typeof(LeapManager)) as LeapManager;
     controller  = new Controller();
 }
Ejemplo n.º 53
0
 void Start()
 {
     leapManager = GameObject.FindGameObjectWithTag("MainCamera").GetComponent<LeapManager>();
 }
Ejemplo n.º 54
0
    void OnApplicationQuit()
    {
        leapPointable = null;
        leapFrame = null;

        if(leapController != null)
        {
            leapController.Dispose();
            leapController = null;
        }

        leapInitialized = false;
        instance = null;
    }
Ejemplo n.º 55
0
 // Use this for initialization
 void Start()
 {
     _menus       = GameObject.FindGameObjectsWithTag("Menu");
     _leapManager = (GameObject.Find("LeapManager") as GameObject).GetComponent(typeof(LeapManager)) as LeapManager;
 }
Ejemplo n.º 56
0
	// Use this for initialization
	void Start () {
		//Get references to the main scene and UI cameras.
		_mainCam = (GameObject.Find("MainCam") as GameObject).GetComponent(typeof(Camera)) as Camera;
		_uiCam = (GameObject.Find("UI Cam") as GameObject).GetComponent(typeof(Camera)) as Camera;
		_baseLocation = gameObject.transform.parent.position;
		_leapManager = (GameObject.Find("LeapManager") as GameObject).GetComponent(typeof(LeapManager)) as LeapManager;
		_leapManager._mainCam = _mainCam;

		//Get a reference to the subLabel
		foreach(Transform child in gameObject.transform.parent)
		{
			if(child.name == "menuSub")
			{
				_subLabel = child.gameObject.GetComponent(typeof(TextMesh)) as TextMesh;
				_hasSubLabel = true;
			}
		}

		float segmentSweep; //how large is each button segment

		_buttonCount = _buttonActions.Length;

		_buttons = new GameObject[_buttonCount];
		segmentSweep = 360.0f / (float)_buttonCount;

		//Create the buttons, fill in their content, etc.
		for(int i=0; i<_buttonCount; i++)
		{
			_buttons[i] = Instantiate(_button_prefab, gameObject.transform.position, Quaternion.identity) as GameObject;
			_buttons[i].transform.parent = gameObject.transform;
			ArcMaker buttonScript = _buttons[i].GetComponent(typeof(ArcMaker)) as ArcMaker;
			buttonScript.CreateMesh(50, (i*segmentSweep)+_angleOffset, (i*segmentSweep)+segmentSweep+_angleOffset, _radius - (_thickness/2.0f), _radius + (_thickness/2.0f));

			//Setup the button content
			if(_buttonActions[i] != ButtonAction.NONE)
			{
				switch(_menu_type)
				{
				case MenuType.ICON:
					if(i < _icons_active.Length && _icons_active[i] != null)
					{
						if(i < _icons_inactive.Length && _icons_inactive[i] != null) { 	
							buttonScript.setContent(_icons_active[i], _icons_inactive[i], _spriteScalingFactor); 
						}
						else { 
							buttonScript.setContent(_icons_active[i], null, _spriteScalingFactor); 
						}
					}
					else
					{
						Debug.LogError("Active icon missing for: " + i);
					}
					break;
				case MenuType.TEXT:
					if(i < _text.Length && _text[i] != null)
					{
						buttonScript.setContent(_text[i]);
					}
					else
					{
						Debug.LogError("Text missing for: " + i);
					}
					break;
				case  MenuType.TEXTURE:
					if(i < _textures.Length && _textures[i] != null)
					{
						buttonScript.setContent(_textures[i]);
					}
					else
					{
						Debug.LogError("Texture missing for: " + i);
					}
					break;
				}
			}
		}

		gameObject.transform.localScale = new Vector3(0,0,1);
		_currentState = MenuState.INACTIVE;
	}
Ejemplo n.º 57
0
    void Start()
    {
        try
        {

            GameObject thePlayer = GameObject.Find("DummyButton");
            LeapGUIButton = thePlayer.GetComponent<LeapGuiButton>();
            containsCursor = LeapGUIButton.isCursorIn;
            notContainCursor = LeapGUIButton.isCursorOut;

            leapController = new Leap.Controller();

            instance = this;
            leapInitialized = true;

            DontDestroyOnLoad(gameObject);

            string sMessage = leapController.Devices.Count > 0 ? "Ready." : "Please make sure the Leap-sensor is connected.";
            Debug.Log(sMessage);

        }
        catch(System.TypeInitializationException ex)
        {
            Debug.LogError(ex.ToString());
            if(debugText != null)
                debugText.guiText.text = "Please check the LeapMotion installation.";
        }
        catch (System.Exception ex)
        {
            Debug.LogError(ex.ToString());
            if(debugText != null)
                debugText.guiText.text = ex.Message;
        }
    }