Example #1
0
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()
Example #2
0
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)
Example #3
0
def CreateSkeletonCurve(curves):
    if curves.Count > 1:
        XSI.SelectObj(curves)
        op = XSI.MergeCurve(curves.GetAsText(), '')
        crv = op.Parent3DObject
    else:
        crv = XSI.Duplicate(curves(0))(0)

    crv.Name = 'Skeleton_Crv'
    return crv
Example #4
0
def ELIWeightMapEditor_SubWeightOnSelectedPoints_OnClicked():
    sel = XSI.Selection(0)
    if not sel.Type == "pntSubComponent":
        XSI.LogMessage("Select some points on Target Object!!",
                       constants.siWarning)
        return

    sub = sel.SubComponent
    obj = sub.Parent3DObject

    if not obj.FullName == PPG.Inspected(0).Parameters("TargetObject").Value:
        XSI.LogMessage("Selected Points are not on Target Geometry...",
                       constants.siWarning)
        XSI.SelectObj(obj)
        WeightMapEditor_RebuildLayout(PPG.Inspected(0))
        return
    else:
        wmname = GetUISelectedWeightMap(PPG.Inspected(0))
        XSI.LogMessage(wmname)
        wm = XSI.Dictionary.GetObject(wmname)
        uti.SubWeightOnSelectedPoints(wm, PPG.Weight.Value, sub)
Example #5
0
def Cloth_Control_SelectWindIcon_OnClicked():
	model = PPG.Inspected(0).Parent3DObject
	icon = model.FindChild("Cloth_Wind")
	if icon:
		XSI.SelectObj(icon)
