Inside Sabertooth
Learn how Sabertooth uses 3ds Max to create 3D interactive projects, including HBO Go’s Game of Thrones interactive experience
  • 1/3
You are here: Forum Home / Autodesk 3ds® Max® / MaxScript / Accessing and Displacing Soft-Selected Vertices
  RSS 2.0 ATOM  

Accessing and Displacing Soft-Selected Vertices
Rate this thread
 
60618
 
Permlink of this thread  
avatar
  • Total Posts: 4
  • Joined: 03 October 2011 07:53 AM

I have written a script that displaces points on an editable mesh object by iterating through the selected vertices with a for loop, and using meshOp methods (eg. meshop.moveVert selected[1] vertIndex Offset node:selected[1] useSoftSel:true) My script works perfectly for points that are directly selected, but I can’t get it to work with soft-selected points.

I have tried using meshop.supportVSelectWeights selected[1], meshop.setVDataChannelSupport selected[1] 1 true and meshop.setNumVDataChannels selected[1] 2 keep:false prior to getting the selected vertices with meshop.getVert selected[1] vertIndex node:selected[1]. The script runs just fine, without compile or runtime errors, but it doesn’t move the soft-selected vertices when I have that mode on.

It appears that my problem is that my method of getting the number of selected points (selected[1].selectedVerts.count) and the points themselves (selected[1].selectedVerts[s].index) don’t recognize soft-selected points. Is there a way I can get these methods to recognize soft-selected vertices with my current setup, or do I have to use another method, (perhaps mapped method?)

[By the way, I used selected = GetCurrentSelection().]

I would greatly appreciate any help. Thank you in advance.

The relevant sections of code:

else if subObjectLevel == and selected[1].selectedVerts.count 0 then
(
    
meshop.supportVSelectWeights selected[1]
    meshop
.setVDataChannelSupport selected[1] 1 true
    meshop
.setNumVDataChannels selected[1] 2 keep:false
    numSelVerts 
selected[1].selectedVerts.count
    
for 1 to numSelVerts do
    (
       global 
0.0
       
global 0.0
       
global 0.0
       vertIndex 
selected[1].selectedVerts[s].index
       softValue 
meshop.getVDataValue selected[1] 1 vertIndex
       vert 
meshop.getVert selected[1] vertIndex node:selected[1]
[
...]
       meshop
.moveVert selected[1] vertIndex Offset node:selected[1] useSoftSel:true
     
)
[...]
)


Using Max 2012

Replies: 0
avatar
  • Location: West Midlands, England, UK
  • Total Posts: 14445
  • Joined: 06 August 2007 11:06 PM
  • Permlink of this post

Not entirely sure why it’s not working, but one thing is definitely wrong - meshop.moveVert requires a bitArray of the selected vertices. You can move a single vertex by using #{vertex_number}. (note - curly braces, not parentheses).



Max 4.2 through 2013.
XP-64 (SP2)
NVidia 9800GTX-512 (Driver 266.58).
Core 2 Quad Q6600 2.4GHz, 8Gb Ram, DX9.0c.

Replies: 0
avatar

Thanks. I substituted the suggested bitArray format in place of the index value for meshOp.moveVert, and the script execution does seem to be faster.

The script still doesn’t take soft-selected points into account in determining the selection. Am I going to have to iterate through all the vertices on the object and check each for selection value greater than 0? This seems likely to work to me, but not terribly efficient. If there is a better way, I’d prefer to use it.

[EDIT: I implemented an iteration over the entire object to check each vertex’s selection value for the case of soft selection (VDataChannel 1 supported) and operated on those with a selection value > 0. This works, but is rather slow.]



Using Max 2012

Replies: 0