Exemple #1
0
 void Start()
 {
     light.enabled = false;
     flashReady = GameObject.Find("Player/MainCamera/TrackingSpace/Flash").GetComponent<TextMesh>();
     myo = GameObject.Find("Myo");
     thalmicMyo = myo.GetComponent<ThalmicMyo>();
 }
Exemple #2
0
    // Update is called once per frame.
    void Update()
    {
        // Access the ThalmicMyo component attached to the Myo game object.
        ThalmicMyo thalmicMyo = myo.GetComponent <ThalmicMyo> ();

        // Check if the pose has changed since last update.
        // The ThalmicMyo component of a Myo game object has a pose property that is set to the
        // currently detected pose (e.g. Pose.Fist for the user making a fist). If no pose is currently
        // detected, pose will be set to Pose.Rest. If pose detection is unavailable, e.g. because Myo
        // is not on a user's arm, pose will be set to Pose.Unknown.
        if (thalmicMyo.pose != _lastPose)
        {
            _lastPose = thalmicMyo.pose;

            // Vibrate the Myo armband when a fist is made.
            if (thalmicMyo.pose == Pose.Fist)
            {
                thalmicMyo.Vibrate(VibrationType.Medium);

                ExtendUnlockAndNotifyUserAction(thalmicMyo);

                // Change material when wave in, wave out or double tap poses are made.
            }
        }
    }
 private void Awake()
 {
     myo_           = myoObject.GetComponent <ThalmicMyo>();
     before_Accel.x = myo_.accelerometer.x;
     before_Accel.y = myo_.accelerometer.y;
     before_Accel.z = myo_.accelerometer.z;
 }
Exemple #4
0
    // Update is called once per frame
    void Update()
    {
        ThalmicMyo thalmicMyo = myo.GetComponent <ThalmicMyo>();

        Vector3 zeroRoll = computeZeroRollVector(myo.transform.forward);
        float   roll     = rollFromZero(zeroRoll, myo.transform.forward, myo.transform.up);


        float relativeRoll = normalizeAngle(roll - _referenceRoll);


        Quaternion antiRoll = Quaternion.AngleAxis(relativeRoll, myo.transform.forward);


        transform.rotation = _antiYaw * antiRoll * Quaternion.LookRotation(myo.transform.forward);


        if (thalmicMyo.xDirection == Thalmic.Myo.XDirection.TowardWrist)
        {
            transform.rotation = new Quaternion(transform.localRotation.x,
                                                -transform.localRotation.y,
                                                transform.localRotation.z,
                                                -transform.localRotation.w);
        }
    }
Exemple #5
0
    // Update is called once per frame
    void Update()
    {
        ThalmicMyo thalmicMyo = myo.GetComponent <ThalmicMyo>();

        // when the escape key is pressed or the Fingers Spread Gesture, depending on the value of GameIsPaused, either pauses or resumes the game
        if (thalmicMyo.pose != _lastPose)
        {
            _lastPose = thalmicMyo.pose;
            if (Input.GetKeyDown(KeyCode.Escape) || thalmicMyo.pose == Pose.FingersSpread)
            {
                if (GameIsPaused)
                {
                    Resume();
                }
                else
                {
                    Pause();
                }
            }
        }
        else if (Input.GetKeyDown(KeyCode.Escape))
        {
            if (GameIsPaused)
            {
                Resume();
            }
            else
            {
                Pause();
            }
        }
    }
    void Start()
    {
        //Set Debugmode
        if (debugMode)
        {
            debugCanvas.enabled = debugMode;
        }

        //Assign the myo script
        myoDataScript = MyoData.GetComponent <ThalmicMyo>();

        //Assign all the Text components
        perSensorMaxValueLabel = new Text[displayBars.Length];

        for (int i = 0; i < displayBars.Length; i++)
        {
            perSensorMaxValueLabel[i] = displayBars[i].transform.Find("maxValueLabel").GetComponent <Text>();
        }

        //Set the per sensor option
        previousPerSensorValue = perSensorValue;
        SetPerSensorDisplayMode();

        //VibrateMyo();
    }
Exemple #7
0
    // Use this for initialization
    void Start()
    {
        ThalmicMyo thalmicMyo = myo.GetComponent <ThalmicMyo> ();

        _lastPose = thalmicMyo.pose;
        isReady   = false;
    }
Exemple #8
0
    // Update is called once per frame.
    void Update()
    {
        // Access the ThalmicMyo component attached to the Myo game object.
        ThalmicMyo thalmicMyo = myo.GetComponent <ThalmicMyo> ();

        // Check if the pose has changed since last update.
        // The ThalmicMyo component of a Myo game object has a pose property that is set to the
        // currently detected pose (e.g. Pose.Fist for the user making a fist). If no pose is currently
        // detected, pose will be set to Pose.Rest. If pose detection is unavailable, e.g. because Myo
        // is not on a user's arm, pose will be set to Pose.Unknown.
        if (thalmicMyo.pose != _lastPose)
        {
            _lastPose = thalmicMyo.pose;

            // Vibrate the Myo armband when a fist is made.
            if (thalmicMyo.pose == Pose.Fist)
            {
                thalmicMyo.Vibrate(VibrationType.Medium);

                // Change material when wave in, wave out or thumb to pinky poses are made.
            }
            else if (thalmicMyo.pose == Pose.WaveIn)
            {
                renderer.material = waveInMaterial;
            }
            else if (thalmicMyo.pose == Pose.WaveOut)
            {
                renderer.material = waveOutMaterial;
            }
            else if (thalmicMyo.pose == Pose.ThumbToPinky)
            {
                renderer.material = thumbToPinkyMaterial;
            }
        }
    }
