Exemplo n.º 1
0
 // Update is called once per frame
 void Update()
 {
     if (my_num == 0)
     {
         num_falcons = FalconUnity.getNumFalcons();
         FalconUnity.Update();
     }
 }
Exemplo n.º 2
0
 void OnApplicationQuit()
 {
     if (my_num == 0)
     {
         FalconUnity.Stop();
         FalconUnity.disconnect();
     }
 }
Exemplo n.º 3
0
 // Update is called once per frame
 void Update()
 {
     FalconUnity.getFalconButtonStates(0, out botones);
     if (botones[1] == true)
     {
         contador.b_instanciar = 0;
         contador.bodynum      = 1;
     }
 }
Exemplo n.º 4
0
 private void Update()
 {
     if (!this.falcon)
     {
         return;
     }
     this.falconPos = this.falcon.transform.localPosition;
     FalconUnity.getFalconButtonStates(0, out this.buttons);
     this.cursor.transform.localPosition = new Vector3(this.falconPos.x * 0.21333f * this.sensitivity, this.falconPos.y * 0.12f * this.sensitivity, 0.418f);
 }
 // Update is called once per frame
 void Update()
 {
     gravedad1 = gravedad1;
     if (contador.b_instanciar == 1)
     {
         //  gravedad = new Vector3(0, 2, 0);
         //Debug.Log(gravedad1);
         FalconUnity.applyForce(0, -gravedad1, 0.2f);
     }
 }
 // Use this for initialization
 void Start()
 {
     contador.acierto = 0;
     aux  = 0;
     solo = 0;
     FalconUnity.setForceField(0, constantforce);
     contador.b_instanciar = 1;
     peso     = 0;
     timebase = 0;
     m_Scene  = SceneManager.GetActiveScene();
 }
Exemplo n.º 7
0
 void push()
 {
     FalconUnity.getTipPosition(0, out pos);
     //if (Mathf.Abs(pos.z - wall) > 0.15f)
     //    FalconUnity.setForceField(0, 500 * Vector3.back);
     //FalconUnity.applyForce(0, 50*(pos.z-wall) * Vector3.back, 0.0001f);
     //    FalconUnity.setForceField(0, 1000*(pos.z-wall) * Vector3.back);
     //else
     //    FalconUnity.setForceField(0, Vector3.zero);
     FalconUnity.applyForce(0, k * pos.z * Vector3.back, 0.001f);
 }
Exemplo n.º 8
0
    void Start()
    {
//		FalconUnity.setForceField(0, new float[] {0,-10,0});
        if (my_num == 0)
        {
            num_falcons = FalconUnity.getNumFalcons();
            if (FalconUnity.IsRemote())
            {
                FalconUnity.Update();
            }
        }
    }
Exemplo n.º 9
0
    // Use this for initialization
    void Start()
    {
        savedHapticTipToWorldScale = hapticTipToWorldScale;

        FalconUnity.setForceField(falcon_num, constantforce);

        Vector3 tipPositionScale = new Vector3(1, 1, -1);

        tipPositionScale *= hapticTipToWorldScale;

        FalconUnity.updateHapticTransform(falcon_num, transform.position, transform.rotation, tipPositionScale, useMotionCompensator, 1 / 60.0f);
    }
Exemplo n.º 10
0
 public void Update()
 {
     if (falcon)
     {
         FalconUnity.getFalconButtonStates(0, out this.buttons); // Which buttons are currently pressed?
         if (!prevClick && (this.buttons[3] || buttons[1]))
         {
             Process();
             eventListener.OnPointerClick(GetFalconEventData());
         }
         prevClick = (this.buttons[3] || buttons[1]);
     }
 }
