def write_mdl(self, stream: TokenStream, version=None):
     stream.start_object_block('ParticleEmitter', self.name)
     self.write_generic_header(stream)
     if self.flags == 0x8000:
         stream.write_flag('EmitterUsesMDL')
     if self.flags == 0x10000:
         stream.write_flag('EmitterUsesTGA')
     if not self.write_animation(stream, 'KPEE'):
         stream.write_number_attrib('static EmissionRate',
                                    self.emission_rate)
     if not self.write_animation(stream, 'KPEG'):
         stream.write_number_attrib('static Gravity', self.gravity)
     if not self.write_animation(stream, 'KPLN'):
         stream.write_number_attrib('static Longitude', self.longitude)
     if not self.write_animation(stream, 'KPLT'):
         stream.write_number_attrib('static Latitude', self.latitude)
     self.write_animation(stream, 'KPEV')
     stream.start_block('Particle', None)
     if not self.write_animation(stream, 'KPEL'):
         stream.write_number_attrib('static LifeSpan', self.life_span)
     if not self.write_animation(stream, 'KPES'):
         stream.write_number_attrib('static InitVelocity', self.speed)
     if (self.flags == 0x8000) or (self.flags == 0x10000):
         stream.write_string_attrib('Path', self.path)
     stream.end_block()
     self.write_generic_animations(stream)
     stream.end_block()
 def write_mdl(self, stream: TokenStream, version=None):
     stream.start_object_block('ParticleEmitterPopcorn', self.name)
     self.write_generic_header(stream)
     if self.flags == 0x10000:
         stream.write_flag('SortPrimsFarZ')
     if self.flags == 0x8000:
         stream.write_flag('Unshaded')
     if self.flags == 0x40000:
         stream.write_flag('Unfogged')
     if not self.write_animation(stream, 'KPPL'):
         stream.write_number_attrib('static LifeSpan', self.life_span)
     if not self.write_animation(stream, 'KPPE'):
         stream.write_number_attrib('static EmissionRate',
                                    self.emission_rate)
     if not self.write_animation(stream, 'KPPS'):
         stream.write_number_attrib('static Speed', self.speed)
     if not self.write_animation(stream, 'KPPC'):
         stream.write_vector_attrib('static Color', self.color)
     if not self.write_animation(stream, 'KPPA'):
         stream.write_number_attrib('static Alpha', self.alpha)
     self.write_animation(stream, 'KPPV')
     if self.replaceable_id != 0:
         stream.write_number_attrib('ReplaceableId', self.replaceable_id)
     if len(self.path):
         stream.write_string_attrib('Path', self.path)
     if len(self.animation_visibility_guide):
         stream.write_string_attrib('AnimVisibilityGuide',
                                    self.animation_visibility_guide)
     self.write_generic_animations(stream)
     stream.end_block()
Example #3
0
 def write_mdl(self, stream: TokenStream, version=None):
     stream.start_object_block('Light', self.name)
     self.write_generic_header(stream)
     if self.type == 0:
         stream.write_flag('Omnidirectional')
     elif self.type == 1:
         stream.write_flag('Directional')
     elif self.type == 2:
         stream.write_flag('Ambient')
     if not self.write_animation(stream, 'KLAS'):
         stream.write_number_attrib('static AttenuationStart',
                                    self.attenuation[0])
     if not self.write_animation(stream, 'KLAE'):
         stream.write_number_attrib('static AttenuationEnd',
                                    self.attenuation[1])
     if not self.write_animation(stream, 'KLAI'):
         stream.write_number_attrib('static Intensity', self.intensity)
     if not self.write_animation(stream, 'KLAC'):
         stream.write_color('static Color', self.color)
     if not self.write_animation(stream, 'KLBI'):
         stream.write_number_attrib('static AmbIntensity',
                                    self.ambient_intensity)
     if not self.write_animation(stream, 'KLBC'):
         stream.write_color('static AmbColor', self.ambient_color)
     self.write_animation(stream, 'KLAV')
     self.write_generic_animations(stream)
     stream.end_block()
 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 #5
0
 def write_mdl(self, stream: TokenStream, version=None):
     stream.start_object_block('Attachment', self.name)
     self.write_generic_header(stream)
     stream.write_number_attrib('AttachmentID', self.attachment_id)
     if len(self.path):
         stream.write_string_attrib('Path', self.path)
     self.write_animation(stream, 'KATV')
     self.write_generic_animations(stream)
     stream.end_block()
