Пример #1
0
    //CSV 파일 처리
    public void ReadCSVFile()
    {
        string strFile = "DroneData.csv";

        ClearDroneObject();
        //FILE OPEN
        using (FileStream fs = new FileStream(strFile, FileMode.Open))
        {
            using (StreamReader sr = new StreamReader(fs, Encoding.UTF8, false))
            {
                string   strLineValue = null;
                string[] values       = null;
                string[] PointValue   = null;
                bool     bfirstLine   = true;
                while ((strLineValue = sr.ReadLine()) != null)
                {
                    DronePointData _dronePoint = new DronePointData();
                    // Must not be empty.
                    if (string.IsNullOrEmpty(strLineValue))
                    {
                        return;
                    }
                    if (bfirstLine)
                    {
                        bfirstLine = false;
                        continue;
                    }
                    values = strLineValue.Split(',');
                    //fist Line -> Collision Size
                    // Output first Column Skip
                    //_dronePoint.Clear ();
                    for (int nIndex = 1; nIndex < values.Length; nIndex++)
                    {
                        PointValue = values [nIndex].Split(' ');
                        float fx     = System.Convert.ToSingle(PointValue [0]);
                        float fy     = System.Convert.ToSingle(PointValue [1]);
                        float fz     = System.Convert.ToSingle(PointValue [2]);
                        float fspeed = System.Convert.ToSingle(PointValue [3]);

                        Mathf.Clamp(fx, 0, 5000);
                        Mathf.Clamp(fy, 0, 5000);
                        Mathf.Clamp(fz, 0, 500);
                        _dronePoint.AddData(fx, fz, fy, fspeed);                         //Unity 좌표계 때문에 Y와  Z를 바꿔서 전달 및 사용
                    }
                    DroneDataList.Add(_dronePoint);
                }
            }
        }
        LoadDroneObject();
    }
Пример #2
0
    // 드론을 DronePatrol 에서 복사함
    private GameObject MakeDrone(DronePointData _data, int iNo)
    {
        GameObject Create_Drone;
        GameObject org_Drone;

        org_Drone = GameObject.Find("DronePatrol");

        Vector3 startPos = _data.GetPoint_Vector3(0);

        Create_Drone = Instantiate(org_Drone, startPos, org_Drone.transform.rotation);
        DroneManager _dm = Create_Drone.GetComponent <DroneManager>(); // 드론 오브젝트 내의 원활한 데이터 처리를 위한 클래스를 불러옴.

        _dm.SetPointData(_data);                                       //Point 데이터리스트를 전달
        _dm.SetColor(ColorList[iColorCount++]);                        //Line 색상을 전달
        Create_Drone.name = "Drone" + iNo.ToString();

        return(Create_Drone);
    }
Пример #3
0
 //외부에서 Point 데이터 전달
 public void SetPointData(DronePointData _PointData)
 {
     _DronePointData = _PointData;
 }