// Generate the mesh of the road
 public void GenerateMesh()
 {
     if (selectedRoad != null)
     {
         GenerateEquidistantPoints();
         selectedRoad.GenerateRoad(RoadMesh.CreateMesh
                                   (
                                       selectedRoad.equidistantPoints,
                                       selectedRoad.RoadWidth,
                                       selectedRoad.IsRingRoad
                                   ),
                                   new Vector2(1, Mathf.RoundToInt(selectedRoad.TextureTiling * selectedRoad.equidistantPoints.Length * selectedRoad.equidistantPointDistance)));
     }
 }
Beispiel #2
0
    public static RoadMesh create(List <RoadSeg> info)
    {
        if (rootObj == null)
        {
            rootObj      = new GameObject().transform;
            rootObj.name = "RoadRoot";
        }
        GameObject obj = new GameObject();

        obj.transform.SetParent(rootObj);
        obj.name = "RoadMesh";
        RoadMesh self = obj.AddComponent <RoadMesh>();

        self.vertices = new List <Vector3>();
        self.uv       = new List <Vector2>();
        self.triang   = new List <int>();
        obj.AddComponent <MeshFilter> ();
        obj.AddComponent <MeshRenderer> ().material = commonObj.mRoadSufM;
        self.addSegments(info);


        return(self);
    }
Beispiel #3
0
 public void ShowObj(bool val, int scale = 100)
 {
     if (menuObj == null && val == true)
     {
         initMenu();
     }
     if (obj == null && val == true)
     {
         if (type == 1)
         {
             obj = pointCloud.create(CppInterface.GetMPList(id));
         }
         if (type == 2)
         {
             obj = KFListObj.create(CppInterface.GetKFList(id), ListId).transform;
         }
         if (type == 3)
         {
             RdSegData = CppInterface.GetRSList(id);
             if (showCount > RdSegData.Count || showCount <= 0)
             {
                 showCount = RdSegData.Count;
             }
             obj = RoadMesh.create(RdSegData.GetRange(0, showCount)).transform;
         }
         if (type == 5)
         {
             ChannelInfo img     = ChannelInfo.getChannel(5, id);
             ChannelInfo feature = ChannelInfo.getChannel(4, id);
             if (img != null)
             {
                 commonObj.mMainUI.updateFrameDisplay(img, feature);
             }
         }
         if (type == 6)
         {
             List <TraficSign> tmp = CppInterface.GetTSList(id);
             if (showCount >= 0 && showCount < tmp.Count)
             {
                 tmp.RemoveRange(showCount, tmp.Count - showCount);
             }
             obj = TraficSignMesh.create(tmp).transform;
         }
         if (type == 7)
         {
             List <ActMapPoint> tmp = CppInterface.GetAMPList(id);
             obj = ActMPMesh.create(tmp);
         }
     }
     if (obj != null)
     {
         obj.gameObject.SetActive(val);
         if (val)
         {
             transform.Find("Text").GetComponent <Text> ().color = getColorFromUI();
         }
         else
         {
             transform.Find("Text").GetComponent <Text> ().color = new Color32(0, 0, 0, 255);
         }
     }
 }