Exemplo n.º 11
0
    private void Update()
    {
        if (!this.falcon) // Not using the contoller, so mouse is fine
        {
            if (Input.mouseScrollDelta.y != 0f)
            {
                this.zoom += Mathf.Sign(Input.mouseScrollDelta.y) * 0.1f;
            }
            // Enforce a boundary on the zoom
            this.zoom = Mathf.Max(Mathf.Min(0.8f, this.zoom), 0f);

            // The new camera rotation will depend on the movement of the mouse
            this.nextpos  = new Vector3(base.transform.localEulerAngles.x - Input.mousePosition.y + this.mousepos.y, base.transform.localEulerAngles.y + Input.mousePosition.x - this.mousepos.x, 0f);
            this.mousepos = Input.mousePosition;
        }
        else                                                        // Using the controller
        {
            FalconUnity.getFalconButtonStates(0, out this.buttons); // Which buttons are currently pressed?
            //Set the new position based on the movement of the controller
            Vector3 cursorPosition = state.getCursorPosition();

            float newX = transform.localEulerAngles.x - (cursorPosition.y - cameraBounds.center.y) / 1000 * this.sensitivity;
            float newY = transform.localEulerAngles.y + (cursorPosition.x - cameraBounds.center.x) / 1000 * this.sensitivity;
            this.nextpos = new Vector3(newX, newY, 0f);
        }

        // Update the zoom
        this.cam.transform.localPosition = new Vector3(this.cam.transform.localPosition.x, this.cam.transform.localPosition.y, this.zoom);

        // Enforce a boundary on rotating up/down
        if (this.nextpos.x > 270f && this.nextpos.x < 280f)
        {
            this.nextpos.x = 280f;
        }
        else if (this.nextpos.x > 35f && this.nextpos.x < 90f)
        {
            this.nextpos.x = 35f;
        }

        // If the pan button is pressed (right click on mouse, or left button on controller), update the camera rotations
        if ((this.falcon && this.buttons[0]) || Input.GetMouseButton(1))
        {
            base.transform.localEulerAngles = this.nextpos;
            this.panning = true;
        }
        else
        {
            this.panning = false;
        }
    }
Exemplo n.º 12
0
    // Update is called once per frame
    void Update()

    {
        contador.peso = -slider.value;
        //Debug.Log(contador.peso);
        gravedad = new Vector3(0, contador.peso, 0);

        if (contador.pieza == 1)
        {
            if (aux == 1)
            {
                p1.gameObject.transform.position = new Vector3(esfera.transform.localPosition.x, esfera.transform.localPosition.y, esfera.transform.localPosition.z);

                FalconUnity.applyForce(0, gravedad, 0.2f);
            }
        }
        else
        {
            if (aux == 1)
            {
                Behaviour halo = (Behaviour)p1.GetComponent("Halo");
                halo.enabled = false;

                figura.enabled = true;
                aux            = 0;
                prueba         = "" + pieza + " (1)";

                if (prueba == referencia)
                {
                    r1 = GameObject.Find(referencia);
                    p1.gameObject.transform.position = r1.gameObject.transform.position;
                    Debug.Log("bien");
                    buenas++;
                    contador.piezasbuenas = buenas;
                    source.PlayOneShot(pibuenas, 1F);
                }
                else
                {
                    Debug.Log("mal");
                    malas++;
                    contador.piezasmalas = malas;
                    contador.errores     = malas;
                    source.PlayOneShot(pimalas, 1F);
                }
            }
        }
        contador.piezaagarrada = aux;
    }
Exemplo n.º 13
0
    // Update is called once per frame
    public void FixedUpdate()
    {
        Vector3    pos;
        Quaternion orient;


        bool res = FalconUnity.getDynamicShapePose(bodyId, out pos, out orient);

        if (!res)
        {
//			Debug.Log("Error getting object pose");
            return;
        }
        transform.localPosition = pos;
        transform.localRotation = orient;
        FalconUnity.updateDynamicShape(bodyId, mass, k, linearFactors, angularFactors, friction);
    }
Exemplo n.º 14
0
    public void ClickRESET()
    {
        FalconUnity.setForceField(0, constantforce);

        m_Scene = SceneManager.GetActiveScene();
        if (m_Scene.name == "puzzleniv1")
        {
            SceneManager.LoadScene("puzzleniv1");
        }
        if (m_Scene.name == "puzzleniv2")
        {
            SceneManager.LoadScene("puzzleniv2");
        }
        if (m_Scene.name == "puzzleniv3")
        {
            SceneManager.LoadScene("puzzleniv3");
        }
    }
