FileFormat — Aspose.3D FOSS for Java
Methods
FileFormat dient sowohl als Formatbeschreiber als auch als Register aller unterstützten 3D‑Dateiformate. Jedes Format wird als ein FileFormat Instanz, die als Klassenattribut oder über statische Fabrikmethoden zugänglich ist. Sie übergeben FileFormat Instanzen an Scene.save() um ein bestimmtes Format zu erzwingen, oder verwenden FileFormat.detect() um das Format einer unbekannten Datei zu ermitteln.
Methods: com.aspose.threed
import com.aspose.threed.FileFormat;Unterstützte Formatkonstanten
Formatkonstanten, die im FOSS‑Release aktiv unterstützt werden (Importeure und/oder Exporteure registriert), sind unten aufgeführt.
Aktiv unterstützt (FOSS‑Release)
| Methods | Methods | Methods |
|---|---|---|
FileFormat.WAVEFRONTOBJ | .obj | Public static final Feld (ObjFormat-Instanz) |
FileFormat.GLTF2 | .gltf / .glb | glTF 2.0 und GLB; public static final Feld (GltfFormat-Instanz). Verwenden GltfSaveOptions mit setContentType(FileContentType.BINARY) für GLB-Ausgabe. |
FileFormat.FBX7400ASCII | .fbx | FBX 7.4 ASCII; nur Import (kein Export) |
FileFormat.STL_BINARY | .stl | STL binary (bei Klassenladen gesetzt) |
FileFormat.STLASCII | .stl | STL ASCII |
Methods
FBX Versionen 6100-7700 (binary), Maya ASCII/Binary, Discreet 3DS, Universal 3D, GLTF 1.0, GLTF binary, PDF, Blender, DXF, PLY, X (binary/text), Draco, RVM, ASE, IFC, Siemens JT, AMF, VRML, HTML5, ZIP, USD/USDA/USDZ, XYZ, PCD, PCD binary.
Statische Methoden
| Methods | Rückgabetyp | Methods |
|---|---|---|
FileFormat.detect(InputStream stream, String fileName) | FileFormat | Ermittelt das Format aus einem Dateistream; fileName wird als Hinweis verwendet |
FileFormat.getFormatByExtension(String ext) | FileFormat | Gibt das Format zurück, das zu einer Erweiterungszeichenkette wie passt ".obj", ".glb", ".fbx", ".stl" |
Instanz‑Eigenschaften
| Methods | Methods | Methods | Methods |
|---|---|---|---|
extension | String | getExtension() | Primäre Dateierweiterung (ohne führenden Punkt) |
extensions | List<String> | getExtensions() | Alle von diesem Format unterstützten Erweiterungen |
contentType | String | getContentType() | MIME-Typ-Zeichenkette |
canExport | boolean | getCanExport() | Ob das Exportieren in dieses Format unterstützt wird |
canImport | boolean | getCanImport() | Ob das Importieren aus diesem Format unterstützt wird |
version | String | getVersion() | Formatversionszeichenkette |
Instanz‑Methoden
| Methods | Rückgabetyp | Methods |
|---|---|---|
createLoadOptions() | LoadOptions | Erstellt das passende formatabhängige LoadOptions Unterklasse |
createSaveOptions() | SaveOptions | Erstellt das passende formatabhängige SaveOptions Unterklasse |
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());
}
}