Example #1
0
 def write(self, stream, resource=None):
     s = StreamWriter(stream)
     s.hash(self.name)
     s.i32(self.start_index)
     s.i32(self.start_vertex)
     s.i32(self.vertex_count)
     s.i32(self.index_count)
Example #2
0
    def write(self, stream, rcol):
        s = StreamWriter(stream)
        len_offset = stream.tell()
        s.u32(0)
        start = stream.tell()
        s.hash(self.name)
        s.u32(rcol.get_block_index(self.material))
        s.u32(rcol.get_block_index(self.vertex_format))
        s.u32(rcol.get_block_index(self.vertex_buffer))
        s.u32(rcol.get_block_index(self.index_buffer))

        flags = self.primitive_type
        flags |= (self.flags << 8)
        s.u32(flags)
        s.u32(self.stream_offset)
        s.i32(self.start_vertex)
        s.i32(self.start_index)
        s.i32(self.min_vertex_index)
        s.i32(self.vertex_count)
        s.i32(self.primitive_count)
        self.bounds.write(stream)
        s.u32(rcol.get_block_index(self.skin_controller))
        s.i32(len(self.bone_references))
        for bone in self.bone_references: s.u32(bone)
        s.u32(rcol.get_block_index(self.scale_offsets))
        s.i32(len(self.states))
        for state in self.states: state.write_rcol(self, rcol)
        if self.parent.version > ModelLod.VERSION.DEFAULT:
            s.hash(self.parent_name)
            for i in range(3): s.f32(self.mirror_plane_normal[i])
            s.f32(self.mirror_plane_offset)
        end = stream.tell()
        stream.seek(len_offset, SEEK_SET)
        s.u32(end - start)
        stream.seek(end, SEEK_SET)
Example #3
0
    def write(self, stream, resources=None):
        s = StreamWriter(stream)
        s.u32(self.version)
        tgi = TGIList(package=resources)
        tgi.begin_write(stream)
        s.i8(len(self.components))
        for component in self.components:
            s.hash(component)

        def write_component_data(data):
            s.i8(data[0])
            val = data[1]
            if isinstance(val, str):
                s.p32(val)
            elif isinstance(val, Resource):
                s.i32(tgi.get_resource_index(val))
            elif isinstance(val, int):
                s.u32(val)
            else:
                raise Exception("Unable to handle data type %" % type(val))

        k = self.component_data.keys()
        s.i8(len(k))
        for key in k:
            s.p32(key)
            write_component_data(self.component_data[key])
        s.i8(self.visible)
        tgi.end_write(stream)
Example #4
0
 def write(self, stream, resource=None):
     s = StreamWriter(stream)
     s.hash(self.name)
     s.i32(self.start_index)
     s.i32(self.start_vertex)
     s.i32(self.vertex_count)
     s.i32(self.index_count)
Example #5
0
 def write_rcol(self, stream, rcol):
     self.write_tag(stream)
     s = StreamWriter(stream)
     s.u32(self.version)
     cBones = len(self.bones)
     s.i32(cBones)
     for i in range(cBones): s.hash(self.bones[i].name)
     for bone in self.bones:
         s.m43(bone.inverse_bind_pose)
Example #6
0
 def write_rcol(self, stream, rcol):
     s = StreamWriter(stream)
     s.u32(self.version)
     s.i32(len(self.deltas))
     for delta in self.deltas:
         s.hash(delta.bone_name)
         for i in range(3): s.f32(delta.offset[i])
         for i in range(3): s.f32(delta.scale[i])
         for i in range(4): s.f32(delta.rotation[i])
Example #7
0
 def write_rcol(self, stream, rcol):
     self.write_tag(stream)
     s = StreamWriter(stream)
     s.u32(self.version)
     s.hash(self.default_material.name)
     s.u32(rcol.get_block_index(self.default_material.material))
     s.u32(len(self.elements))
     for state in self.elements:
         s.u32(rcol.get_block_index(state.material))
         s.hash(state.name)
Example #8
0
 def write_rcol(self, stream, rcol):
     self.write_tag(stream)
     s = StreamWriter(stream)
     s.u32(self.version)
     s.hash(self.default_material.name)
     s.u32(rcol.get_block_index(self.default_material.material))
     s.u32(len(self.elements))
     for state in self.elements:
         s.u32(rcol.get_block_index(state.material))
         s.hash(state.name)
