Projection modifier: setting source type to "vertex color" from script


#1

I’m having a problem where I want to use the Projection modifier to project vertex colors from a high-density mesh onto a low-density one. Doing this by hand works fine. I have the beginnings of a script to automate it:

AddPModObjects #(projectorObj) true true objList:#(orig)
proj = projectorObj.modifiers[#Projection]
projMap = proj.getProjectionType 1
projMap.createNewHolder = true
projMap.sameAsSource = true
--Would like to set source channel here
proj.projectAll()

The problem is that I don’t see how the source channel option is exposed to MaxScript. if I look at the docs or run showProperties on projMap, I see:

  .name : string
  .holderName (Projection_Holder_Name) : string
  .alwaysUpdate (Always_Update_Holder) : boolean
  .createNewHolder (Create_New_Holder) : boolean
  .sourceMapChannel (Source_Map_Channel) : integer
  .sameAsSource (Same_as_Source) : boolean
  .targetMapChannel (Target_Map_Channel) : integer
  .projectMaterialIDs (Project_Material_IDs) : boolean
  .sameTopology (Same_Topology) : boolean
  .ignoreBackfacing (Ignore_Backfacing) : boolean
  .testSeams (Test_Seams) : boolean
  .checkEdgeRatios (Check_Edge_Ratios) : boolean
  .weldUVs (Weld_UVs) : boolean
  .weldUVsThreshold (Weld_UVs_Threshold) : float
  .edgeRatioThreshold (Edge_Ratio_Threshold) : float

The most similar one is sourceMapChannel, but changing that only changes the integer map channel for the “Map Channel” source type - the red X in my screenshot. How can I set the radio button for the green arrow, “Vertex Color” from maxscript?

image


#2

projMap.sourceMapChannel = 0


#3

Wow, that worked. Thank you.

Additionally, it seems to be possible to set sourceMapChannel to a negative index to select the other radio buttons.

This behavior is undocumented, though. How did you know about it, may I ask?


#4

tools > channel info
%D0%B8%D0%B7%D0%BE%D0%B1%D1%80%D0%B0%D0%B6%D0%B5%D0%BD%D0%B8%D0%B5
simple as that

btw mxs reference also say it pretty much clear
<Vertex_Color>.map Integer default: 0 -- integer; Map_ID