Example #6
0
 def write_mdl(self, stream: TokenStream, version=None):
     stream.start_object_block('EventObject', self.name)
     self.write_generic_header(stream)
     stream.start_block('EventTrack', len(self.tracks))
     if self.global_sequence_id != -1:
         stream.write_number_attrib('GlobalSeqId', self.global_sequence_id)
     for track in self.tracks:
         stream.write_flag(f'{track}')
     stream.end_block()
     self.write_generic_animations(stream)
     stream.end_block()
Example #7
0
 def write_mdl(self, stream: TokenStream, version=None):
     stream.start_object_block('Anim', self.name)
     stream.write_vector_attrib('Interval', self.interval)
     if self.flags == 1:
         stream.write_flag('NonLooping')
     if self.move_speed != 0:
         stream.write_number_attrib('MoveSpeed', self.move_speed)
     if self.rarity != 0:
         stream.write_number_attrib('Rarity', self.rarity)
     self.extent.write_mdl(stream)
     stream.end_block()
Example #8
0
 def write_mdl(self, stream: TokenStream, version=None):
     stream.start_object_block('Camera', self.name)
     stream.write_vector_attrib('Position', self.position)
     self.write_animation(stream, 'KCTR')
     self.write_animation(stream, 'KCRL')
     stream.write_number_attrib('FieldOfView', self.field_of_view)
     stream.write_number_attrib('FarClip', self.far_clipping_plane)
     stream.write_number_attrib('NearClip', self.near_clipping_plane)
     stream.start_block('Target', None)
     stream.write_vector_attrib('Position', self.target_position)
     self.write_animation(stream, 'KTTR')
     stream.end_block()
     stream.end_block()
Example #9
0
 def write_mdl(self, stream: TokenStream, version=None):
     stream.start_object_block('Bone', self.name)
     self.write_generic_header(stream)
     if self.geoset_id == -1:
         stream.write_flag_attrib('GeosetId', 'Multiple')
     else:
         stream.write_number_attrib('GeosetId', self.geoset_id)
     if self.geoset_animation_id == -1:
         stream.write_flag_attrib('GeosetAnimId', 'None')
     else:
         stream.write_number_attrib('GeosetAnimId',
                                    self.geoset_animation_id)
     self.write_generic_animations(stream)
     stream.end_block()
Example #10
0
 def save_model_block(self, stream: TokenStream):
     stream.start_object_block('Model', self.name)
     self.mdl_num_of_chunk = [
         len(self.geosets),
         len(self.geoset_animations),
         len(self.helpers),
         len(self.lights),
         len(self.bones),
         len(self.attachments),
         len(self.particle_emitters),
         len(self.particle_emitters2),
         len(self.particle_emitters_popcorn),
         len(self.ribbon_emitters),
         len(self.event_objects),
         len(self.face_effects)
     ]
     stream.write_number_attrib('NumGeosets', self.mdl_num_of_chunk[0])
     stream.write_number_attrib('NumGeosetAnims', self.mdl_num_of_chunk[1])
     stream.write_number_attrib('NumHelpers', self.mdl_num_of_chunk[2])
     stream.write_number_attrib('NumLights', self.mdl_num_of_chunk[3])
     stream.write_number_attrib('NumBones', self.mdl_num_of_chunk[4])
     stream.write_number_attrib('NumAttachments', self.mdl_num_of_chunk[5])
     stream.write_number_attrib('NumParticleEmitters',
                                self.mdl_num_of_chunk[6])
     stream.write_number_attrib('NumParticleEmitters2',
                                self.mdl_num_of_chunk[7])
     if self.version > 800:
         stream.write_number_attrib('NumParticleEmittersPopcorn',
                                    self.mdl_num_of_chunk[8])
     stream.write_number_attrib('NumRibbonEmitters',
                                self.mdl_num_of_chunk[9])
     stream.write_number_attrib('NumEvents', self.mdl_num_of_chunk[10])
     if self.version > 800:
         stream.write_number_attrib('NumFaceFX', self.mdl_num_of_chunk[11])
     stream.write_number_attrib('BlendTime', self.blend_time)
     self.extent.write_mdl(stream)
     if len(self.animation_file):
         stream.write_string_attrib('AnimationFile', self.animation_file)
     stream.end_block()
