Beispiel #1
0
        public static void DiscardSavingMaterial()
        {
            // ExStart:DiscardSavingMaterial
            // The code example uses the DummyFileSystem, so the material files are not created.
            // 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();

            opt.FileSystem = new DummyFileSystem();
            // Save 3D scene
            scene.Save(RunExamples.GetOutputFilePath("DiscardSavingMaterial_out.obj"), opt);
            // ExEnd:DiscardSavingMaterial
        }
Beispiel #2
0
        public static void SavingDependenciesInLocalDirectory()
        {
            // ExStart:SavingDependenciesInLocalDirectory
            // The code example uses the LocalFileSystem class to save dependencies to the local directory.
            string dataDir = 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();

            opt.FileSystem = new LocalFileSystem(dataDir);
            // Save 3D scene
            scene.Save(RunExamples.GetOutputFilePath("SavingDependenciesInLocalDirectory_out.obj"), opt);
            // ExEnd:SavingDependenciesInLocalDirectory
        }
Beispiel #3
0
        public static void ObjSaveOption()
        {
            // ExStart:ObjSaveOption
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir();
            // Initialize an object
            ObjSaveOptions saveObjOpts = new ObjSaveOptions();

            // Import materials from external material library file
            saveObjOpts.EnableMaterials = true;
            // Flip the coordinate system.
            saveObjOpts.FlipCoordinateSystem = true;
            // Configure the look up paths to allow importer to find external dependencies.
            saveObjOpts.LookupPaths = new List <string>(new string[] { dataDir });
            // Serialize W component in model's vertex position
            saveObjOpts.SerializeW = true;
            // Generate comments for each section
            saveObjOpts.Verbose = true;
            // ExEnd:ObjSaveOption
        }
Beispiel #4
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 ObjSaveOption()
 {
     // ExStart:ObjSaveOption
     // The path to the documents directory.
     string MyDir = RunExamples.GetDataDir();
     // Initialize an object
     ObjSaveOptions saveObjOpts = new ObjSaveOptions();
     // Import materials from external material library file
     saveObjOpts.EnableMaterials = true;
     // Flip the coordinate system.
     saveObjOpts.FlipCoordinateSystem = true;
     // Configure the look up paths to allow importer to find external dependencies.
     saveObjOpts.LookupPaths = new List<string>(new string[] { MyDir });
     // Serialize W component in model's vertex position
     saveObjOpts.SerializeW = true;
     // Generate comments for each section
     saveObjOpts.Verbose = true;
     // ExEnd:ObjSaveOption
 }
 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
 }
 public static void SavingDependenciesInLocalDirectory()
 {
     // ExStart:SavingDependenciesInLocalDirectory
     // The code example uses the LocalFileSystem class to save dependencies to the local directory.
     // 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();
     opt.FileSystem = new LocalFileSystem(MyDir);
     // Save 3D scene
     scene.Save(MyDir + "SavingDependenciesInLocalDirectory_out.obj", opt);
     // ExEnd:SavingDependenciesInLocalDirectory
 }
 public static void DiscardSavingMaterial()
 {
     // ExStart:DiscardSavingMaterial
     // The code example uses the DummyFileSystem, so the material files are not created.
     // 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();
     opt.FileSystem = new DummyFileSystem();
     // Save 3D scene
     scene.Save(MyDir + "DiscardSavingMaterial_out.obj", opt);
     // ExEnd:DiscardSavingMaterial
 }
Beispiel #9
0
        ///<Summary>
        /// Convert3dToFormat method to convert 3d to other format
        ///</Summary>
        public Response Convert3dToFormat(string fileName, string folderName, string outputType)
        {
            SaveOptions saveOptions     = null;
            bool        foundSaveOption = true;
            bool        createZip       = false;

            switch (outputType)
            {
            case "fbx":
                saveOptions = new FBXSaveOptions(Aspose.ThreeD.FileFormat.FBX7500Binary);
                break;

            case "obj":
                saveOptions = new ObjSaveOptions();
                break;

            case "3ds":
                saveOptions = new Discreet3DSSaveOptions();
                break;

            case "drc":
                saveOptions = new DracoSaveOptions();
                break;

            case "amf":
                saveOptions = new AMFSaveOptions();
                break;

            case "rvm":
                saveOptions = new RvmSaveOptions();
                break;

            case "dae":
                saveOptions = new ColladaSaveOptions();
                break;

            case "gltf":
                saveOptions = new GLTFSaveOptions(FileContentType.ASCII);
                createZip   = true;
                break;

            case "glb":
                saveOptions = new GLTFSaveOptions(FileContentType.Binary);
                break;

            case "pdf":
                saveOptions = new PdfSaveOptions();
                break;

            case "html":
                saveOptions = new HTML5SaveOptions();
                createZip   = true;
                break;

            case "ply":
                saveOptions = new PlySaveOptions();
                break;

            case "stl":
                saveOptions = new STLSaveOptions();
                break;

            case "u3d":
                saveOptions = new U3DSaveOptions();
                break;

            case "att":
                RvmSaveOptions att = new RvmSaveOptions();
                att.ExportAttributes = true;
                saveOptions          = att;
                break;

            default:
                foundSaveOption = false;
                break;
            }

            if (foundSaveOption)
            {
                return(ProcessTask(fileName, folderName, "." + outputType, createZip, false, delegate(string inFilePath, string outPath, string zipOutFolder)
                {
                    Scene scene = new Scene(inFilePath);
                    scene.Save(outPath, saveOptions);
                }));
            }
            else
            {
                return(new Response
                {
                    FileName = null,
                    Status = "Output type not found",
                    StatusCode = 500
                });
            }
        }