Esempio n. 1
0
def mirrorShapeKey(shape):

    # Get Symmetry Map
    mesh = shape.Parent3DObject
    symmetry_map = uti.getSymmetryMap(mesh)
    if not symmetry_map:
        gear.log("There is no symmetry map available on this mesh", gear.sev_warning)
        return

    cls = shape.Parent
    shape_tuple = shape.Elements.Array
    symmetry_array = symmetry_map.Elements.Array

    shape_array = [0] * len(shape_tuple[0])*3

    # Process
    for iPntIndex in cls.Elements:

        iSymIndex = int(symmetry_array[0][iPntIndex])

        shape_array[iSymIndex*3+0] = - shape_tuple[0][iPntIndex]
        shape_array[iSymIndex*3+1] = shape_tuple[1][iPntIndex]
        shape_array[iSymIndex*3+2] = shape_tuple[2][iPntIndex]

    duplicate_shape = xsi.StoreShapeKey(cls, shape.Name+"_Mirror", c.siShapeObjectReferenceMode, 1, None, None, c.siShapeContentSecondaryShape, True)
    duplicate_shape.Elements.Array = shape_array
    xsi.ApplyShapeKey(duplicate_shape, None, None, 100, None, None, None, 2)
    xsi.FreezeObj(duplicate_shape)

    return duplicate_shape
Esempio n. 2
0
File: shape.py Progetto: jeanim/gear
def createHalfShape(shape, c_points, prefix, opp_points):

    new_shape = xsi.StoreShapeKey(shape.Parent, prefix + shape.Name,
                                  c.siShapeObjectReferenceMode)
    shape_tuple = shape.Elements.Array
    shape_array = [
        shape_tuple[j][i] for i in range(len(shape_tuple[0]))
        for j in range(len(shape_tuple))
    ]

    for i in opp_points:
        shape_array[i * 3 + 0] = 0
        shape_array[i * 3 + 1] = 0
        shape_array[i * 3 + 2] = 0

    for i in c_points:
        shape_array[i * 3 + 0] *= 0.5
        shape_array[i * 3 + 1] *= 0.5
        shape_array[i * 3 + 2] *= 0.5

    new_shape.Elements.Array = shape_array

    xsi.ApplyShapeKey(new_shape, None, None, 100, None, None, None, 2)
    xsi.FreezeObj(new_shape)

    return new_shape
Esempio n. 3
0
File: shape.py Progetto: jeanim/gear
def mergeShapeKeys(shapes):

    cls = shapes[0].Parent

    merged_array = [
        0
    ] * 3 * cls.Parent3DObject.ActivePrimitive.Geometry.Points.Count
    for shape in shapes:
        shape_tuple = shape.Elements.Array

        for i in range(len(shape_tuple[0])):
            merged_array[i * 3 + 0] += shape_tuple[0][i]
            merged_array[i * 3 + 1] += shape_tuple[1][i]
            merged_array[i * 3 + 2] += shape_tuple[2][i]

    cls = shapes[0].Parent

    merged_shape = xsi.StoreShapeKey(cls, "shapeKey_merged",
                                     c.siShapeObjectReferenceMode, 1, None,
                                     None, c.siShapeContentSecondaryShape,
                                     True)
    merged_shape.Elements.Array = merged_array

    xsi.ApplyShapeKey(merged_shape, None, None, 100, None, None, None, 2)
    xsi.FreezeObj(merged_shape)

    return merged_shape
Esempio n. 4
0
def duplicateShapeKey(shape, cluster=None):

    if cluster is None:
        cluster = shape.Parent

    shape_array = shape.Elements.Array

    duplicate_shape = xsi.StoreShapeKey(cluster, shape.Name+"_Copy", c.siShapeObjectReferenceMode, 1, None, None, c.siShapeContentSecondaryShape, True)
    duplicate_shape.Elements.Array = shape_array
    xsi.ApplyShapeKey(duplicate_shape, None, None, 100, None, None, None, 2)
    xsi.FreezeObj(duplicate_shape)

    return duplicate_shape