-
Notifications
You must be signed in to change notification settings - Fork 2
/
import_sit.py
31 lines (23 loc) · 892 Bytes
/
import_sit.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
29
30
31
import bpy
from struct import unpack
from . import shared
def load(context, filepath):
with open(filepath, 'rb') as f:
(version,) = unpack('<i', f.read(4))
assert version == 2, 'Unknown file version.'
# Texture file name
f.read(64)
vertices = []
faces = []
vertex_uvs = []
(vertex_count,) = unpack('<i', f.read(4))
for _ in range(vertex_count):
vertices.append(unpack('<fff', f.read(4 * 3)))
vertex_uvs.append(unpack('<ff', f.read(4 * 2)))
(face_count,) = unpack('<i', f.read(4))
for _ in range(face_count):
vertex_indices = unpack('<iii', f.read(4 * 3))[::-1]
faces.append(vertex_indices)
name = bpy.path.display_name_from_filepath(filepath)
shared.load_mesh(context, name, vertices, faces, vertex_uvs)
return {'FINISHED'}