FileFormat — Aspose.3D FOSS for Java
Methods
FileFormat służy zarówno jako opis formatu, jak i rejestr wszystkich obsługiwanych formatów plików 3D. Każdy format jest reprezentowany jako FileFormat instancja dostępna jako atrybut klasy lub poprzez statyczne metody fabryczne. Przekazujesz FileFormat instancje do Scene.save() aby wymusić konkretny format, lub użyj FileFormat.detect() do zidentyfikowania formatu nieznanego pliku.
Methods: com.aspose.threed
import com.aspose.threed.FileFormat;Stałe formatów obsługiwanych
Stałe formatów, które są aktywnie wspierane (zarejestrowane importery i/lub eksportery) w wydaniu FOSS, są pokazane poniżej.
Aktywnie wspierane (wydanie FOSS)
| Methods | Methods | Methods |
|---|---|---|
FileFormat.WAVEFRONTOBJ | .obj | Public static final field (instancja ObjFormat) |
FileFormat.GLTF2 | .gltf / .glb | glTF 2.0 i GLB; public static final field (instancja GltfFormat). Użyj GltfSaveOptions z setContentType(FileContentType.BINARY) dla wyjścia GLB. |
FileFormat.FBX7400ASCII | .fbx | FBX 7.4 ASCII; tylko import (bez eksportu) |
FileFormat.STL_BINARY | .stl | STL binarny (ustawiany przy ładowaniu klasy) |
FileFormat.STLASCII | .stl | STL ASCII |
Methods
Wersje FBX 6100-7700 (binarny), Maya ASCII/Binary, Discreet 3DS, Universal 3D, GLTF 1.0, GLTF binarny, PDF, Blender, DXF, PLY, X (binarny/tekstowy), Draco, RVM, ASE, IFC, Siemens JT, AMF, VRML, HTML5, ZIP, USD/USDA/USDZ, XYZ, PCD, PCD binarny.
Metody statyczne
| Methods | Typ zwracany | Methods |
|---|---|---|
FileFormat.detect(InputStream stream, String fileName) | FileFormat | Wykrywa format z strumienia pliku; fileName jest używany jako podpowiedź |
FileFormat.getFormatByExtension(String ext) | FileFormat | Zwraca format pasujący do ciągu rozszerzenia, takiego jak ".obj", ".glb", ".fbx", ".stl" |
Właściwości instancji
| Methods | Methods | Methods | Methods |
|---|---|---|---|
extension | String | getExtension() | Podstawowe rozszerzenie pliku (bez wiodącej kropki) |
extensions | List<String> | getExtensions() | Wszystkie rozszerzenia obsługiwane przez ten format |
contentType | String | getContentType() | Ciąg typu MIME |
canExport | boolean | getCanExport() | Czy eksport do tego formatu jest obsługiwany |
canImport | boolean | getCanImport() | Czy import z tego formatu jest obsługiwany |
version | String | getVersion() | Ciąg wersji formatu |
Metody instancji
| Methods | Typ zwracany | Methods |
|---|---|---|
createLoadOptions() | LoadOptions | Tworzy odpowiedni specyficzny dla formatu LoadOptions podklasa |
createSaveOptions() | SaveOptions | Tworzy odpowiedni specyficzny dla formatu SaveOptions podklasa |
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());
}
}