public static Object3D drawTrafficSign(Vector3 pos)
 {
     Object3D obj = new Object3D();
     obj.name = "Traffic Light";
     obj.type = ObjectType.TrafficSign;
     obj.resourcePath = "Prefabs/CityRelated/Prefabs/TrafficLight1Prefab";
     obj.object3D = (GameObject)MonoBehaviour.Instantiate(Resources.Load("Prefabs/CityRelated/Prefabs/TrafficLight1Prefab"));
     obj.object3D.AddComponent<Object3dMouseHandler>();
     obj.object3D.transform.position = pos + new Vector3(0.2f, 2.0f, -0.2f);
     obj.object3D.tag = "3DObject";
     obj.object3D.name = "Traffic Light";
     return obj;
 }
        private static Object3D drawDrinkingFountain(Node nd)
        {
            Object3D obj = new Object3D();
            obj.id = nd.id;
            obj.name = "Drinking Fountain";
            obj.type = ObjectType.Default;
            obj.resourcePath = "Prefabs/Environment/Prefabs/Fountain2";
            obj.object3D = (GameObject)MonoBehaviour.Instantiate(Resources.Load(obj.resourcePath));
            obj.object3D.AddComponent<Object3dMouseHandler>();
            obj.object3D.transform.position = nd.meterPosition;
            obj.object3D.tag = "3DObject";
            obj.object3D.name = "Drinking Fountain";

            return obj;
        }
        public static Object3D drawStreetLamp(Vector3 pos, string id)
        {
            Object3D obj = new Object3D();
            obj.id = id;
            obj.name = "Street Lamp";
            obj.type = ObjectType.Tree;
            obj.resourcePath = "Prefabs/CityRelated/Prefabs/StreetLampPrefab";
            obj.object3D = (GameObject)MonoBehaviour.Instantiate(Resources.Load(obj.resourcePath));
            obj.object3D.AddComponent<Object3dMouseHandler>();
            obj.object3D.transform.position = pos;
            obj.object3D.tag = "3DObject";
            obj.object3D.name = "Street Lamp";

            return obj;
        }
Exemplo n.º 4
0
        private static Object3D drawDrinkingFountain(Node nd)
        {
            Object3D obj = new Object3D();

            obj.id           = nd.id;
            obj.name         = "Drinking Fountain";
            obj.type         = ObjectType.Default;
            obj.resourcePath = "Prefabs/Environment/Prefabs/Fountain2";
            obj.object3D     = (GameObject)MonoBehaviour.Instantiate(Resources.Load(obj.resourcePath));
            obj.object3D.AddComponent <Object3dMouseHandler>();
            obj.object3D.transform.position = nd.meterPosition;
            obj.object3D.tag  = "3DObject";
            obj.object3D.name = "Drinking Fountain";

            return(obj);
        }
Exemplo n.º 5
0
        private static Object3D drawPhoneBox(Node nd)
        {
            Object3D obj = new Object3D();

            obj.id           = nd.id;
            obj.name         = "Phone Box";
            obj.type         = ObjectType.Default;
            obj.resourcePath = "Prefabs/CityRelated/Prefabs/PhoneBoxPrefab";
            obj.object3D     = (GameObject)MonoBehaviour.Instantiate(Resources.Load(obj.resourcePath));
            obj.object3D.AddComponent <Object3dMouseHandler>();
            obj.object3D.transform.position = nd.meterPosition;
            obj.object3D.tag  = "3DObject";
            obj.object3D.name = "Phone Box";

            return(obj);
        }
Exemplo n.º 6
0
        private static Object3D drawTree(Node nd)
        {
            Object3D obj = new Object3D();

            obj.id           = nd.id;
            obj.name         = "Broad Leaf Tree";
            obj.type         = ObjectType.Tree;
            obj.resourcePath = "Prefabs/Environment/Prefabs/BroadLeafDesktop";
            obj.object3D     = (GameObject)MonoBehaviour.Instantiate(Resources.Load(obj.resourcePath));
            obj.object3D.AddComponent <Object3dMouseHandler>();
            obj.object3D.transform.position = nd.meterPosition;
            obj.object3D.tag  = "3DObject";
            obj.object3D.name = "Broad Leaf Tree";

            return(obj);
        }
