public static void ExportRoomToWavefront()
        {
            string selectedFile = EditorUtility.OpenFilePanelWithFilters("Select Room File", MeshSaver.MeshFolderName, new string[] { "Room", "room" });

            if (string.IsNullOrEmpty(selectedFile))
            {
                return;
            }

            string             fileName = Path.GetFileNameWithoutExtension(selectedFile);
            IEnumerable <Mesh> meshes   = null;

            try
            {
                meshes = MeshSaver.Load(fileName);
            }
            catch
            {
                // Handling exceptions, and null returned by MeshSaver.Load, by checking if meshes
                // is still null below.
            }

            if (meshes == null)
            {
                EditorUtility.DisplayDialog(ExportDialogErrorTitle, "Unable to parse selected file.", "Ok");
                return;
            }

            SaveMeshesToWavefront(fileName, meshes);

            // Open the location on where the mesh was saved.
            System.Diagnostics.Process.Start(ExportDirectory);
        }
Esempio n. 2
0
        /// <summary>
        /// Loads the SpatialMapping mesh from the specified file.
        /// </summary>
        /// <param Name="fileName">The Name, without path or extension, of the file to load.</param>
        public void Load(string fileName)
        {
            if (string.IsNullOrEmpty(fileName))
            {
                Debug.Log("No mesh file specified.");
                return;
            }

            Cleanup();

            try
            {
                IList <Mesh> storedMeshes = MeshSaver.Load(fileName);

                for (int iMesh = 0; iMesh < storedMeshes.Count; iMesh++)
                {
                    AddSurfaceObject(CreateSurfaceObject(
                                         mesh: storedMeshes[iMesh],
                                         objectName: "storedmesh-" + iMesh,
                                         parentObject: transform,
                                         meshID: iMesh
                                         ));
                }
            }
            catch
            {
                Debug.Log("Failed to load " + fileName);
            }
        }
        /// <summary>
        /// Loads the SpatialMapping mesh from the specified file.
        /// </summary>
        /// <param name="fileName">The name, without path or extension, of the file to load.</param>
        public void Load(string fileName)
        {
            if (string.IsNullOrEmpty(fileName))
            {
                Debug.Log("No mesh file specified.");
                return;
            }

            Cleanup();

            List <Mesh> storedMeshes = new List <Mesh>();

            try
            {
                storedMeshes.AddRange(MeshSaver.Load(fileName));

                foreach (Mesh mesh in storedMeshes)
                {
                    GameObject surface      = AddSurfaceObject(mesh, "storedmesh-" + SurfaceObjects.Count, transform);
                    Renderer   meshRenderer = surface.GetComponent <MeshRenderer>();

                    if (SpatialMappingManager.Instance.DrawVisualMeshes == false)
                    {
                        meshRenderer.enabled = false;
                    }

                    if (SpatialMappingManager.Instance.CastShadows == false)
                    {
                        meshRenderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
                    }

                    // Reset the surface mesh collider to fit the updated mesh.
                    // Unity tribal knowledge indicates that to change the mesh assigned to a
                    // mesh collider, the mesh must first be set to null.  Presumably there
                    // is a side effect in the setter when setting the shared mesh to null.
                    MeshCollider meshCollider = surface.GetComponent <MeshCollider>();
                    meshCollider.sharedMesh = null;
                    meshCollider.sharedMesh = surface.GetComponent <MeshFilter>().mesh;
                }
            }
            catch
            {
                Debug.Log("Failed to load " + fileName);
            }
        }
Esempio n. 4
0
        private void AnchorStoreReady(WorldAnchorStore store)
        {
            // save instance
            anchorStore = store;

            // load room meshes
            roomMeshes = MeshSaver.Load(fileName) as List <Mesh>;

            foreach (Mesh surface in roomMeshes)
            {
                GameObject obj = Instantiate(surfaceObject) as GameObject;
                obj.GetComponent <MeshFilter>().mesh         = surface;
                obj.GetComponent <MeshCollider>().sharedMesh = surface;

                if (!anchorStore.Load(surface.name, obj))
                {
                    Debug.Log("WorldAnchor load failed...");
                }
            }

            GameObject.Find("GameManager").GetComponent <GameManager>().RoomLoaded();
        }
Esempio n. 5
0
        public static void ExportRoomToWavefront()
        {
            string             fileName = Path.GetFileNameWithoutExtension("MeshModel");
            IEnumerable <Mesh> meshes   = null;

            try {
                meshes = MeshSaver.Load(fileName);
            }
            catch {
                // Handling exceptions, and null returned by MeshSaver.Load, by checking if meshes
                // is still null below.
            }

            if (meshes == null)
            {
                return;
            }

            SaveMeshesToWavefront(fileName, meshes);

            // Open the location on where the mesh was saved.
            //System.Diagnostics.Process.Start(MeshFolderName);
        }