Ejemplo n.º 1
0
 def read_mdl(self, stream: TokenStream):
     self.name = stream.read()
     for token in stream.read_block():
         if token == 'Position':
             self.position = stream.read_vector(3)
         elif token == 'Translation':
             self.read_animation(stream, 'KCTR')
         elif token == 'Rotation':
             self.read_animation(stream, 'KCRL')
         elif token == 'FieldOfView':
             self.field_of_view = stream.read_float()
         elif token == 'FarClip':
             self.far_clipping_plane = stream.read_float()
         elif token == 'NearClip':
             self.near_clipping_plane = stream.read_float()
         elif token == 'Target':
             for token in stream.read_block():
                 if token == 'Position':
                     self.target_position = stream.read_vector(3)
                 elif token == 'Translation':
                     self.read_animation(stream, 'KTTR')
                 else:
                     raise TokenStreamError('Camera', token, want_name=self.name, want_target=1)
         else:
             raise TokenStreamError('Camera', token, want_name=self.name)
Ejemplo n.º 2
0
 def load_model_block(self, stream: TokenStream):
     self.name = stream.read()
     for token in stream.read_block():
         if token.startswith('Num'):
             stream.read()
         elif token == 'BlendTime':
             self.blend_time = stream.read_int()
         elif token == 'MinimumExtent':
             self.extent.min = stream.read_vector(3)
         elif token == 'MaximumExtent':
             self.extent.max = stream.read_vector(3)
         elif token == 'BoundsRadius':
             self.extent.bounds_radius = stream.read_float()
         elif token == 'AnimationFile':
             self.animation_file = stream.read()
         else:
             raise TokenStreamError('Model', token)
Ejemplo n.º 3
0
 def read_mdl(self, stream: TokenStream):
     self.name = stream.read()
     for token in stream.read_block():
         if token == 'Interval':
             self.interval = stream.read_vector(2)
         elif token == 'NonLooping':
             self.flags = 1
         elif token == 'MoveSpeed':
             self.move_speed = stream.read_float()
         elif token == 'Rarity':
             self.rarity = stream.read_float()
         elif token == 'MinimumExtent':
             self.extent.min = stream.read_vector(3)
         elif token == 'MaximumExtent':
             self.extent.max = stream.read_vector(3)
         elif token == 'BoundsRadius':
             self.extent.bounds_radius = stream.read_float()
         else:
             raise TokenStreamError('Sequence', token)
Ejemplo n.º 4
0
 def load_bind_pose_block(self, stream: TokenStream):
     for token in stream.read_block():
         if token == 'Matrices':
             matrices = stream.read_int()
             stream.read()
             for i in range(matrices):
                 self.bind_pose.append(stream.read_vector(12))
             stream.read()
         else:
             raise TokenStreamError('BindPose', token)
Ejemplo n.º 5
0
 def read_mdl(self, stream: TokenStream):
     for token in super().read_generic_block(stream):
         if token == 'Box':
             self.type = 0
         elif token == 'Plane':
             self.type = 1
         elif token == 'Sphere':
             self.type = 2
         elif token == 'Cylinder':
             self.type = 3
         elif token == 'Vertices':
             count = stream.read_int()
             stream.read()
             self.vertices[0] = stream.read_vector(3)
             if count == 2:
                 self.vertices[1] = stream.read_vector(3)
             stream.read()
         elif token == 'BoundsRadius':
             self.bounds_radius = stream.read_float()
         else:
             raise TokenStreamError('CollisionShape', token)