Example #9
0
 def write_rcol(self, stream, rcol):
     s = StreamWriter(stream)
     self.write_tag(stream)
     s.u32(self.version)
     s.hash(self.name)
     s.u32(self.properties)
     s.u32(rcol.get_block_index(self.decision_graph, DecisionGraph))
     s.i32(len(self.transitions))
     for transition in self.transitions: s.u32(rcol.get_block_index(transition, State))
     s.u32(self.awareness_overlay_level)
Example #10
0
 def write_rcol(self, stream, rcol):
     self.write_tag(stream)
     s = StreamWriter(stream)
     s.u32(self.version)
     cBones = len(self.bones)
     s.i32(cBones)
     for i in range(cBones):
         s.hash(self.bones[i].name)
     for bone in self.bones:
         s.m43(bone.inverse_bind_pose)
Example #11
0
 def write_rcol(self, stream, rcol):
     s = StreamWriter(stream)
     self.write_tag(stream)
     s.u32(self.version)
     s.hash(self.name)
     s.u32(self.properties)
     s.u32(rcol.get_block_index(self.decision_graph, DecisionGraph))
     s.i32(len(self.transitions))
     for transition in self.transitions:
         s.u32(rcol.get_block_index(transition, State))
     s.u32(self.awareness_overlay_level)
Example #12
0
 def write_rcol(self, stream, rcol):
     s = StreamWriter(stream)
     s.u32(self.version)
     s.i32(len(self.deltas))
     for delta in self.deltas:
         s.hash(delta.bone_name)
         for i in range(3):
             s.f32(delta.offset[i])
         for i in range(3):
             s.f32(delta.scale[i])
         for i in range(4):
             s.f32(delta.rotation[i])
Example #13
0
 def write_rcol(self, stream, rcol):
     s = StreamWriter(stream)
     self.write_tag(stream)
     s.u32(self.version)
     s.i32(self.parameter_index)
     s.i32(len(self.items))
     for item in self.items:
         s.hash(item.value)
         s.i32(len(item.actions))
         for action in item.actions:
             s.u32(rcol.get_block_index(action, DecisionGraphNode.get_node_types()))
     s.u32(DEADBEEF)
     DecisionGraphNode.write(self, stream, rcol)
Example #14
0
 def write_rcol(self, stream, rcol):
     self.write_tag(stream)
     s = StreamWriter(stream)
     s.u32(self.version)
     s.hash(self.name)
     s.hash(self.shader_name)
     material_block_stream = BytesIO()
     self.material_block.write(material_block_stream, rcol)
     s.u32(material_block_stream.tell())
     if self.version >= self.VERSION.STANDARD:
         s.u32(0 if not self.is_video_surface else 1)
         s.u32(0 if not self.is_painting_surface else 1)
     material_block_stream.seek(0, SEEK_SET)
     stream.write(material_block_stream.read(-1))
Example #15
0
 def write_rcol(self, stream, rcol):
     self.write_tag(stream)
     s = StreamWriter(stream)
     s.u32(self.version)
     s.hash(self.name)
     s.hash(self.shader_name)
     material_block_stream = BytesIO()
     self.material_block.write(material_block_stream, rcol)
     s.u32(material_block_stream.tell())
     if self.version >= self.VERSION.STANDARD:
         s.u32(0 if not self.is_video_surface else 1)
         s.u32(0 if not self.is_painting_surface else 1)
     material_block_stream.seek(0, SEEK_SET)
     stream.write(material_block_stream.read(-1))
Example #16
0
 def write_rcol(self, stream, rcol):
     s = StreamWriter(stream)
     self.write_tag(stream)
     s.u32(self.version)
     s.i32(self.parameter_index)
     s.i32(len(self.items))
     for item in self.items:
         s.hash(item.value)
         s.i32(len(item.actions))
         for action in item.actions:
             s.u32(
                 rcol.get_block_index(action,
                                      DecisionGraphNode.get_node_types()))
     s.u32(DEADBEEF)
     DecisionGraphNode.write(self, stream, rcol)
