import warnings


def ParseSMFString(stringList):
    """v,f,n,c,r <-- ParseSMFString(stringList)
Parse an ascii SMF file and returnes a list of 3D vertices, triangular faces
(0-based indices, faces with more edges generate warnings), normals, colors
and 2D texture coordinates.
"""
    
    vertices = []
    faces = []
    normals = []
    colors = []
    textures = []
    fi = 0
    for l in stringList:
        w = l.split()
        if w[0]=='v': # vertices
            vertices.append( [float(w[1]),float(w[2]),float(w[3])] )
        elif w[0]=='f': # faces
            if len(w) > 4:
                warnings.warn("face %d has more than 3 edges"%fi);
            faces.append( [int(w[1])-1,int(w[2])-1,int(w[3])-1] )
            fi += 1
        if w[0]=='n': # normal vectors
            normals.append( [float(w[1]),float(w[2]),float(w[3])] )
        if w[0]=='c': # colors
            colors.append( [float(w[1]),float(w[2]),float(w[3])] )
        if w[0]=='r': # 2D texture indices
            textures.append( [float(w[1]),float(w[2])] )
    return vertices, faces, normals, colors, textures