Hello everyone.

The Mixed Reality Forums here are no longer being used or maintained.

There are a few other places we would like to direct you to for support, both from Microsoft and from the community.

The first way we want to connect with you is our mixed reality developer program, which you can sign up for at https://aka.ms/IWantMR.

For technical questions, please use Stack Overflow, and tag your questions using either hololens or windows-mixed-reality.

If you want to join in discussions, please do so in the HoloDevelopers Slack, which you can join by going to https://aka.ms/holodevelopers, or in our Microsoft Tech Communities forums at https://techcommunity.microsoft.com/t5/mixed-reality/ct-p/MicrosoftMixedReality.

And always feel free to hit us up on Twitter @MxdRealityDev.
Options

Saving mesh from HoloLens emulator - 230

I've been trying to save a .room file from the HoloLens emulator, as described in the 230 tutorial - https://developer.microsoft.com/en-us/windows/holographic/holograms_230

The tutorial uses an actual HoloLens, but I assume it should be possible from the emulator as well (using one of the loaded xef rooms in the emulator). I have been unable to get it to work (I'm thinking it might be a network thing). Has anyone tried this and been successful?

Answers

  • Options

    Get your meshes from the spatialmappingmanager
    SpatialMappingManager.Instance.GetMeshes()

    public static string Save(string fileName, IEnumerable<Mesh> meshes)
        {
            if (string.IsNullOrEmpty(fileName))
            {
                throw new ArgumentException("Must specify a valid fileName.");
            }
    
            if (meshes == null)
            {
                throw new ArgumentNullException("Value of meshes cannot be null.");
            }
    
            // Create the mesh file.
            String folderName = MeshFolderName;
            Debug.Log(String.Format("Saving mesh file: {0}", Path.Combine(folderName, fileName + fileExtension)));
    
            using (Stream stream = OpenFileForWrite(folderName, fileName + fileExtension))
            {
                // Serialize and write the meshes to the file.
                byte[] data = SimpleMeshSerializer.Serialize(meshes);
                stream.Write(data, 0, data.Length);
                stream.Flush();
            }
    
            Debug.Log("Mesh file saved.");
    
            return Path.Combine(folderName, fileName + fileExtension);
        }
    
  • Options

    @Calzaretta said:
    Get your meshes from the spatialmappingmanager
    SpatialMappingManager.Instance.GetMeshes()

    public static string Save(string fileName, IEnumerable<Mesh> meshes)
        {
            if (string.IsNullOrEmpty(fileName))
            {
                throw new ArgumentException("Must specify a valid fileName.");
            }
    
            if (meshes == null)
            {
                throw new ArgumentNullException("Value of meshes cannot be null.");
            }
    
            // Create the mesh file.
            String folderName = MeshFolderName;
            Debug.Log(String.Format("Saving mesh file: {0}", Path.Combine(folderName, fileName + fileExtension)));
    
            using (Stream stream = OpenFileForWrite(folderName, fileName + fileExtension))
            {
                // Serialize and write the meshes to the file.
                byte[] data = SimpleMeshSerializer.Serialize(meshes);
                stream.Write(data, 0, data.Length);
                stream.Flush();
            }
    
            Debug.Log("Mesh file saved.");
    
            return Path.Combine(folderName, fileName + fileExtension);
        }
    

    The code seems not working? my .obj file cannot show models

          using (Stream stream = new FileStream(Application.persistentDataPath+ "/Room.obj", FileMode.Create, FileAccess.Write, FileShare.None))
                {
                    // Serialize and write the meshes to the file.
                    byte[] data = SimpleMeshSerializer.Serialize(meshes);
                    stream.Write(data, 0, data.Length);
                    stream.Flush();
                }
    
Sign In or Register to comment.