Example #17
0
 def write(self, stream, resource=None):
     s = StreamWriter(stream)
     self.bounds.clear()
     s.hash(self.name)
     s.i8(self.priority)
     s.u32(self.footprint_type_flags)
     s.i32(len(self.points))
     for point in self.points:
         self.bounds.add(point)
         s.f32(point[0])
         s.f32(point[1])
     s.u32(self.allow_intersection_flags)
     s.u32(self.surface_type_flags)
     s.u32(self.surface_attribute_flags)
     s.i8(self.level_offset)
     if self.ftpt.version >= Footprint.VERSION.EXTENDED: s.f32(self.elevation_offset)
     self.bounds.write(stream)
Example #18
0
 def write(self, stream, resource=None):
     s = StreamWriter(stream)
     self.bounds.clear()
     s.hash(self.name)
     s.i8(self.priority)
     s.u32(self.footprint_type_flags)
     s.i32(len(self.points))
     for point in self.points:
         self.bounds.add(point)
         s.f32(point[0])
         s.f32(point[1])
     s.u32(self.allow_intersection_flags)
     s.u32(self.surface_type_flags)
     s.u32(self.surface_attribute_flags)
     s.i8(self.level_offset)
     if self.ftpt.version >= Footprint.VERSION.EXTENDED: s.f32(self.elevation_offset)
     self.bounds.write(stream)
Example #19
0
 def write_rcol(self, stream, rcol):
     s = StreamWriter(stream)
     self.write_tag(stream)
     s.u32(self.version)
     tgi = TGIList(32, 'TGI')
     tgi.begin_write(stream)
     s.hash(self.shader)
     if self.shader:
         self.material.write(stream, tgi)
     s.u32(self.merge_group)
     s.u32(self.sort_order)
     s.u32(len(self.vertices))
     self.vertex_format.from_vertex(self.vertices[0])
     self.vertex_format.write(stream)
     for vertex in self.vertices:
         uv_index = 0
         for declaration in self.vertex_format.declarations:
             if declaration.usage == self.VertexFormat.Declaration.USAGE.POSITION:
                 for i in range(3):
                     s.f32(vertex.position)
             elif declaration.usage == self.VertexFormat.Declaration.USAGE.NORMAL:
                 for i in range(3):
                     s.f32(vertex.normal)
             elif declaration.usage == self.VertexFormat.Declaration.USAGE.UV:
                 for i in range(2):
                     s.f32(vertex.uv[uv_index])
                 uv_index += 1
             elif declaration.usage == self.VertexFormat.Declaration.USAGE.BLEND_INDEX:
                 for i in range(4):
                     s.i8(vertex.blend_indices)
             elif declaration.usage == self.VertexFormat.Declaration.USAGE.BLEND_WEIGHT:
                 for i in range(4):
                     s.f32(vertex.blend_weights)
             elif declaration.usage == self.VertexFormat.Declaration.USAGE.TANGENT:
                 for i in range(3):
                     s.f32(vertex.tangents)
             elif declaration.usage == self.VertexFormat.Declaration.USAGE.COLOUR:
                 for i in range(4):
                     s.i8(vertex.colour)
             elif declaration.usage == self.VertexFormat.Declaration.USAGE.ID:
                 s.u32(vertex.id)
     s.u32(tgi.get_resource_index(self.skin_controller))
     s.u32(len(self.bones))
     for bone in self.bones:
         s.u32(bone)
Example #20
0
 def write_rcol(self, stream, rcol):
     s = StreamWriter(stream)
     self.write_tag(stream)
     s.u32(self.version)
     s.hash(self.name)
     s.i32(len(self.actors))
     for actor in self.actors: s.u32(rcol.get_block_index(actor, ActorDefinition))
     s.i32(len(self.parameters))
     for parameter in self.parameters: s.u32(rcol.get_block_index(parameter, ParameterDefinition))
     s.i32(len(self.states))
     for state in self.states: s.u32(rcol.get_block_index(state, State))
     s.i32(len(self.namespace_map))
     for actor_pair in self.namespace_map: actor_pair.write(stream)
     s.u32(DEADBEEF)
     s.u32(self.flags)
     s.u32(self.default_priority)
     s.u32(self.awareness_overlay_level)
     for i in range(4): s.u32(0)
