Example #1
0
def Cloth_GetMimic(prop, target, prefix):
    obj = prop.Parent3DObject
    syflex_op = obj.ActivePrimitive.ConstructionHistory.Find('syCloth')

    mimic_cluster = obj.ActivePrimitive.Geometry.Clusters(
        '{}MimicCls'.format(prefix))
    if not mimic_cluster:
        mimic_cluster = Utils.CreateCompleteButNotAlwaysCluster(
            obj, constants.siVertexCluster, '{}MimicCls'.format(prefix))

    mimic_map = Utils.GetWeightMap(obj, '{}MimicMap'.format(prefix), 1, 0, 1,
                                   mimic_cluster)
    mimic_op = XSI.ApplyOperator(
        'syMimic', ';'.join([
            syflex_op.FullName, target.FullName, target.Kinematics.FullName,
            mimic_cluster.FullName, obj.Kinematics.FullName, mimic_map.FullName
        ]))

    mimic_op.Reset = 1
    mimic_op.Active = False

    if prefix == 'Soft':
        mimic_op.Distance = 0.001
        mimic_op.Stiff = 0.1
        mimic_op.Damp = 0.01
        XSI.SaveKey(mimic_op.ModifMap, 0, True)

    else:
        mimic_op.Distance = 0
        mimic_op.Damp = 0.01
        mimic_op.Stiff = 1
Example #2
0
def Cloth_ApplySyflexOp(obj):
    syflex_op = obj.ActivePrimitive.ConstructionHistory.Find('syCloth')
    if syflex_op:
        XSI.DeleteObj(syflex_op)

    cloth_cluster = obj.ActivePrimitive.Geometry.Clusters('ClothCls')
    if not cloth_cluster:
        cloth_cluster = Utils.CreateCompleteButNotAlwaysCluster(
            obj, constants.siVertexCluster, 'ClothCls')

    mass_map = Utils.GetWeightMap(obj, 'MassMap', 1, 0, 1, cloth_cluster)
    stiffness_map = Utils.GetWeightMap(obj, 'StiffMap', 1, 0, 1, cloth_cluster)
    restore_map = Utils.GetWeightMap(obj, 'RestoreMap', 0, 0, 1, cloth_cluster)

    XSI.FreezeObj(mass_map.FullName + "," + stiffness_map.FullName)
    syflex_op = XSI.ApplyOp(
        'syCloth', ';'.join(obj.FullName, mass_map.FullName,
                            stiffness_map.FullName), 3, 0, None, 2)(0)
    stf = XSI.ApplyOperator('syProperties', syflex_op)
    start_frame = Utils.GetStartFrame()
    syflex_op.Parameters('FirstFrame').Value = start_frame
    XSI.SaveKey(syflex_op.Parameters('Update'), 1, 1)

    stf.Parameters('Density').Value = 0.5
    stf.Parameters('StretchStiffness').Value = 1
    stf.Parameters('ShearStiffness').Value = 0.2
    stf.Parameters('BendStiffness').Value = 0.1
    stf.Parameters('StretchDamping').Value = 0.1
    stf.Parameters('ShearDamping').Value = 0.02
    stf.Parameters('BendDamping').Value = 0.01

    return syflex_op