Beispiel #1
0
def get_CV_line(dagPath, v, eK1, eK2):
    meshFn = om.MFnMesh(dagPath);
    
    e = mt.vertex_edges(dagPath, v);
    
    if e[0]==eK1 or e[0]==eK2:
        e = [e[1], e[3]];
    else:
        e = [e[0], e[2]];

    tccNode = mt.get_TCC_DGnode(dagPath);
    T = cmds.getAttr(tccNode.name()+".T");
      
    he = []; hv = [];
    for eK in e:
        f = mt.edge_faces(dagPath, eK);
    
        he0 = mt.halfedge(dagPath, f[0], eK1);
        if he0[1]==-1:
            he0 = mt.halfedge(dagPath, f[0], eK2);
        eN = mt.edge(mt.next(he0));
        dir = 0;
        if eN == e[0] or eN == e[1]:
            dir = 1;
        else:
            dir = -1;
            
        he0 = mt.next(he0, dir); 
        T0 = mt.get_halfedge_data(dagPath, T, he0) if dir ==1 else mt.get_halfedge_data(dagPath, T, mt.prev(he0));
        he1 = mt.next(he0, dir) if T0 else mt.next(mt.twin(mt.next(he0, dir)),dir);
        T1 = mt.get_halfedge_data(dagPath, T, he1) if dir ==1 else mt.get_halfedge_data(dagPath, T, mt.prev(he1));
        he2 = mt.next(he1, dir) if T1 else mt.next(mt.twin(mt.next(he1, dir)),dir);
        
        he.append(he0);
        he.append(he1);
        he.append(he2);
        
        hv.append(mt.tip(he0, dir));
        hv.append(mt.tip(he1, dir));
        hv.append(mt.tip(he2, dir));
        
        
    he = [ he[2], he[1], he[0], he[3], he[4], he[5] ];
    hv = [ hv[2], hv[1], hv[0], v, hv[3], hv[4], hv[5] ];
    
    return (he, hv);
Beispiel #2
0
def get_CV_line(dagPath, v, eK1, eK2):
    meshFn = om.MFnMesh(dagPath)

    e = mt.vertex_edges(dagPath, v)

    if e[0] == eK1 or e[0] == eK2:
        e = [e[1], e[3]]
    else:
        e = [e[0], e[2]]

    tccNode = mt.get_TCC_DGnode(dagPath)
    T = cmds.getAttr(tccNode.name() + ".T")

    he = []
    hv = []
    for eK in e:
        f = mt.edge_faces(dagPath, eK)

        he0 = mt.halfedge(dagPath, f[0], eK1)
        if he0[1] == -1:
            he0 = mt.halfedge(dagPath, f[0], eK2)
        eN = mt.edge(mt.next(he0))
        dir = 0
        if eN == e[0] or eN == e[1]:
            dir = 1
        else:
            dir = -1

        he0 = mt.next(he0, dir)
        T0 = mt.get_halfedge_data(dagPath, T, he0) if dir == 1 else mt.get_halfedge_data(dagPath, T, mt.prev(he0))
        he1 = mt.next(he0, dir) if T0 else mt.next(mt.twin(mt.next(he0, dir)), dir)
        T1 = mt.get_halfedge_data(dagPath, T, he1) if dir == 1 else mt.get_halfedge_data(dagPath, T, mt.prev(he1))
        he2 = mt.next(he1, dir) if T1 else mt.next(mt.twin(mt.next(he1, dir)), dir)

        he.append(he0)
        he.append(he1)
        he.append(he2)

        hv.append(mt.tip(he0, dir))
        hv.append(mt.tip(he1, dir))
        hv.append(mt.tip(he2, dir))

    he = [he[2], he[1], he[0], he[3], he[4], he[5]]
    hv = [hv[2], hv[1], hv[0], v, hv[3], hv[4], hv[5]]

    return (he, hv)
    def doIt(self, args):

        if args.length() < 1:
            raise RuntimeError("have to specify 'insert'/'remove'!")

        if args.asString(0) == "double":
            multiplier = 2.0
        elif args.asString(0) == "half":
            multiplier = 0.5
        else:
            raise RuntimeError("have to specify 'double'/'half'!")

        (dagPath, comp) = mt.selected_dagPath_component()
        dagPath.extendToShape()

        meshFn = om.MFnMesh(dagPath)
        nFV = om.MIntArray()
        F = om.MIntArray()
        meshFn.getVertices(nFV, F)

        edgeIt = om.MItMeshEdge(dagPath, comp)

        outMeshAttr = meshFn.attribute("outMesh")
        outMeshPlug = om.MPlug(dagPath.node(), outMeshAttr)
        plugArray = om.MPlugArray()
        outMeshPlug.connectedTo(plugArray, True, True)

        foundTCC = False
        for k in range(0, plugArray.length()):
            TCCnode = plugArray[k].node()
            TCCDepNode = om.MFnDependencyNode(TCCnode)
            if TCCDepNode.typeName() == "TCC":
                foundTCC = True
                break

        if not foundTCC:
            raise Exception('did not find TCC node')

        eqc = cmds.getAttr(TCCDepNode.name() + ".eqc")
        itv = cmds.getAttr(TCCDepNode.name() + ".itv")

        he = mt.halfedges(dagPath, edgeIt.index())
        he = he[0]

        targetEqc = mt.get_halfedge_data(dagPath, eqc, he)

        for k in range(len(eqc)):
            if eqc[k] == targetEqc: itv[k] = itv[k] * multiplier

        cmds.setAttr(TCCDepNode.name() + ".itv", itv, type="doubleArray")
    def doIt(self, args):

        if args.length()<1:
            raise RuntimeError("have to specify 'insert'/'remove'!");
            
        if args.asString(0)=="double":
            multiplier = 2.0;
        elif args.asString(0)=="half":
            multiplier = 0.5;
        else:
            raise RuntimeError("have to specify 'double'/'half'!");
    
        (dagPath, comp) = mt.selected_dagPath_component();
        dagPath.extendToShape();
        
        meshFn = om.MFnMesh(dagPath);
        nFV = om.MIntArray(); F = om.MIntArray(); 
        meshFn.getVertices(nFV, F);
        
        edgeIt = om.MItMeshEdge(dagPath, comp);
        
        
        outMeshAttr = meshFn.attribute( "outMesh" );
        outMeshPlug = om.MPlug(dagPath.node(), outMeshAttr );
        plugArray = om.MPlugArray(); outMeshPlug.connectedTo(plugArray, True, True);
                    
        foundTCC = False;
        for k in range(0, plugArray.length()):
            TCCnode = plugArray[k].node();
            TCCDepNode = om.MFnDependencyNode( TCCnode );
            if TCCDepNode.typeName() == "TCC":
                foundTCC = True; break;
                
        if not foundTCC: 
            raise Exception('did not find TCC node');

        eqc = cmds.getAttr(TCCDepNode.name()+".eqc");
        itv = cmds.getAttr(TCCDepNode.name()+".itv");
        
        he = mt.halfedges(dagPath, edgeIt.index()); he = he[0];
        
        targetEqc = mt.get_halfedge_data(dagPath, eqc, he);

        for k in range(len(eqc)): 
            if eqc[k]==targetEqc: itv[k] = itv[k] * multiplier;
            
        cmds.setAttr(TCCDepNode.name()+".itv", itv, type="doubleArray");