Beispiel #4
0
    // Update is called once per frame
    void Update()
    {
        timerForRecording = timerForRecording + Time.deltaTime;
        updateCurTime     = updateCurTime + Time.deltaTime;

        if (isRecording)
        {
            if (timerForRecording > timeDForRecording)
            {
                timerForRecording = 0;
                string fileName = String.Format("c{0}", recordFrameCount.ToString("D8"));
                Application.CaptureScreenshot("/Volumes/chamo/dataset/vRecord/" + fileName + ".png");
                recordFrameCount++;
            }
        }

        if (curStep < 0)
        {
            return;
        }

        if (isPause)
        {
            if (needOneMoreStep)
            {
                needOneMoreStep = false;
            }
            else
            {
                return;
            }
        }

        if (updateCurTime > timeD)
        {
            updateCurTime = 0;
            int algoType = commonObj.mMainUI.AlgoTypeUI;
            if (algoType == 1)
            {
                ChannelInfo img     = ChannelInfo.getChannel(5, curStep);
                ChannelInfo feature = ChannelInfo.getChannel(4, curStep);
                if (img != null && feature != null)
                {
                    commonObj.mMainUI.updateFrameDisplay(img, feature);
                }
                else
                {
                    if (img == null)
                    {
                        curStep = -1;
                        return;
                    }
                }
                ChannelInfo item;

                item = ChannelInfo.getChannel(2, curStep - 1);
                if (item != null)
                {
                    item.showTog.isOn = false;
                    item.DelObj();
                }
                item = null;
                //item = ChannelInfo.getChannel (1, curStep-1);
                if (item != null)
                {
                    //item.DelObj ();
                    //item.showTog.isOn = false;
                }
                item = null;
                item = ChannelInfo.getChannel(2, curStep);
                if (item != null)
                {
                    item.showTog.isOn = true;
                }
                item = null;
                item = ChannelInfo.getChannel(1, curStep);
                if (item != null)
                {
                    item.showTog.isOn = true;
                }
            }
            if (algoType == 2)
            {
                ChannelInfo item = ChannelInfo.getChannel(3, 0);
                if (item != null)
                {
                    if (curStep == 0)
                    {
                        item.showCount    = 50;
                        item.showTog.isOn = true;
                    }
                    else if (curStep <= 100)
                    {
                        if (item.obj != null)
                        {
                            RoadMesh       roadobj = item.obj.GetComponent <RoadMesh> ();
                            List <RoadSeg> tmpData = item.RdSegData;
                            roadobj.addSegments(tmpData.GetRange(curStep * 20, 22));
                        }
                    }
                    else
                    {
                        item.showCount    = -1;
                        item.showTog.isOn = false;
                        item.DelObj();
                        item.showTog.isOn = true;
                        curStep           = -1;
                    }
                }
            }
            if (algoType == 3)
            {
                if (curStep == 0)
                {
                    commonObj.pausePlayTog.isOn = true;
                    ChannelInfo item = ChannelInfo.getChannel(2, 2);
                    if (item != null)
                    {
                        item.showTog.isOn = true;
                    }
                    item = ChannelInfo.getChannel(1, 2);
                    if (item != null)
                    {
                        item.showTog.isOn = true;
                    }
                }
                if (curStep == 1)
                {
                    ChannelInfo item = ChannelInfo.getChannel(2, 3);
                    if (item != null)
                    {
                        item.showTog.isOn = true;
                    }
                    item = ChannelInfo.getChannel(1, 3);
                    if (item != null)
                    {
                        item.showTog.isOn = true;
                    }
                }
                if (curStep == 2)
                {
                    ChannelInfo item = ChannelInfo.getChannel(2, 3);
                    if (item != null)
                    {
                        item.showTog.isOn = false;
                    }
                    item = ChannelInfo.getChannel(1, 3);
                    if (item != null)
                    {
                        item.showTog.isOn = false;
                    }
                    item = ChannelInfo.getChannel(2, 4);
                    if (item != null)
                    {
                        item.showTog.isOn = true;
                    }
                    item = ChannelInfo.getChannel(1, 4);
                    if (item != null)
                    {
                        item.showTog.isOn = true;
                    }
                }
                if (curStep == 3)
                {
                    ChannelInfo item = ChannelInfo.getChannel(2, 4);
                    if (item != null)
                    {
                        item.showTog.isOn = false;
                    }
                    item = ChannelInfo.getChannel(1, 4);
                    if (item != null)
                    {
                        item.showTog.isOn = false;
                    }
                    item = ChannelInfo.getChannel(2, 2);
                    if (item != null)
                    {
                        item.showTog.isOn = false;
                    }
                    item = ChannelInfo.getChannel(1, 2);
                    if (item != null)
                    {
                        item.showTog.isOn = false;
                    }
                    item = ChannelInfo.getChannel(2, 5);
                    if (item != null)
                    {
                        item.showTog.isOn = true;
                    }
                    item = ChannelInfo.getChannel(1, 5);
                    if (item != null)
                    {
                        item.showTog.isOn = true;
                    }
                }
                if (curStep == 4)
                {
                    ChannelInfo item = ChannelInfo.getChannel(2, 6);
                    if (item != null)
                    {
                        item.showTog.isOn = true;
                    }
                    item = ChannelInfo.getChannel(1, 6);
                    if (item != null)
                    {
                        item.showTog.isOn = true;
                    }
                }
                if (curStep == 5)
                {
                    ChannelInfo item = ChannelInfo.getChannel(2, 6);
                    if (item != null)
                    {
                        item.showTog.isOn = false;
                    }
                    item = ChannelInfo.getChannel(1, 6);
                    if (item != null)
                    {
                        item.showTog.isOn = false;
                    }
                    item = ChannelInfo.getChannel(2, 7);
                    if (item != null)
                    {
                        item.showTog.isOn = true;
                    }
                    item = ChannelInfo.getChannel(1, 7);
                    if (item != null)
                    {
                        item.showTog.isOn = true;
                    }
                }
                if (curStep == 6)
                {
                    ChannelInfo item = ChannelInfo.getChannel(2, 7);
                    if (item != null)
                    {
                        item.showTog.isOn = false;
                    }
                    item = ChannelInfo.getChannel(1, 7);
                    if (item != null)
                    {
                        item.showTog.isOn = false;
                    }
                    item = ChannelInfo.getChannel(2, 5);
                    if (item != null)
                    {
                        item.showTog.isOn = false;
                    }
                    item = ChannelInfo.getChannel(1, 5);
                    if (item != null)
                    {
                        item.showTog.isOn = false;
                    }
                    item = null;
                    item = ChannelInfo.getChannel(2, 8);
                    if (item != null)
                    {
                        item.showTog.isOn = true;
                    }
                    item = ChannelInfo.getChannel(1, 8);
                    if (item != null)
                    {
                        item.showTog.isOn = true;
                    }
                }
            }

            if (algoType == 4)
            {
                ChannelInfo img = ChannelInfo.getChannel(5, curStep + 1);
                if (img != null)
                {
                    commonObj.mMainUI.updateFrameDisplay(img, null);
                    ChannelInfo item = ChannelInfo.getChannel(6, curStep);
                    if (item != null)
                    {
                        item.showTog.isOn           = true;
                        commonObj.pausePlayTog.isOn = true;
                    }
                }
                else
                {
                    curStep = -1;
                    return;
                }
            }
            curStep = curStep + 1;
        }
    }