FileFormat — Aspose.3D FOSS for Java
Methods
FileFormat berfungsi sebagai deskripsi format sekaligus registri semua format file 3D yang didukung. Setiap format direpresentasikan sebagai a FileFormat instance yang dapat diakses sebagai atribut kelas atau melalui metode pabrik statis. Anda mengirim FileFormat instance ke Scene.save() untuk memaksa format tertentu, atau gunakan FileFormat.detect() untuk mengidentifikasi format file yang tidak diketahui.
Methods: com.aspose.threed
import com.aspose.threed.FileFormat;Konstanta Format yang Didukung
Konstanta format yang secara aktif didukung (importir dan/atau pengekspor terdaftar) dalam rilis FOSS ditampilkan di bawah.
Didukung Secara Aktif (rilis FOSS)
| Methods | Methods | Methods |
|---|---|---|
FileFormat.WAVEFRONTOBJ | .obj | Field publik statis final (instance ObjFormat) |
FileFormat.GLTF2 | .gltf / .glb | glTF 2.0 dan GLB; field publik statis final (instance GltfFormat). Gunakan GltfSaveOptions dengan setContentType(FileContentType.BINARY) untuk output GLB. |
FileFormat.FBX7400ASCII | .fbx | FBX 7.4 ASCII; hanya impor (tidak ada ekspor) |
FileFormat.STL_BINARY | .stl | STL biner (ditetapkan saat kelas dimuat) |
FileFormat.STLASCII | .stl | STL ASCII |
Methods
FBX versi 6100-7700 (biner), Maya ASCII/Biner, Discreet 3DS, Universal 3D, GLTF 1.0, GLTF biner, PDF, Blender, DXF, PLY, X (biner/teks), Draco, RVM, ASE, IFC, Siemens JT, AMF, VRML, HTML5, ZIP, USD/USDA/USDZ, XYZ, PCD, PCD biner.
Metode Statis
| Methods | Tipe Pengembalian | Methods |
|---|---|---|
FileFormat.detect(InputStream stream, String fileName) | FileFormat | Mendeteksi format dari aliran file; fileName digunakan sebagai petunjuk |
FileFormat.getFormatByExtension(String ext) | FileFormat | Mengembalikan format yang cocok dengan string ekstensi seperti ".obj", ".glb", ".fbx", ".stl" |
Properti Instansi
| Methods | Methods | Methods | Methods |
|---|---|---|---|
extension | String | getExtension() | Ekstensi file utama (tanpa titik di depan) |
extensions | List<String> | getExtensions() | Semua ekstensi yang didukung oleh format ini |
contentType | String | getContentType() | String tipe MIME |
canExport | boolean | getCanExport() | Apakah mengekspor ke format ini didukung |
canImport | boolean | getCanImport() | Apakah mengimpor dari format ini didukung |
version | String | getVersion() | String versi format |
Metode Instansi
| Methods | Tipe Pengembalian | Methods |
|---|---|---|
createLoadOptions() | LoadOptions | Membuat format-spesifik yang sesuai LoadOptions subkelas |
createSaveOptions() | SaveOptions | Membuat format-spesifik yang sesuai SaveOptions subkelas |
Methods
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());
}
}