FileFormat — Aspose.3D FOSS for Java

Methods

FileFormat ทำหน้าที่เป็นทั้งตัวบรรยายรูปแบบและทะเบียนของรูปแบบไฟล์ 3D ที่รองรับทั้งหมด แต่ละรูปแบบจะถูกแทนด้วย FileFormat อินสแตนซ์ที่เข้าถึงได้เป็นแอตทริบิวต์ของคลาสหรือผ่านเมธอดแฟกทอรีแบบสแตติก คุณส่ง FileFormat อินสแตนซ์ไปยัง Scene.save() เพื่อบังคับรูปแบบเฉพาะ หรือใช้ FileFormat.detect() เพื่อระบุรูปแบบของไฟล์ที่ไม่ทราบ.

Methods: com.aspose.threed

import com.aspose.threed.FileFormat;

ค่าคงที่รูปแบบที่รองรับ

ค่าคงที่รูปแบบที่ได้รับการสนับสนุนอย่างเต็มที่ (ผู้นำเข้าและ/หรือผู้ส่งออกที่ลงทะเบียน) ในรุ่น FOSS แสดงด้านล่าง.

สนับสนุนอย่างเต็มที่ (รุ่น FOSS)

MethodsMethodsMethods
FileFormat.WAVEFRONTOBJ.objฟิลด์สาธารณะ static final (อินสแตนซ์ ObjFormat)
FileFormat.GLTF2.gltf / .glbglTF 2.0 และ GLB; ฟิลด์สาธารณะ static final (อินสแตนซ์ GltfFormat) ใช้ GltfSaveOptions กับ setContentType(FileContentType.BINARY) สำหรับการส่งออกเป็น GLB.
FileFormat.FBX7400ASCII.fbxFBX 7.4 ASCII; รองรับการนำเข้าเท่านั้น (ไม่มีการส่งออก)
FileFormat.STL_BINARY.stlSTL binary (ตั้งค่าเมื่อโหลดคลาส)
FileFormat.STLASCII.stlSTL ASCII

Methods

FBX เวอร์ชัน 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.

เมธอดสแตติก

Methodsประเภทการคืนค่าMethods
FileFormat.detect(InputStream stream, String fileName)FileFormatตรวจจับรูปแบบจากสตรีมไฟล์; fileName ใช้เป็นคำแนะนำ
FileFormat.getFormatByExtension(String ext)FileFormatคืนค่ารูปแบบที่ตรงกับสตริงส่วนขยายเช่น ".obj", ".glb", ".fbx", ".stl"

คุณสมบัติของอินสแตนซ์

MethodsMethodsMethodsMethods
extensionStringgetExtension()ส่วนขยายไฟล์หลัก (ไม่มีจุดนำหน้า)
extensionsList<String>getExtensions()ส่วนขยายทั้งหมดที่รองรับโดยรูปแบบนี้
contentTypeStringgetContentType()สตริงประเภท MIME
canExportbooleangetCanExport()ว่าการส่งออกเป็นรูปแบบนี้ได้รับการสนับสนุนหรือไม่
canImportbooleangetCanImport()ว่าการนำเข้าจากรูปแบบนี้ได้รับการสนับสนุนหรือไม่
versionStringgetVersion()สตริงเวอร์ชันของรูปแบบ

เมธอดของอินสแตนซ์

Methodsประเภทการคืนค่าMethods
createLoadOptions()LoadOptionsสร้างที่เหมาะสมตามฟอร์แมต LoadOptions คลาสย่อย
createSaveOptions()SaveOptionsสร้างที่เหมาะสมตามฟอร์แมต SaveOptions คลาสย่อย

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

ดูเพิ่มเติม

 ภาษาไทย