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)

MethodsMethodsMethods
FileFormat.WAVEFRONTOBJ.objPublic static final Feld (ObjFormat-Instanz)
FileFormat.GLTF2.gltf / .glbglTF 2.0 und GLB; public static final Feld (GltfFormat-Instanz). Verwenden GltfSaveOptions mit setContentType(FileContentType.BINARY) für GLB-Ausgabe.
FileFormat.FBX7400ASCII.fbxFBX 7.4 ASCII; nur Import (kein Export)
FileFormat.STL_BINARY.stlSTL binary (bei Klassenladen gesetzt)
FileFormat.STLASCII.stlSTL 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

MethodsRückgabetypMethods
FileFormat.detect(InputStream stream, String fileName)FileFormatErmittelt das Format aus einem Dateistream; fileName wird als Hinweis verwendet
FileFormat.getFormatByExtension(String ext)FileFormatGibt das Format zurück, das zu einer Erweiterungszeichenkette wie passt ".obj", ".glb", ".fbx", ".stl"

Instanz‑Eigenschaften

MethodsMethodsMethodsMethods
extensionStringgetExtension()Primäre Dateierweiterung (ohne führenden Punkt)
extensionsList<String>getExtensions()Alle von diesem Format unterstützten Erweiterungen
contentTypeStringgetContentType()MIME-Typ-Zeichenkette
canExportbooleangetCanExport()Ob das Exportieren in dieses Format unterstützt wird
canImportbooleangetCanImport()Ob das Importieren aus diesem Format unterstützt wird
versionStringgetVersion()Formatversionszeichenkette

Instanz‑Methoden

MethodsRückgabetypMethods
createLoadOptions()LoadOptionsErstellt das passende formatabhängige LoadOptions Unterklasse
createSaveOptions()SaveOptionsErstellt 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());
    }
}

Siehe auch

 Deutsch