Beispiel #5
0
def knot_modifier(modType):
    (dagPath, component) = mt.selected_dagPath_component()

    meshFn = om.MFnMesh(dagPath)

    tccNode = mt.get_TCC_DGnode(dagPath)

    itv = cmds.getAttr(tccNode.name() + ".itv")
    T = cmds.getAttr(tccNode.name() + ".T")

    ve = build_knot_removal_data(dagPath)

    R = []

    for (v, e) in ve.items():
        (he, v) = get_CV_line(dagPath, v, e[0], e[1])

        i = []
        for k in range(6):
            i.append(mt.get_halfedge_data(dagPath, itv, he[k]))

        p = []
        for k in range(1, 6):
            pk = om.MPoint()
            meshFn.getPoint(v[k], pk)
            p.append(Vec3(pk.x, pk.y, pk.z))

        if modType == KnotModifier.Insert:
            (p2, p3, p4) = compute_knot_insertion(p, i)
        elif modType == KnotModifier.Remove:
            (p2, p3, p4) = compute_knot_removal(p, i)
        else:
            raise Exception("Unknown Modifier")

        R.append((v[2], p2))
        R.append((v[3], p3))
        R.append((v[4], p4))

    return R
Beispiel #6
0
def knot_modifier(modType):    
    (dagPath, component) = mt.selected_dagPath_component();
    
    meshFn = om.MFnMesh(dagPath);
    
    tccNode = mt.get_TCC_DGnode(dagPath);
    
    itv = cmds.getAttr(tccNode.name()+".itv");
    T = cmds.getAttr(tccNode.name()+".T");
    
    ve = build_knot_removal_data(dagPath);

    R = [];

    for (v,e) in ve.items():
        (he, v) = get_CV_line(dagPath, v, e[0], e[1]);

        i = [];
        for k in range(6):
            i.append(mt.get_halfedge_data(dagPath, itv, he[k]));
            
        p = [];
        for k in range(1,6):
            pk = om.MPoint(); meshFn.getPoint(v[k], pk); 
            p.append(Vec3(pk.x, pk.y, pk.z));

        if modType == KnotModifier.Insert:
            (p2, p3, p4) = compute_knot_insertion(p, i);
        elif modType == KnotModifier.Remove:
            (p2, p3, p4) = compute_knot_removal(p, i);
        else:
            raise Exception("Unknown Modifier");

        R.append( (v[2], p2) )
        R.append( (v[3], p3) )
        R.append( (v[4], p4) )
    
    return R;