示例#1
0
        /// <summary>
        /// Save the 3D scene to HTML5 document
        /// This method is supported by version 19.9 or greater.
        /// </summary>
        public static void Html5SaveOption()
        {
            // ExStart:HtmlSaveOption
            // Initialize 3D scene
            var scene = new Scene();
            // Create a child node
            var node = scene.RootNode.CreateChildNode(new Cylinder());

            // Set child node properites
            node.Material = new LambertMaterial()
            {
                DiffuseColor = new Vector3(Color.Chartreuse)
            };
            scene.RootNode.CreateChildNode(new Light()
            {
                LightType = LightType.Point
            }).Transform.Translation = new Vector3(10, 0, 10);
            // Create a HTML5SaveOptions
            var opt = new HTML5SaveOptions();

            //Turn off the grid
            opt.ShowGrid = false;
            //Turn off the user interface
            opt.ShowUI = false;
            // Save 3D to HTML5
            scene.Save(RunExamples.GetOutputFilePath("HtmlSaveOption.html"), opt);
            // ExEnd:HtmlSaveOption
        }
示例#2
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
                });
            }
        }