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 릴리스)

ExampleExampleExample
FileFormat.WAVEFRONT_OBJ().obj인스턴스를 반환하는 정적 메서드 ObjFormat 인스턴스
FileFormat.GLTF2().gltf / .glbglTF 2.0 및 GLB; 인스턴스를 반환하는 정적 메서드 GltfFormat 인스턴스. 사용 GltfSaveOptions 와 함께 setContentType(FileContentType.BINARY) GLB 출력용.
FileFormat.FBX7400ASCII().fbxFBX 7.4 ASCII; 가져오기 전용 (내보내기 없음)
FileFormat.STL_BINARY.stlSTL 바이너리 (클래스 로드 시 설정)
FileFormat.STLASCII.stlSTL 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"

인스턴스 속성

ExampleExampleExampleExample
extensionStringgetExtension()주요 파일 확장자(선행 점 없이)
extensionsList<String>getExtensions()이 형식이 지원하는 모든 확장자
contentTypeStringgetContentType()MIME 타입 문자열
canExportbooleangetCanExport()이 형식으로 내보내기가 지원되는지 여부
canImportbooleangetCanImport()이 형식에서 가져오기가 지원되는지 여부
versionStringgetVersion()형식 버전 문자열

인스턴스 메서드

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

참고

 한국어