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)

ExampleExampleExample
FileFormat.WAVEFRONT_OBJ().objStatische Methode, die ein ObjFormat Instanz
FileFormat.GLTF2().gltf / .glbglTF 2.0 und GLB zurückgibt; statische Methode, die ein 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 festgelegt)
FileFormat.STLASCII.stlSTL 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

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

Instanz-Eigenschaften

ExampleExampleExampleExample
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

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

Siehe auch

 Deutsch