Example #21
0
 def write_pointer(self, stream):
     self.size32 = 1
     t = type(self.value)
     if isinstance(self.value, list):
         self.size32 = len(self.value)
         t = type(self.value[0])
     if t == float:
         self.type_code = self.TYPE.FLOAT
     elif t == int:
         self.type_code = self.TYPE.INT
     elif  t == ExternalResource:
         self.type_code = self.TYPE.TEXTURE
     elif t == ResourceKey:
         self.size32 = 4
         self.type_code = self.TYPE.TEXTURE
     else:
         raise NotImplementedError("Serialization of type %s is not supported in this format!" % t)
     s = StreamWriter(stream)
     s.hash(self.name)
     s.u32(self.type_code)
     s.u32(self.size32)
     self.pointer = StreamPtr.begin_write(s)
Example #22
0
    def write(self, stream, rcol):
        s = StreamWriter(stream)
        len_offset = stream.tell()
        s.u32(0)
        start = stream.tell()
        s.hash(self.name)
        s.u32(rcol.get_block_index(self.material))
        s.u32(rcol.get_block_index(self.vertex_format))
        s.u32(rcol.get_block_index(self.vertex_buffer))
        s.u32(rcol.get_block_index(self.index_buffer))

        flags = self.primitive_type
        flags |= (self.flags << 8)
        s.u32(flags)
        s.u32(self.stream_offset)
        s.i32(self.start_vertex)
        s.i32(self.start_index)
        s.i32(self.min_vertex_index)
        s.i32(self.vertex_count)
        s.i32(self.primitive_count)
        self.bounds.write(stream)
        s.u32(rcol.get_block_index(self.skin_controller))
        s.i32(len(self.bone_references))
        for bone in self.bone_references:
            s.u32(bone)
        s.u32(rcol.get_block_index(self.scale_offsets))
        s.i32(len(self.states))
        for state in self.states:
            state.write_rcol(self, rcol)
        if self.parent.version > ModelLod.VERSION.DEFAULT:
            s.hash(self.parent_name)
            for i in range(3):
                s.f32(self.mirror_plane_normal[i])
            s.f32(self.mirror_plane_offset)
        end = stream.tell()
        stream.seek(len_offset, SEEK_SET)
        s.u32(end - start)
        stream.seek(end, SEEK_SET)
Example #23
0
 def write_rcol(self, stream, rcol):
     s = StreamWriter(stream)
     self.write_tag(stream)
     s.u32(self.version)
     s.hash(self.name)
     s.i32(len(self.actors))
     for actor in self.actors:
         s.u32(rcol.get_block_index(actor, ActorDefinition))
     s.i32(len(self.parameters))
     for parameter in self.parameters:
         s.u32(rcol.get_block_index(parameter, ParameterDefinition))
     s.i32(len(self.states))
     for state in self.states:
         s.u32(rcol.get_block_index(state, State))
     s.i32(len(self.namespace_map))
     for actor_pair in self.namespace_map:
         actor_pair.write(stream)
     s.u32(DEADBEEF)
     s.u32(self.flags)
     s.u32(self.default_priority)
     s.u32(self.awareness_overlay_level)
     for i in range(4):
         s.u32(0)
Example #24
0
 def write(self, stream, resource=None):
     Event.write(self, stream)
     s = StreamWriter(stream)
     s.u32(self.unknown4)
     s.u32(self.unknown5)
     s.hash(self.effect_name)
     s.hash(self.actor_name)
     s.hash(self.slot_name)
     s.u32(self.unknown6)