Exemple #9
0
    // Update is called once per frame
    void Update()
    {
        ThalmicMyo thalmicMyo = myo.GetComponent <ThalmicMyo>();

        userPose = thalmicMyo.pose;
        float dax = thalmicMyo.accelerometer.x - axi;
        float day = thalmicMyo.accelerometer.y - ayi;

        //if (dax > A_FIREBALL && restFrames == 0 && (userPose == Thalmic.Myo.Pose.FingersSpread || userPose == Thalmic.Myo.Pose.WaveOut))
        //if (dax > A_FIREBALL && restFrames == 0)
        if (thalmicMyo.accelerometer.magnitude > 2)
        {
            fireballNum++;
            restFrames = FRAMES_BETWEEN_ATTACK;

            GameObject go = GameObject.Instantiate(effect);
            go.transform.position = this.transform.position;
            //rb.AddForce(0, 0, 10);
        }
        //else if (day > 0.8 && restFrames == 0 && userPose == Thalmic.Myo.Pose.Fist)
        else if (day > 0.8 && restFrames == 0)
        // Make a fist and accelerate down to
        {
            meteorNum++;
            restFrames = FRAMES_BETWEEN_ATTACK;
            Debug.Log("METEOR " + meteorNum);
            //rb.AddForce(0, 10, 0);
        }


        if (restFrames > 0)
        {
            restFrames--;
        }
    }
    // Update is called once per frame
    void Update()
    {
        ThalmicMyo thalmicMyo = myo.GetComponent <ThalmicMyo>();
        Vector3    acc        = thalmicMyo.accelerometer;

        Debug.Log("X: " + thalmicMyo.accelerometer.x);
        transform.position = new Vector3((transform.position.y + (Mathf.Pow(acc.y, 3))) * 1.0f / 3.0f * Time.deltaTime * accelFactor,
                                         (transform.position.x + (Mathf.Pow(acc.x, 3) * 70)) * 1.0f / 3.0f * Time.deltaTime, 0);
        ParticleSystem particles = system.GetComponent <ParticleSystem>();

        if (thalmicMyo.pose == Pose.Fist)
        {
            particles.emissionRate = 2500.0f;
        }
        else
        {
            particles.emissionRate = 60.0f;
        }
        if (thalmicMyo.pose == Pose.WaveIn)
        {
            particles.startColor = Color.cyan;
        }
        else if (thalmicMyo.pose == Pose.WaveOut)
        {
            particles.startColor = Color.yellow;
        }
        else
        {
            particles.startColor = Color.grey;
        }
    }
Exemple #11
0
    // Update is called once per frame
    void Update()
    {
        ThalmicMyo thalmicMyo = myo.GetComponent <ThalmicMyo>();

        if ((Input.GetKeyDown("z") || thalmicMyo.pose == Pose.Fist) && endTime < DateTime.Now.TimeOfDay.TotalSeconds)
        {
            GameObject spell = Instantiate((GameObject)spell_1, mainCamera.transform.position + new Vector3(7 * (float)Math.Sin(player.gameObject.transform.rotation.eulerAngles.y * Math.PI / 180), 0, 7 * (float)Math.Cos(player.gameObject.transform.rotation.eulerAngles.y * Math.PI / 180)), transform.rotation) as GameObject;
            spell.gameObject.GetComponent <BoulderSpell>().x_direction = (float)Math.Sin(player.gameObject.transform.rotation.eulerAngles.y * Math.PI / 180);
            spell.gameObject.GetComponent <BoulderSpell>().z_direction = (float)Math.Cos(player.gameObject.transform.rotation.eulerAngles.y * Math.PI / 180);
            endTime = DateTime.Now.TimeOfDay.TotalSeconds + 0.5f;
            ExtendUnlockAndNotifyUserAction(thalmicMyo);
        }

        if (Input.GetKeyDown("x") && endTime < DateTime.Now.TimeOfDay.TotalSeconds)
        {
            GameObject spell = Instantiate((GameObject)spell_2, mainCamera.transform.position + new Vector3(0, 17, 0), transform.rotation) as GameObject;
            spell.gameObject.GetComponent <MeteorScript>().x_direction = 0;
            spell.gameObject.GetComponent <MeteorScript>().y_direction = -0.5f;
            spell.gameObject.GetComponent <MeteorScript>().z_direction = 1;
            endTime = DateTime.Now.TimeOfDay.TotalSeconds + 2;
        }

        if ((Input.GetKey("c") || thalmicMyo.pose == Pose.FingersSpread) && endTime < DateTime.Now.TimeOfDay.TotalSeconds)
        {
            GameObject spell = Instantiate((GameObject)spell_3, mainCamera.transform.position + new Vector3(5 * (float)Math.Sin(player.gameObject.transform.rotation.eulerAngles.y * Math.PI / 180), 0, 5 * (float)Math.Cos(player.gameObject.transform.rotation.eulerAngles.y * Math.PI / 180)), transform.rotation) as GameObject;
            spell.gameObject.GetComponent <DigitalRuby.LightningBolt.LightningBoltScript>().StartPosition = mainCamera.transform.position + new Vector3(2 * (float)Math.Sin(player.gameObject.transform.rotation.eulerAngles.y * Math.PI / 180), 0, 2 * (float)Math.Cos(player.gameObject.transform.rotation.eulerAngles.y * Math.PI / 180));
            spell.gameObject.GetComponent <DigitalRuby.LightningBolt.LightningBoltScript>().EndPosition   = mainCamera.transform.position + new Vector3(60 * (float)Math.Sin(player.gameObject.transform.rotation.eulerAngles.y * Math.PI / 180), 0, 60 * (float)Math.Cos(player.gameObject.transform.rotation.eulerAngles.y * Math.PI / 180));
            spell.gameObject.GetComponent <BoxCollider>().size = new Vector3(58 * (float)Math.Sin(player.gameObject.transform.rotation.eulerAngles.y * Math.PI / 180), 3f, 58 * (float)Math.Cos(player.gameObject.transform.rotation.eulerAngles.y * Math.PI / 180));
            endTime = DateTime.Now.TimeOfDay.TotalSeconds + 0.1f;
        }
    }
 // Update is called once per frame
 void Update()
 {
     if (inTrigger)
     {
         // Access the ThalmicMyo component attached to the Myo object.
         ThalmicMyo thalmicMyo = myo.GetComponent <ThalmicMyo> ();
         if (Input.GetKeyDown(KeyCode.E) || thalmicMyo.pose == Pose.DoubleTap)
         {
             leverAnim.SetTrigger("throw");
             if (aMultiLever)
             {
                 GameManager.instance.AddLever(gameObject);
             }
             else if (arrows)
             {
                 StartCoroutine("TriggerArrowTrap");
             }
             else if (trap)
             {
                 openTrap.TriggerTraps();
             }
             else
             {
                 StartCoroutine(GameManager.instance.DelayDoor(1.5f));
             }
         }
     }
 }
