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)

MethodsMethodsMethods
FileFormat.WAVEFRONTOBJ.objPublic static final field (instancja ObjFormat)
FileFormat.GLTF2.gltf / .glbglTF 2.0 i GLB; public static final field (instancja GltfFormat). Użyj GltfSaveOptions z setContentType(FileContentType.BINARY) dla wyjścia GLB.
FileFormat.FBX7400ASCII.fbxFBX 7.4 ASCII; tylko import (bez eksportu)
FileFormat.STL_BINARY.stlSTL binarny (ustawiany przy ładowaniu klasy)
FileFormat.STLASCII.stlSTL 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

MethodsTyp zwracanyMethods
FileFormat.detect(InputStream stream, String fileName)FileFormatWykrywa format z strumienia pliku; fileName jest używany jako podpowiedź
FileFormat.getFormatByExtension(String ext)FileFormatZwraca format pasujący do ciągu rozszerzenia, takiego jak ".obj", ".glb", ".fbx", ".stl"

Właściwości instancji

MethodsMethodsMethodsMethods
extensionStringgetExtension()Podstawowe rozszerzenie pliku (bez wiodącej kropki)
extensionsList<String>getExtensions()Wszystkie rozszerzenia obsługiwane przez ten format
contentTypeStringgetContentType()Ciąg typu MIME
canExportbooleangetCanExport()Czy eksport do tego formatu jest obsługiwany
canImportbooleangetCanImport()Czy import z tego formatu jest obsługiwany
versionStringgetVersion()Ciąg wersji formatu

Metody instancji

MethodsTyp zwracanyMethods
createLoadOptions()LoadOptionsTworzy odpowiedni specyficzny dla formatu LoadOptions podklasa
createSaveOptions()SaveOptionsTworzy 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());
    }
}

Zobacz także

 Polski