3D 通过 C# 进行格式转换
无需任何3D建模和渲染软件即可转换 3D 文档格式以构建跨平台.NET应用程序。
开发人员可以使用 3D 图形库轻松读取、创建、转换、更新和控制 3D 格式的内容。 API 支持的格式很少是 WavefrontOBJ、Discreet3DS、STL(ASCII、二进制)、FBX(ASCII、二进制)、Universal3D、Collada、GLB、glTF、PLY、DirectX、Google Draco 格式等。转换过程很容易通过实例加载源文件 场景类 ,并使用相关的输出格式参数调用 Save 方法。
将 3D 场景转换为各种格式
开发人员可以通过上面列出的相同过程轻松转换 3D 场景。考虑几个例子,例如 FBX 到 OBJ 转换。通过场景类对象加载 FBX 文件。使用创建保存选项 对象保存选项 并调用具有输出文件路径和 obj 选项作为参数的场景保存方法。 API 具有适当的选项类,用于保存到相关类中,例如 A3dwSaveOptions AmfSave 选项 Discreet3dsSaveOptions FbxSaveOptions Html5SaveOptions RvmSaveOptions 和更多。这是 3D 的完整列表 转换格式 选项。此外,开发人员可以轻松地将 3D 场景保存到 PDF。
C# FBX 到 OBJ 转换的代码
// Load the FBX in an object of Scene | |
var fbxtoObj = new Aspose.ThreeD.Scene("sourceTemplate.fbx"); | |
// create an instance of ObjSaveOptions | |
var objOptions = new Aspose.ThreeD.Formats.ObjSaveOptions(); | |
// save FBX as a OBJ | |
fbxtoObj.Save("csharp-fbx-to.obj", objOptions); |
C# 将 3D 场景转换为 PDF 的代码
// For complete examples and data files, please go to https://github.com/aspose-3d/Aspose.3D-for-.NET | |
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir(); | |
// Create a new scene | |
Scene scene = new Scene(); | |
// Create a cylinder child node | |
scene.RootNode.CreateChildNode("cylinder", new Cylinder()).Material = new PhongMaterial() { DiffuseColor = new Vector3(Color.DarkCyan) }; | |
// Set rendering mode and lighting scheme | |
PdfSaveOptions opt = new PdfSaveOptions(); | |
opt.LightingScheme = PdfLightingScheme.CAD; | |
opt.RenderMode = PdfRenderMode.ShadedIllustration; | |
// Save in the PDF format | |
scene.Save(MyDir + "output_out.pdf", opt); |