Exemple #13
0
    // Update is called once per frame.
    void Update()
    {
        // Access the ThalmicMyo component attached to the Myo game object.
        ThalmicMyo thalmicMyo = myo.GetComponent <ThalmicMyo> ();

        // Check if the pose has changed since last update.
        // The ThalmicMyo component of a Myo game object has a pose property that is set to the
        // currently detected pose (e.g. Pose.Fist for the user making a fist). If no pose is currently
        // detected, pose will be set to Pose.Rest. If pose detection is unavailable, e.g. because Myo
        // is not on a user's arm, pose will be set to Pose.Unknown.
        if (thalmicMyo.pose != _lastPose)
        {
            _lastPose = thalmicMyo.pose;

            // Change the material on wave in or wave out
            if (thalmicMyo.pose == Pose.WaveIn)
            {
                GetComponent <Renderer>().material = waveInMaterial;
                myoState = "BLUE";
            }
            else if (thalmicMyo.pose == Pose.WaveOut)
            {
                GetComponent <Renderer>().material = waveOutMaterial;
                myoState = "GREEN";
            }
            else if (thalmicMyo.pose == Pose.FingersSpread)
            {
                GetComponent <Renderer>().material = spreadMaterial;
                myoState = "RED";
            }
        }
        Debug.Log(myoState);
    }
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            if (GameIsPaused)
            {
                Resume();
            }
            else
            {
                Pause();
            }
        }

        // Access the ThalmicMyo component attached to the Myo game object.
        ThalmicMyo thalmicMyo = myo.GetComponent <ThalmicMyo> ();

        if (thalmicMyo.pose != _lastPose)
        {
            //Doing a fist will make the user resume the game and do nothing while in-game
            if (thalmicMyo.pose == Pose.Fist)
            {
                Resume();
                Debug.Log("Fist");
            }
            // Double Tapping makes the game pause while playing
            else if (thalmicMyo.pose == Pose.DoubleTap)
            {
                Pause();
                Debug.Log("DoubleTap");
            }
        }
    }
    void Start()
    {
        Debug.Log("lancement connexion!");
        ThalmicHub hub = ThalmicHub.instance;

        /* Access the ThalmicMyo script attached to the Myo object */
        ThalmicMyo thalmicMyo = myo.GetComponent <ThalmicMyo>();

        if (!hub.hubInitialized)
        {
            Debug.Log("Cannot contact Myo Connect. Is Myo Connect running?\n" +
                      "Press Q to try again.");
            ConnexionMyo.myoConnected = false;
        }

        else if (!thalmicMyo.isPaired)
        {
            Debug.Log("No Myo currently paired.\n");
            ConnexionMyo.myoConnected = false;
        }

        else
        {
            ConnexionMyo.myoConnected = true;
            Debug.Log("myoConnected");
        }
    }
Exemple #16
0
    // Update is called once per frame
    void Update()
    {
        thalmicMyo = myo.GetComponent <ThalmicMyo>();
        float movement;

        if (thalmicMyo.pose == Pose.WaveIn)
        {
            movement = -1 * speed * Time.deltaTime;
        }
        else if (thalmicMyo.pose == Pose.WaveOut)
        {
            movement = speed * Time.deltaTime;
        }

        else
        {
            movement = 0;
        }

        if (!isright)
        {
            movement *= -1;
        }


        transform.Translate(new Vector3(movement, 0));

        if (time <= 0)
        {
            Destroy(myo.transform.parent.gameObject);
            Application.LoadLevel("Menu");
        }
    }
 void Start()
 {
     //  Initialise objects in game
     rb         = GetComponent <Rigidbody>();
     bulletClip = GetComponent <AudioSource>();
     myoArmband = myo.GetComponent <ThalmicMyo>();
 }
Exemple #18
0
    // Use this for initialization
    void Start()
    {
        tMyo    = myo.GetComponent <ThalmicMyo> ();
        vectors = new List <Vector3> ();

        //thrown = false;
    }
Exemple #19
0
    void Update()
    {
        timer    += Time.deltaTime;
        myoTimer += Time.deltaTime;
        ThalmicMyo thalmicMyo = myo.GetComponent <ThalmicMyo> ();

        if (thalmicMyo.pose == Pose.Fist && timer >= timeBetweenBullets && Time.timeScale != 0 && myoTimer < myoCountConstant)
        {
            if (bulletCount < 10)
            {
                Shoot();
            }
            bulletCount = bulletCount + 1;
            //}
            ExtendUnlockAndNotifyUserAction(thalmicMyo);
        }
        _lastPose = thalmicMyo.pose;

        if (myoTimer > myoCountConstant && thalmicMyo.pose != Pose.Fist)
        {
            myoTimer = 0f;
        }

        if (timer >= timeBetweenBullets * effectsDisplayTime)
        {
            DisableEffects();
            bulletCount = bulletCount - 1;
            if (bulletCount < 0)
            {
                bulletCount = 0;
            }
        }
    }
