기능 및 특성

기능 및 특성

이 페이지에서는 모든 주요 기능 영역을 다룹니다 Aspose.3D 26.1.0 작동하는 C# 예제와 함께.


씬 로드 및 저장

Scene.Open() 파일을 로드합니다; Scene.Save() 내보냅니다. 형식은 파일 확장자에서 감지됩니다:

using Aspose.ThreeD;

var scene = new Scene();
scene.Open("input.obj");
scene.Save("output.glb");

정적 팩터리를 사용하십시오 Scene.FromFile() 대안으로:

var scene = Scene.FromFile("input.fbx");
scene.Save("output.stl");

포맷별 옵션

전달합니다 LoadOptions 또는 SaveOptions 세밀한 제어를 위한 서브클래스:

using Aspose.ThreeD;
using Aspose.ThreeD.Formats;

var scene = new Scene();
scene.Open("model.obj", new ObjLoadOptions { FlipCoordinateSystem = true });
scene.Save("model.fbx");

사용 가능한 옵션 클래스:

클래스방향핵심 속성
ObjLoadOptions가져오기FlipCoordinateSystem, EnableMaterials, Scale
ObjSaveOptions내보내기FlipCoordinateSystem, EnableMaterials, PointCloud
FbxLoadOptions가져오기(기본 설정)
GltfLoadOptions가져오기(기본 설정)
GltfSaveOptions내보내기(기본 설정)
StlLoadOptions가져오기(기본 설정)
StlSaveOptions내보내기(기본 설정)
ColladaLoadOptions가져오기FlipCoordinateSystem
ColladaSaveOptions내보내기Indented, TransformStyle
PlyLoadOptions가져오기(기본 설정)

씬 그래프 구축

노드를 생성하고 엔터티를 연결하여 계층 구조를 구축합니다:

var scene = new Scene();
var root = scene.RootNode;

var boxNode = root.CreateChildNode("box", new Box(5, 5, 5));
var sphereNode = root.CreateChildNode("sphere", new Sphere(3));

다음으로 자식에 접근 node.ChildNodes 및 연결된 엔터티를 통해 node.Entity.


메시와 프리미티브

생성 Mesh 프로그래밍 방식으로 제어점 및 폴리곤을 사용하여:

// Mesh.ControlPoints uses Aspose.ThreeD.Utilities.Vector4
// (double-precision, lowercase fields: x, y, z, w)
using Aspose.ThreeD.Utilities;

var mesh = new Mesh("custom");
mesh.ControlPoints.Add(new Vector4(0.0, 0.0, 0.0));   // w defaults to 1.0
mesh.ControlPoints.Add(new Vector4(10.0, 0.0, 0.0));
mesh.ControlPoints.Add(new Vector4(10.0, 10.0, 0.0));
mesh.ControlPoints.Add(new Vector4(0.0, 10.0, 0.0));
mesh.CreatePolygon(0, 1, 2, 3);

내장 프리미티브 (Box, Sphere, Cylinder)를 변환할 수 있습니다 Mesh:

var box = new Box(10, 10, 10);
Mesh boxMesh = box.ToMesh();

버텍스 요소

노멀, UV, 그리고 버텍스 색상을 지오메트리에 연결합니다:

var normals = new VertexElementNormal(MappingMode.ControlPoint, ReferenceMode.Direct);
mesh.AddElement(normals);

사용 가능한 정점 요소 유형: VertexElementNormal, VertexElementUV, VertexElementVertexColor, VertexElementBinormal, VertexElementTangent.


변환

모든 Node 운반한다 TransformTranslation, Rotation, 그리고 Scale:

var node = scene.RootNode.CreateChildNode("moved", new Box());
node.Transform.Translation = new FVector3(10, 0, 5);
node.Transform.Scale = new FVector3(2, 2, 2);

월드 공간 위치를 다음을 통해 읽기 node.GlobalTransform.Matrix 또는 node.EvaluateGlobalTransform().


재질

셰이딩 데이터를 위해 노드에 머티리얼을 할당합니다:

var mat = new PhongMaterial("shiny");
mat.Diffuse = new Vector4(0.8, 0.2, 0.2, 1.0);
mat.Specular = new Vector4(1, 1, 1, 1);
mat.Shininess = 32;

scene.RootNode.CreateChildNode("red_box", new Box(), mat);

재질 유형: LambertMaterial, PhongMaterial, PbrMaterial.


팁 및 모범 사례

  • 사용 Scene.FromFile() 맞춤형이 필요하지 않을 때 한 줄 로드용 LoadOptions
  • 프리미티브를 로 변환 MeshToMesh() 버텍스 요소를 추가하기 전에
  • 사용 GltfSaveOptions 와 함께 .glb 압축된 바이너리 출력을 위한 확장
  • 확인 node.Entity 에 대한 null 캐스팅하기 전에 — 모든 노드가 기하를 가지고 있는 것은 아닙니다
  • 사용 PolygonModifier.Triangulate() STL과 같은 삼각형 전용 포맷으로 내보내기 전에 쿼드 메쉬를 변환

일반적인 문제

문제원인수정
ImportException 로드 시지원되지 않거나 손상된 파일파일이 3D 뷰어에서 열리는지 확인하고, 형식이 지원 목록에 있는지 확인하십시오.
OBJ 로드 후 재질이 누락되었습니다.mtl 파일을 찾을 수 없습니다배치하십시오 .mtl 파일을 .obj 또는 설정하십시오 ObjLoadOptions.EnableMaterials = true
FBX 가져오기 후 스케일 불일치다른 단위 시스템사용하십시오 ObjLoadOptions.Scale 또는 적용하십시오 Transform 로드 후

FAQ

알 수 없는 파일의 포맷을 어떻게 감지하나요?

사용하십시오 FileFormat.Detect():

var format = FileFormat.Detect("unknown_file.bin");
Console.WriteLine(format.Extension);

파일 경로 대신 스트림에서 로드할 수 있나요?

예. Scene.Open() 다음을 허용합니다 Stream:

using var stream = File.OpenRead("model.glb");
scene.Open(stream);

어떤 포맷이 가져오기와 내보내기를 모두 지원하나요?

OBJ, STL, glTF/GLB, FBX, COLLADA, 3MF는 양방향을 지원합니다. PLY는 가져오기만 지원하며 (PLY 내보내기는 연결되어 있지 않습니다).


API 레퍼런스 요약

클래스 / 메서드설명
Scene최상위 3D 씬 컨테이너
Scene.Open()경로나 스트림으로 3D 파일을 로드합니다
Scene.Save()씬을 파일이나 스트림으로 내보냅니다
Scene.FromFile()로드하고 반환하는 정적 팩토리 Scene
Node엔티티와 변환을 보유하는 씬 계층 노드
Node.CreateChildNode()자식 노드를 생성하고 연결합니다
Mesh제어점 및 면 리스트가 있는 폴리곤 메시
Mesh.CreatePolygon()정점 인덱스로 폴리곤 면 정의
Box / Sphere / Cylinder내장 파라메트릭 프리미티브
Transform로컬 이동, 회전 및 스케일
FileFormat지원되는 포맷에 대한 레지스트리 및 탐지기
LambertMaterial / PhongMaterial / PbrMaterial쉐이딩을 위한 재질 유형
 한국어