Example #1
0
        public static void SavingDependenciesInMemoryFileSystem()
        {
            // ExStart:SavingDependenciesInMemoryFileSystem
            // The code example uses the MemoryFileSystem to intercepts the dependencies writing.
            // Initialize Scene object
            Scene scene = new Scene();

            // Create a child node
            scene.RootNode.CreateChildNode("sphere", new Sphere()).Material = new PhongMaterial();
            // Set saving options
            ObjSaveOptions   opt = new ObjSaveOptions();
            MemoryFileSystem mfs = new MemoryFileSystem();

            opt.FileSystem = mfs;
            // Save 3D scene
            scene.Save(RunExamples.GetOutputFilePath("SavingDependenciesInMemoryFileSystem_out.obj"), opt);
            // Get the test.mtl file content
            byte[] mtl = mfs.GetFileContent("SavingDependenciesInMemoryFileSystem_out.mtl");
            File.WriteAllBytes(RunExamples.GetOutputFilePath("Material.mtl"), mtl);
            // ExEnd:SavingDependenciesInMemoryFileSystem
        }
 public static void SavingDependenciesInMemoryFileSystem()
 {
     // ExStart:SavingDependenciesInMemoryFileSystem
     // The code example uses the MemoryFileSystem to intercepts the dependencies writing.
     // The path to the documents directory.
     string MyDir = RunExamples.GetDataDir();
     // Initialize Scene object
     Scene scene = new Scene();
     // Create a child node
     scene.RootNode.CreateChildNode("sphere", new Sphere()).Material = new PhongMaterial();
     // Set saving options
     ObjSaveOptions opt = new ObjSaveOptions();
     MemoryFileSystem mfs = new MemoryFileSystem();
     opt.FileSystem = mfs;
     // Save 3D scene
     scene.Save(MyDir + "SavingDependenciesInMemoryFileSystem_out.obj", opt);
     // Get the test.mtl file content
     byte[] mtl = mfs.GetFileContent(MyDir + "test.mtl");
     File.WriteAllBytes( MyDir + "Material.mtl", mtl);
     // ExEnd:SavingDependenciesInMemoryFileSystem
 }