-
Notifications
You must be signed in to change notification settings - Fork 0
/
save_fbx.py
28 lines (22 loc) · 922 Bytes
/
save_fbx.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import pyassimp
import numpy as np
def save(point_cloud, triangle_mesh):
scene = pyassimp.structs.scene.Scene()
cloud_node = pyassimp.structs.Node("PointCloud")
mesh_node = pyassimp.structs.Node("TriangleMesh")
# Add the point cloud vertices to the mesh node
cloud_mesh = pyassimp.structs.Mesh(
vertices=np.asarray(point_cloud.points, dtype=np.float32)
)
mesh_node.meshes.append(cloud_mesh)
# Add the triangle mesh to the mesh node
mesh_mesh = pyassimp.structs.Mesh(
vertices=np.asarray(triangle_mesh.vertices, dtype=np.float32),
faces=np.asarray(triangle_mesh.triangles, dtype=np.uint32)
)
mesh_node.meshes.append(mesh_mesh)
# Add the nodes to the scene
scene.rootnode.children.append(cloud_node)
scene.rootnode.children.append(mesh_node)
# Export the scene to an FBX file
pyassimp.export(scene, "output.fbx", file_type="fbx")