def Cloth_Control_PaintMap(map): object = map.Parent3DObject object.Properties("Visibility").Parameters("ViewVis").Value = True XSI.SelectObj(map) view = XSI.OpenView("Object View", True) view.SetAttributeValue("lockstatus",True) XSI.PaintTool()
def Cloth_Control_PaintPush_OnClicked(): prop = PPG.Inspected(0) clothes = Cloth_Control_GetClothObjects(prop) if len(clothes) == 1: selectedpush = prop.CorrectivePushList.value cls = clothes[0].ActivePrimitive.Geometry.Clusters("CorrectivePushCls") XSI.SelectObj(cls.Properties(selectedpush)) XSI.PaintTool() else: XSI.LogMessage("[Cloth_Control] Paint Corrective Push only works in Single Item Mode!!", constants.siError)
def CorrectPush(obj, wmap, frame, exist): # check if tree exists prim = obj.ActivePrimitive tree = prim.ICETrees.Find("CorrectivePush") if not tree: tree = ICETree.CreateIceTree(obj, "CorrectivePush", 2) t = str(tree) set1 = XSI.AddICENode("SetOneDataNode", t) set1.Parameters("Reference").Value = "Self.PointPosition" ifnode = XSI.AddIceNode("IfNode", t) XSI.ConnectICENodes(t + ".port1", str(ifnode) + ".Result") XSI.ConnectICENodes(str(ifnode) + ".IfFalse", str(set1) + ".Value") get = XSI.AddICENode("GetDataNode", t) get.Parameters("Reference").Value = "Self.PointPosition" get1 = XSI.AddICENode("GetDataNode", t) get1.Parameters("Reference").Value = "Self.PointNormal" add = XSI.AddICENode("AddNode", t) XSI.ConnectICENodes(str(add) + ".Value1", str(get) + ".Value") add1 = XSI.AddIceNode("AddNode", t) mult = XSI.AddIceNode("MultiplyByScalarNode", t) mult1 = XSI.AddIceNode("MultiplyByScalarNode", t) XSI.ConnectICENodes(str(add) + ".Value2", str(mult) + ".Result") XSI.ConnectICENodes(str(mult) + ".Value", str(get1) + ".Value") XSI.ConnectICENodes(str(mult) + ".Factor", str(mult1) + ".Result") XSI.ConnectICENodes(str(mult1) + ".Value", str(add1) + ".Result") XSI.ConnectICENodes(str(set1) + ".Source", str(add) + ".Result") nodes = [get, get1, ifnode, add, add1, set1] compound = XSI.CreateICECompoundNode(",".join(nodes), None) XSI.EditICECompoundProperties(compound, "CorrectivePush", "", "", "", "", "", 1, 0, "", 4, 6732954) XSI.AddExposedParamToICECompoundNode(str(ifnode) + ".Condition", str(compound), None, "Mute") XSI.AddExposedParamToICECompoundNode(str(mult1) + ".Factor", str(compound), None, "Factor") if not exist: compound = tree.CompoundNodes("CorrectivePush") add = compound.Nodes.Filter("AddNode")(0) mult = XSI.AddIceNode("MultiplyByScalarNode", compound) addInputs = add.InputPorts checkPorts = -1 p = 0 for i in addInputs: if not i.IsConnected: checkPorts = p break p += 1 if not checkPorts == -1: XSI.ConnectIceNodes(str(add) + ".Value" + str(checkPorts + 1), str(mult) + ".Result") else: index = add.InputPorts.Count XSI.AddPortToICENode(str(add) + ".value" + str(index), constants.siNodePortDataInsertionLocationAfter) XSI.ConnectICENodes (str(add) + ".value" + str(index + 1), str(mult) + ".result") pushStr = "Self.cls.CorrectivePushCls."+wmap.Name+".Weights" getPushMap = XSI.AddIceNode("GetDataNode", str(tree)) getPushMap.Parameters("Reference").Value = pushStr inputs = compound.InputPorts count = 0 for i in inputs: if i.Name.find("Position")>-1: count += 1 XSI.AddExposedParamToICECompoundNode(str(mult) + ".value", str(compound), None, "Push") XSI.EditExposedParamInICECompoundNode(str(compound) + ".Push", "Push" + str(frame), "0", "0", None, None, 0, "") XSI.AddExposedParamToICECompoundNode(str(mult) + ".Factor", str(compound), None, "Frame" + str(frame)) XSI.EditExposedParamInICECompoundNode(str(compound) + ".Frame" + str(frame), "Frame" + str(frame), "0", "1", None, None, 0, "") XSI.ConnectICENodes(str(compound) + ".Push" + str(frame), str(getPushMap) + ".Value") XSI.InspectObj(compound, None, None, constants.siLock) XSI.SelectObj(wmap) XSI.PaintTool()
def CorrectSmooth(obj, wmap, frame, exist): # check if tree exists prim = obj.ActivePrimitive tree = prim.ICETrees.Find( "CorrectiveSmooth" ) if not tree: above = prim.ICETrees.Find("CorrectivePush") if not above: above = prim.ICETrees.Find("CorrectiveShape") if above: XSI.DeactivateAbove(above, True) tree = ICETree.CreateIceTree(obj, "CorrectiveSmooth", 2) if above: XSI.DeactivateAbove(above, False) t = str(tree) set1 = XSI.AddICENode("SetOneDataNode", t) set1.Parameters("Reference").Value = "Self.PointPosition" ifnode = XSI.AddIceNode("IfNode", t) repeat = XSI.AddICENode("RepeatNode", t) XSI.ConnectICENodes(str(repeat) + ".port", str(set1) + ".value") repeat.InputPorts("iterations").Value = 10 XSI.ConnectICENodes(t + ".port1", str(ifnode) + ".Result") XSI.ConnectICENodes(str(ifnode) + ".IfFalse", str(set1) + ".Value") XSI.ConnectICENodes(str(ifnode) + ".IfFalse", str(repeat) + ".Execute") get = XSI.AddICENode("GetDataNode", t) get.Parameters("Reference").Value = "Self.PointPosition" get1 = XSI.AddICENode("GetDataNode", t) get1.Parameters("Reference").Value = "Self.PointNeighbors" get2 = XSI.AddICENode("GetDataNode", t) get2.Parameters("Reference").Value = "PointPosition" XSI.ConnectICENodes(str(get2) + ".Source", str(get1) + ".Value") average = XSI.AddICENode("GetArrayAverageNode", t) XSI.ConnectICENodes(str(average) + ".Array", str(get2) + ".Value") interp = XSI.AddIceNode("LinearInterpolateNode", t) XSI.ConnectICENodes(str(interp) + ".First", str(get) + ".Value") XSI.ConnectICENodes(str(interp) + ".Second", str(average) + ".Result") XSI.ConnectIceNodes(str(set1) + ".Source", str(interp) + ".Result") clamp = XSI.AddICENode("ClampNode", t) XSI.ConnectICENodes(str(interp) + ".Blend", str(clamp) + ".Result") scalarZero = XSI.AddICENode("ScalarNode", t) scalarZero.InputPorts("Value").Value = 0 scalarOne = XSI.AddICENode("ScalarNode", t) scalarOne.InputPorts("Value").Value = 1 add = XSI.AddICENode("AddNode", t) XSI.ConnectICENodes(str(clamp) + ".Limit1", str(scalarZero) + ".Result") XSI.ConnectICENodes(str(clamp) + ".Limit2", str(scalarOne) + ".Result") XSI.ConnectICENodes(str(clamp) + ".Value", str(add) + ".Result") nodes = [get, set1, get1, get2, average, interp, repeat, ifnode, clamp, add] compound = XSI.CreateICECompoundNode(",".join(nodes), None) XSI.EditICECompoundProperties(compound, "CorrectiveSmooth", "", "", "", "", "", 1, 0, "", 4, 6732954) XSI.AddExposedParamToICECompoundNode(str(ifnode) + ".Condition", str(compound), None, "Mute") XSI.AddExposedParamToICECompoundNode(str(repeat) + ".Iterations", str(compound), None, "Repeat") if not exist: compound = tree.CompoundNodes("CorrectiveSmooth") add = compound.Nodes.Filter("AddNode")(0) mult = XSI.AddIceNode("MultiplyByScalarNode", str(compound)) addInputs = add.InputPorts checkPorts = -1 i = 0 for p in addInputs: if not p.IsConnected: checkPorts = i break if checkPorts > -1: XSI.ConnectIceNodes(str(add) + ".Value" + str(checkPorts + 1), str(mult) + ".Result") else: index = add.InputPorts.Count XSI.AddPortToICENode(str(add) + ".Value" + str(index), constants.siNodePortDataInsertionLocationAfter) XSI.ConnectICENodes(str(add) + ".Value" + str(index + 1), str(mult) + ".Result") t = str(tree) smoothStr = "Self.cls.CorrectiveSmoothCls." + wmap.Name + ".Weights" get = XSI.AddIceNode("GetDataNode", t) get.Parameters("Reference").Value = smoothStr inputs = compound.InputPorts count = 0 for i in inputs: if not i.Name.find("Smooth") == -1: count += 1 XSI.AddExposedParamToICECompoundNode(str(mult) + ".value", str(compound), None, "Smooth") XSI.EditExposedParamInICECompoundNode(str(compound) + ".Smooth", "Smooth" + str(frame), "0", "0", None, None, 0, "") XSI.AddExposedParamToICECompoundNode(str(mult) + ".Factor", str(compound), None, "Factor") XSI.EditExposedParamInICECompoundNode(str(compound) + ".Factor", "Frame" + str(frame), "0", "1", None, None, 0, "") XSI.ConnectICENodes(str(compound) + ".Smooth" + str(frame), str(get) + ".Value") XSI.InspectObj(compound, None, None, constants.siLock) XSI.SelectObj(wmap) XSI.PaintTool()