Exemple #20
0
    // Draw some basic instructions.
    void OnGUI()
    {
        GUI.skin.label.fontSize = 20;

        ThalmicHub hub = ThalmicHub.instance;

        // Access the ThalmicMyo script attached to the Myo object.
        ThalmicMyo thalmicMyo = myo.GetComponent <ThalmicMyo> ();

        if (!hub.hubInitialized)
        {
            GUI.Label(new Rect(12, 8, Screen.width, Screen.height),
                      "Cannot contact Myo Connect. Is Myo Connect running?\n" +
                      "Press Q to try again."
                      );
        }
        else if (!thalmicMyo.isPaired)
        {
            GUI.Label(new Rect(12, 8, Screen.width, Screen.height),
                      "No Myo currently paired."
                      );
        }
        else if (!thalmicMyo.armSynced)
        {
            GUI.Label(new Rect(12, 8, Screen.width, Screen.height),
                      "Perform the Sync Gesture."
                      );
        }
        else
        {
            GUI.Label(new Rect(12, 8, Screen.width, Screen.height),
                      "Fist: Set forward direction"
                      );
        }
    }
Exemple #21
0
    // Update is called once per frame
    void Update()
    {
        ThalmicMyo thalmicMyo = myo.GetComponent <ThalmicMyo>();

        userPose = thalmicMyo.pose;
        float dax = thalmicMyo.accelerometer.x - axi;
        float day = thalmicMyo.accelerometer.y - ayi;

        if (dax > A_FIREBALL && restFrames == 0 && (userPose == Thalmic.Myo.Pose.FingersSpread || userPose == Thalmic.Myo.Pose.WaveOut))
        {
            fireballNum++;
            restFrames = FRAMES_BETWEEN_ATTACK;
            Debug.Log("FIREBALL " + fireballNum + "   " + dax);
            rb.AddForce(0, 0, 10);
        }
        else if (day > 0.8 && restFrames == 0 && userPose == Thalmic.Myo.Pose.Fist)
        // Make a fist and accelerate down to
        {
            meteorNum++;
            restFrames = FRAMES_BETWEEN_ATTACK;
            Debug.Log("METEOR " + meteorNum);
            rb.AddForce(0, 10, 0);
        }


        if (restFrames > 0)
        {
            restFrames--;
        }
    }
    // Update is called once per frame
    void Update()
    {
        ThalmicMyo thalmicMyo = myoGameObject.GetComponent <ThalmicMyo>();

        if (thalmicMyo.pose != _lastPose)
        {
            _lastPose = thalmicMyo.pose;

            if (thalmicMyo.pose == Pose.DoubleTap)
            {
                ExtendUnlockAndNotifyUserAction(thalmicMyo);
                if (GamePause == true)
                {
                    if (thalmicMyo.pose == Pose.DoubleTap) //
                    {
                        ResumeGame();                      // Resume Game
                    }
                    if (thalmicMyo.pose == Pose.FingersSpread)
                    {
                        Debug.Log("Game Quit");
                        QuitGame();// Quit Game
                    }
                }
                else
                {
                    PauseGame();
                }
            }
        }
    }
Exemple #23
0
    public void LightColor()
    {
        Material panel = GetComponent <Renderer>().material;
        // Light leftLight = GameObject.Find("LeftLight").GetComponent<Light>();
        // Light rightLight = GameObject.Find("RightLight").GetComponent<Light>();

        ThalmicMyo thalmicMyo = myo.GetComponent <ThalmicMyo>();

        //if (thalmicMyo.pose == Pose.FingersSpread)
        if (deltaSpeed < 0)   // car is slowing down
        {
            slowing = true;
        }
        if (slowing)
        {
            panel.SetColor("_EmissionColor", Color.yellow);
            leftLight.color  = Color.yellow;
            rightLight.color = Color.yellow;
            //Debug.Log("DeltaSpeed: " + deltaSpeed);
        }
        if (deltaSpeed < 0.000001f && deltaSpeed > -0.000001f && deltaX - lastX > 0)   // if the car is stopped
        //Debug.Log("Stopped");
        {
            panel.SetColor("_EmissionColor", Color.green);
            leftLight.color  = Color.green;
            rightLight.color = Color.green;
            // slowing = false;
        }
        if (!slowing)     // if the car is not slowing down and not stopped
        {
            panel.SetColor("_EmissionColor", Color.red);
            leftLight.color  = Color.red;
            rightLight.color = Color.red;
        }
    }
 void PerformShoot(AudioClip sound, Material material, GameObject laser, ThalmicMyo myo)
 {
     source.PlayOneShot(sound);
     GetComponent<Renderer>().material = material;
     CreateShot(laser);
     ExtendUnlockAndNotifyUserAction(myo);
 }
