示例#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
示例#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
示例#3
0
def Cloth_GetGravity(op):
    gravity = XSI.ApplyOperator('syGravity', op)
    gravity.Parameters('Gy').Value = -0.1

    model = op.Parent3DObject.Model
    icon = model.FindChild('Cloth_Gravity')
    if not icon:
        icon = XSI.GravityIcon()
        icon.Name = 'Cloth_Gravity'
        op.Parent3DObject.Parent3DObject.AddChild(icon)

    XSI.ApplySyGravityIconOp(gravity, icon)
示例#4
0
def Cloth_GetSelfCollide(obj):
    syflex_op = obj.ActivePrimitive.ConstructionHistory.Find('syCloth')

    cls = obj.ActivePrimitive.Geometry.Clusters('SelfCollideCls')
    if not cls:
        cls = Utils.CreateCompleteButNotAlwaysCluster(
            obj, constants.siPolygonCluster, 'SelfCollideCls')

    self_collide_op = XSI.ApplyOperator(
        'sySelfCollide',
        ';'.join([syflex_op.FullName, obj.FullName, cls.FullName]))
    self_collide_op.Reset = 1
    self_collide_op.Envelope = 0.05
示例#5
0
def Cloth_GetWind(op):
    wind = XSI.ApplyOperator('syWind', op)
    model = op.Parent3DObject.Model
    icon = model.FindChild('Cloth_Wind')
    if not icon:
        icon = XSI.WindIcon()
        icon.Name = 'Cloth_Wind'
        op.Parent3DObject.Parent3DObject.AddChild(icon)

    wind.Parameters('Intensity').Value = 0.1
    wind.Parameters('Active').Value = False

    XSI.ApplySyWindIconOp(wind, icon)
示例#6
0
    def Rig(self):
        cloth_op = GetClothOperator(self.object)
        if not cloth_op:
            XSIUIToolKit.MsgBox(
                'No Syflex Operator on "{}"+"'.format(self.object),
                constants.siMsgCritical, 'ClothBuilder')
            return

        collide_op = XSI.ApplyOperator(
            'syCollide', ';'.join([
                cloth_op.FullName, self.pntCluster.FullName,
                self.collider.ActivePrimitive.FullName,
                self.collider.Kinematics.FullName, self.polyCluster.FullName,
                self.object.Kinematics.FullName
            ]))

        collide_op.Parameters('Reset').Value = True

        collide_op.Parameters('ExtEnvelope').Value = 0.05
        collide_op.Parameters('IntEnvelope').Value = -0.05
        collide_op.Parameters('Friction').Value = 0.2
        collide_op.Parameters('Damp').Value = 0.01

        # if this collider isn't a cloth object
        # nor extra collider object we add pre roll setup
        if not self.collider.Properties('Cloth_Rigger') and not self.extra:
            # create init ICE tree
            trees = self.collider.ActivePrimitive.ICETrees
            if not trees.Find('InitCollide'):
                tree = ICETree.CreateIceTree(self.collider, 'InitCollide', 1)
                compound = XSI.AddICECompoundNode('ClothInitTarget', str(tree))
                XSI.ConnectICENodes('{}.port1'.format(tree),
                                    '{}.Execute'.format(compound))

            # create pre-roll ICE tree
            if not trees.Find('PreRollCollide'):
                tree = ICETree.CreateIceTree(self.collider, 'PreRollCollide',
                                             3)
                compound = XSI.AddICECompoundNode('ClothTargetPreRoll',
                                                  str(tree))
                XSI.ConnectICENodes('{}.port1'.format(tree),
                                    '{}.Execute'.format(compound))
示例#7
0
def Cloth_GetAir(op):
    air = XSI.ApplyOperator('syAir', op)
    air.Parameters('Damp').Value = 0.05