Example #25
0
 def write_rcol(self, stream, rcol):
     s = StreamWriter(stream)
     self.write_tag(stream)
     s.u32(self.version)
     tgi = TGIList(32, 'TGI')
     tgi.begin_write(stream)
     s.hash(self.shader)
     if self.shader:
         self.material.write(stream, tgi)
     s.u32(self.merge_group)
     s.u32(self.sort_order)
     s.u32(len(self.vertices))
     self.vertex_format.from_vertex(self.vertices[0])
     self.vertex_format.write(stream)
     for vertex in self.vertices:
         uv_index = 0
         for declaration in self.vertex_format.declarations:
             if declaration.usage == self.VertexFormat.Declaration.USAGE.POSITION:
                 for i in range(3): s.f32(vertex.position)
             elif declaration.usage == self.VertexFormat.Declaration.USAGE.NORMAL:
                 for i in range(3): s.f32(vertex.normal)
             elif declaration.usage == self.VertexFormat.Declaration.USAGE.UV:
                 for i in range(2): s.f32(vertex.uv[uv_index])
                 uv_index += 1
             elif declaration.usage == self.VertexFormat.Declaration.USAGE.BLEND_INDEX:
                 for i in range(4): s.i8(vertex.blend_indices)
             elif declaration.usage == self.VertexFormat.Declaration.USAGE.BLEND_WEIGHT:
                 for i in range(4): s.f32(vertex.blend_weights)
             elif declaration.usage == self.VertexFormat.Declaration.USAGE.TANGENT:
                 for i in range(3): s.f32(vertex.tangents)
             elif declaration.usage == self.VertexFormat.Declaration.USAGE.COLOUR:
                 for i in range(4): s.i8(vertex.colour)
             elif declaration.usage == self.VertexFormat.Declaration.USAGE.ID:
                 s.u32(vertex.id)
     s.u32(tgi.get_resource_index(self.skin_controller))
     s.u32(len(self.bones))
     for bone in self.bones: s.u32(bone)
Example #26
0
 def write(self, stream, resource=None):
     Event.write(self, stream)
     s = StreamWriter(stream)
     s.u32(self.unknown4)
     s.u32(self.unknown5)
     s.hash(self.effect_name)
     s.hash(self.actor_name)
     s.hash(self.slot_name)
     s.u32(self.unknown6)
Example #27
0
 def write_pointer(self, stream):
     self.size32 = 1
     t = type(self.value)
     if isinstance(self.value, list):
         self.size32 = len(self.value)
         t = type(self.value[0])
     if t == float:
         self.type_code = self.TYPE.FLOAT
     elif t == int:
         self.type_code = self.TYPE.INT
     elif t == ExternalResource:
         self.type_code = self.TYPE.TEXTURE
     elif t == ResourceKey:
         self.size32 = 4
         self.type_code = self.TYPE.TEXTURE
     else:
         raise NotImplementedError(
             "Serialization of type %s is not supported in this format!"
             % t)
     s = StreamWriter(stream)
     s.hash(self.name)
     s.u32(self.type_code)
     s.u32(self.size32)
     self.pointer = StreamPtr.begin_write(s)
Example #28
0
    def write(self, stream, resource=None):
        Event.write(self, stream)
        s = StreamWriter(stream)
        s.hash(self.prop_actor_name)
        s.hash(self.object_actor_name)
        s.hash(self.slot_name)
        s.u32(self.unknown4)

        for i in range(4):
            for j in range(4): s.f32(self.matrix[i][j])
Example #29
0
    def write(self, stream, resource=None):
        Event.write(self, stream)
        s = StreamWriter(stream)
        s.hash(self.prop_actor_name)
        s.hash(self.object_actor_name)
        s.hash(self.slot_name)
        s.u32(self.unknown4)

        for i in range(4):
            for j in range(4):
                s.f32(self.matrix[i][j])
Example #30
0
 def write_rcol(self, stream, rcol):
     s = StreamWriter(stream)
     self.write_tag(stream)
     s.u32(self.version)
     s.hash(self.name)
     s.hash(self.default)
Example #31
0
 def write(self, stream, resources=None):
     s = StreamWriter(stream)
     s.hash(self.target_namespace)
     s.hash(self.ik_suffix)
Example #32
0
 def write(self, stream, resources=None):
     s = StreamWriter(stream)
     s.u32(self.chain_id)
     s.u32(self.slot_id)
     s.hash(self.target_namespace)
     s.hash(self.target_slot)
Example #33
0
 def write(self, stream, resources=None):
     s = StreamWriter(stream)
     s.hash(self.filename)
     s.hash(self.clip_actor)
     s.hash(self.jazz_actor)
Example #34
0
 def write(self, stream, resources=None):
     s = StreamWriter(stream)
     s.hash(self.filename)
     s.hash(self.clip_actor)
     s.hash(self.jazz_actor)
Example #35
0
 def write(self, stream, resources=None):
     s = StreamWriter(stream)
     s.hash(self.target_namespace)
     s.hash(self.ik_suffix)
