FileFormat — Aspose.3D FOSS for Java

Example

FileFormat dient zowel als een formatbeschrijving als een register van alle ondersteunde 3D‑bestandsformaten. Elk format wordt weergegeven als een FileFormat instantie toegankelijk als een klasse‑attribuut of via statische fabrieksmethoden. Je geeft FileFormat instanties aan Scene.save() om een specifiek formaat af te dwingen, of gebruik FileFormat.detect() om het formaat van een onbekend bestand te identificeren.

Example: com.aspose.threed

import com.aspose.threed.FileFormat;

Ondersteunde formatconstanten

Formatconstanten die actief worden ondersteund (importeurs en/of exporteurs geregistreerd) in de FOSS-release worden hieronder weergegeven.

Actief ondersteund (FOSS-release)

ExampleExampleExample
FileFormat.WAVEFRONT_OBJ().objStatische methode die een ObjFormat instantie
FileFormat.GLTF2().gltf / .glbglTF 2.0 en GLB; statische methode die een GltfFormat instance. Gebruik GltfSaveOptions met setContentType(FileContentType.BINARY) voor GLB-uitvoer.
FileFormat.FBX7400ASCII().fbxFBX 7.4 ASCII; alleen importeren (geen export)
FileFormat.STL_BINARY.stlSTL binair (ingesteld bij het laden van de klasse)
FileFormat.STLASCII.stlSTL ASCII

Example

FBX-versies 6100-7700 (binair), Maya ASCII/Binary, Discreet 3DS, Universal 3D, GLTF 1.0, GLTF binary, PDF, Blender, DXF, PLY, X (binair/tekst), Draco, RVM, ASE, IFC, Siemens JT, AMF, VRML, HTML5, ZIP, USD/USDA/USDZ, XYZ, PCD, PCD binary.

Statische methoden

ExampleRetourtypeExample
FileFormat.detect(InputStream stream, String fileName)FileFormatDetecteert het formaat vanuit een bestandsstroom; fileName wordt gebruikt als hint
FileFormat.getFormatByExtension(String ext)FileFormatRetourneert het formaat dat overeenkomt met een extensiestring zoals ".obj", ".glb", ".fbx", ".stl"

Instantie-eigenschappen

ExampleExampleExampleExample
extensionStringgetExtension()Primaire bestandsextensie (zonder voorafgaande punt)
extensionsList<String>getExtensions()Alle extensies die door dit formaat worden ondersteund
contentTypeStringgetContentType()MIME-type string
canExportbooleangetCanExport()Of het exporteren naar dit formaat wordt ondersteund
canImportbooleangetCanImport()Of het importeren vanuit dit formaat wordt ondersteund
versionStringgetVersion()Formaatversiestring

Instantie-methoden

ExampleRetourtypeExample
createLoadOptions()LoadOptionsMaakt de juiste formaat‑specifieke LoadOptions subklasse
createSaveOptions()SaveOptionsMaakt de juiste formaat‑specifieke SaveOptions subklasse

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

Zie ook

 Nederlands