您的第一个 Aspose.3D 应用程序
Contents
[
Hide
]
本教程介绍如何使用 Aspose.3D 的简单 API 创建您的第一个应用程序。这个简单的应用程序在指定的 3D 场景中创建一个3d文件。
如何创建应用程序
以下步骤使用 Aspose.3D API 创建应用程序:
- 创建 场景 类的实例。
- 如果您有许可证,则为 应用它。 如果您使用的是评估版,请跳过与许可证相关的代码行。
- 创建新的 3D 文件,或打开现有的 3D 文件。
- 访问 3D 文件中的场景内容。
- 生成修改后的 3D 文件。
上述步骤的实现在下面的实施例中演示。
如何新建场景文档
下面的示例从头开始创建一个新的 3D 场景文件。首先,创建一个 3D 场景,然后以 FBX 格式保存文件。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
String MyDir = RunExamples.getDataDir(); | |
MyDir = MyDir + "document.fbx"; | |
// Create an object of the Scene class | |
Scene scene = new Scene(); | |
// Save 3D scene document | |
scene.save(MyDir, FileFormat.FBX7500ASCII); |
如何打开现有文件
下面的示例打开名为 “document.fbx” 的现有 3D 模板文件,然后将 3D 场景或文档以各种支持的 3D 格式保存到流中。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
String MyDir = RunExamples.getDataDir(); | |
// Load a 3D document into Aspose.3D | |
Scene scene = new Scene(); | |
// Open an existing 3D scene | |
scene.open(MyDir + "document.fbx"); | |
// Save Scene to a stream | |
try (MemoryStream dstStream = new MemoryStream()) { | |
scene.save(dstStream, FileFormat.FBX7500ASCII); | |
} | |
// Save Scene to a local path | |
scene.save(MyDir + "output_out.fbx", FileFormat.FBX7500ASCII); |