Exemple #25
0
 // Use this for initialization
 void Start()
 {
     myo = FindObjectOfType <ThalmicMyo>();
     // Debug.Log(myo);
     emg = myo.GetEMGData();
     Debug.Log(emg.Count());
 }
    void Update()
    {
        //Having this lets us get the updated position & gesture of the Armband every frame.
        ThalmicMyo myoArmband = myo.GetComponent <ThalmicMyo> ();

        //Decrement the timer in seconds.
        timer -= Time.deltaTime;

        //Simple calls to the API of the Armband to check the current pose.

        //If Rest, we set the arrow colour to black.
        if (myoArmband.pose == Thalmic.Myo.Pose.Rest)
        {
            fist   = false;
            spread = false;
            rest   = true;
            arrowMaterial.color = Color.black;
            //Debug.Log("Rest");
        }

        //If Fist, we fire red bullets every 0.25s, and change the arrow colour to red.
        else if (myoArmband.pose == Thalmic.Myo.Pose.Fist ||
                 Input.GetKey("r"))
        {
            rest   = false;
            spread = false;
            fist   = true;
            arrowMaterial.color = Color.red;
            //Debug.Log("Fist");

            if (timer <= 0.0f)
            {
                Object.Instantiate(redBullet, this.transform);
                this.transform.DetachChildren();
                timer = 0.25f;
                //Debug.Log("Shoot Red");
            }
        }

        //Likewise for Spread Fingers, we do the same, but blue.
        else if (myoArmband.pose == Thalmic.Myo.Pose.FingersSpread ||
                 Input.GetKey("b"))
        {
            rest   = false;
            fist   = false;
            spread = true;
            arrowMaterial.color = Color.blue;

            if (timer <= 0.0f)
            {
                Object.Instantiate(blueBullet, this.transform);
                this.transform.DetachChildren();
                timer = 0.25f;
                //Debug.Log("Shoot Blue");
            }

            //Debug.Log("Spread");
        }
    }
    // Use this for initialization
    void Start()
    {
        myoGameObject = GameObject.FindGameObjectWithTag("myo");
        myo           = myoGameObject.GetComponent <ThalmicMyo> ();

        PlayerPrefs.SetString("lastLoadedScene", SceneManager.GetActiveScene().name);
        Debug.Log(PlayerPrefs.GetString("lastSceneLoaded"));
    }
    void Start()
    {
        _myoTM = myo.GetComponent <ThalmicMyo>();

        //TO DO: Activate this only on sync.
        //Though, might not need it? It still tracks position well I think.
        InvokeRepeating("CollectData", 0, detectionInterval);
    }
Exemple #29
0
    void Start()
    {
        //Get myo compononent
        myoArmband = myo.GetComponent <ThalmicMyo> ();

        //Set default values of the fore arm bone rotation at start
        SetDefaultRollValues();
    }
    // Run and get components
    void Start () {
        MyoConnector myoConnect = new MyoConnector();
        myo = GameObject.FindWithTag("Myo");
        thalmicMyo = myo.GetComponent<ThalmicMyo>();

        mRigidBody = GetComponent<Rigidbody> ();
        mAudioSource = GetComponent<AudioSource> ();
    }// End of Start
Exemple #31
0
    void Start()
    {
        //Assign the myo script
        myoDataScript = MyoData.GetComponent <ThalmicMyo>();

        //Reset the data
        ResetPunchData();
    }
Exemple #32
0
    // Update is called once per frame.
    void Update()
    {
        // Access the ThalmicMyo component attached to the Myo object.
        ThalmicMyo thalmicMyo = myo.GetComponent <ThalmicMyo> ();

        // Update references when the pose becomes fingers spread or the q key is pressed.
        bool updateReference = false;

        if (thalmicMyo.pose != _lastPose)
        {
            _lastPose = thalmicMyo.pose;

            //if (thalmicMyo.pose == Pose.FingersSpread) {
            //updateReference = true;

            //ExtendUnlockAndNotifyUserAction (thalmicMyo);
            //}
        }

        if (Input.GetKeyDown("r"))
        {
            updateReference = true;
        }

        if (thalmicMyo.pose == Pose.DoubleTap)
        {
            updateReference = true;
        }

        if (updateReference)
        {
            transform.SetPositionAndRotation(new Vector3(333.0f, 180.0f, 0f), new Quaternion(0, 0, 0, 0));

            // _antiYaw represents a rotation of the Myo armband about the Y axis (up) which aligns the forward
            // vector of the rotation with Z = 1 when the wearer's arm is pointing in the reference direction.
            _antiYaw = Quaternion.FromToRotation(
                new Vector3(myo.transform.forward.x, 0, myo.transform.forward.z),
                new Vector3(0, 0, 1)
                );

            Vector3 referenceZeroRoll = computeZeroRollVector(myo.transform.forward);
            _referenceRoll = rollFromZero(referenceZeroRoll, myo.transform.forward, myo.transform.up);
        }

        Vector3    zeroRoll     = computeZeroRollVector(myo.transform.forward);
        float      roll         = rollFromZero(zeroRoll, myo.transform.forward, myo.transform.up);
        float      relativeRoll = normalizeAngle(roll - _referenceRoll);
        Quaternion antiRoll     = Quaternion.AngleAxis(relativeRoll, myo.transform.forward);

        transform.rotation = _antiYaw * antiRoll * Quaternion.LookRotation(myo.transform.forward);

        Vector2 dxdy = gyroConversion(thalmicMyo.gyroscope, myo.transform.rotation, thalmicMyo.xDirection);

        float dx = updateMouseDeltas(dxdy [0], dxdy [1]) [0];
        float dy = updateMouseDeltas(dxdy [0], dxdy [1]) [1];

        transform.Translate(dx, dy * dyScale, 0, Space.World);
    }
    // Extend the unlock if ThalmcHub's locking policy is standard, and notifies the given myo that a user action was
    // recognized.
    void ExtendUnlockAndNotifyUserAction(ThalmicMyo myo)
    {
        ThalmicHub hub = ThalmicHub.instance;

        if (hub.lockingPolicy == LockingPolicy.Standard) {
            myo.Unlock (UnlockType.Timed);
        }
        myo.NotifyUserAction ();
    }
 // Use this for initialization
 public MyoMovement(GameObject myo)
 {
     this.myo = myo;
     this.thalmicMyo = myo.GetComponent<ThalmicMyo> ();
     if (thalmicMyo.isPaired) {
         isMyo = true;
     }
     curPose = _lastPose;
 }
 // Update is called once per frame
 void Update()
 {
     thalmicMyo = myo.GetComponent<ThalmicMyo>();
     if (split.splitted)
     {
         Debug.Log("splitted");
         thalmicMyo.Vibrate(VibrationType.Long);
         vib.vibe = true;
     }
 }
