def write_mdl(self, stream: TokenStream, version=None):
     stream.start_object_block('CollisionShape', self.name)
     self.write_generic_header(stream)
     _type = ''
     vertices = 2
     bounds_radius = False
     if self.type == 0:
         _type = 'Box'
     elif self.type == 1:
         _type = 'Plane'
     elif self.type == 2:
         _type = 'Sphere'
         vertices = 1
         bounds_radius = True
     elif self.type == 3:
         _type = 'Cylinder'
         bounds_radius = True
     stream.write_flag(_type)
     stream.start_block('Vertices', vertices)
     stream.write_vector(self.vertices[0])
     if vertices == 2:
         stream.write_vector(self.vertices[1])
     stream.end_block()
     if bounds_radius:
         stream.write_number_attrib('BoundsRadius', self.bounds_radius)
     self.write_generic_animations(stream)
     stream.end_block()
Example #2
0
 def save_bind_pose_block(self, stream: TokenStream):
     if len(self.bind_pose):
         stream.start_block('BindPose', None)
         stream.start_block('Matrices', len(self.bind_pose))
         for matrix in self.bind_pose:
             stream.write_vector(matrix)
         stream.end_block()
         stream.end_block()
Example #3
0
 def write_mdl(self, stream: TokenStream, version=None):
     stream.start_block('Geoset', None)
     stream.write_vector_array_block('Vertices', self.vertices, 3)
     stream.write_vector_array_block('Normals', self.normals, 3)
     for uv_set in self.uv_sets:
         stream.write_vector_array_block('TVertices', uv_set, 2)
     if version > 800 or len(self.tangents):
         stream.write_vector_array_block('Tangents', self.tangents, 4)
     if version > 800 or len(self.skin):
         stream.start_block('SkinWeights', len(self.skin) // 8)
         for i in range(0, len(self.skin), 8):
             stream.write_line(
                 f'{", ".join([str(a) for a in self.skin[i:i + 8]])+","}')
     else:
         stream.start_block('VertexGroup', None)
         for i in range(len(self.vertex_groups)):
             stream.write_line(f'{self.vertex_groups[i]},')
     stream.end_block()
     stream.start_block('Faces', [str(1), str(len(self.faces))])
     stream.start_block('Triangles', None)
     stream.write_vector(self.faces)
     stream.end_block()
     stream.end_block()
     stream.start_block(
         'Groups',
         [str(len(self.matrix_groups)),
          str(len(self.matrix_indices))])
     index = 0
     for group_size in self.matrix_groups:
         stream.write_vector_attrib(
             'Matrices', self.matrix_indices[index:index + group_size])
         index += group_size
     stream.end_block()
     self.extent.write_mdl(stream)
     for sequence_extent in self.sequence_extents:
         stream.start_block('Anim', None)
         sequence_extent.write_mdl(stream)
         stream.end_block()
     stream.write_number_attrib('MaterialID', self.material_id)
     stream.write_number_attrib('SelectionGroup', self.selection_group)
     if self.selection_flags == 4:
         stream.write_flag('Unselectable')
     if version > 800:
         stream.write_number_attrib('LevelOfDetail', self.lod)
         if len(self.lod_name):
             stream.write_string_attrib('Name', self.lod_name)
     stream.end_block()
Example #4
0
 def save_pivot_point_block(self, stream: TokenStream):
     if len(self.pivot_points):
         stream.start_block('PivotPoints', len(self.pivot_points))
         for pivot_point in self.pivot_points:
             stream.write_vector(pivot_point)
         stream.end_block()