Example #11
0
 def write_mdl(self, stream: TokenStream, version=None):
     stream.start_object_block('RibbonEmitter', self.name)
     self.write_generic_header(stream)
     if not self.write_animation(stream, 'KRHA'):
         stream.write_number_attrib('static HeightAbove', self.height_above)
     if not self.write_animation(stream, 'KRHB'):
         stream.write_number_attrib('static HeightBelow', self.height_below)
     if not self.write_animation(stream, 'KRAL'):
         stream.write_number_attrib('static Alpha', self.alpha)
     if not self.write_animation(stream, 'KRCO'):
         stream.write_color('static Color', self.color)
     if not self.write_animation(stream, 'KRTX'):
         stream.write_number_attrib('static TextureSlot', self.texture_slot)
     self.write_animation(stream, 'KRVS')
     stream.write_number_attrib('EmissionRate', self.emission_rate)
     stream.write_number_attrib('LifeSpan', self.lifespan)
     if self.gravity != 0:
         stream.write_number_attrib('Gravity', self.gravity)
     stream.write_number_attrib('Rows', self.rows)
     stream.write_number_attrib('Columns', self.columns)
     stream.write_number_attrib('MaterialID', self.material_id)
     self.write_generic_animations(stream)
     stream.end_block()
Example #12
0
 def write_mdl(self, stream: TokenStream, version=None):
     stream.start_object_block('FaceFX', self.type)
     stream.write_string_attrib('Path', self.path)
     stream.end_block()
 def write_mdl(self, stream: TokenStream, version=None):
     stream.start_object_block('ParticleEmitter2', self.name)
     self.write_generic_header(stream)
     if self.flags == 0x10000:
         stream.write_flag('SortPrimsFarZ')
     if self.flags == 0x8000:
         stream.write_flag('Unshaded')
     if self.flags == 0x20000:
         stream.write_flag('LineEmitter')
     if self.flags == 0x40000:
         stream.write_flag('Unfogged')
     if self.flags == 0x80000:
         stream.write_flag('ModelSpace')
     if self.flags == 0x100000:
         stream.write_flag('XYQuad')
     if not self.write_animation(stream, 'KP2S'):
         stream.write_number_attrib('static Speed', self.speed)
     if not self.write_animation(stream, 'KP2R'):
         stream.write_number_attrib('static Variation', self.variation)
     if not self.write_animation(stream, 'KP2L'):
         stream.write_number_attrib('static Latitude', self.latitude)
     if not self.write_animation(stream, 'KP2G'):
         stream.write_number_attrib('static Gravity', self.gravity)
     self.write_animation(stream, 'KP2V')
     if self.squirt:
         stream.write_flag('Squirt')
     stream.write_number_attrib('LifeSpan', self.life_span)
     if not self.write_animation(stream, 'KP2E'):
         stream.write_number_attrib('static EmissionRate',
                                    self.emission_rate)
     if not self.write_animation(stream, 'KP2N'):
         stream.write_number_attrib('static Width', self.width)
     if not self.write_animation(stream, 'KP2W'):
         stream.write_number_attrib('static Length', self.length)
     if self.filter_mode == 0:
         stream.write_flag('Blend')
     elif self.filter_mode == 1:
         stream.write_flag('Additive')
     elif self.filter_mode == 2:
         stream.write_flag('Modulate')
     elif self.filter_mode == 3:
         stream.write_flag('Modulate2x')
     elif self.filter_mode == 4:
         stream.write_flag('AlphaKey')
     stream.write_number_attrib('Rows', self.rows)
     stream.write_number_attrib('Columns', self.columns)
     if self.head_or_tail == 0:
         stream.write_flag('Head')
     elif self.head_or_tail == 1:
         stream.write_flag('Tail')
     elif self.head_or_tail == 2:
         stream.write_flag('Both')
     stream.write_number_attrib('TailLength', self.tail_length)
     stream.write_number_attrib('Time', self.time_middle)
     stream.start_block('SegmentColor', None)
     stream.write_color('Color', self.segment_colors[0])
     stream.write_color('Color', self.segment_colors[1])
     stream.write_color('Color', self.segment_colors[2])
     stream.end_block_comma()
     stream.write_vector_attrib('Alpha', self.segment_alphas)
     stream.write_vector_attrib('ParticleScaling', self.segment_scaling)
     stream.write_vector_attrib('LifeSpanUVAnim', self.head_intervals[0])
     stream.write_vector_attrib('DecayUVAnim', self.head_intervals[1])
     stream.write_vector_attrib('TailUVAnim', self.tail_intervals[0])
     stream.write_vector_attrib('TailDecayUVAnim', self.tail_intervals[1])
     stream.write_number_attrib('TextureID', self.texture_id)
     if self.replaceable_id != 0:
         stream.write_number_attrib('ReplaceableId', self.replaceable_id)
     if self.priority_plane != 0:
         stream.write_number_attrib('PriorityPlane', self.priority_plane)
     self.write_generic_animations(stream)
     stream.end_block()
Example #14
0
 def write_mdl(self, stream: TokenStream, version=None):
     stream.start_object_block('Helper', self.name)
     self.write_generic_header(stream)
     self.write_generic_animations(stream)
     stream.end_block()