Esempio n. 1
0
    public void setInitialpos()
    {
        altitude = alldata[0][3];
        float[] xzy = MathCalculations.Convert(alldata[0][1], alldata[0][2], alldata[0][3]); //lat long

        //MathCalculations.DistanceToLatlong(new Vector2(xzy[0], xzy[1]));
        x = xzy[0];
        z = xzy[1];
        //maxheight = y;
        y = xzy[2];
        targetPosition          = new Vector3(x, y, z);
        transform.localPosition = targetPosition;

        //This is correct and verified
        roll                    = alldata[0][4];
        pitch                   = alldata[0][5];
        heading                 = alldata[0][6];
        speed                   = alldata[0][11];
        targetRotation          = Quaternion.Euler(pitch, heading, -roll); //roll and heading are swapped
        transform.localRotation = targetRotation;

        startPosition   = targetPosition = gameObject.transform.localPosition;
        startRotation   = targetRotation = transform.localRotation;
        initialPosition = transform.position;

        t1 = alldata[0][0];

        //Debug.Log("Time T1"+ t1);
        //Add Time Offset to start time
        //int offset = (type == "F7") ? 8 : 0;
        //		hr = GameObject.Find("StartTimeManager").GetComponent<EditStartTime>().hrs.ToString();
        //		min = GameObject.Find ("StartTimeManager").GetComponent<EditStartTime> ().mins.ToString();
        //		sec = GameObject.Find ("StartTimeManager").GetComponent<EditStartTime> ().secs.ToString();
        //
        //		updatedStartTime = hr + ":" + min + ":" + sec;
        //Debug.Log ("Updated Time From UI From AddMission Scene = " + updatedStartTime);

        localtime = MathCalculations.ConvertTime(t1, offset);

        //        hr = PlayerPrefs.GetFloat("StartHour").ToString();
        //		min = PlayerPrefs.GetFloat("StartMinute").ToString();
        //		sec = PlayerPrefs.GetFloat("StartSecond").ToString();
        //UnityEngine.Debug.Log("list values" + TailIDElements);

        //starttime = updatedStartTime;
        starttime = localtime;
        //Debug.Log("Starttime after mathcalculation = "+ starttime);

        endtime = MathCalculations.ConvertTime(alldata[alldata.Count - 1][0], offset);

        //dashboardData = alldata[counterAllData];
        counterAllData = 1;
        //time.GetComponent<TextMesh>().text = "Local Time:\n" + localtime;
        planeInfo.GetComponent <TextMesh>().text = "Callsign: " + callsign + "\nTailID: " + tailID + "\nAltitude: " + altitude.ToString() + "ft\nHeading: " + heading.ToString() + "\nSpeed: " + speed.ToString() + "kn";
    }
Esempio n. 2
0
    public void DoBullEyeCalculation()
    {
        float altitude = 1000;

        float[] xzy = MathCalculations.Convert(LatLong.x, LatLong.y, altitude); //lat long

        float x = xzy[0];
        float z = xzy[1];

        //float y = xzy[2];
        targetPosition = new Vector3(x, 0, z);

        bullsEyeObject.GetComponent <PositionData>().SetLatLong(LatLong);
    }
Esempio n. 3
0
    private List <float> ConvertToXYForBullsEye(List <float> attributes)
    {
        List <float> convertedAttributes = new List <float>();

        double altitude = 1000;

        float[] p1        = MathCalculations.Convert(attributes[0], attributes[1], altitude); //lat long
        float   latitude  = p1[0];
        float   longitude = p1[1];

        convertedAttributes.Add(latitude);
        convertedAttributes.Add(longitude);
        convertedAttributes.Add(attributes[2]);


        return(convertedAttributes);
    }
Esempio n. 4
0
    public void SetAircraftsPosition(LiveAcmiDataReciever.ACMIdata liveData, GameObject aircraft)
    {
        float[] xzy = MathCalculations.Convert(liveData.Latitude, liveData.Longitude, liveData.Altitude);

        float x = xzy[0];
        float z = xzy[1];
        float y = xzy[2];

        updatedPosition = new Vector3(x, y, z);
        aircraft.transform.localPosition = updatedPosition;


        float roll    = liveData.Roll;
        float pitch   = liveData.Pitch;
        float heading = liveData.Heading;

        heading         = heading - 180;
        updatedRotation = Quaternion.Euler(pitch, heading, -roll);
        aircraft.transform.localRotation = updatedRotation;
    }
Esempio n. 5
0
    public void SetCurrentPosition(int positionId)
    {
        altitude = alldata[positionId][3];
        float[] xzy = MathCalculations.Convert(alldata[positionId][1], alldata[positionId][2], alldata[positionId][3]); //lat long
        x = xzy[0];
        z = xzy[1];
        //maxheight = y;
        y = xzy[2];
        targetPosition          = new Vector3(x, y, z);
        transform.localPosition = targetPosition;

        //This is correct and verified
        roll                    = alldata[positionId][4];
        pitch                   = alldata[positionId][5];
        heading                 = alldata[positionId][6];
        speed                   = alldata[positionId][11];
        targetRotation          = Quaternion.Euler(pitch, heading, -roll); //roll and heading are swapped
        transform.localRotation = targetRotation;

        startPosition = targetPosition = gameObject.transform.localPosition;
        startRotation = targetRotation = transform.localRotation;


        t1 = alldata[positionId][0];

        //Add Time Offset to start time
        int offset = (type == "F7") ? 8 : 0;

        localtime = MathCalculations.ConvertTime(t1, offset);



        //dashboardData = alldata[counterAllData];
        counterAllData = positionId + 1;
        //time.GetComponent<TextMesh>().text = "Local Time:\n" + localtime;
        planeInfo.GetComponent <TextMesh>().text = "Callsign: " + callsign + "\nTailID: " + tailID + "\nAltitude: " + altitude.ToString() + "ft\nHeading: " + heading.ToString() + "\nSpeed: " + speed.ToString() + "kn";
    }