Example #6
0
def bbppTransformation_BuildOutputMesh_OnClicked( ):
	oPPG = PPG.Inspected(0)
	oModel = oPPG.Parent3DObject
	oStartCloud = oModel.FindChild("StartCloud")
	oEndCloud = oModel.FindChild("EndCloud")
	
	oStartGrp = oModel.Groups("Start");
	oEndGrp = oModel.Groups("End");
	
	# does geometry exists?
	oStartGeomStatic =  bbppTransformation_StartGeometryStaticExist(oPPG)
	oEndGeomStatic =  bbppTransformation_EndGeometryStaticExist(oPPG)
	
	if not oStartGeomStatic or not oEndGeomStatic:
		XSI.LogMessage("bbppTransformation Geometry Does not exist ---> Can't build Output Mesh!", constants.siError)
		return
	
	if oPPG.AnimatedTransformation.Value:
		oStartGeomAnimated =  bbppTransformation_StartGeometryAnimatedExist(oPPG)
		oEndGeomAnimated =  bbppTransformation_EndGeometryAnimatedExist(oPPG)
		
		if not oStartGeomAnimated or not oEndGeomAnimated:
			XSI.LogMessage("bbppTransformation Geometry Does not exist ---> Can't build Output Mesh!", constants.siError)
			return
	
	# create start geometry point cloud
	if not oStartCloud:
		# create emission node
		oStartCloud = XSI.GetPrim("PointCloud", "StartCloud", oModel)
		oIceTree = XSI.ApplyOp("ICETree", oStartCloud, "siNode", "", "", 0)
		oEmit = XSI.AddICECompoundNode("bbpp Emit From Points", oIceTree)
		XSI.ConnectICENodes(str(oIceTree) + ".port1", str(oEmit) + ".add")
		oGet1 = XSI.AddICENode("GetDataNode", oIceTree)
		XSI.SetValue(str(oGet1) + ".reference", oStartGeomStatic.FullName)
		XSI.ConnectICENodes(str(oEmit) + ".Emiter", str(oGet1) + ".outname")
		XSI.SetValue(str(oEmit) + ".Color_red", 0.9)
		XSI.SetValue(str(oEmit) + ".Color_green", 0.4)
		XSI.SetValue(str(oEmit) + ".Color_blue", 0.1)
		
		# create blend node
		oBlend = XSI.AddICECompoundNode("bbpp Blend Cloud", oIceTree)
		XSI.AddPortToICENode(str(oIceTree) + ".port1", "siNodePortDataInsertionLocationAfter")
		XSI.ConnectICENodes(str(oIceTree) + ".port2", str(oBlend) + ".Execute")
		oGet2 = XSI.AddICENode("GetDataNode", oIceTree)
		XSI.SetValue(str(oGet2) + ".reference", str(oStartGrp))
		XSI.ConnectICENodes(str(oBlend) + ".Start_Cloud", str(oGet2) + ".outname")
		oGet3 = XSI.AddICENode("GetDataNode", oIceTree)
		XSI.SetValue(str(oGet3) + ".reference", str(oEndGrp))
		XSI.ConnectICENodes(str(oBlend) + ".End_Cloud", str(oGet3) + ".outname")
		oGet4 = XSI.AddICENode("GetDataNode", oIceTree)
		XSI.SetValue(str(oGet4) + ".reference", oEndGeomStatic.FullName)
		XSI.ConnectICENodes(str(oBlend) + ".Target_Geometry", str(oGet4) + ".value")
		
		# connect timer
		oTimer = XSI.AddICECompoundNode("bbpp Transformation Timer", oIceTree)
		XSI.ConnectICENodes(str(oBlend) + ".Blend", str(oTimer) + ".Blend")
		oGet5 = XSI.AddICENode("GetDataNode", oIceTree)
		XSI.SetValue(str(oGet5) + ".reference", oPPG.StartFrame.FullName)
		oGet6 = XSI.AddICENode("GetDataNode", oIceTree)
		XSI.SetValue(str(oGet6) + ".reference", oPPG.EndFrame.FullName)
		XSI.ConnectICENodes(str(oTimer) + ".Start_Frame", str(oGet5) + ".value")
		XSI.ConnectICENodes(str(oTimer) + ".End_Frame", str(oGet6) + ".value")

	# create end geometry point cloud
	if not oEndCloud:
		# create emission node
		oEndCloud = XSI.GetPrim("PointCloud", "EndCloud", oModel)
		oIceTree = XSI.ApplyOp("ICETree", oEndCloud, "siNode", "", "", 0)
		oEmit = XSI.AddICECompoundNode("bbpp Emit From Points", oIceTree)
		XSI.ConnectICENodes(str(oIceTree) + ".port1", str(oEmit) + ".add")
		oGet1 = XSI.AddICENode("GetDataNode", oIceTree)
		XSI.SetValue(str(oGet1) + ".reference", oEndGeomStatic.FullName)
		XSI.ConnectICENodes(str(oEmit) + ".Emiter", str(oGet1) + ".outname")
		XSI.SetValue(str(oEmit) + ".Color_red", 0.1)
		XSI.SetValue(str(oEmit) + ".Color_green", 0.9)
		XSI.SetValue(str(oEmit) + ".Color_blue", 0.4)
		
		# create blend node
		oBlend = XSI.AddICECompoundNode("bbpp Blend Cloud", oIceTree)
		XSI.AddPortToICENode(str(oIceTree) + ".port1", "siNodePortDataInsertionLocationAfter")
		XSI.ConnectICENodes(str(oIceTree) + ".port2", str(oBlend) + ".Execute")
		oGet2 = XSI.AddICENode("GetDataNode", oIceTree)
		XSI.SetValue(str(oGet2) + ".reference", str(oEndGrp))
		XSI.ConnectICENodes(str(oBlend) + ".Start_Cloud", str(oGet2) + ".outname")
		oGet3 = XSI.AddICENode("GetDataNode", oIceTree)
		XSI.SetValue(str(oGet3) + ".reference", str(oStartGrp))
		XSI.ConnectICENodes(str(oBlend) + ".End_Cloud", str(oGet3) + ".outname")
		oGet4 = XSI.AddICENode("GetDataNode", oIceTree)
		XSI.SetValue(str(oGet4) + ".reference", oStartGeomStatic.FullName)
		XSI.ConnectICENodes(str(oBlend) + ".Target_Geometry", str(oGet4) + ".value")
		
		# connect timer
		oTimer = XSI.AddICECompoundNode("bbpp Transformation Timer", oIceTree)
		XSI.ConnectICENodes(str(oBlend) + ".Blend", str(oTimer) + ".Blend")
		oGet5 = XSI.AddICENode("GetDataNode", oIceTree)
		XSI.SetValue(str(oGet5) + ".reference", oPPG.StartFrame.FullName)
		oGet6 = XSI.AddICENode("GetDataNode", oIceTree)
		XSI.SetValue(str(oGet6) + ".reference", oPPG.EndFrame.FullName)
		XSI.ConnectICENodes(str(oTimer) + ".Start_Frame", str(oGet5) + ".value")
		XSI.ConnectICENodes(str(oTimer) + ".End_Frame", str(oGet6) + ".value")
		XSI.SetValue(str(oTimer) + ".Revert", True)
		
	# create Blob Mesh
	# delete it if already exists
	bbppTransformation_BlobGeometryExist(oPPG)
	XSI.SelectObj(str(oStartCloud) + "," + str(oEndCloud))
	XSI.Create_Polygonizer_Polymesh()
	oBlob = XSI.Selection(0)
	oBlob.Name = "OutputMesh"
	oModel.AddChild(oBlob)
	oBlobOp = oBlob.ActivePrimitive.ConstructionHistory.Find("Polygonizer")
	
	
	# create expression for in-between
	#--------------------------------------
	# detail
	sStartFrame = oPPG.StartFrame.FullName
	sEndFrame = oPPG.EndFrame.FullName
	sTimelapse = sEndFrame+" - "+sStartFrame
	oExpr = "(1 - sin(cond(FC>"+sStartFrame+",cond(Fc<"+sEndFrame+",(Fc - "+sStartFrame+")/("+sTimelapse+"),1),0)*180)) *2 + 2"
	oBlobOp.Parameters("Detail").AddExpression(oExpr)
	
	# blur isofield
	oExpr = "sin(cond(FC>"+sStartFrame+",cond(Fc<"+sEndFrame+",(Fc - "+sStartFrame+")/("+sTimelapse+"),1),0)*180)/2"
	oBlobOp.Parameters("BlurIsofieldStrength").AddExpression(oExpr)
	
	# smooth mesh
	oExpr = "sin(cond(FC>"+sStartFrame+",cond(Fc<"+sEndFrame+",(Fc - "+sStartFrame+")/("+sTimelapse+"),1),0)*180)*4+2"
	oBlobOp.Parameters("SmoothMeshStrength").AddExpression(oExpr)
	
	# isolevel
	oBlobOp.Parameters("Isolevel").Value = 1
