Load and Save Options

Load and Save Options — Aspose.3D FOSS for Java

Properties

所有导入和导出操作都接受一个可选的 options 对象,派生自 LoadOptionsSaveOptions. 将适当的子类传递给 Scene.open()Scene.save() 以控制特定格式的行为。.

Properties: com.aspose.threed

import com.aspose.threed.*;

LoadOptions

所有 load-option 对象的基类。Extends A3DObject.

PropertiesPropertiesPropertiesProperties
fileFormatFileFormatgetFileFormat()此配置关联的格式(只读)

SaveOptions

所有 save-option 对象的基类。Extends A3DObject.


ObjLoadOptions

Wavefront OBJ 文件的加载选项(.obj).

ObjLoadOptions opts = new ObjLoadOptions(); opts.setFlipCoordinateSystem(true); opts.setScale(0.01); Scene scene = new Scene(); scene.open(“model.obj”, opts);


| Properties             | Properties | Properties                  | Properties                         | Properties | Properties        |
| ---------------------- | ---------- | --------------------------- | ---------------------------------- | ---------- | ----------------- |
| `flipCoordinateSystem` | `boolean`  | `getFlipCoordinateSystem()` | `setFlipCoordinateSystem(boolean)` | `false`    | 导入时翻转坐标系          |
| `enableMaterials`      | `boolean`  | `getEnableMaterials()`      | `setEnableMaterials(boolean)`      | `true`     | 加载随附的 `.mtl` 材质文件 |
| `scale`                | `double`   | `getScale()`                | `setScale(double)`                 | `1.0`      | 对所有导入的几何体应用统一缩放   |
| `normalizeNormal`      | `boolean`  | `getNormalizeNormal()`      | `setNormalizeNormal(boolean)`      | `true`     | 将导入的法向量归一化为单位长度   |

---

## ObjSaveOptions

Wavefront OBJ 文件的保存选项。.



ObjSaveOptions opts = new ObjSaveOptions();
opts.setEnableMaterials(false);
scene.save("output.obj", opts);
PropertiesPropertiesPropertiesPropertiesPropertiesProperties
applyUnitScalebooleangetApplyUnitScale()setApplyUnitScale(boolean)false将场景的单位缩放因子应用于导出的坐标
pointCloudbooleangetPointCloud()setPointCloud(boolean)false仅导出顶点(不包括多边形面)
verbosebooleangetVerbose()setVerbose(boolean)false在输出中包含额外的 OBJ 注释
serializeWbooleangetSerializeW()setSerializeW(boolean)false写入控制点的 W 分量
enableMaterialsbooleangetEnableMaterials()setEnableMaterials(boolean)true写入 a .mtl 材质文件并从中引用它 .obj
flipCoordinateSystembooleangetFlipCoordinateSystem()setFlipCoordinateSystem(boolean)false在导出时翻转坐标系

GltfLoadOptions

加载 glTF 2.0 和 GLB 文件的选项(.gltf, .glb).

GltfLoadOptions opts = new GltfLoadOptions(); opts.setFlipCoordinateSystem(true); Scene scene = new Scene(); scene.open(“model.gltf”, opts);


| Properties             | Properties | Properties                  | Properties                         | Properties | Properties              |
| ---------------------- | ---------- | --------------------------- | ---------------------------------- | ---------- | ----------------------- |
| `flipCoordinateSystem` | `boolean`  | `getFlipCoordinateSystem()` | `setFlipCoordinateSystem(boolean)` | `false`    | 在导入时翻转坐标系               |
| `prettyPrint`          | `boolean`  | `getPrettyPrint()`          | `setPrettyPrint(boolean)`          | `false`    | 格式化输出 JSON,使其带有缩进以提高可读性 |

---

## GltfSaveOptions

glTF 2.0 和 GLB 输出的保存选项。.

