FileFormat — Aspose.3D FOSS for Java

Example

FileFormat slúži ako opis formátu aj ako register všetkých podporovaných 3D formátov súborov. Každý formát je reprezentovaný ako a FileFormat inštancia prístupná ako atribút triedy alebo prostredníctvom statických továrenských metód. Predáte FileFormat inštancie do Scene.save() na vynútenie konkrétneho formátu, alebo použite FileFormat.detect() na identifikáciu formátu neznámeho súboru.

Example: com.aspose.threed

import com.aspose.threed.FileFormat;

Podporované konštanty formátov

Konštanty formátov, ktoré sú aktívne podporované (importéry a/alebo exportéry zaregistrované) vo vydaní FOSS, sú uvedené nižšie.

Aktívne podporované (vydanie FOSS)

ExampleExampleExample
FileFormat.WAVEFRONT_OBJ().objStatická metóda vracajúca ObjFormat inštanciu
FileFormat.GLTF2().gltf / .glbglTF 2.0 a GLB; statická metóda vracajúca a GltfFormat inštancia. Použiť GltfSaveOptions s setContentType(FileContentType.BINARY) pre výstup GLB.
FileFormat.FBX7400ASCII().fbxFBX 7.4 ASCII; iba import (žiadny export)
FileFormat.STL_BINARY.stlSTL binárny (nastavené pri načítaní triedy)
FileFormat.STLASCII.stlSTL ASCII

Example

FBX verzie 6100-7700 (binárne), Maya ASCII/Binárny, Discreet 3DS, Universal 3D, GLTF 1.0, GLTF binárny, PDF, Blender, DXF, PLY, X (binárny/text), Draco, RVM, ASE, IFC, Siemens JT, AMF, VRML, HTML5, ZIP, USD/USDA/USDZ, XYZ, PCD, PCD binárny.

Statické metódy

ExampleNávratový typExample
FileFormat.detect(InputStream stream, String fileName)FileFormatZistí formát zo súborového prúdu; fileName sa používa ako nápoveda
FileFormat.getFormatByExtension(String ext)FileFormatVráti formát zodpovedajúci reťazcu prípony, napríklad ".obj", ".glb", ".fbx", ".stl"

Vlastnosti inštancie

ExampleExampleExampleExample
extensionStringgetExtension()Primárna prípona súboru (bez úvodnej bodky)
extensionsList<String>getExtensions()Všetky prípony podporované týmto formátom
contentTypeStringgetContentType()Reťazec typu MIME
canExportbooleangetCanExport()Či je export do tohto formátu podporovaný
canImportbooleangetCanImport()Či je import z tohto formátu podporovaný
versionStringgetVersion()Reťazec verzie formátu

Metódy inštancie

ExampleNávratový typExample
createLoadOptions()LoadOptionsVytvára príslušný formátovo-špecifický LoadOptions podtrieda
createSaveOptions()SaveOptionsVytvára príslušný formátovo-špecifický SaveOptions podtrieda

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

Pozri tiež

 Slovenčina