Exemple #36
0
    // Use this for initialization
    void Start()
    {
        pose = Thalmic.Myo.Pose.Rest;
        poseDuration = 0.0f;

        stream = new SerialPort(COM_PORT_NAME, BAUD_RATE);
        stream.WriteTimeout = 100;
        stream.Open();

        myoRef = null;
    }
	void UpdateKeyPresses (ThalmicMyo thalmicMyo) {
		ThalmicHub hub = ThalmicHub.instance;
		
		if (Input.GetKeyDown (KeyCode.Q)) {
			hub.ResetHub();
		} else if (Input.GetKeyDown (KeyCode.RightArrow)) {
			CM.Advance();
		} else if (Input.GetKeyDown (KeyCode.LeftArrow)) {
			CM.Reverse();
		}
	}
Exemple #38
0
 // Myo game object to connect with.
 // This object must have a ThalmicMyo script attached.
 void Update()
 {
     SoundManager.getInstance().updateSoundManager();
     if (Input.GetKey("escape"))
         Application.Quit();
     thalmicMyo = myo.GetComponent<ThalmicMyo> ();
     hub = ThalmicHub.instance;
     if (Input.GetKeyDown("q"))
     {
         hub.ResetHub();
     }
     //if (
 }
    void ResetScene()
    {
        if(myo == null) myo = GameObject.Find("Myo");
        _myoTM = myo.GetComponent<ThalmicMyo>();
        //mc = GameObject.Find("Joint").GetComponent<MyoController>();
        mc = MyoController.Instance;
        HoldArmOut = GameObject.Find("HoldArmOut");
        LeftArmSet = GameObject.Find("LeftArm");
        RightArmSet = GameObject.Find("RightArm");
        Text = GameObject.Find("Text");
        TutorialCat = GameObject.Find("TutorialCat");
        TutorialCat.SetActive(false);

        if(am == null) am = GameObject.Find("AudioManager").GetComponent<AudioManager>();
    }
	void UpdatePoses (ThalmicMyo thalmicMyo) {
		if (thalmicMyo.pose != _lastPose && thalmicMyo.pose != Pose.Unknown) {
			
			_lastPose = thalmicMyo.pose;
			
			if (thalmicMyo.pose == Pose.Rest) {
				return;
			}
			
			// Give feedback
			//thalmicMyo.Vibrate (VibrationType.Short);
			
			if (thalmicMyo.pose == Pose.Fist) {
				print("Fist detected");
				
			} else if (thalmicMyo.pose == Pose.WaveIn) {
				if (thalmicMyo.arm == Thalmic.Myo.Arm.Left) {
					print("Wave RIGHT detected (left arm)");
					thalmicMyo.Vibrate (VibrationType.Short);
					CM.Reverse ();
					
				} else if (thalmicMyo.arm == Thalmic.Myo.Arm.Right) {
					print("Wave LEFT detected (right arm)");
					thalmicMyo.Vibrate (VibrationType.Short);
					CM.Advance ();
				}
				
			} else if (thalmicMyo.pose == Pose.WaveOut) {
				if (thalmicMyo.arm == Thalmic.Myo.Arm.Left) {
					print("Wave LEFT detected (left arm)");
					thalmicMyo.Vibrate (VibrationType.Short);
					CM.Advance ();
					
				} else if (thalmicMyo.arm == Thalmic.Myo.Arm.Right) {
					print("Wave RIGHT detected (right arm)");
					thalmicMyo.Vibrate (VibrationType.Short);
					CM.Reverse ();
				}
				
			} else if (thalmicMyo.pose == Pose.ThumbToPinky) {
				print("Thumb to Pinky detected");
				
			} else if (thalmicMyo.pose == Pose.FingersSpread) {
				print("Fingers Spread detected");

			}
		}
	}
    //private InputMapping;
    // Use this for initialization
    void Start()
    {
        hub = ThalmicHub.instance;
        //myo = GameObject.FindGameObjectWithTag("Player");
        if (myo == null) {
            myo = this.gameObject;
        }

        // Access the ThalmicMyo script attached to the Myo object.
        thalmicMyo = myo.GetComponent<ThalmicMyo> ();

        if (thalmicMyo.isPaired) {
            thalmicMyo.Vibrate(Thalmic.Myo.VibrationType.Short);
        }
        Debug.Log (thalmicMyo);
        Debug.Log (myo);
    }
Exemple #42
0
    // Update is called once per frame.
    void Update()
    {
        // Access the ThalmicMyo component attached to the Myo game object.
        thalmicMyo = myo.GetComponent<ThalmicMyo> ();

        // Check if the pose has changed since last update.
        // The ThalmicMyo component of a Myo game object has a pose property that is set to the
        // currently detected pose (e.g. Pose.Fist for the user making a fist). If no pose is currently
        // detected, pose will be set to Pose.Rest. If pose detection is unavailable, e.g. because Myo
        // is not on a user's arm, pose will be set to Pose.Unknown.
        if (thalmicMyo.pose != _lastPose) {
            _lastPose = thalmicMyo.pose;

            // Vibrate the Myo armband when a fist is made.
            if (thalmicMyo.pose == Pose.Fist) {
                thalmicMyo.Vibrate (VibrationType.Medium);

                ExtendUnlockAndNotifyUserAction (thalmicMyo);

            // Change material when wave in, wave out or double tap poses are made.
            } else if (thalmicMyo.pose == Pose.WaveIn) {
                GetComponent<Renderer>().material = waveInMaterial;

                GameObject arms = GameObject.FindGameObjectWithTag("ARMS");
                Instantiate (arms);

                ExtendUnlockAndNotifyUserAction (thalmicMyo);
            } else if (thalmicMyo.pose == Pose.WaveOut) {
                GetComponent<Renderer>().material = waveOutMaterial;

                ExtendUnlockAndNotifyUserAction (thalmicMyo);
            } else if (thalmicMyo.pose == Pose.DoubleTap) {
                GetComponent<Renderer>().material = doubleTapMaterial;

                ExtendUnlockAndNotifyUserAction (thalmicMyo);
            }
        }
    }
