ZBrushCentral

Detecting default blue polypaint on model (also detecting absence of UVs)

As sometimes happens, a new model will appear in bright blue. I think this is the case if the polys haven’t yet been assigned color (through fill object button or by polypainting).

In a script where I try to detect that the blue is present, I use the PixolPick command (mode 2, 3, 4) to get the R, G, B value. However, it seems if default blue is found (0, 0, 255), PixolPick returns 255 for R, G and B, even though the model on canvas is obviously bright blue.

All I really want to do here is detect the presence of the default blue (0, 0, 255) and in that one case, automatically fill the model with white (255, 255, 255).

Has anyone else run into this? Is there a PixolPick solution? Is there some other guaranteed way to detect the presence of default blue requiring a fill object button?

An extension of the same idea… If I’m trying to detect whether a model has no UV mapping assigned, I might load a texture map, then press Col>Txr… and, using PixolPick (mode 2, 3, 4), test for black (0, 0, 0), indicating that UV mapping is not assigned… and then offer option to automatically assign GUV mapping. I’d also be interested in any other strategy for detecting the absence of UV mapping, as well.

Anyone?

thanx, Sven

Hi Sven,

PixolPick works for me as expected. Have you tried using the 0 index - this should return the composite color, which for Blue will be 255?

For checking the presence of UVs you could use Mesh3DGet:


[VarDef,uvbounds,0]
[Mesh3DGet,3,,,uvbounds]

which will return 0 if there are no UVs.

Another method would be to do a UV check which would apply a black texture if there are no UVs and a pixolpick(0) would return 0.

Ah, good. I’ll give it a try!

Sven

Edit updated - to modify UV test as suggested below…

[RoutineDef, UVExist,

	[Mesh3dGet, 3, 0,  ,  minU, minV, maxU, maxV ]
	[VarSet, UVtest, (maxU-minU) * (maxV-minV) ]
	[If, UVtest == 0,
     	   	[NoteIButton, " Yes ", , , , , , , , 0xffffff, 0xf00000]
  		[NoteIButton, " No ", , , , , , , , 0xffffff, 0x808080]
  		[Note, "\Cff0000       * * * WARNING * * *

", , -1 ]
   		[Note, "\C202020    No UV mapping assigned
", , -1 ]
   		[Note, "     to this model.  Apply
", , -1 ]
   		[Note, "     ZBrush GUV mapping?
", , -1 ]
		[VarSet, Reply, [Note,  ,  , , 0xffffff, , 230 ] ] 	  															
		[If, Reply == 1,
			[IFreeze,
				[ISet,TOOL:Geometry:SDiv, 1 ] 
				[IPress, TOOL:Texture:EnableUV ]
				[IPress, TOOL:Texture:GUVTiles ]
				[ISet,TOOL:Geometry:SDiv, 99 ]
			]
		]
	]	
]


Sven,

I realized (in the middle of the night, as one does), that I was being an idiot. Although, for your purposes, that code is OK it could conceivably produce an error (e.g. if UV planar is used).

The proper code to check for UV area would be:


[Mesh3DGet,3,,,minU,minV,maxU,maxV]
[VarSet,uvArea,(maxU-minU)*(maxV-minV)]

HTH,

Right you are Marcus, I should have tested the subroutine further myself. I’m updating the routine.

Thanks again!

Sven

Afterthought: I wonder if testing both U and V differences is necessary? If (maxU - MinU) comes back zero, wouldn’t that in effect imply no mapping or, at any rate, pointless or flawed mapping?

After-Afterthought: Or more simply, if maxU comes back zero, would that by itself indicate no mapping?

Sven,

Unless the UV space was -1,0, -1,0, [could it be??] just getting the maxUV should indicate UVs or not.

Marcus,

I tried it in my own script and, with standard UV mapping, maxU test works! (I also learned that Mesh3dGet insists on output variables at minU and minV even if they aren’t used.

Thanks again for pointing the way here - it really helps. (I might add this to the PolyPaint utility, too.)

Sven