FileFormat — Aspose.3D FOSS for Java

Methods

FileFormat berfungsi sebagai deskripsi format sekaligus registri semua format file 3D yang didukung. Setiap format direpresentasikan sebagai a FileFormat instance yang dapat diakses sebagai atribut kelas atau melalui metode pabrik statis. Anda mengirim FileFormat instance ke Scene.save() untuk memaksa format tertentu, atau gunakan FileFormat.detect() untuk mengidentifikasi format file yang tidak diketahui.

Methods: com.aspose.threed

import com.aspose.threed.FileFormat;

Konstanta Format yang Didukung

Konstanta format yang secara aktif didukung (importir dan/atau pengekspor terdaftar) dalam rilis FOSS ditampilkan di bawah.

Didukung Secara Aktif (rilis FOSS)

MethodsMethodsMethods
FileFormat.WAVEFRONTOBJ.objField publik statis final (instance ObjFormat)
FileFormat.GLTF2.gltf / .glbglTF 2.0 dan GLB; field publik statis final (instance GltfFormat). Gunakan GltfSaveOptions dengan setContentType(FileContentType.BINARY) untuk output GLB.
FileFormat.FBX7400ASCII.fbxFBX 7.4 ASCII; hanya impor (tidak ada ekspor)
FileFormat.STL_BINARY.stlSTL biner (ditetapkan saat kelas dimuat)
FileFormat.STLASCII.stlSTL ASCII

Methods

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

Metode Statis

MethodsTipe PengembalianMethods
FileFormat.detect(InputStream stream, String fileName)FileFormatMendeteksi format dari aliran file; fileName digunakan sebagai petunjuk
FileFormat.getFormatByExtension(String ext)FileFormatMengembalikan format yang cocok dengan string ekstensi seperti ".obj", ".glb", ".fbx", ".stl"

Properti Instansi

MethodsMethodsMethodsMethods
extensionStringgetExtension()Ekstensi file utama (tanpa titik di depan)
extensionsList<String>getExtensions()Semua ekstensi yang didukung oleh format ini
contentTypeStringgetContentType()String tipe MIME
canExportbooleangetCanExport()Apakah mengekspor ke format ini didukung
canImportbooleangetCanImport()Apakah mengimpor dari format ini didukung
versionStringgetVersion()String versi format

Metode Instansi

MethodsTipe PengembalianMethods
createLoadOptions()LoadOptionsMembuat format-spesifik yang sesuai LoadOptions subkelas
createSaveOptions()SaveOptionsMembuat format-spesifik yang sesuai SaveOptions subkelas

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

Lihat Juga

 Bahasa Indonesia