FileFormat — Aspose.3D FOSS for Java
Example
FileFormat フォーマット記述子として、またサポートされているすべての3Dファイルフォーマットのレジストリとして機能します。各フォーマットは FileFormat クラス属性として、または静的ファクトリーメソッドを通じてアクセス可能なインスタンスです。あなたは FileFormat インスタンスを Scene.save() 特定のフォーマットを強制するために、または使用する FileFormat.detect() 未知のファイルのフォーマットを識別するために使用します。.
Example: com.aspose.threed
import com.aspose.threed.FileFormat;サポートされている形式定数
FOSS リリースで積極的にサポートされている(インポーターおよび/またはエクスポーターが登録されている)形式定数を以下に示します。.
積極的にサポートされている(FOSS リリース)
| Example | Example | Example |
|---|---|---|
FileFormat.WAVEFRONT_OBJ() | .obj | インスタンスを返す静的メソッド ObjFormat インスタンス |
FileFormat.GLTF2() | .gltf / .glb | glTF 2.0 と GLB; インスタンスを返す静的メソッド GltfFormat インスタンス。使用 GltfSaveOptions と setContentType(FileContentType.BINARY) GLB 出力用。. |
FileFormat.FBX7400ASCII() | .fbx | FBX 7.4 ASCII; インポートのみ(エクスポートなし) |
FileFormat.STL_BINARY | .stl | STL バイナリ(クラスロード時に設定) |
FileFormat.STLASCII | .stl | STL ASCII |
Example
FBX バージョン 6100-7700(バイナリ)、Maya ASCII/バイナリ、Discreet 3DS、Universal 3D、GLTF 1.0、GLTF バイナリ、PDF、Blender、DXF、PLY、X(バイナリ/テキスト)、Draco、RVM、ASE、IFC、Siemens JT、AMF、VRML、HTML5、ZIP、USD/USDA/USDZ、XYZ、PCD、PCD バイナリ。.
静的メソッド
| Example | 戻り値の型 | Example |
|---|---|---|
FileFormat.detect(InputStream stream, String fileName) | FileFormat | ファイルストリームからフォーマットを検出します;; fileName ヒントとして使用されます |
FileFormat.getFormatByExtension(String ext) | FileFormat | 拡張子文字列(例:)に一致するフォーマットを返します ".obj", ".glb", ".fbx", ".stl" |
インスタンス プロパティ
| Example | Example | Example | Example |
|---|---|---|---|
extension | String | getExtension() | 主要なファイル拡張子(先頭のドットなし) |
extensions | List<String> | getExtensions() | このフォーマットがサポートするすべての拡張子 |
contentType | String | getContentType() | MIMEタイプ文字列 |
canExport | boolean | getCanExport() | この形式へのエクスポートがサポートされているか |
canImport | boolean | getCanImport() | この形式からのインポートがサポートされているか |
version | String | getVersion() | フォーマットバージョン文字列 |
インスタンス メソッド
| Example | 戻り値の型 | Example |
|---|---|---|
createLoadOptions() | LoadOptions | 適切なフォーマット固有の LoadOptions サブクラス |
createSaveOptions() | SaveOptions | 適切なフォーマット固有の SaveOptions サブクラス |
Example
import com.aspose.threed.Scene;
import com.aspose.threed.FileFormat;
import com.aspose.threed.*;
// Auto-detect and load
Scene scene = Scene.fromFile("model.obj");
// Save with explicit format (force GLB binary)
GltfSaveOptions opts = new GltfSaveOptions();
opts.setContentType(FileContentType.BINARY);
scene.save("output.glb", opts);
// Get format by extension
FileFormat fmt = FileFormat.getFormatByExtension(".fbx");
if (fmt != null) {
System.out.println(fmt.getCanImport()); // true
System.out.println(fmt.getCanExport()); // false (FBX export not available)
}
// Create options from a format instance
FileFormat fmtObj = FileFormat.getFormatByExtension(".obj");
LoadOptions loadOpts = fmtObj.createLoadOptions(); // ObjLoadOptions
SaveOptions saveOpts = fmtObj.createSaveOptions(); // ObjSaveOptions
// Detect format from file stream
try (FileInputStream fis = new FileInputStream("unknown_file.bin")) {
FileFormat detected = FileFormat.detect(fis, "unknown_file.bin");
if (detected != null) {
System.out.println(detected.getClass().getSimpleName());
}
}