Exemple #43
0
    // Update is called once per frame
    void Update()
    {
        if (myoRef == null) {
            myoRef = FindObjectOfType<ThalmicMyo> ();
        } else {

            Thalmic.Myo.Pose overriddenPose = POSE_OVERRIDES[myoRef.pose];

            if (overriddenPose != pose && poseDuration > MIN_POSE_DURATION)
            {
                byte[] output = new byte[1];
                output[0] = ANGLE_OPEN;

                switch (overriddenPose)
                {
                    case Thalmic.Myo.Pose.Rest:
                        output[0] = ANGLE_OPEN;
                        break;
                    case Thalmic.Myo.Pose.Fist:
                        output[0] = ANGLE_CLOSE;
                        break;
                }

                pose = overriddenPose;
                poseDuration = 0.0f;

                //send hand command
                Debug.Log("Pose: " + pose.ToString() + "\nActual: " + myoRef.pose.ToString() + "\nAngle: " + output[0]);
                stream.Write(output, 0, 1);
            }
            else
            {
                poseDuration += Time.deltaTime;
            }
        }
    }
    // Draw some basic instructions.
    void OnGUI()
    {
        GUI.skin.label.fontSize = 20;

        hub = ThalmicHub.instance;

        // Access the ThalmicMyo script attached to the Myo object.
        thalmicMyo = myo.GetComponent<ThalmicMyo> ();

        if (!hub.hubInitialized) {
            GUI.Label(new Rect (12, 8, Screen.width, Screen.height),
                      "Cannot contact Myo Connect. Is Myo Connect running?\n" +
                      "Press Q to try again."
                      );
        } else if (!thalmicMyo.isPaired) {
            GUI.Label(new Rect (12, 8, Screen.width, Screen.height),
                      "No Myo currently paired."
                      );
        } else if (!thalmicMyo.armSynced) {
            GUI.Label(new Rect (12, 8, Screen.width, Screen.height),
                      "Perform the Sync Gesture."
                      );
        } else {
            myoIsPaired = true;
            /*
            GUI.Label (new Rect (12, 8, Screen.width, Screen.height),

                       "Fist: Vibrate Myo armband\n" +
                       "Wave in: Set box material to blue\n" +
                       "Wave out: Set box material to green\n" +
                       "Double tap: Reset box material\n" +
                       "Fingers spread: Set forward direction"
                       );
            */
        }
    }
Exemple #45
0
 void Start()
 {
     light = GetComponent<flashlight>();
     myo = GameObject.Find("Myo");
     thalmicMyo = myo.GetComponent<ThalmicMyo>();
 }
    // Use this for initialization
    void Start()
    {
        myo = GameObject.FindWithTag ("Myo");

                        thalmicMyo = myo.GetComponent<ThalmicMyo> ();
    }
Exemple #47
0
	void UpdateKeyPresses (ThalmicMyo thalmicMyo) {
		ThalmicHub hub = ThalmicHub.instance;
		
		if (Input.GetKeyDown (KeyCode.Q)) {
			hub.ResetHub();
		} else if (Input.GetKeyDown (KeyCode.R)) {
			_updateReference = true;
		}
	}
Exemple #48
0
	void UpdatePoses (ThalmicMyo thalmicMyo) {
		if (thalmicMyo.pose != _lastPose && thalmicMyo.pose != Pose.Unknown) {

			_lastPose = thalmicMyo.pose;

			if (thalmicMyo.pose == Pose.Rest) {
				return;
			}

			// Give feedback
			// thalmicMyo.Vibrate (VibrationType.Short);

			if (thalmicMyo.pose == Pose.Fist) {
				print("Fist detected");
				if (grabEnabled) {
					if (_grab == null) {
						RaycastHit hit;
						if (Physics.Raycast (transform.position, transform.rotation * Vector3.forward, out hit, 100f)) {
							_grab = hit.collider.transform;
							_updateGrabReference = true;
							thalmicMyo.Vibrate (VibrationType.Short);
							print("Grabbed");
						}
					}
				}

			} else if (thalmicMyo.pose == Pose.WaveIn) {
				if (thalmicMyo.arm == Thalmic.Myo.Arm.Left) {
					print("Wave RIGHT detected (left arm)");
					thalmicMyo.Vibrate (VibrationType.Short);
					slideGen.Reverse ();

				} else if (thalmicMyo.arm == Thalmic.Myo.Arm.Right) {
					print("Wave LEFT detected (right arm)");
					thalmicMyo.Vibrate (VibrationType.Short);
					slideGen.Advance ();
				}

			} else if (thalmicMyo.pose == Pose.WaveOut) {
				if (thalmicMyo.arm == Thalmic.Myo.Arm.Left) {
					print("Wave LEFT detected (left arm)");
					thalmicMyo.Vibrate (VibrationType.Short);
					slideGen.Advance ();

				} else if (thalmicMyo.arm == Thalmic.Myo.Arm.Right) {
					print("Wave RIGHT detected (right arm)");
					thalmicMyo.Vibrate (VibrationType.Short);
					slideGen.Reverse ();
				}

			} else if (thalmicMyo.pose == Pose.ThumbToPinky) {
				print("Thumb to Pinky detected");
				//if (Mathf.Approximately (_referenceRoll, 0f)) {
				_updateReference = true;
				thalmicMyo.Vibrate (VibrationType.Short);
				print("Calibrated");
				//}

			} else if (thalmicMyo.pose == Pose.FingersSpread) {
				print("Fingers Spread detected");
				thalmicMyo.Vibrate (VibrationType.Short);
				if (_grab == null) {
					showPointer = !showPointer;
					print("Pointer " + showPointer.ToString());
				} else {
					_grab = null;
					print("Released");
				}
			}
		}
	}
