Example #1
0
 def parse_chunk_triangles(self, chunk):
     parser = BinaryReader(chunk)
     ghost_vertices = []
     num_ghost_vertices = parser.read_unsigned_int32()
     for i in range(num_ghost_vertices):
         ghost_vertex = parser.read_vec3_float32()
         ghost_vertices.append(ghost_vertex)
     smoothed_normals = []
     num_smoothed_normals = parser.read_unsigned_int32()
     for i in range(num_smoothed_normals):
         smoothed_normal = parser.read_vec3_float32()
         smoothed_normals.append(smoothed_normal)
     num_faces = parser.read_unsigned_int32()
     num_triangles = parser.read_unsigned_int32()
     triangles = {"total": num_triangles, "faces": []}
     for i in range(num_faces):
         triangles["faces"].append([])
         num_face_triangles = parser.read_unsigned_int32()
         for j in range(num_face_triangles):
             vertex_index1 = parser.read_unsigned_int32()
             vertex_index2 = parser.read_unsigned_int32()
             vertex_index3 = parser.read_unsigned_int32()
             smoothed_normal_index1 = parser.read_unsigned_int32()
             smoothed_normal_index2 = parser.read_unsigned_int32()
             smoothed_normal_index3 = parser.read_unsigned_int32()
             triangles["faces"][i].append({
                 "vi_1": vertex_index1,
                 "vi_2": vertex_index2,
                 "vi_3": vertex_index3,
                 "sni_1": smoothed_normal_index1,
                 "sni_2": smoothed_normal_index2,
                 "sni_3": smoothed_normal_index3
             })
     return (ghost_vertices, smoothed_normals, triangles)
Example #2
0
 def parse_chunk_vertices(self, chunk):
     parser = BinaryReader(chunk)
     vertices = []
     num_vertices = parser.read_unsigned_int32()
     for i in range(num_vertices):
         vec3 = parser.read_vec3_float32()
         has_smoothing = bool(parser.read_unsigned_char8())
         vertices.append({
             "x": vec3[0],
             "y": vec3[1],
             "z": vec3[2],
             "has_smoothing": has_smoothing
         })
     return vertices
Example #3
0
 def parse_chunk_mappinggroups(self, chunk):
     parser = BinaryReader(chunk)
     mappinggroups = {}
     num_mappinggroups = parser.read_unsigned_int32()
     for i in range(num_mappinggroups):
         mgid = parser.read_unsigned_int32()
         angle = parser.read_float32()
         scale = parser.read_vec2_float32()
         offset = parser.read_vec2_float32()
         normal = parser.read_vec3_float32()
         mappinggroups[mgid] = {
             "angle": angle,
             "scale": scale,
             "offset": offset,
             "normal": normal
         }
     return mappinggroups