Esempio n. 6
0
    private List <float> ConvertToXY(List <float> attributes)
    {
        List <float> convertedAttributes = new List <float>();

        double altitude = 1000;

        float[] start   = MathCalculations.Convert(attributes[4], attributes[2], altitude); //lat long
        float   startX4 = start[0];
        float   startY2 = start[1];


        float[] end   = MathCalculations.Convert(attributes[5], attributes[3], altitude); //lat long
        float   endX5 = end[0];
        float   endY3 = end[1];

        convertedAttributes.Add(attributes[0]);
        convertedAttributes.Add(attributes[1]);
        convertedAttributes.Add(startY2);
        convertedAttributes.Add(endY3);
        convertedAttributes.Add(startX4);
        convertedAttributes.Add(endX5);

        return(convertedAttributes);
    }
Esempio n. 7
0
    // Update is called once per frame
    void FixedUpdate()
    {
        //Object Position and rotation Updated
        if (flag && startReal)
        {
            if (counterAllData < alldata.Count)
            {
                if (timerTime >= timeDeltaConstant)
                {
                    timerTime = 0f;
                    //Display();
                    planeInfo.GetComponent <TextMesh>().text = "Call Sign: " + callsign + "\nTailID: " + tailID + "\nAltitude: " + altitude.ToString() + "\nHeading: " + heading.ToString() + "\nSpeed: " + speed.ToString();
                    //time.GetComponent<TextMesh>().text = "Local Time:\n" + localtime;
                    List <float> data = alldata[counterAllData];
                    dashboardData = alldata[counterAllData - 1];

                    //alldata.RemoveAt(0);
                    if (playdirection)
                    {
                        counterAllData++;
                    }
                    else
                    {
                        if (counterAllData != 0)
                        {
                            counterAllData--;
                        }
                    }


                    t2        = data[0];
                    localtime = MathCalculations.ConvertTime(t2);
                    if (t2 > t1)
                    {
                        timeToReachTarget = (float)(t2 - t1);
                    }
                    else
                    {
                        timeToReachTarget = (float)(t1 - t2);
                    }
                    timeDeltaConstant = timeToReachTarget;
                    t1       = t2;
                    altitude = data[3];
                    float[] xzy = MathCalculations.Convert(data[1], data[2], data[3]);
                    x = xzy[0];
                    z = xzy[1];
                    y = xzy[2];

                    //This is correct and verified
                    roll           = data[4];
                    pitch          = data[5];
                    heading        = data[6];
                    speed          = data[11];
                    targetRotation = Quaternion.Euler(pitch, heading, -roll);

                    /*assuming plane is facing left,
                     * roll is Rotation on longitudinal axis
                     * pitch is Rotation on lateral axis
                     * yaw is Rotation on vertical axis*/
                    if (data[14] != 0 || toggleMissileLaunch)
                    {
                        toggleMissileLaunch = false;
                        Debug.Log("Mission Event Happened");
                        int x = GetCounterAllData() + GetOffsetTime();
                        events.AddMissionEvent(localtime.ToString() + " " + callsign, x);
                        LaunchMissile();
                        //localtime.ToString() + " " + transform.name;
                    }


                    deltat        = 0;
                    startPosition = gameObject.transform.localPosition;
                    startRotation = gameObject.transform.localRotation;
                    //We are dealing with 200 milliseconds
                    //timeToReachTarget = 0.2f;
                    targetPosition = new Vector3(x, y, z);

                    //Vector3.RotateTowards(transform.forward, targetPosition, 0.2f * Time.deltaTime, 0.0f);
                    // transform.rotat(targetPosition);
                    //transform.rotation = Quaternion.LookRotation(targetPosition);
                }
                //gameObject.transform.position += transform.forward * Time.deltaTime * 2;
                float varDeltaTime = Time.fixedDeltaTime;
                float ratio        = varDeltaTime / timeToReachTarget;
                timerTime += varDeltaTime;
                gameObject.transform.localPosition = Vector3.Lerp(startPosition, targetPosition, ratio);
                //callSignObj.transform.localPosition = gameObject.transform.localPosition;
                transform.localRotation = Quaternion.Slerp(startRotation, targetRotation, ratio);
                // callSignObj.transform.localPosition = gameObject.transform.localPosition;
                timeToReachTarget -= varDeltaTime;
                anchor.SetPosition(0, gameObject.transform.GetChild(1).GetChild(1).position + (Vector3.down * 0.008f));
                anchor.SetPosition(1, gameObject.transform.GetChild(0).position);


                //Vector3 v = Camera.main.transform.position - transform.position;
                //v.x = v.z = 0.0f;
                //callSignObj.transform.LookAt(Camera.main.transform.position - v);
                //callSignObj.transform.Rotate(0, 180, 0);
            }
            else
            {
                dashboardData = alldata[counterAllData - 1];
            }
        }
    }