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) پشتیبانی میشوند (واردکنندهها و/یا صادرکنندههای ثبتشده) در زیر نشان داده شدهاند.
پشتیبانی فعال (نسخهٔ متنباز)
| Methods | Methods | Methods |
|---|---|---|
FileFormat.WAVEFRONTOBJ | .obj | فیلد عمومی استاتیک نهایی (نمونه ObjFormat) |
FileFormat.GLTF2 | .gltf / .glb | glTF 2.0 و GLB؛ فیلد عمومی استاتیک نهایی (نمونه GltfFormat). استفاده کنید GltfSaveOptions با setContentType(FileContentType.BINARY) برای خروجی GLB. |
FileFormat.FBX7400ASCII | .fbx | FBX 7.4 ASCII؛ فقط وارد کردن (بدون خروجی) |
FileFormat.STL_BINARY | .stl | STL باینری (در زمان بارگذاری کلاس تنظیم میشود) |
FileFormat.STLASCII | .stl | STL ASCII |
Methods
نسخههای FBX 6100-7700 (باینری)، Maya ASCII/Binary، Discreet 3DS، Universal 3D، GLTF 1.0، GLTF binary، PDF، Blender، DXF، PLY، X (باینری/متن)، 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" |
ویژگیهای نمونه
| Methods | Methods | Methods | Methods |
|---|---|---|---|
extension | String | getExtension() | پسوند اصلی فایل (بدون نقطهٔ پیشرو) |
extensions | List<String> | getExtensions() | تمام پسوندهای پشتیبانیشده توسط این قالب |
contentType | String | getContentType() | رشتهٔ نوع MIME |
canExport | boolean | getCanExport() | آیا خروجی به این قالب پشتیبانی میشود |
canImport | boolean | getCanImport() | آیا وارد کردن از این قالب پشتیبانی میشود |
version | String | getVersion() | رشتهٔ نسخهٔ قالب |
متدهای نمونه
| 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());
}
}