Ejemplo n.º 6
0
 def read_mdl(self, stream: TokenStream):
     for token in super().read_animated_block(stream):
         if token == 'FilterMode':
             self.filter_mode = filter_mode_to_mdx(stream.read())
         elif token == 'Unshaded':
             self.flags |= 0x1
         elif token == 'SphereEnvMap':
             self.flags |= 0x2
         elif token == 'TwoSided':
             self.flags |= 0x10
         elif token == 'Unfogged':
             self.flags |= 0x20
         elif token == 'NoDepthTest':
             self.flags |= 0x40
         elif token == 'NoDepthSet':
             self.flags |= 0x80
         elif token == 'Unlit':
             self.flags |= 0x100
         elif token == 'static TextureID':
             self.texture_id = stream.read_int()
         elif token == 'TextureID':
             self.read_animation(stream, 'KMTF')
         elif token == 'TVertexAnimId':
             self.texture_animation_id = stream.read_int()
         elif token == 'CoordId':
             self.coord_id = stream.read_int()
         elif token == 'static Alpha':
             self.alpha = stream.read_float()
         elif token == 'Alpha':
             self.read_animation(stream, 'KMTA')
         elif token == 'static EmissiveGain':
             self.emissive_gain = stream.read_float()
         elif token == 'EmissiveGain':
             self.read_animation(stream, 'KMTE')
         elif token == 'static FresnelColor':
             self.fresnel_color = stream.read_vector(3)
         elif token == 'FresnelColor':
             self.read_animation(stream, 'KFC3')
         elif token == 'static FresnelOpacity':
             self.fresnel_opacity = stream.read_float()
         elif token == 'FresnelOpacity':
             self.read_animation(stream, 'KFCA')
         elif token == 'static FresnelTeamColor':
             self.fresnel_team_color = stream.read_float()
         elif token == 'FresnelTeamColor':
             self.read_animation(stream, 'KFTC')
         else:
             raise TokenStreamError('Layer', token)
 def read_mdl(self, stream: TokenStream):
     for token in super().read_generic_block(stream):
         if token == 'SortPrimsFarZ':
             self.flags = 0x10000
         elif token == 'Unshaded':
             self.flags = 0x8000
         elif token == 'Unfogged':
             self.flags = 0x40000
         elif token == 'static LifeSpan':
             self.life_span = stream.read_float()
         elif token == 'LifeSpan':
             self.read_animation(stream, 'KPPL')
         elif token == 'static EmissionRate':
             self.emission_rate = stream.read_float()
         elif token == 'EmissionRate':
             self.read_animation(stream, 'KPPE')
         elif token == 'static Speed':
             self.speed = stream.read_float()
         elif token == 'Speed':
             self.read_animation(stream, 'KPPS')
         elif token == 'static Color':
             self.color = stream.read_vector(3)
         elif token == 'Color':
             self.read_animation(stream, 'KPPC')
         elif token == 'static Alpha':
             self.alpha = stream.read_float()
         elif token == 'Alpha':
             self.read_animation(stream, 'KPPA')
         elif token == 'Visibility':
             self.read_animation(stream, 'KPPV')
         elif token == 'ReplaceableId':
             self.replaceable_id = stream.read_int()
         elif token == 'Path':
             self.path = stream.read()
         elif token == 'AnimVisibilityGuide':
             self.animation_visibility_guide = stream.read()
         else:
             raise TokenStreamError('ParticleEmitterPopcorn', token)
Ejemplo n.º 8
0
 def read_mdl(self, stream: TokenStream):
     for token in stream.read_block():
         if token == 'Vertices':
             self.vertices = stream.read_vectors_block(stream.read_int(), 3)
         elif token == 'Normals':
             self.normals = stream.read_vectors_block(stream.read_int(), 3)
         elif token == 'TVertices':
             self.uv_sets.append(
                 stream.read_vectors_block(stream.read_int(), 2))
         elif token == 'VertexGroup':
             vertex_groups = []
             for vertex_group in stream.read_block():
                 vertex_groups.append(int(vertex_group))
             self.vertex_groups = vertex_groups
         elif token == 'Tangents':
             self.tangents = stream.read_vectors_block(stream.read_int(), 4)
         elif token == 'SkinWeights':
             self.skin = stream.read_vector(stream.read_int() * 8)
         elif token == 'Faces':
             self.face_type_groups = []
             vectors = stream.read_int()
             count = stream.read_int()
             stream.read()
             stream.read()
             self.faces = stream.read_single_vector_block(count)
             self.face_groups = [count]
             stream.read()
         elif token == 'Groups':
             indices = []
             groups = []
             stream.read_int()
             stream.read_int()
             for _ in stream.read_block():
                 size = 0
                 for index in stream.read_block():
                     indices.append(int(index))
                     size += 1
                 groups.append(size)
             self.matrix_indices = indices
             self.matrix_groups = groups
         elif token == 'MinimumExtent':
             self.extent.min = stream.read_vector(3)
         elif token == 'MaximumExtent':
             self.extent.max = stream.read_vector(3)
         elif token == 'BoundsRadius':
             self.extent.bounds_radius = stream.read_float()
         elif token == 'Anim':
             extent = Extent()
             for token in stream.read_block():
                 if token == 'MinimumExtent':
                     extent.min = stream.read_vector(3)
                 elif token == 'MaximumExtent':
                     extent.max = stream.read_vector(3)
                 elif token == 'BoundsRadius':
                     extent.bounds_radius = stream.read_float()
             self.sequence_extents.append(extent)
         elif token == 'MaterialID':
             self.material_id = stream.read_int()
         elif token == 'SelectionGroup':
             self.selection_group = stream.read_int()
         elif token == 'Unselectable':
             self.selection_flags = 4
         elif token == 'LevelOfDetail':
             self.lod = stream.read_int()
         elif token == 'Name':
             self.lod_name = stream.read()
         else:
             raise TokenStreamError('Geoset', token)