Example #7
0
def CreateEnvelopeNullsFromSkeletonCloud(model):
    cloud = model.FindChild('ICE_Skeleton')
    grp = Utils.GroupSetup(model, None, 'Envelope')

    root = model.FindChild('Envelopes', constants.siNullPrimType)
    if root:
        XSI.SelectObj(root, 'BRANCH')
        XSI.DeleteObj()

    root = model.AddNull('Envelopes')
    idx = 0
    attrs = cloud.ActivePrimitive.ICEAttributes
    pos = attrs('PointPosition').DataArray
    scl = attrs('Scale').DataArray
    ori = attrs('Orientation').DataArray

    # we have to display this attribute for accessing it
    emit = cloud.ActivePrimitive.ICETrees(1)
    node = emit.Nodes(0)
    XSI.LogMessage(node)
    XSI.SetValue('{}.Show_Name'.format(node), True, '')
    skeleton_name = cloud.ActivePrimitive.GetICEAttributeFromName(
        'SkeletonName').DataArray
    XSI.SetValue('{}.Show_Name'.format(node), False, '')

    group = Utils.GroupSetup(model, None, 'Envelope')

    t = XSIMath.CreateTransform()
    last_name = ''
    sub_index = 1
    for idx in xrange(cloud.ActivePrimitive.Geometry.Points.Count):
        p = pos[idx]
        o = ori[idx]
        s = scl[idx]
        t.SetTranslation(p)
        t.SetRotation(o)
        t.SetScaling(s)
        '''
		n = root.AddNull("Buffer"+str(id))
		tr = tree.CreateICETree(n,"Kinematics")
		node = xsi.AddICECompoundNode("BindTransformToPoint", str(tr))
		xsi.ConnectICENodes(str(tr)+".port1", str(node)+".Execute")
		xsi.SetValue(str(node)+".ID", id, "")
		'''
        current_name = skeleton_name[idx]
        if not skeleton_name:
            XSI.LogMessage('You need to display SkeletonName ICE Attribute !',
                           constants.siWarning)
            break
        else:
            if not current_name == last_name:
                last_name = current_name
                sub_index = 1

            n = root.AddNull('{}{}_Env'.format(current_name, sub_index))
            n.ActivePrimitive.Primary_Icon = 4
            group.AddMember(n)
            n.Kinematics.Global.Transform = t
            idx += 1
            sub_index += 1

    return grp
Example #8
0
def WeightMapEditor_WeightMapChooser_OnChanged():
    sel = XSI.Selection(0)
    wmname = GetUISelectedWeightMap(PPG.Inspected(0))
    wm = XSI.Dictionary.GetObject(wmname)
    XSI.SelectObj(wm)
    XSI.SelectObj(sel)
Example #9
0
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()
Example #10
0
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()