Пример #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)
Пример #2
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)
Пример #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)
 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)
Пример #5
0
 def read_mdl(self, stream: TokenStream):
     for token in super().read_generic_block(stream):
         if token == 'static HeightAbove':
             self.height_above = stream.read_float()
         elif token == 'HeightAbove':
             self.read_animation(stream, 'KRHA')
         elif token == 'static HeightBelow':
             self.height_below = stream.read_float()
         elif token == 'HeightBelow':
             self.read_animation(stream, 'KRHB')
         elif token == 'static Alpha':
             self.alpha = stream.read_float()
         elif token == 'Alpha':
             self.read_animation(stream, 'KRAL')
         elif token == 'static Color':
             self.color = stream.read_color()
         elif token == 'Color':
             self.read_animation(stream, 'KRCO')
         elif token == 'static TextureSlot':
             self.texture_slot = stream.read_int()
         elif token == 'TextureSlot':
             self.read_animation(stream, 'KRTX')
         elif token == 'Visibility':
             self.read_animation(stream, 'KRVS')
         elif token == 'EmissionRate':
             self.emission_rate = stream.read_int()
         elif token == 'LifeSpan':
             self.lifespan = stream.read_float()
         elif token == 'Gravity':
             self.gravity = stream.read_float()
         elif token == 'Rows':
             self.rows = stream.read_int()
         elif token == 'Columns':
             self.columns = stream.read_int()
         elif token == 'MaterialID':
             self.material_id = stream.read_int()
         else:
             raise TokenStreamError('RibbonEmitter', token)
Пример #6
0
 def read_mdl(self, stream: TokenStream):
     for token in super().read_generic_block(stream):
         if token == 'Omnidirectional':
             self.type = 0
         elif token == 'Directional':
             self.type = 1
         elif token == 'Ambient':
             self.type = 2
         elif token == 'static AttenuationStart':
             self.attenuation[0] = stream.read_float()
         elif token == 'AttenuationStart':
             self.read_animation(stream, 'KLAS')
         elif token == 'static AttenuationEnd':
             self.attenuation[1] = stream.read_float()
         elif token == 'AttenuationEnd':
             self.read_animation(stream, 'KLAE')
         elif token == 'static Intensity':
             self.intensity = stream.read_float()
         elif token == 'Intensity':
             self.read_animation(stream, 'KLAI')
         elif token == 'static Color':
             self.color = stream.read_color()
         elif token == 'Color':
             self.read_animation(stream, 'KLAC')
         elif token == 'static AmbIntensity':
             self.ambient_intensity = stream.read_float()
         elif token == 'AmbIntensity':
             self.read_animation(stream, 'KLBI')
         elif token == 'static AmbColor':
             self.ambient_color = stream.read_color()
         elif token == 'AmbColor':
             self.read_animation(stream, 'KLBC')
         elif token == 'Visibility':
             self.read_animation(stream, 'KLAV')
         else:
             raise TokenStreamError('Light', token)
Пример #7
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)
Пример #8
0
 def read_mdl(self, stream: TokenStream, version=None):
     for token in super().read_animated_block(stream):
         if token == 'DropShadow':
             self.flags |= 0x1
         elif token == 'static Alpha':
             self.alpha = stream.read_float()
         elif token == 'Alpha':
             self.read_animation(stream, 'KGAO')
         elif token == 'static Color':
             self.flags |= 0x2
             self.color = stream.read_color()
         elif token == 'Color':
             self.flags |= 0x2
             self.read_animation(stream, 'KGAC')
         elif token == 'GeosetId':
             self.geoset_id = stream.read_int()
         else:
             raise TokenStreamError('GeosetAnimation', token)
Пример #9
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)
Пример #10
0
 def read_mdl(self, stream: TokenStream, version=None):
     for token in super().read_generic_block(stream):
         if token == 'EmitterUsesMDL':
             self.flags = 0x8000
         elif token == 'EmitterUsesTGA':
             self.flags = 0x10000
         elif token == 'static EmissionRate':
             self.emission_rate = stream.read_float()
         elif token == 'EmissionRate':
             self.read_animation(stream, 'KPEE')
         elif token == 'static Gravity':
             self.gravity = stream.read_float()
         elif token == 'Gravity':
             self.read_animation(stream, 'KPEG')
         elif token == 'static Longitude':
             self.longitude = stream.read_float()
         elif token == 'Longitude':
             self.read_animation(stream, 'KPLN')
         elif token == 'static Latitude':
             self.latitude = stream.read_float()
         elif token == 'Latitude':
             self.read_animation(stream, 'KPLT')
         elif token == 'Visibility':
             self.read_animation(stream, 'KPEV')
         elif token == 'Particle':
             for token in self.read_animated_block(stream):
                 if token == 'static LifeSpan':
                     self.life_span = stream.read_float()
                 elif token == 'LifeSpan':
                     self.read_animation(stream, 'KPEL')
                 elif token == 'static InitVelocity':
                     self.speed = stream.read_float()
                 elif token == 'InitVelocity':
                     self.read_animation(stream, 'KPES')
                 elif token == 'Path':
                     self.path = stream.read()
         else:
             raise TokenStreamError('ParticleEmitter', token)
Пример #11
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)
Пример #12
0
 def read_mdl_value(self, stream: TokenStream) -> tuple:
     self.byte_value = 4
     return stream.read_float()
Пример #13
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)