Notifications
Clear all

[Closed] How does the paint blend weights function work?

Trying to write the function in maxscript, just wondering how it works.

Hopefully someone with the sdk inspected can post the sdk version of it.

The way i think it works now in english is…

forEachVertex in theVerticesBeingPaintedOn do
(
theBlendedWeight = theCurrentVertWeight – ((theCurrentVertWeight – theCurrentVertAndSurroundingVertsAverageWeight) * thePaintWeight)
)

only on selected bone, and uses a function similar to skinOps.setVertexWeights?

5 Replies

would help if you post the function call name.

<Skin>.paintBlendMode BooleanClass default:false

think this might be what you are looking for, though it’s a hefty plugin to wade through… the rest can be found in maxsdk\samples\modifiers\bonesdef

void BonesDefMod::ApplyPaintWeights(BOOL alt, INode *incNode)
	{
//5.1.03
	BOOL blendMode = FALSE;
	pblock_param->GetValue(skin_paintblendmode,0,blendMode,FOREVER);

	INode *node = NULL;
	for (int i =0;i < painterData.Count(); i++)
		{
		painterData[i].alt = alt;
		if (incNode == NULL)
			node = painterData[i].node;
		else node = incNode;
		if (node == painterData[i].node)
			{
			BoneModData *bmd = painterData[i].bmd;
			int count;
			float *str = pPainterInterface->RetrievePointGatherStr(node, count);
			int *isMirror = pPainterInterface->RetrievePointGatherIsMirror(node, count);

			BitArray excludedVerts;
			BOOL useExclusion = FALSE;
			if ((ModeBoneIndex >= 0) && (ModeBoneIndex < bmd->exclusionList.Count()))
			{
				if (bmd->exclusionList[ModeBoneIndex])
				{								
					excludedVerts.SetSize(count);
					excludedVerts.ClearAll();
					useExclusion = TRUE;
					for (int j = 0; j < bmd->exclusionList[ModeBoneIndex]->Count(); j++)
					{
						int index = bmd->exclusionList[ModeBoneIndex]->Vertex(j);
						if (index < excludedVerts.GetSize())
							excludedVerts.Set(index,TRUE);
					}
				}
			}

			if ((mirrorIndex >= 0) && (mirrorIndex < bmd->exclusionList.Count()))
			{
				if ((mirrorIndex != -1) && bmd->exclusionList[mirrorIndex])
				{			
					if (excludedVerts.GetSize() != count)
					{
						excludedVerts.SetSize(count);
						excludedVerts.ClearAll();
					}
					useExclusion = TRUE;
					for (int j = 0; j < bmd->exclusionList[mirrorIndex]->Count(); j++)
					{
						int index = bmd->exclusionList[mirrorIndex]->Vertex(j);
						if (index < excludedVerts.GetSize())
							excludedVerts.Set(index,TRUE);
					}
				}
			}
			for (int j =0; j < count; j++)
				{

				BOOL skip = FALSE;
				if (useExclusion)
				{
					if (excludedVerts[j])
						skip = TRUE;
				}
				if ((str[j] != 0.0f) && (!skip))
					{
//get original amount
					float amount = 0.0f;
					int boneID = ModeBoneIndex;
					if (isMirror[j] == MIRRRORED) boneID = mirrorIndex;

					if(boneID != -1)
						{
//add to it str
						for (int k =0; k < bmd->VertexData[j]->WeightCount(); k++)
							{
							if (bmd->VertexData[j]->GetBoneIndex(k) == boneID)
								{
									amount = bmd->VertexData[j]->GetNormalizedWeight(k);			
									k = bmd->VertexData[j]->WeightCount();
								}
							}
//5.1.03
						if (blendMode &&  bmd->blurredWeights.Count() != 0)
							{
								float blurAmount = bmd->blurredWeights[j];
								 amount += (bmd->blurredWeights[j] - amount) * str[j];
							 }
						  else
							 {
							if (alt)
								amount -= str[j];
							else 
								amount += str[j];
							if (amount > 1.0f) amount = 1.0f;
							if (amount < 0.0f) amount = 0.0f;
							}

						
//set it back
						updateDialogs = FALSE;
						SetVertex(bmd, j, boneID, amount);
						updateDialogs = TRUE;
						}
					}
				}

			}
		}
	}

silly page

got it to work thanks!