Exemple #49
0
 // Use this for initialization
 void Start()
 {
     selectedBall = GameObject.Find("1").GetComponent<Transform>().position;
     solidCount = stripeCount = 7;
     gc = GameControl.getInstance ();
     generalInfo = GeneralInfo.getInstance();
     getCueInfo ();
     getCueStickInfo();
     setCueStick();
     //MYO TESTS
     //cueStickRB.constraints = RigidbodyConstraints.FreezePositionY;
     //cueStickCollider.enabled = false;
     ThalmicHub hub = ThalmicHub.instance;
     thalmicMyo = myo.GetComponent<ThalmicMyo> ();
 }
 // Use this for initialization
 void Start()
 {
     btSerial = btSerialGO.GetComponent<BTSerial>();
     thalmicMyo = myoGO.GetComponent<ThalmicMyo>();
 }
 // Use this for initialization
 private void Start()
 {
     m_CharacterController = GetComponent<CharacterController>();
     m_Camera = Camera.main;
     m_OriginalCameraPosition = m_Camera.transform.localPosition;
     m_FovKick.Setup(m_Camera);
     m_HeadBob.Setup(m_Camera, m_StepInterval);
     m_StepCycle = 0f;
     m_NextStep = m_StepCycle/2f;
     m_Jumping = false;
     m_AudioSource = GetComponent<AudioSource>();
     m_MouseLook.Init(transform , m_Camera.transform);
     myo = GameObject.Find("Myo");
     thalmicMyo = myo.GetComponent<ThalmicMyo>();
 }
Exemple #52
0
    // Use this for initialization
    void Start()
    {
        if(!isBattling)
        aggz = new Vector3[aggtime];
        jerks = new Vector3[aggtime];

        pokeballs = new Transform[4];
        pokeballs [0] = pokeball_bulb;
        pokeballs [1] = pokeball_squirt;
        pokeballs [2] = pokeball_char;
        pokeballs [3] = pokeball_pika;

        myoController = myo.GetComponent<ThalmicMyo> ();

        for(int pBall = 0; pBall < numberOfPokeballs; pBall++) {
            pokeballs[pBall].gameObject.AddComponent<handBallCollision>();
        }
    }
 void Awake()
 {
     myo_ = myoObject.GetComponent<ThalmicMyo>();
 }
Exemple #54
0
	void UpdateOrientation (ThalmicMyo thalmicMyo) {
		// Update references. This anchors the joint on-screen such that it faces forward away
		// from the viewer when the Myo armband is oriented the way it is when these references are taken.
		if (_updateReference) {
			// _antiYaw represents a rotation of the Myo armband about the Y axis (up) which aligns the forward
			// vector of the rotation with Z = 1 when the wearer's arm is pointing in the reference direction.
			_antiYaw = Quaternion.FromToRotation (
				new Vector3 (myo.transform.forward.x, 0, myo.transform.forward.z),
				new Vector3 (0, 0, 1)
				);
			
			// _referenceRoll represents how many degrees the Myo armband is rotated clockwise
			// about its forward axis (when looking down the wearer's arm towards their hand) from the reference zero
			// roll direction. This direction is calculated and explained below. When this reference is
			// taken, the joint will be rotated about its forward axis such that it faces upwards when
			// the roll value matches the reference.
			Vector3 referenceZeroRoll = computeZeroRollVector (myo.transform.forward);
			_referenceRoll = rollFromZero (referenceZeroRoll, myo.transform.forward, myo.transform.up);
			_parentRotation = transform.parent.GetChild(0).rotation;
			_updateReference = false;
		} else if (_updateGrabReference) {
			_grabInitialObjectRotation = _grab.transform.rotation;
			_grabInitialPointerRotation = transform.rotation;
			_updateGrabReference = false;
		}

		// Current zero roll vector and roll value.
		Vector3 zeroRoll = computeZeroRollVector (myo.transform.forward);
		float roll = rollFromZero (zeroRoll, myo.transform.forward, myo.transform.up);
		
		// The relative roll is simply how much the current roll has changed relative to the reference roll.
		// adjustAngle simply keeps the resultant value within -180 to 180 degrees.
		float relativeRoll = normalizeAngle (roll - _referenceRoll);
		
		// antiRoll represents a rotation about the myo Armband's forward axis adjusting for reference roll.
		Quaternion antiRoll = Quaternion.AngleAxis (relativeRoll, myo.transform.forward);
		
		// Here the anti-roll and yaw rotations are applied to the myo Armband's forward direction to yield
		// the orientation of the joint.
		transform.rotation = _antiYaw * antiRoll * Quaternion.LookRotation (myo.transform.forward);
		
		// The above calculations were done assuming the Myo armbands's +x direction, in its own coordinate system,
		// was facing toward the wearer's elbow. If the Myo armband is worn with its +x direction facing the other way,
		// the rotation needs to be updated to compensate.
		if (thalmicMyo.xDirection == Thalmic.Myo.XDirection.TowardWrist) {
			// Mirror the rotation around the XZ plane in Unity's coordinate system (XY plane in Myo's coordinate
			// system). This makes the rotation reflect the arm's orientation, rather than that of the Myo armband.
			transform.rotation = new Quaternion(transform.localRotation.x,
			                                    -transform.localRotation.y,
			                                    transform.localRotation.z,
			                                    -transform.localRotation.w);
		}

		if (_grab != null) {
			_grab.rotation = Quaternion.Inverse (transform.rotation) * _grabInitialPointerRotation * _grabInitialObjectRotation;
		}
	}
Exemple #55
0
 void Start()
 {
     batteryLeft = GameObject.Find("Player/MainCamera/TrackingSpace/Battery").GetComponent<TextMesh>();
        myo = GameObject.Find("Myo");
        thalmicMyo = myo.GetComponent<ThalmicMyo>();
 }
Exemple #56
0
	// Use this for initialization
	void Start () {
		tMyo = myo.GetComponent<ThalmicMyo> ();
		vectors = new List<Vector3> ();

		//thrown = false;
	}