Notifications
Clear all

[Closed] setting a mesh's vertex alpha through code?

Is there an accurate way to set a selected verts vertex alpha amount through code?

meshop.setvertalpha uses the map channel, so you could be assigning to any number of verts, so its not very accurate.

Does someone have a more accurate solution?

Thanks

4 Replies
1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

why setvertalpha is not accurate for you? build default map faces for alpha channel and use geo vertex indexes to set the alpha values.

basically we are creating new faces through

meshop.extrudefaces

then taking those new verts, and attempting to put alpha on them. The problem is, that since there is no mapping etc on those verts, the mapping channel verts do not align with geo verts, causing undesired results.

An easier solution, would be if we could get the actual vert indice that corrisponds to the face data of the newly created faces and apply the vertex alpha to them directly, like you would in an engine/exporter. But i’m not sure how to accomplish that in max without rebuilding the whole mesh? Which is not an option unfortunately.

I wrote a script last week that did that exact thingy:

fn SetVertexColor targetColor mapChannel =
   (
   	target = selection[1]
   	vertlist = target.selectedverts
   	polyop.setVertColor target mapchannel vertlist targetColor
   )

the mapChannel value for vertex alpha is -2
simples

Thanks slimeburger, i am already using a similar technique though.

The problem i was running into is that since we were creating new verts, the mapping verts of channel -2 was not matching up with the mesh verts, as mapping and geo verts do not align indexly. We found a work around with detatching the object, so our chance for error was minimal.