```java
import com.aspose.threed.*;
import com.aspose.threed.FileContentType;

// Save as glTF JSON
GltfSaveOptions opts = new GltfSaveOptions();
scene.save("output.gltf", opts);

// Save as GLB (binary glTF)
GltfSaveOptions glbOpts = new GltfSaveOptions();
glbOpts.setContentType(FileContentType.BINARY);
scene.save("output.glb", glbOpts);
PropertiesPropertiesPropertiesPropertiesPropertiesProperties
contentTypeFileContentTypegetContentType()setContentType(FileContentType)FileContentType.ASCII设置为 FileContentType.BINARY 以生成一个自包含的 GLB 文件;设置为 FileContentType.ASCII 用于 JSON .gltf 使用外部缓冲区
flipCoordinateSystembooleangetFlipCoordinateSystem()setFlipCoordinateSystem(boolean)false在导出时翻转坐标系
prettyPrintbooleangetPrettyPrint()setPrettyPrint(boolean)false使用缩进格式化输出 JSON,以提高可读性
bufferFilePrefixStringgetBufferFilePrefix()setBufferFilePrefix(String)null外部缓冲区文件名的前缀
saveExtrasStringgetSaveExtras()setSaveExtras(String)null在 glTF 输出中包含的自定义 extras 数据

StlLoadOptions

STL 文件的加载选项(.stl).

StlLoadOptions opts = new StlLoadOptions(); opts.setFlipCoordinateSystem(true); Scene scene = new Scene(); scene.open(“part.stl”, opts);


| Properties             | Properties        | Properties                  | Properties                         | Properties | Properties           |
| ---------------------- | ----------------- | --------------------------- | ---------------------------------- | ---------- | -------------------- |
| `flipCoordinateSystem` | `boolean`         | `getFlipCoordinateSystem()` | `setFlipCoordinateSystem(boolean)` | `false`    | 导入时翻转坐标系             |
| `recalculateNormal`    | `boolean`         | `getRecalculateNormal()`    | `setRecalculateNormal(boolean)`    | `false`    | 导入时根据几何体重新计算法线       |
| `contentType`          | `FileContentType` | `getContentType()`          | `setContentType(FileContentType)`  | --         | 二进制与 ASCII STL 检测的提示 |

---

## StlSaveOptions

STL 输出的保存选项。.



StlSaveOptions opts = new StlSaveOptions();
opts.setContentType(FileContentType.BINARY);
scene.save("output.stl", opts);
PropertiesPropertiesPropertiesPropertiesPropertiesProperties
flipCoordinateSystembooleangetFlipCoordinateSystem()setFlipCoordinateSystem(boolean)false导出时翻转坐标系
axisSystemAxisSystemgetAxisSystem()setAxisSystem(AxisSystem)导出时覆盖目标轴系
contentTypeFileContentTypegetContentType()setContentType(FileContentType)FileContentType.BINARY设置为 BINARYASCII 用于控制输出格式

FbxLoadOptions

加载 FBX 文件的选项(.fbx).

FbxLoadOptions opts = new FbxLoadOptions(); opts.setFlipCoordinateSystem(true); Scene scene = new Scene(); scene.open(“animation.fbx”, opts);


| Properties             | Properties | Properties                  | Properties                         | Properties | Properties |
| ---------------------- | ---------- | --------------------------- | ---------------------------------- | ---------- | ---------- |
| `flipCoordinateSystem` | `boolean`  | `getFlipCoordinateSystem()` | `setFlipCoordinateSystem(boolean)` | `false`    | 导入时翻转坐标系   |

---

## FbxSaveOptions

**注意::** FBX 导出是 **不可用** 在 Java FOSS 版中。FBX 仅支持导入。该 `FbxSaveOptions` class 在 API 中存在,但如果用于保存会产生错误。请改用 OBJ、STL、glTF 或 GLB 进行导出。.

---

## 另见

- [FileFormat 类参考](/3d/java/file-format/)
- [Scene 类参考](/3d/java/scene/)
 中文