Exemplo n.º 15
0
 private void Update()
 {
     buttons = 0;
     if (this.falcon) // Update the cursor position every frame
     {
         this.cursorPosition = falconCamera.WorldToScreenPoint(this.falconCursor.transform.position);
         FalconUnity.getFalconButtonStates(0, out falconButtons);
         buttons |= falconButtons[0] ? 1 : 0; // middle button
         buttons |= falconButtons[1] ? 2 : 0; // left button
         buttons |= falconButtons[2] ? 4 : 0; // top button
         buttons |= falconButtons[3] ? 2 : 0; // right button
     }
     else
     {
         this.cursorPosition = Input.mousePosition;
         buttons            |= Input.GetMouseButton(1) ? 1 : 0; // right mouse button
         buttons            |= Input.GetMouseButton(0) ? 2 : 0; // left mouse button
     }
 }
Exemplo n.º 16
0
    public void ClickRESET()
    {
        FalconUnity.setForceField(0, constantforce);

        m_Scene = SceneManager.GetActiveScene();
        if (m_Scene.name == "consultorioniv1")
        {
            SceneManager.LoadScene("consultorioniv1");
        }
        if (m_Scene.name == "consultorioniv2")
        {
            SceneManager.LoadScene("consultorioniv2");
        }
        if (m_Scene.name == "consultorioniv3")
        {
            contador.reseteo = 0;
            SceneManager.LoadScene("consultorioniv3");
        }
    }
Exemplo n.º 17
0
    // Use this for initialization
    void Awake()
    {
        my_num = getNextNum();

        if (my_num == 0)
        {
            Debug.Log(address + " " + port);
            FalconUnity.setServerParams(address, port);
            FalconUnity.Start();

            FalconUnity.Update();
            if (FalconUnity.IsRemote())
            {
                FalconUnity.Update();
            }

            FalconUnity.setGravity(gravity);
        }
    }
Exemplo n.º 18
0
    // Update is called once per frame
    void Update()
    {
        elapsedTime += Time.deltaTime;
        //times.Add(elapsedTime);
        //cameraRot.Add(cam.transform.localEulerAngles);

        if (falcon)
        {
            FalconUnity.getTipPosition(0, out tempPos);
            falconPos.Add(tempPos);
        }

        string path = userPath + "panData.csv";

        new FileStream(path, FileMode.Append, FileAccess.Write, FileShare.Write).Close();
        StreamWriter streamWriter = new StreamWriter(path, true, Encoding.ASCII);

        if (!writtenPanDataColumnNames)           //Only write this once:
        {
            streamWriter.Write("time (s), rotation_x, rotation_y, falcon_x, falcon_y, falcon_z\n");
            writtenPanDataColumnNames = true;
        }
        string line = elapsedTime.ToString() + "," +
                      cam.transform.localEulerAngles.x.ToString() + "," + cam.transform.localEulerAngles.y.ToString();

        if (falcon)
        {
            line += "," + tempPos.x.ToString() + "," + tempPos.y.ToString() + "," + tempPos.z.ToString() + "\n";
        }
        else
        {
            line += "\n";
        }
        streamWriter.Write(line);
        streamWriter.Close();

        /* Not needed if it's writing every frame:
         * times.Clear();
         * cameraRot.Clear();
         * falconPos.Clear();
         */
    }
    // Use this for initialization
    void Start()
    {
        /* FalconUnity.setForceField(0, new Vector3(0, -6, 0));
         * int d = 0;
         * while (d < 500)
         * {
         *   d++;
         *   Debug.Log(d);
         * }
         *
         * m_Scene = SceneManager.GetActiveScene();
         * if (m_Scene.name== "consultorioniv1")
         * {
         *   Instantiate(mesa, new Vector3(-4.179646f, -15.7f, 6.1f), Quaternion.Euler(new Vector3(-90, 180, 0)));
         *   Instantiate(base_niv, new Vector3(9.31f, -10.424f, 7.95f), Quaternion.Euler(new Vector3(90, 180, 0)));
         *   Instantiate(figuras, new Vector3(-15.04f, -12.16f, 6.87f), Quaternion.Euler(new Vector3(90, 0, 0)));
         * }
         * if (m_Scene.name == "consultorioniv2")
         * {
         *   Instantiate(mesa, new Vector3(-4.179646f, -15.7f, 6.1f), Quaternion.Euler(new Vector3(-90, 180, 0)));
         *   Instantiate(base_niv, new Vector3(3.62f, -9.36f, 5.4f), Quaternion.Euler(new Vector3(-90, 0, 0)));
         *   Instantiate(figuras, new Vector3(3.625f, -13.876f, 5.46f), Quaternion.Euler(new Vector3(90, 0, 0)));
         * }*/
        contador.ganador_consultorio = 1;

        contador.activacion = false;

        aux = 1;

        savedHapticTipToWorldScale = hapticTipToWorldScale;

        // FalconUnity.setForceField(falcon_num, new Vector3(0, 0, 0));
        Vector3 tipPositionScale = new Vector3(1, 1, -1);

        tipPositionScale *= hapticTipToWorldScale;

        FalconUnity.updateHapticTransform(falcon_num, transform.position, transform.rotation, tipPositionScale, useMotionCompensator, 1 / 60.0f);

        godObjectMass = 0.0001f;
        //  FalconUnity.setForceField(falcon_num, new Vector3(0, 0, 0));
        aux2 = 0;
    }