Example #36
0
 def write(self, stream, resources=None):
     s = StreamWriter(stream)
     s.u32(self.chain_id)
     s.u32(self.slot_id)
     s.hash(self.target_namespace)
     s.hash(self.target_slot)
Example #37
0
 def write_rcol(self, stream, rcol):
     s = StreamWriter(stream)
     self.write_tag(stream)
     s.u32(self.version)
     s.hash(self.name)
     s.hash(self.default)
Example #38
0
 def write(self, stream, resource=None):
     Event.write(self, stream)
     s = StreamWriter(stream)
     s.hash(self.prop_actor_name)
Example #39
0
 def write(self, stream, resources=None):
     s = StreamWriter(stream)
     s.u32(self.version)
     tgi = TGIList()
     tgi.begin_write(stream)
     ProductBase.write_presets(stream,self.presets,tgi)
     if self.version >= 0x00000016:
         s.s7(self.instance_name,size=16,order='>')
     self.product_info.write(stream,tgi)
     s.i32(tgi.get_resource(self.object_component))
     s.u32(self.object_type_flags)
     if self.version >= 0x000001A:
         s.u32(self.object_type_flags_2)
     s.u32(self.wall_placement_flags)
     s.u32(self.movement_flags)
     s.i32(self.num_wall_cutout_tiles_per_level)
     s.i32(self.num_levels)
     s.i8(len(self.wall_masks))
     for wall_mask in self.wall_masks:
         wall_mask.write(stream,tgi)
     s.i8(1 if self.script_enabled else 0)
     s.i32(tgi.get_resource_index(self.diagonal_object))
     s.hash(self.ambiance_type)
     s.u32(self.room_flags)
     s.u32(self.function_category_flags)
     s.u64(self.sub_category_flags)
     if self.version >= 0x0000001C:
         s.u64(self.sub_category_flags_2)
     s.u64(self.sub_room_flags)
     s.u32(self.build_category_flags)
     s.i32(tgi.get_resource_index(self.wall_cutout_texture))
     if self.version >= 0x00000017:
         s.i32(tgi.get_resource_index(self.floor_cutout_texture))
         s.i32(self.floor_cutout_level_offset)
         s.f32(self.floor_cutout_bounds_length )
     if self.version >= 0x00000020:
         s.f32(self.floor_cutout_bounds_width )
     if self.version >= 0x0000021:
         s.f32(self.floor_cutout_offset_x )
         s.f32(self.floor_cutout_offset_z )
     if self.version >= 0x00000018:
         s.i32(len(self.shell_states))
         for shell_state in self.shell_states: s.hash(shell_state)
     if self.version >= 0x00000019:
         s.i32(tgi.get_resource_index(self.shell_level_below ))
     if self.version >= 0x0000001B:
         s.i32(tgi.get_resource_index(self.shell_proxy ))
     if self.version >= 0x0000001D:
         s.i32(tgi.get_resource_index(self.blueprint_xml ))
     if self.version >= 0x0000001E:
         s.i32(tgi.get_resource_index(self.blueprint_icon ))
     if self.version >= 0x0000001F:
         s.f32(self.blueprint_icon_offset_min_x)
         s.f32(self.blueprint_icon_offset_min_z)
         s.f32(self.blueprint_icon_offset_max_x)
         s.f32(self.blueprint_icon_offset_max_z)
     s.u32(self.slot_placement_flags)
     s.s7(self.surface_type,size=16,order='>')
     s.s7(self.source_material,size=16,order='>')
     s.u32(self.moodlet_given)
     s.u32(self.moodlet_score)
     s.u32(5)
     for rating in self.ratings: rating.write(stream)
     s.i32(tgi.get_resource_index(self.fallback))
     if self.version >= 0x00000022:
         s.i32(tgi.get_resource_index(self.modular_arch_end_east_model))
         s.i32(tgi.get_resource_index(self.modular_arch_end_east_model))
         s.i32(tgi.get_resource_index(self.modular_arch_connecting_model))
         s.i32(tgi.get_resource_index(self.modular_arch_single_model))
     tgi.end_write(stream)
Example #40
0
 def write(self, stream, resource=None):
     Event.write(self, stream)
     s = StreamWriter(stream)
     s.hash(self.prop_actor_name)