Exemplo n.º 7
0
        public static Object3D drawStreetLamp(Vector3 pos, string id)
        {
            Object3D obj = new Object3D();

            obj.id           = id;
            obj.name         = "Street Lamp";
            obj.type         = ObjectType.Tree;
            obj.resourcePath = "Prefabs/CityRelated/Prefabs/StreetLampPrefab";
            obj.object3D     = (GameObject)MonoBehaviour.Instantiate(Resources.Load(obj.resourcePath));
            obj.object3D.AddComponent <Object3dMouseHandler>();
            obj.object3D.transform.position = pos;
            obj.object3D.tag  = "3DObject";
            obj.object3D.name = "Street Lamp";

            return(obj);
        }
        void Update()
        {
            if (fbd.state == myFileBrowserDialog.BrowserState.Selected)
            {
                LoadExternalOBJ loader = new LoadExternalOBJ();

                Transform camera = GameObject.Find("Main Camera").transform;
                Vector3 position = camera.position + camera.forward * 10.0f;

                Object3D obj = new Object3D();
                obj.type = ObjectType.External;
                obj.resourcePath = fbd.selectedPath;
                try
                {
                    obj.object3D = loader.loadOBJ(fbd.selectedPath);
                }
                catch (Exception ex)
                {
                    Debug.Log("<color=red>LOADER ERROR</color> " + ex.Message);
                    fbd.state = myFileBrowserDialog.BrowserState.None;
                    return;
                }
                obj.object3D.tag = "3DObject";
                obj.object3D.AddComponent<Object3dMouseHandler>();
                obj.object3D.transform.position = position;

                LoadSaveMenu lsm = GameObject.Find("Canvas").transform.Find("LoadSave Menu").GetComponent<LoadSaveMenu>();
                lsm.scene.object3DList.Add(obj);

                fbd.state = myFileBrowserDialog.BrowserState.None;
            }
        }
        private void selectItem(Text prefabPath,Text name, ObjectType type)
        {
            Transform camera = GameObject.Find("Main Camera").transform;
            Vector3 position = camera.position + camera.forward * 10.0f;

            Object3D obj = new Object3D();
            obj.name = name.text;
            obj.type = type;
            obj.resourcePath = prefabPath.text;
            obj.object3D = (GameObject)Instantiate(Resources.Load(prefabPath.text));
            obj.object3D.tag = "3DObject";
            obj.object3D.name = name.text;
            obj.object3D.AddComponent<Object3dMouseHandler>();
            obj.object3D.transform.position = position;

            LoadSaveMenu lsm = GameObject.Find("Canvas").transform.Find("LoadSave Menu").GetComponent<LoadSaveMenu>();
            lsm.scene.object3DList.Add(obj);
            this.gameObject.SetActive(false);
        }
        private static Object3D drawPhoneBox(Node nd)
        {
            Object3D obj = new Object3D();
            obj.id = nd.id;
            obj.name = "Phone Box";
            obj.type = ObjectType.Default;
            obj.resourcePath = "Prefabs/CityRelated/Prefabs/PhoneBoxPrefab";
            obj.object3D = (GameObject)MonoBehaviour.Instantiate(Resources.Load(obj.resourcePath));
            obj.object3D.AddComponent<Object3dMouseHandler>();
            obj.object3D.transform.position = nd.meterPosition;
            obj.object3D.tag = "3DObject";
            obj.object3D.name = "Phone Box";

            return obj;
        }
        private static Object3D drawTree(Node nd)
        {
            Object3D obj = new Object3D();
            obj.id = nd.id;
            obj.name = "Broad Leaf Tree";
            obj.type = ObjectType.Tree;
            obj.resourcePath = "Prefabs/Environment/Prefabs/BroadLeafDesktop";
            obj.object3D = (GameObject)MonoBehaviour.Instantiate(Resources.Load(obj.resourcePath));
            obj.object3D.AddComponent<Object3dMouseHandler>();
            obj.object3D.transform.position = nd.meterPosition;
            obj.object3D.tag = "3DObject";
            obj.object3D.name = "Broad Leaf Tree";

            return obj;
        }