Exemplo n.º 20
0
    // Update is called once per frame
    public void FixedUpdate()
    {
        Vector3    pos;
        Quaternion orient;


        bool res = FalconUnity.getDynamicShapePose(bodyId, out pos, out orient);

        if (!res)
        {
//			Debug.Log("Error getting object pose");
            return;
        }
        transform.localPosition = pos;
        transform.localRotation = orient;

        FalconUnity.updateDynamicShape(bodyId, mass, k, linearFactors, angularFactors, friction);

        FalconUnity.lerpSpring(springId, max_force, dampingFactor, springPos, springOrientation, posConstraintLower, posConstraintUpper, orientConstraintCCW, orientConstraintCW, directionality, 0);
//		FalconUnity.setSpring(springId,max_force,goalPos,goalOrient,pConstraintl,pConstraintu, oConstraintl, oConstraintu);
    }
Exemplo n.º 21
0
    void LateUpdate()
    {
        bool res = FalconUnity.getFalconButtonStates(falcon_num, out curr_buttons);


        if (!res)
        {
            //			Debug.Log("Error getting button states");
            return;
        }
        //go through the buttons, seeing which are pressed
        for (int i = 0; i < 4; i++)
        {
            if (button_states[i] && button_states[i] != curr_buttons[i])
            {
                buttonPressed(i);
            }

            button_states[i] = curr_buttons[i];
        }
    }
Exemplo n.º 22
0
    public void Clicksalir()
    {
        FalconUnity.setForceField(0, constantforce);
        m_Scene = SceneManager.GetActiveScene();


        if (m_Scene.name == "consultorioniv1")
        {
            NIV = 1;
        }
        if (m_Scene.name == "consultorioniv2")
        {
            NIV = 2;
        }
        if (m_Scene.name == "consultorioniv3")
        {
            NIV = 3;
        }

        guardar();
        SceneManager.LoadScene("MENUCONSULTORIO");
    }
Exemplo n.º 23
0
    public void Clicksalir()
    {
        FalconUnity.setForceField(0, constantforce);
        m_Scene = SceneManager.GetActiveScene();


        if (m_Scene.name == "puzzleniv1")
        {
            NIV = 1;
        }
        if (m_Scene.name == "puzzleniv2")
        {
            NIV = 2;
        }
        if (m_Scene.name == "puzzleniv3")
        {
            NIV = 3;
        }

        guardar();
        SceneManager.LoadScene("MENUPUZZLE");
    }
