您的第一个 Aspose.3D 应用程序

如何创建应用程序

以下步骤使用 Aspose.3D API 创建应用程序:

  1. 创建 场景 类的实例。
  2. 如果您有许可证,则为 应用它。 如果您使用的是评估版,请跳过与许可证相关的代码行。
  3. 创建新的 3D 文件,或打开现有的 3D 文件。
  4. 访问 3D 文件中的场景内容。
  5. 生成修改后的 3D 文件。

上述步骤的实现在下面的实施例中演示。

如何新建场景文档

下面的示例从头开始创建一个新的 3D 场景文件。首先,创建一个 3D 场景,然后以 FBX 格式保存文件。

// 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 格式保存到流中。

// 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);