Ejemplo n.º 1
0
def _fill_piece_sections(convex_coll_locators, export_scale):
    """Fills up "Piece" sections for convex colliders."""

    len_vertices = 0
    len_faces = 0
    piece_sections = []
    index = 0
    for item in convex_coll_locators:
        stream_cnt = 0
        verts = item.scs_props.get("coll_convex_verts", 0)
        faces = item.scs_props.get("coll_convex_faces", 0)
        if verts:
            stream_cnt += 1

        len_vertices += len(verts)
        len_faces += len(faces)

        section = _SectionData("Piece")
        section.props.append(("Index", index))
        section.props.append(("Material", 0))
        section.props.append(("VertexCount", len(verts)))
        section.props.append(("TriangleCount", len(faces)))
        section.props.append(("StreamCount", stream_cnt))
        section.props.append(("", ""))

        # VERTICES
        if verts:
            vector_verts = []
            for vert in verts:
                # scs_position = Matrix.Scale(scs_globals.export_scale, 4) * io_utils.scs_to_blend_matrix().inverted() * mat_world * position ##
                # POSITION
                scs_position = Matrix.Scale(
                    export_scale, 4) * _convert_utils.scs_to_blend_matrix(
                    ).inverted() * Vector(vert)  # POSITION
                vector_verts.append(Vector(scs_position))
            section.sections.append(
                _pix_container.make_stream_section(vector_verts, "_POSITION",
                                                   ()))

        # FACES (TRIANGLES)
        if faces:
            # FACE FLIPPING
            flipped_faces = _mesh_utils.flip_faceverts(faces)
            section.sections.append(
                _pix_container.make_triangle_stream(flipped_faces))

        index += 1
        piece_sections.append(section)
    return len_vertices, len_faces, piece_sections
Ejemplo n.º 2
0
def _fill_piece_sections(convex_coll_locators, export_scale):
    """Fills up "Piece" sections for convex colliders."""

    len_vertices = 0
    len_faces = 0
    piece_sections = []
    index = 0
    for item in convex_coll_locators:
        stream_cnt = 0
        verts = item.scs_props.get("coll_convex_verts", 0)
        faces = item.scs_props.get("coll_convex_faces", 0)
        if verts:
            stream_cnt += 1

        len_vertices += len(verts)
        len_faces += len(faces)

        section = _SectionData("Piece")
        section.props.append(("Index", index))
        section.props.append(("Material", 0))
        section.props.append(("VertexCount", len(verts)))
        section.props.append(("TriangleCount", len(faces)))
        section.props.append(("StreamCount", stream_cnt))
        section.props.append(("", ""))

        # VERTICES
        if verts:
            vector_verts = []
            for vert in verts:
                # scs_position = Matrix.Scale(scs_globals.export_scale, 4) * io_utils.scs_to_blend_matrix().inverted() * mat_world * position ##
                # POSITION
                scs_position = Matrix.Scale(export_scale, 4) * _convert_utils.scs_to_blend_matrix().inverted() * Vector(vert)  # POSITION
                vector_verts.append(Vector(scs_position))
            section.sections.append(_pix_container.make_stream_section(vector_verts, "_POSITION", ()))

        # FACES (TRIANGLES)
        if faces:
            # FACE FLIPPING
            flipped_faces = _mesh_utils.flip_faceverts(faces)
            section.sections.append(_pix_container.make_triangle_stream(flipped_faces))

        index += 1
        piece_sections.append(section)
    return len_vertices, len_faces, piece_sections