FileFormat — Aspose.3D FOSS for Java

Example

FileFormat služi i kao opis formata i kao registar svih podržanih 3D formata datoteka. Svaki format je predstavljen kao a FileFormat instanca dostupna kao atribut klase ili putem statičkih fabričkih metoda. Prosljeđujete FileFormat instance u Scene.save() da biste nametnuli određeni format, ili koristite FileFormat.detect() da identifikujete format nepoznate datoteke.

Example: com.aspose.threed

import com.aspose.threed.FileFormat;

Podržane konstante formata

Konstantе formata koje su aktivno podržane (registrirani uvoznici i/ili izvoznici) u FOSS izdanju prikazane su ispod.

Aktivno podržano (FOSS izdanje)

ExampleExampleExample
FileFormat.WAVEFRONT_OBJ().objStatička metoda koja vraća an ObjFormat instancu
FileFormat.GLTF2().gltf / .glbglTF 2.0 i GLB; statička metoda koja vraća GltfFormat instancu. Koristite GltfSaveOptions sa setContentType(FileContentType.BINARY) za GLB izlaz.
FileFormat.FBX7400ASCII().fbxFBX 7.4 ASCII; samo uvoz (bez izvoza)
FileFormat.STL_BINARY.stlSTL binarni (postavljeno pri učitavanju klase)
FileFormat.STLASCII.stlSTL ASCII

Example

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

Statičke metode

ExamplePovratni tipExample
FileFormat.detect(InputStream stream, String fileName)FileFormatDetektuje format iz toka fajla; fileName se koristi kao sugestija
FileFormat.getFormatByExtension(String ext)FileFormatVraća format koji odgovara nizu ekstenzija, kao što je ".obj", ".glb", ".fbx", ".stl"

Svojstva instance

ExampleExampleExampleExample
extensionStringgetExtension()Primarna ekstenzija fajla (bez početne tačke)
extensionsList<String>getExtensions()Sve ekstenzije koje podržava ovaj format
contentTypeStringgetContentType()MIME tip string
canExportbooleangetCanExport()Da li je izvoz u ovaj format podržan
canImportbooleangetCanImport()Da li je uvoz iz ovog formata podržan
versionStringgetVersion()String verzije formata

Metode instance

ExampleTip povratne vrednostiExample
createLoadOptions()LoadOptionsKreira odgovarajući format‑specifični LoadOptions podklasu
createSaveOptions()SaveOptionsKreira odgovarajući format‑specifični SaveOptions podklasu

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

Vidi takođe

 Српски