FileFormat — Aspose.3D FOSS for Java
Example
FileFormat एक format descriptor और सभी समर्थित 3D फ़ाइल फ़ॉर्मेट्स के registry दोनों के रूप में कार्य करता है। प्रत्येक फ़ॉर्मेट को एक FileFormat इंस्टेंस जो class attribute के रूप में या static factory methods के माध्यम से सुलभ है। आप पास FileFormat इंस्टेंस को Scene.save() एक विशिष्ट फ़ॉर्मेट को बाध्य करने के लिए, या उपयोग करें FileFormat.detect() एक अज्ञात फ़ाइल के फ़ॉर्मेट की पहचान करने के लिए।.
Example: com.aspose.threed
import com.aspose.threed.FileFormat;समर्थित फ़ॉर्मेट स्थिरांक
FOSS रिलीज़ में सक्रिय रूप से समर्थित (importers और/या exporters पंजीकृत) format constants नीचे दिखाए गए हैं।.
सक्रिय रूप से समर्थित (FOSS release)
| Example | Example | Example |
|---|---|---|
FileFormat.WAVEFRONT_OBJ() | .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 |
Example
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.
स्थैतिक विधियाँ
| Example | रिटर्न टाइप | Example |
|---|---|---|
FileFormat.detect(InputStream stream, String fileName) | FileFormat | फ़ाइल स्ट्रीम से फ़ॉर्मेट का पता लगाता है; fileName संकेत के रूप में उपयोग किया जाता है |
FileFormat.getFormatByExtension(String ext) | FileFormat | एक एक्सटेंशन स्ट्रिंग जैसे से मेल खाने वाला फ़ॉर्मेट लौटाता है ".obj", ".glb", ".fbx", ".stl" |
इंस्टेंस प्रॉपर्टीज़
| Example | Example | Example | Example |
|---|---|---|---|
extension | String | getExtension() | प्राथमिक फ़ाइल एक्सटेंशन (शुरुआती डॉट के बिना) |
extensions | List<String> | getExtensions() | इस फ़ॉर्मेट द्वारा समर्थित सभी एक्सटेंशन |
contentType | String | getContentType() | MIME टाइप स्ट्रिंग |
canExport | boolean | getCanExport() | क्या इस फ़ॉर्मेट में निर्यात समर्थित है |
canImport | boolean | getCanImport() | क्या इस फ़ॉर्मेट से आयात समर्थित है |
version | String | getVersion() | फ़ॉर्मेट संस्करण स्ट्रिंग |
इंस्टेंस मेथड्स
| Example | रिटर्न टाइप | Example |
|---|---|---|
createLoadOptions() | LoadOptions | उपयुक्त फ़ॉर्मेट-विशिष्ट बनाता है LoadOptions सबक्लास |
createSaveOptions() | SaveOptions | उपयुक्त फ़ॉर्मेट-विशिष्ट बनाता है SaveOptions सबक्लास |
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());
}
}