PDA

View Full Version : soft selection math


antonv
04-24-2008, 01:55 PM
Hi guys,

I was trying last night to write a tool that moves a vert in a poly to a specified location and I wanted to implement the soft selection into it. So when I move one vert the rest in the soft selection area to be affected too. I've gotten their vDataValue but I cannot figure out what the math should be to get the same result as when you do in max.

Any ideea on how to calculate that or what is the algorithm max uses for that?

Thanks!

eek
04-24-2008, 03:17 PM
Hi guys,

I was trying last night to write a tool that moves a vert in a poly to a specified location and I wanted to implement the soft selection into it. So when I move one vert the rest in the soft selection area to be affected too. I've gotten their vDataValue but I cannot figure out what the math should be to get the same result as when you do in max.

Any ideea on how to calculate that or what is the algorithm max uses for that?

Thanks!

Same here - Ive been trying to find out the math of soft selection too for a while - maybe its just linear interpolation with a radius?

Light
04-24-2008, 04:58 PM
It's easy.

Implementation:

(
local offsetTransformation = lastPos - firstPos
for eachVert in softVerts do
(
local softTransform = (PolyOp.GetVDataValue selection[1] 1 eachVert) * offsetTransformation
PolyOp.MoveVert selection[1] eachVert softTransform
)
)




Light

antonv
04-25-2008, 02:53 AM
That's pretty much what I have but the results are different from what you get when you manually do it... Check the attached image.

marktsang
04-25-2008, 09:32 AM
it isnt linear,
its based on a curve i think,
look at bubble and pinch.....

eek
04-25-2008, 02:57 PM
it isnt linear,
its based on a curve i think,
look at bubble and pinch.....

Yes i think your right, bubble and pinch are just controlling the bias of the interpolation. I should be able to right the math i think for that..

vasilescu_anton - i think the results your getting are correct.

antonv
04-25-2008, 03:02 PM
The non linearity of it is controlled by max through the color of the selected verts. When you read the VData for the soft selection channel you get values from 0 to 1 and those are plotted in a non linear fashion. The actual move should be linear...

antonv
04-29-2008, 04:03 AM
Ok, my bad, the algorithm works perfect only I was trying to do it to multiple verts at once and then it would do that. With only one vert it does it properly! Thanks, Light!

How would you go about doing it for multiple verts at once? How do you choose the direction to move a vert that would be affected by more that one other vert?

antonv
05-09-2008, 03:05 PM
So I got the time to get back to it and figure it out for multiple verts. Light's algorithm works perfect and you just need to find for each of the verts in the soft selection which selected vert is it closest to then apply the formula based on that. Works as a charm.

CGTalk Moderation
05-09-2008, 03:05 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.