Пример #1
0
def gear_NormalizeWeights_Execute():

    if not xsi.Selection.Count:
        gear.log("No selection", gear.sev_error)
        return

    sel = xsi.Selection(0)

    if sel.Type in ["polymsh", "surfmsh", "crvlist"]:
        mesh = sel
        points = range(mesh.ActivePrimitive.Geometry.Points.Count)
    elif sel.Type == "pntSubComponent":
        mesh = sel.SubComponent.Parent3DObject
        points = sel.SubComponent.ElementArray
    else:
        gear.log("Invalid selection", gear.sev_error)
        return

    # Get Envelope from object
    envelope_op = ope.getOperatorFromStack(mesh, "envelopop")
    if not envelope_op:
        gear.log("There is no envelope on selected mesh", gear.sev_error)
        return

    # Process
    points = env.getUnnormalizedPoints(envelope_op, points)
    if not env.normalizeWeights(envelope_op, points):
        return

    env.freezeEnvelope(envelope_op)
    env.rebuiltEnvelope(envelope_op)
Пример #2
0
def gear_NormalizeWeights_Execute():

    if not xsi.Selection.Count:
        gear.log("No selection", gear.sev_error)
        return

    sel = xsi.Selection(0)

    if sel.Type in ["polymsh", "surfmsh", "crvlist"]:
        mesh = sel
        points = range(mesh.ActivePrimitive.Geometry.Points.Count)
    elif sel.Type == "pntSubComponent":
        mesh = sel.SubComponent.Parent3DObject
        points = sel.SubComponent.ElementArray
    else:
        gear.log("Invalid selection", gear.sev_error)
        return

    # Get Envelope from object
    envelope_op = ope.getOperatorFromStack(mesh, "envelopop")
    if not envelope_op:
        gear.log("There is no envelope on selected mesh", gear.sev_error)
        return

    # Process
    points = env.getUnnormalizedPoints(envelope_op, points)
    if not env.normalizeWeights(envelope_op, points):
        return

    env.freezeEnvelope(envelope_op)
    env.rebuiltEnvelope(envelope_op)
Пример #3
0
def gear_NormalizeToDeformer_Execute():

    if not xsi.Selection.Count:
        gear.log("No selection", gear.sev_error)
        return

    sel = xsi.Selection(0)

    if sel.Type in ["polymsh", "surfmsh", "crvlist"]:
        mesh = sel
        points = range(mesh.ActivePrimitive.Geometry.Points.Count)
    elif sel.Type == "pntSubComponent":
        mesh = sel.SubComponent.Parent3DObject
        points = sel.SubComponent.ElementArray
    else:
        gear.log("Invalid selection", gear.sev_error)
        return

    # Get Envelope from object
    envelope_op = ope.getOperatorFromStack(mesh, "envelopop")
    if not envelope_op:
        gear.log("There is no envelope on selected mesh", gear.sev_error)
        return

    # Get The deformers
    deformers = XSIFactory.CreateObject("XSI.Collection")
    while True:
        deformer = uit.pickSession(c.siGenericObjectFilter, "Pick Deformer",
                                   False)
        if not deformer:
            break

        if env.isDeformer(envelope_op, deformer):
            deformers.Add(deformer)
        else:
            gear.log("Picked object is not a deformer for this envelope",
                     c.siWarning)

    if not deformers.Count:
        return

    # Process
    env.normalizeToDeformer(envelope_op, deformers, points)
    env.freezeEnvelope(envelope_op)
    env.rebuiltEnvelope(envelope_op)
Пример #4
0
def gear_RebuildEnvelope_Execute():

    if not xsi.Selection.Count:
        gear.log("No selection", gear.sev_error)
        return

    for mesh in xsi.Selection:

        if mesh.Type not in ["polymsh", "surfmsh", "crvlist"]:
            gear.log("Invalid selection", gear.sev_error)
            continue

        # Get Envelope from object
        envelope_op = ope.getOperatorFromStack(mesh, "envelopop")
        if not envelope_op:
            gear.log("There is no envelope on selected mesh", c.siWarning)
            continue

        env.rebuiltEnvelope(envelope_op)
Пример #5
0
def gear_NormalizeToDeformer_Execute():

    if not xsi.Selection.Count:
        gear.log("No selection", gear.sev_error)
        return

    sel = xsi.Selection(0)

    if sel.Type in ["polymsh", "surfmsh", "crvlist"]:
        mesh = sel
        points = range(mesh.ActivePrimitive.Geometry.Points.Count)
    elif sel.Type == "pntSubComponent":
        mesh = sel.SubComponent.Parent3DObject
        points = sel.SubComponent.ElementArray
    else:
        gear.log("Invalid selection", gear.sev_error)
        return

    # Get Envelope from object
    envelope_op = ope.getOperatorFromStack(mesh, "envelopop")
    if not envelope_op:
        gear.log("There is no envelope on selected mesh", gear.sev_error)
        return

    # Get The deformers
    deformers = XSIFactory.CreateObject("XSI.Collection")
    while True:
        deformer =  uit.pickSession(c.siGenericObjectFilter, "Pick Deformer", False)
        if not deformer:
            break

        if env.isDeformer(envelope_op, deformer):
            deformers.Add(deformer)
        else:
            gear.log("Picked object is not a deformer for this envelope", c.siWarning)

    if not deformers.Count:
        return

    # Process
    env.normalizeToDeformer(envelope_op, deformers, points)
    env.freezeEnvelope(envelope_op)
    env.rebuiltEnvelope(envelope_op)
Пример #6
0
def gear_RebuildEnvelope_Execute():

    if not xsi.Selection.Count:
        gear.log("No selection", gear.sev_error)
        return

    for mesh in xsi.Selection:

        if mesh.Type not in ["polymsh", "surfmsh", "crvlist"]:
            gear.log("Invalid selection", gear.sev_error)
            continue

        # Get Envelope from object
        envelope_op = ope.getOperatorFromStack(mesh, "envelopop")
        if not envelope_op:
            gear.log("There is no envelope on selected mesh", c.siWarning)
            continue

        env.rebuiltEnvelope(envelope_op)