Exemplo n.º 24
0
    // Update is called once per frame
    void Update()
    {
        if (!falcon)
        {
            float mouseWheelDelta = Input.GetAxis("Mouse ScrollWheel"); //This is the change in mousewheel position, not absolute position
            scrollPos += mouseWheelDelta;
        }
        else
        {
            FalconUnity.getTipPosition(0, out falconPos);
            scrollPos = (float)Math.Tanh(z - (Mathf.Max(z, Mathf.Abs(falconPos.z))));  // * 0.5f;
        }


        //Image blackens completely at above 0.33 scrollPos or below -0.33, this shouldn't be too hard to translate/modify over to the falcon:
        image.color = new Color(0, 0, 0, Mathf.Abs(scrollPos) * 3);

        //This part doesn't need to change at all:
        ViewConeScript.modifyRotation(-camera.transform.localEulerAngles.y);

        //With the falcon, the part "Mathf.Abs(1.0f + scrollPos)" can just be changed to "falcon.z / 2.0f + 1.0" (ranges from 0.5f to 1.5f scale)
        ViewConeScript.modifyScale(1.0f + falconPos.z / 2.0f);
    }
Exemplo n.º 25
0
    // Use this for initialization
    void Start()
    {
        contador.pieza         = 0;
        contador.piezaagarrada = 0;
        contador.piezasbuenas  = 0;
        contador.piezasmalas   = 0;
        contador.cronometro    = 0;
        contador.ganador       = 0;
        contador.errores       = 0;
        contador.modo          = 0;
        contador.fuerza        = 0;

        savedHapticTipToWorldScale = hapticTipToWorldScale;

        FalconUnity.setForceField(falcon_num, new Vector3(0, 0, -10));
        Vector3 tipPositionScale = new Vector3(1, 1, -1);

        tipPositionScale *= hapticTipToWorldScale;

        FalconUnity.updateHapticTransform(falcon_num, transform.position, transform.rotation, tipPositionScale, useMotionCompensator, 1 / 60.0f);

        godObjectMass = 0.0001f;
        FalconUnity.setForceField(falcon_num, new Vector3(0, 0, 0));
    }
Exemplo n.º 26
0
    private static void PiscaEnterHaptic()
    {
        FalconUnity.setForceField(0, new Vector3(1f, 1f, 1f));      //força para baixo

        //FalconUnity.applyForce(0, new Vector3(2, 2, 2), 0.5f);
    }
Exemplo n.º 27
0
    // Update is called once per frame
    public void FixedUpdate()
    {
        Vector3    pos;
        Quaternion orient;

        if (contador.bodynum == 1 || contador.ganador_consultorio == 1)
        {
            if (gameObject.tag == "cubo")
            {
                FalconUnity.removeDynamicShape(bodyId);
                Destroy(gameObject);
            }
            if (gameObject.tag == "cilindro")
            {
                FalconUnity.removeDynamicShape(bodyId);
                Destroy(gameObject);
            }
            if (gameObject.tag == "octa")
            {
                FalconUnity.removeDynamicShape(bodyId);
                Destroy(gameObject);
            }
            if (gameObject.tag == "triangulo")
            {
                FalconUnity.removeDynamicShape(bodyId);
                Debug.Log("destruye");
                Destroy(gameObject);
            }
            if (gameObject.tag == "cubo_peque")
            {
                Debug.Log(bodyId);
                FalconUnity.removeDynamicShape(bodyId);
                Destroy(gameObject);
            }
            if (gameObject.tag == "cilindro_peque")
            {
                FalconUnity.removeDynamicShape(bodyId);
                Destroy(gameObject);
            }
            if (gameObject.tag == "octa_peque")
            {
                FalconUnity.removeDynamicShape(bodyId);
                Destroy(gameObject);
            }
            if (gameObject.tag == "triangulo_peque")
            {
                FalconUnity.removeDynamicShape(bodyId);
                Debug.Log("destruye");
                Destroy(gameObject);
            }
            // contador.bodynum = 0;
        }

        if (gameObject.tag != "cubo" && gameObject.tag != "cilindro" && gameObject.tag != "octa" && gameObject.tag != "triangulo" && gameObject.tag != "cubo_peque" && gameObject.tag != "cilindro_peque" && gameObject.tag != "octa_peque" && gameObject.tag != "triangulo_peque")
        {
            bool res = FalconUnity.getDynamicShapePose(bodyId, out pos, out orient);
            if (!res)
            {
                //			Debug.Log("Error getting object pose");
                return;
            }
            transform.localPosition = pos;
            transform.localRotation = orient;
            FalconUnity.updateDynamicShape(bodyId, mass, k, linearFactors, angularFactors, friction);
        }
    }
