FileFormat — Aspose.3D FOSS for Java
Example
FileFormat dient sowohl als Formatbeschreiber als auch als Register aller unterstützten 3D‑Dateiformate. Jedes Format wird dargestellt 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 Sie FileFormat.detect() um das Format einer unbekannten Datei zu ermitteln.
Example: 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)
| Example | Example | Example |
|---|---|---|
FileFormat.WAVEFRONT_OBJ() | .obj | Statische Methode, die ein ObjFormat Instanz |
FileFormat.GLTF2() | .gltf / .glb | glTF 2.0 und GLB zurückgibt; statische Methode, die ein 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 festgelegt) |
FileFormat.STLASCII | .stl | STL ASCII |
Example
FBX-Versionen 6100-7700 (binär), Maya ASCII/Binär, Discreet 3DS, Universal 3D, GLTF 1.0, GLTF binär, PDF, Blender, DXF, PLY, X (binär/Text), Draco, RVM, ASE, IFC, Siemens JT, AMF, VRML, HTML5, ZIP, USD/USDA/USDZ, XYZ, PCD, PCD binär.
Statische Methoden
| Example | Rückgabetyp | Example |
|---|---|---|
FileFormat.detect(InputStream stream, String fileName) | FileFormat | Erkennt 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 ".obj", ".glb", ".fbx", ".stl" |
Instanz-Eigenschaften
| Example | Example | Example | Example |
|---|---|---|---|
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
| Example | Rückgabetyp | Example |
|---|---|---|
createLoadOptions() | LoadOptions | Erstellt das passende formatabhängige LoadOptions Unterklasse |
createSaveOptions() | SaveOptions | Erstellt das passende formatabhängige SaveOptions Unterklasse |
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());
}
}