Exemple #1
0
    private GSDRoad CreateNewRoad(List <Vector3> nodeList, int numLanes)
    {
        GSDRoad road = GSDRoadAutomation.CreateRoad_Programmatically(roadSystem, ref nodeList);

        //Debug.Log("CreateNewRoad: " + nodeList[0].y);

        /*for (int i = 0; i < road.GSDSpline.mNodes.Count - 1; i++)
         * {
         *  //road.GSDSpline.mNodes[i].LoadWizardObjectsFromLibrary("GSDGroup-KRailLights-6L", true, false);
         *  //road.GSDSpline.mNodes[i].LoadWizardObjectsFromLibrary("GSDGroup-Fancy1-6L", true, false);
         * }*/

        //road.opt_bIsLightmapped = true; // These are just a quick way to edit the road
        //road.opt_bIsStatic = true;
        road.opt_Lanes = numLanes;
        //road.opt_ClearDetailsDistance = 36;

        roadSystem.opt_bAllowRoadUpdates = false;
        //roadSystem.UpdateAllRoads();

        return(road);
    }
Exemple #2
0
    static void CreateRoadNetwork(GSDRoadSystem roadSystem, string netPath, int roadNum)
    {
        for (int i = 1; i <= roadNum; i++)
        {
            string fileName = netPath + "/Road" + i.ToString();

            StreamReader reader = new StreamReader(fileName);
            string       line   = reader.ReadLine();

            List <Vector3> nodePos = new List <Vector3>();
            while (line != null)
            {
                string[] words = line.Split(',');
                nodePos.Add(new Vector3(float.Parse(words[0]), float.Parse(words[1]), float.Parse(words[2])));
                line = reader.ReadLine();
            }
            reader.Close();

            GSDRoad tmpRoad = null;
            tmpRoad = GSDRoadAutomation.CreateRoad_Programmatically(roadSystem, ref nodePos);

            // TODO: the generation of intersection doesn't work very well at this point
            // Weizi: seems like an intersection will only get created when two nodes are within 3.3 distance
            //GSDRoadAutomation.CreateIntersections_ProgrammaticallyForRoad(tmpRoad, GSDRoadIntersection.iStopTypeEnum.TrafficLight1, GSDRoadIntersection.RoadTypeEnum.NoTurnLane); // GSDRoadIntersection.iStopTypeEnum.TrafficLight2 doesn't work
        }


        ///////////////////////////
        // Debug file reading
        ///////////////////////////

        /*int hCount = nodePos.Count;
         * Debug.Log(hCount.ToString());
         * for (int i = 0; i < hCount; i++)
         * {
         *  string ot = nodePos[i].x.ToString() + " " + nodePos[i].y.ToString() + " " + nodePos[i].z.ToString() + "\n";
         *  Debug.Log(ot);
         * }*/


        ///////////////////////////
        // Test road and intersection creation by manually specifying some road nodes
        ///////////////////////////

        /*float StartLocX = 800f;
         * float StartLocZ = 200f;
         * float GapZ = 200f;
         * float tHeight = 0.03f;
         * GSDRoad bRoad = null;
         *
         *
         * // Create roads
         * List<Vector3> nodePos = new List<Vector3>();
         * for (int i = 0; i < 5; i++)
         * {
         *  nodePos.Add(new Vector3(StartLocX + (i * 200f), tHeight, 600f));
         * }
         * bRoad = GSDRoadAutomation.CreateRoad_Programmatically(roadSystem, ref nodePos);
         *
         * nodePos.Clear();
         * for (int i = 0; i < 5; i++)
         * {
         *  nodePos.Add(new Vector3(StartLocX, tHeight, StartLocZ + (i * GapZ) + 3.3f));
         * }
         * bRoad = GSDRoadAutomation.CreateRoad_Programmatically(roadSystem, ref nodePos);
         *
         * // Create intersections (TrafficLight2 doesn't work)
         * // Weizi: seems like an intersection will only get created when two nodes are within 3.3 distance
         * GSDRoadAutomation.CreateIntersections_ProgrammaticallyForRoad(bRoad, GSDRoadIntersection.iStopTypeEnum.TrafficLight1, GSDRoadIntersection.RoadTypeEnum.NoTurnLane);*/
    }