Exemplo n.º 28
0
    public void Clicksalir2()
    {
        FalconUnity.setForceField(0, constantforce);

        SceneManager.LoadScene("MENUPUZZLE");
    }
Exemplo n.º 29
0
    public void Update()
    {
        Vector3    pos;
        Quaternion orient;

        if (contador.bodynum == 0)

        {
            if (gameObject.tag == "cubo" || gameObject.tag == "cilindro" || gameObject.tag == "octa" || gameObject.tag == "triangulo" || gameObject.tag == "cubo_peque" || gameObject.tag == "cilindro_peque" || gameObject.tag == "octa_peque" || gameObject.tag == "triangulo_peque")
            {
                bool res = FalconUnity.getDynamicShapePose(bodyId, out pos, out orient);
                if (!res)
                {
                    //			Debug.Log("Error getting object pose");
                    return;
                }
                transform.localPosition = pos;
                transform.localRotation = orient;
                FalconUnity.updateDynamicShape(bodyId, mass, k, linearFactors, angularFactors, friction);
            }    /*
                  * if (gameObject.tag == "cilindro")
                  * {
                  * bool res = FalconUnity.getDynamicShapePose(bodyId, out pos, out orient);
                  * if (!res)
                  * {
                  * //			Debug.Log("Error getting object pose");
                  * return;
                  * }
                  * transform.localPosition = pos;
                  * transform.localRotation = orient;
                  * FalconUnity.updateDynamicShape(bodyId, mass, k, linearFactors, angularFactors, friction);
                  * }
                  * if (gameObject.tag == "octa")
                  * {
                  * bool res = FalconUnity.getDynamicShapePose(bodyId, out pos, out orient);
                  * if (!res)
                  * {
                  * //			Debug.Log("Error getting object pose");
                  * return;
                  * }
                  * transform.localPosition = pos;
                  * transform.localRotation = orient;
                  * FalconUnity.updateDynamicShape(bodyId, mass, k, linearFactors, angularFactors, friction);
                  * }
                  * if (gameObject.tag == "triangulo")
                  * {
                  * bool res = FalconUnity.getDynamicShapePose(bodyId, out pos, out orient);
                  * if (!res)
                  * {
                  * //			Debug.Log("Error getting object pose");
                  * return;
                  * }
                  * transform.localPosition = pos;
                  * transform.localRotation = orient;
                  * FalconUnity.updateDynamicShape(bodyId, mass, k, linearFactors, angularFactors, friction);
                  * }
                  */
        }



        //Debug.Log(bodyId);

        /*      if (bodyId == numero)
         *    {
         *        if (removido)
         *        {
         *            if (contador.activacion)
         *            {
         *                refreshShape();
         *                Debug.Log("vuelve");
         *                removido = false;
         *                contador.activacion = false;
         *            }
         *        }
         *        else
         *        {
         *            if (contador.activacion)
         *            {
         *
         *                FalconUnity.removeDynamicShape(numero);
         *                removido = true;
         *                contador.activacion = false;
         *                Destroy(gameObject);
         *            }
         *        }
         *    }*/
    }
Exemplo n.º 30
0
 // Use this for initialization
 void Start()
 {
     FalconUnity.applyForce(0, constantforce, 0.01f);
     peso     = 0;
     timebase = 0;
 }