Querying skinWeights, but not by vertex (Maya)

Hey,

Does anyone know how to query skin weight values at an arbitrary point on the mesh, i.e not at a vertex?

I had thought that UV coordinate would be the obvious candidate, but I can’t see a way to query weights using this.

Cheers,
Matt.

Even if there were a way to do this in UV space, I don’t think it would be a good idea (e.g., what would happen if there were overlapping UVs?).

If you have an arbitrary point on a mesh, then I would suggest computing a weight value based on the barycentric coordinate of the point (i.e. just blend the weights of the 3 points on the triangle where your point exists based on your point’s relative distance to them). Depending upon how comfortable you are with the API, and how exactly you are obtaining your point, there are API methods that can accelerate this process for you, such as MFnMesh.closestIntersection().

This is something I’ve been wondering about myself. Would it not be possible, even more efficient, to use an Octree or some other form of BSP to accomplish this? I’m working on something similar to average weights from one mesh to another based on the world space location of the points, but also work on Nurbs, polys, subds, lattices, curves, etc.

[QUOTE=sockmonkey;5813]Hey,

Does anyone know how to query skin weight values at an arbitrary point on the mesh, i.e not at a vertex?

I had thought that UV coordinate would be the obvious candidate, but I can’t see a way to query weights using this.

Cheers,
Matt.[/QUOTE]

using “colorAtPoint”

Half of my junk in the pic, was only needed fer visualizing/concept proof. ( else my brain bleeds )

Basically,
export weight maps ( from the smooth weights tool @ 4096 X 4096 jpeg in the example above. )
( also, 13 files/bones in the example )
Load those images into your project ( textures/Hypershade )
And yer done!

Using UV coordinates from the position on your object in question:

	float $vector[] = `colorAtPoint -output RGB -u $U  -v $V "myObject"`; //
	print ( "$vector[0]+
" ); // weight from a channel "red is pretty"

In the example above, I use closestPointOnSurface to return UV @ points position. ( UV at closestPoint )
( since closestPoint although manually positioned in the following example…
It still is a good method for returning an unpredicatble result.
( Hopefully guaranteeing at least some semblance to a real world situation. )
If not, sorry. I’m jes guessing final usage. :lookdown:

I setup A locator brush to manually test color ( skinning weight )values on
an object ( “pPlane1” ) using the closestPointOnSurfaceNode:
closest point on “pPlane1”, from locator4’s position.

locator4’s position is connected to closestPointOnSurface Node ( cpom4 )'s .inputPosition.
( cpom4 )'s result.position connected to locator1’s position.
Navigating In this way,
we can use our object’s( pPlane1 ) UV’s at the closestPoint Locator position
to query skin weight on a skin map’s corresponding UV.

{
	float $uVU = `getAttr npom4.result.parameterU`;
	float $uVV = `getAttr npom4.result.parameterV`;
	float $rgbVector[] = `colorAtPoint -o RGB -u $uVU  -v $uVV "pPlane1_joint1_1"`; // <-from jpg texture file
	//float $rgbVector[] = `colorAtPoint -o RGB -u $uVU  -v $uVV "pPlane1_joint2_1"`; // <-from jpg texture file of another bones
	print ( " The \"Skinning Weight\" @ this position's UV is: "+ $rgbVector[0] ); // 1 channel "red is pretty"
	print "
";
}

The weight maps imported into our scene is all we really need
( weight maps do not have to be applied. textures have UV’s Irregardless :nod: )
For visualization however,
Applying the maps into easily managed/accessible vertex Color Sets
sure comes in handy. Not only for visual reference.
But for organizaion and provides for quick toggle via the set Editor UI.
Also.
Importing weight maps as vertex colors for visualization is pretty painless with the vertex color tool.

Ah, that looks like it might be just the ticket! Awesome, thank you. I will implement this next week and let you know how it goes.

Thanks for all your input,
Matt.