Ejemplo n.º 9
0
 def read_mdl_value(self, stream: TokenStream) -> tuple:
     self.byte_value = 16
     return stream.read_vector(4)
Ejemplo n.º 10
0
 def load_pivot_point_block(self, stream: TokenStream):
     count = stream.read_int()
     stream.read()
     for i in range(count):
         self.pivot_points.append(stream.read_vector(3))
     stream.read()
Ejemplo n.º 11
0
 def read_mdl(self, stream: TokenStream):
     for token in super().read_generic_block(stream):
         if token == 'SortPrimsFarZ':
             self.flags = self.flags or 0x10000
         elif token == 'Unshaded':
             self.flags = self.flags or 0x8000
         elif token == 'LineEmitter':
             self.flags = self.flags or 0x20000
         elif token == 'Unfogged':
             self.flags = self.flags or 0x40000
         elif token == 'ModelSpace':
             self.flags = self.flags or 0x80000
         elif token == 'XYQuad':
             self.flags = self.flags or 0x100000
         elif token == 'static Speed':
             self.speed = stream.read_float()
         elif token == 'Speed':
             self.read_animation(stream, 'KP2S')
         elif token == 'static Variation':
             self.variation = stream.read_float()
         elif token == 'Variation':
             self.read_animation(stream, 'KP2R')
         elif token == 'static Latitude':
             self.latitude = stream.read_float()
         elif token == 'Latitude':
             self.read_animation(stream, 'KP2L')
         elif token == 'static Gravity':
             self.gravity = stream.read_float()
         elif token == 'Gravity':
             self.read_animation(stream, 'KP2G')
         elif token == 'Visibility':
             self.read_animation(stream, 'KP2V')
         elif token == 'Squirt':
             self.squirt = 1
         elif token == 'LifeSpan':
             self.life_span = stream.read_float()
         elif token == 'static EmissionRate':
             self.emission_rate = stream.read_float()
         elif token == 'EmissionRate':
             self.read_animation(stream, 'KP2E')
         elif token == 'static Width':
             self.width = stream.read_float()
         elif token == 'Width':
             self.read_animation(stream, 'KP2N')
         elif token == 'static Length':
             self.length = stream.read_float()
         elif token == 'Length':
             self.read_animation(stream, 'KP2W')
         elif token == 'Blend':
             self.filter_mode = 0
         elif token == 'Additive':
             self.filter_mode = 1
         elif token == 'Modulate':
             self.filter_mode = 2
         elif token == 'Modulate2x':
             self.filter_mode = 3
         elif token == 'AlphaKey':
             self.filter_mode = 4
         elif token == 'Rows':
             self.rows = stream.read_int()
         elif token == 'Columns':
             self.columns = stream.read_int()
         elif token == 'Head':
             self.head_or_tail = 0
         elif token == 'Tail':
             self.head_or_tail = 1
         elif token == 'Both':
             self.head_or_tail = 2
         elif token == 'TailLength':
             self.tail_length = stream.read_float()
         elif token == 'Time':
             self.time_middle = stream.read_float()
         elif token == 'SegmentColor':
             stream.read()
             for i in range(3):
                 stream.read()
                 self.segment_colors[i] = stream.read_color()
             stream.read()
         elif token == 'Alpha':
             self.segment_alphas = stream.read_vector(3)
         elif token == 'ParticleScaling':
             self.segment_scaling = stream.read_vector(3)
         elif token == 'LifeSpanUVAnim':
             self.head_intervals[0] = stream.read_vector(3)
         elif token == 'DecayUVAnim':
             self.head_intervals[1] = stream.read_vector(3)
         elif token == 'TailUVAnim':
             self.tail_intervals[0] = stream.read_vector(3)
         elif token == 'TailDecayUVAnim':
             self.tail_intervals[1] = stream.read_vector(3)
         elif token == 'TextureID':
             self.texture_id = stream.read_int()
         elif token == 'ReplaceableId':
             self.replaceable_id = stream.read_int()
         elif token == 'PriorityPlane':
             self.priority_plane = stream.read_int()
         else:
             raise TokenStreamError('ParticleEmitter2', token)