FileFormat — Aspose.3D FOSS for Java

Methods

FileFormat fungerar både som en formatbeskrivning och ett register över alla stödda 3D‑filformat. Varje format representeras som en FileFormat instans som är tillgänglig som ett klassattribut eller via statiska fabriksmetoder. Du skickar FileFormat instanser till Scene.save() för att tvinga ett specifikt format, eller använd FileFormat.detect() för att identifiera ett okänt fils format.

Methods: com.aspose.threed

import com.aspose.threed.FileFormat;

Stödda formatkonstanter

Formatkonstanter som aktivt stöds (importörer och/eller exportörer registrerade) i FOSS‑utgåvan visas nedan.

Aktivt stödda (FOSS‑utgåva)

MethodsMethodsMethods
FileFormat.WAVEFRONTOBJ.objPublikt statiskt finalfält (ObjFormat-instans)
FileFormat.GLTF2.gltf / .glbglTF 2.0 och GLB; publikt statiskt finalfält (GltfFormat-instans). Använd GltfSaveOptions med setContentType(FileContentType.BINARY) för GLB-utdata.
FileFormat.FBX7400ASCII.fbxFBX 7.4 ASCII; endast import (ingen export)
FileFormat.STL_BINARY.stlSTL binär (sätts vid klassladdning)
FileFormat.STLASCII.stlSTL ASCII

Methods

FBX versioner 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.

Statiska metoder

MethodsReturtypMethods
FileFormat.detect(InputStream stream, String fileName)FileFormatDetekterar formatet från en filström; fileName används som en ledtråd
FileFormat.getFormatByExtension(String ext)FileFormatReturnerar formatet som matchar en filändelse-sträng såsom ".obj", ".glb", ".fbx", ".stl"

Instansegenskaper

MethodsMethodsMethodsMethods
extensionStringgetExtension()Primär filändelse (utan inledande punkt)
extensionsList<String>getExtensions()Alla filändelser som stöds av detta format
contentTypeStringgetContentType()MIME-typsträng
canExportbooleangetCanExport()Om export till detta format stöds
canImportbooleangetCanImport()Om import från detta format stöds
versionStringgetVersion()Formatversionssträng

Instansmetoder

MethodsReturtypMethods
createLoadOptions()LoadOptionsSkapar den lämpliga format‑specifika LoadOptions subklass
createSaveOptions()SaveOptionsSkapar den lämpliga format‑specifika SaveOptions subklass

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());
    }
}

Se även

 Svenska