Thursday, September 22, 2011

MaxScript Set Face Smoothing Groups

One of the artists asked for a script to set all UV Shell’s to different smoothing groups awhile back. Today I finally got the time to take a look at it. Pulling some of the code from TexTools to get UV Shell Elements gave me what I needed to get the Poly Faces in each UV Shell. When I started working on setting the smoothing groups for the UV Shells, all appeared to work, except that I ended up with only 6 smoothing groups on each object. I tried a few different things thinking it was either modifier panel weirdness or I was just applying them wrong. After watching the MaxScript listener while manually setting smoothing groups I realized what I was doing wrong. PolyOp.SetFaceSmoothGroup doesn’t take the integer equivalent of the smoothing group that you want to set, it takes a bit flag. Looking in the MaxScript documentation confirmed this, but it is easy to miss if you aren’t just skimming through it.

So, for anyone who runs into this, the solution is simple

––Set the bit flag for the smoothing group

bit_flag = bit.set 0 true

polyOp.SetFaceSmoothGroup bit_flag

No comments:

Post a Comment