Exemplo n.º 12
0
        /// <summary>
        /// Load urban scene using a save file
        /// </summary>
        /// <param name="save"> Save file object </param>
        public void loadProject(SceneSave save)
        {
            List <Way> WayListforHighway  = new List <Way>();
            List <Way> WayListforBuilding = new List <Way>();

            InitialConfigLoader configloader = new InitialConfigLoader();

            OSMPath = save.osmPath;
            OSMparser parser = new OSMparser();

            scenebbox = parser.readBBox(save.osmPath);
            scenebbox = editbbox(scenebbox);
            config    = configloader.loadInitialConfig(); //--> Maybe it is better to include config to SaveProject file

            HeightmapLoader heightMap = new HeightmapLoader(scenebbox, save.continent);

            terrain = new myTerrain(heightMap, scenebbox, save.osmPath, save.provider);
            osmxml  = parser.parseOSM(save.osmPath);
            assignNodePositions();

            defaultObject3DList = DefaultObject3DHandler.drawDefaultObjects(osmxml.defaultobject3DList);

            LoadExternalOBJ objloader = new LoadExternalOBJ();

            //3D OBJECT LOAD
            for (int i = 0; i < save.objectSaveList.Count; i++)
            {
                Object3D obj = new Object3D();
                obj.name = save.objectSaveList[i].name;

                if (save.objectSaveList[i].type == ObjectType.External)
                {
                    obj.object3D = objloader.loadOBJ(save.objectSaveList[i].resourcePath);
                }
                else
                {
                    obj.object3D = (GameObject)MonoBehaviour.Instantiate(Resources.Load(save.objectSaveList[i].resourcePath));
                }
                obj.object3D.AddComponent <Object3dMouseHandler>();
                obj.resourcePath = save.objectSaveList[i].resourcePath;
                obj.object3D.transform.position   = save.objectSaveList[i].translate;
                obj.object3D.transform.localScale = save.objectSaveList[i].scale;
                Quaternion quat = new Quaternion();
                quat.eulerAngles = save.objectSaveList[i].rotate;
                obj.object3D.transform.rotation = quat;
                obj.object3D.name = obj.name;
                obj.object3D.tag  = "3DObject";
                object3DList.Add(obj);
            }

            for (int k = 0; k < osmxml.wayList.Count; k++)
            {
                Way w = osmxml.wayList[k];

                switch (w.type)
                {
                case ItemEnumerator.wayType.building:
                    WayListforBuilding.Add(w);
                    break;

                case ItemEnumerator.wayType.highway:
                    WayListforHighway.Add(w);
                    break;

                case ItemEnumerator.wayType.area:
                    break;

                case ItemEnumerator.wayType.barrier:
                    barrierList.Add(new Barrier(w, config.barrierConfig));
                    break;

                case ItemEnumerator.wayType.river:
                    highwayList.Add(new Highway(w, config.highwayConfig, terrain));
                    break;

                case ItemEnumerator.wayType.none:
                    break;
                }
            }

            highwayModeller = new HighwayModeller(WayListforHighway, terrain, config.highwayConfig, save.highwaySaveList);
            highwayModeller.renderHighwayList();
            highwayModeller.renderPavementList();
            highwayList  = highwayModeller.highwayList;
            pavementList = highwayModeller.pavementList;

            BuildingListModeller buildingListModeller = new BuildingListModeller(WayListforBuilding, osmxml.buildingRelations, config.buildingConfig, save.buildingSaveList);

            buildingListModeller.renderBuildingList();
            buildingList = buildingListModeller.buildingList;

            if (save.controller == null)
            {
                return;
            }

            if (save.controller.controllerType == ControllerSave.ControllerType.CameraVan)
            {
                Transform        mainCamera    = GameObject.Find("Main Camera").transform;
                CameraController camController = mainCamera.GetComponent <CameraController>();

                controller = (GameObject)GameObject.Instantiate(Resources.Load("Prefabs/Car/PolimiCameraCar/CameraVan"));
                controller.AddComponent <CameraVanMouseHandler>();
                controller.tag  = "CameraVan";
                controller.name = "Camera Van";
                controller.transform.position = mainCamera.position + mainCamera.forward * 10.0f;
                controller.GetComponent <Rigidbody>().useGravity = false;
                camController.target = controller.transform;
            }

            else
            {
                Transform        mainCamera    = GameObject.Find("Main Camera").transform;
                CameraController camController = mainCamera.GetComponent <CameraController>();

                controller = (GameObject)GameObject.Instantiate(Resources.Load("Prefabs/Ethan/ThirdPersonController"));
                controller.AddComponent <CameraVanMouseHandler>();
                controller.tag  = "CameraVan";
                controller.name = "Third Person (Ethan)";
                controller.transform.position = mainCamera.position + mainCamera.forward * 10.0f;
                camController.target          = controller.transform;
            }

            controller.transform.position = save.controller.controllerPosition;
            Quaternion controllerQuat = new Quaternion();

            controllerQuat.eulerAngles    = save.controller.controllerRotation;
            controller.transform.rotation = controllerQuat;

            CameraVanEdit cve = GameObject.Find("Canvas").transform.Find("CameraVanEdit").GetComponent <CameraVanEdit>();

            cve.cameraList   = save.controller.convertBackToCamList(save.controller.cameraSettings);
            cve.laserScanner = save.controller.convertBackToLaser(save.controller.laserSetting);
        }