FileFormat — Aspose.3D FOSS for Java
Example
FileFormat 포맷 설명자이자 지원되는 모든 3D 파일 포맷의 레지스트리 역할을 합니다. 각 포맷은 FileFormat 클래스 속성으로 접근하거나 정적 팩토리 메서드를 통해 사용할 수 있는 인스턴스입니다. 당신은 FileFormat 인스턴스를 Scene.save() 특정 포맷을 강제하기 위해, 혹은 사용합니다 FileFormat.detect() 알 수 없는 파일의 포맷을 식별하기 위해.
Example: com.aspose.threed
import com.aspose.threed.FileFormat;지원되는 형식 상수
FOSS 릴리스에서 적극적으로 지원되는(importers 및/또는 exporters가 등록된) 형식 상수는 아래에 표시됩니다.
적극적으로 지원됨 (FOSS 릴리스)
| 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 (바이너리), Maya ASCII/바이너리, Discreet 3DS, Universal 3D, GLTF 1.0, GLTF 바이너리, PDF, Blender, DXF, PLY, X (바이너리/텍스트), Draco, RVM, ASE, IFC, Siemens JT, AMF, VRML, HTML5, ZIP, USD/USDA/USDZ, XYZ, PCD, PCD 바이너리.
정적 메서드
| 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());
}
}