Show soft selection on unselected mesh?


#3

help if i bothered to read it correctly :slight_smile: If I had to I would probably do it as denis suggests as a modifier.


#4

Okay, I’m able to get the vertex weight values and set the vertex color values easily enough, but not quite sure what I need to do in order to convert the weight value (0.0 to 1.0) to an RGB color value…


#5

the thing is that soft selection channel is a vertex channel (not a map channel). only map channel can be used as vertex color display. except… yes. soft selection.
but max handles it specially.

so we have to copy float values of soft-selection channel to a map (point3) channel and colorize a float weight. as i remember there is a formula that converts soft-weight to red-to-blue gradient. (not exactly correct but it’s a half way of HUE in the HSV color representation)


#6

MCG :thumbsup:


#7

no. it’s not a half. but very easy to see - just check red.h and blue.h


#8

i’ve never tried that but what if:

red * soft_weight + blue * (1 - soft_weight)

#9

you could load a 1 pixel color gradient bitmap and use the 0-1 as a color “lookup”


#10

Thanks Denis, that does the trick!

fn vertColorFromSoftSel obj = (
	polyop.setVDataChannelSupport obj 1 true

	for v = 1 to obj.numVerts do (
		local w = polyOp.getVDataValue obj 1 v
		local c = (red * w) + (blue * (1 - w))

		polyop.setVertColor obj 0 v	c
	)
)

#11

Wait. Wait no, it doesn’t, sorry.

That colors the verts directly from red to blue, basically running the opposite direction on the color wheel.


#12

polyop.setVertColor is very slow method (i’ve already explained why it is). if you need it faster use polyop.setmapvert instead


#13

But doesn’t polyOp.setMapVert set UVW coordinates?

Also, still need a way to get the correct color…


#14

as i said we have to use HSV space. here it is (found in my archive):

	fn makeWeightColor weight asRGB:off =
	(
		c = red
		c.h = (1.0 - weight)*170
		if asRGB do c = c as point4
		c
	)

170 is a number around blue.h


#15

so i meant:

		c = red
		c.h = red.h * weight + blue.h * (1.0 - weight)
		c

#16

Currently using this with your makeWeightColor function, and it is working perfectly as far as I can tell. Thanks again!

fn vertColorFromSoftSel obj = (
	obj.showVertexColors = on
	obj.vertexColorsShaded = on

	for v = 1 to obj.numVerts do (
		local w = polyOp.getVDataValue obj 1 v
		polyop.setMapVert obj 0 v	((weightToColor w) as point4)
	)

	redrawViews()
)

#17

All right, one last thing I guess… right now it still only works when the node is selected with subselection on. Otherwise polyOp.getVDataValue <node> 1 <vertex> always returns 1.0.

If I first select the node and lock the soft selection, then deselect the node, it will return the correct values. But is there any way to do this without having to select the node at all?


#18
(weightToColor w) as point4

is not necessary. the function as you can see has an option argument.

about a sub-selection level… i think it’s a limitation. probably using sdk is possible to force soft-selection level update. with pure mxs is probably not. but just in case i would check the state of baseobject instead of polyobject. maybe it updates.

other way is to calculate ‘soft selection’ weights yourself. the formula is known. as i remember it was posted (by Klvnk?) on this forum


#19

Not sure what you mean by calculate the soft selection weights?


#20

far distance is lower weight. selection you know, neighbors you can find… distance as well.
the formula is something about distance, falloff, pinch, and bubble… it was shown here


#21

Oh yeah, that. Unfortunately that won’t work if painted soft selection is on, which for my purposes it will be. Given that, not sure if this is the most efficient way to get the desired result, but it works.

fn vertColorFromSoftSel obj = (
	-- Store selection and subobject level
	sel = selection as array
	setCommandPanelTaskMode #modify
	SOL = subObjectLevel

	-- Temporarily set object and subselection
	select obj
	if subObjectLevel == 0 do subObjectLevel = 1

	-- Set mapping and display
	polyOp.setMapSupport obj 0 true
	obj.showVertexColors = true
	obj.vertexColorsShaded = true
	obj.useSoftSel = true

	-- Set vertex colors
	for v = 1 to obj.numVerts do (
		local w = polyOp.getVDataValue obj.baseObject 1 v
		polyop.setMapVert obj 0 v	(makeWeightColor w asRGB:on)
	)

	-- Restore selection and subobject level
	deselect selection
	select sel
	subObjectLevel = SOL

	redrawViews()
)

#22

you can disable max redraw (including viewports and command panel). and no one will see your selecting-deselecting. i’ve cheated this way a lot :slight_smile:
also you can disable reference messages to make everything hidden for callbacks.