Пример #1
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);
 }
Пример #2
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();
         */
    }
    // 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);
    }
Пример #4
0
    // Update is called once per frame
    void Update()
    {
        if (!haveReceivedTipPosition)
        {
            Vector3 posTip2;
            bool    result = FalconUnity.getTipPosition(falcon_num, out posTip2);
            if (!result)
            {
//				Debug.Log("Error getting tip position");
                return;
            }
            receivedCount++;

            if (receivedCount < 25 && (posTip2.x == 0 && posTip2.y == 0 && posTip2.z == 0))
            {
                return;
            }

            hapticTip.position = posTip2;

            godObject.position = posTip2;

            Debug.Log("Initialized with tip position: ");
            Debug.Log(posTip2);
            FalconUnity.setSphereGodObject(falcon_num, godObject.localScale.x * godObject.GetComponent <SphereCollider>().radius, godObjectMass, godObject.position, minDistToMaxForce * hapticTipToWorldScale, maxDistToMaxForce * hapticTipToWorldScale);

            haveReceivedTipPosition = true;
        }

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

        tipPositionScale *= hapticTipToWorldScale;

        if (savedHapticTipToWorldScale != hapticTipToWorldScale)
        {
            FalconUnity.setSphereGodObject(falcon_num, godObject.localScale.x * godObject.GetComponent <SphereCollider>().radius, godObjectMass, godObject.position, minDistToMaxForce * hapticTipToWorldScale, maxDistToMaxForce * hapticTipToWorldScale);
            savedHapticTipToWorldScale = hapticTipToWorldScale;
        }

        FalconUnity.updateHapticTransform(falcon_num, transform.position, transform.rotation, tipPositionScale, useMotionCompensator, Time.deltaTime);

        Vector3 posGod;
        bool    res = FalconUnity.getGodPosition(falcon_num, out posGod);

        if (!res)
        {
//			Debug.Log("Error getting god tip position");
            return;
        }
        Vector3 posTip;

        res = FalconUnity.getTipPosition(falcon_num, out posTip);
        if (!res)
        {
//			Debug.Log("Error getting tip position");
            return;
        }
        hapticTip.position = posTip;

        godObject.position = posGod;
        godObject.rotation = new Quaternion(0, 0, 0, 1);

        FalconUnity.setForceField(falcon_num, constantforce + TurretForce);
    }
    // Update is called once per frame
    void Update()
    {
        if (contador.b_instanciar == 0)
        {
            aux1 = 0;
        }
        if (contador.b_instanciar == 0 && aux2 == 0)
        {
            aux2 = 1;
            FalconUnity.setSphereGodObject(falcon_num, godObject.localScale.x * godObject.GetComponent <SphereCollider>().radius, godObjectMass, godObject.position, minDistToMaxForce * hapticTipToWorldScale, maxDistToMaxForce * hapticTipToWorldScale);
        }


        if (contador.b_instanciar == 1 && aux1 == 0)
        {
            aux  = 0;
            aux2 = 0;
        }


        if (aux == 0)
        {
            FalconUnity.setSphereGodObject(falcon_num, godObject.localScale.x * godObject.GetComponent <SphereCollider>().radius, godObjectMass, godObject.position, minDistToMaxForce * hapticTipToWorldScale, maxDistToMaxForce * hapticTipToWorldScale);
            aux  = 1;
            aux1 = 1;
            aux2 = 0;
        }


        num_falcons = FalconUnity.getNumFalcons();
        FalconUnity.Update();



        if (contador.ganador_consultorio == 0)
        {
            if (!haveReceivedTipPosition)
            {
                Vector3 posTip2;
                bool    result = FalconUnity.getTipPosition(falcon_num, out posTip2);
                if (!result)
                {
                    //				Debug.Log("Error getting tip position");
                    return;
                }
                receivedCount++;

                if (receivedCount < 25 && (posTip2.x == 0 && posTip2.y == 0 && posTip2.z == 0))
                {
                    return;
                }

                //hapticTip.position = posTip2;

                //godObject.position = posTip2;
                hapticTip.position = new Vector3(posTip2.x, posTip2.y, posTip2.z);//posTip2.z

                godObject.position = new Vector3(posTip2.x, posTip2.y, posTip2.z);

                Debug.Log("Initialized with tip position: ");
                Debug.Log(posTip2);
                FalconUnity.setSphereGodObject(falcon_num, godObject.localScale.x * godObject.GetComponent <SphereCollider>().radius, godObjectMass, godObject.position, minDistToMaxForce * hapticTipToWorldScale, maxDistToMaxForce * hapticTipToWorldScale);

                haveReceivedTipPosition = true;
            }

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

            if (savedHapticTipToWorldScale != hapticTipToWorldScale)
            {
                FalconUnity.setSphereGodObject(falcon_num, godObject.localScale.x * godObject.GetComponent <SphereCollider>().radius, godObjectMass, godObject.position, minDistToMaxForce * hapticTipToWorldScale, maxDistToMaxForce * hapticTipToWorldScale);
                //FalconUnity.updateDynamicShape(contador.cuerpo, 0.001f, 0.01f,godObject.transform.localScale, new Vector3(0, 0, 0), 0.8f);
                savedHapticTipToWorldScale = hapticTipToWorldScale;
            }

            FalconUnity.updateHapticTransform(falcon_num, new Vector3(transform.position.x, transform.position.y, 0), transform.rotation, tipPositionScale, useMotionCompensator, Time.deltaTime);

            Vector3 posGod;
            bool    res = FalconUnity.getGodPosition(falcon_num, out posGod);
            if (!res)
            {
                //			Debug.Log("Error getting god tip position");
                return;
            }
            Vector3 posTip;
            res = FalconUnity.getTipPosition(falcon_num, out posTip);
            if (!res)
            {
                //			Debug.Log("Error getting tip position");
                return;
            }
            hapticTip.position = posTip;

            godObject.position = posGod;
            // manito.position = posGod;

            godObject.rotation = new Quaternion(0, 0, 0, 1);

            camara.position = godObject.position;
        }
        else
        {
        }
    }