Nice tool! got a quick question…
When you do you access the vertex normal so it can be passed to the SetValueCommand?
From the sounds of the documentation, it seems like the flags goes from the Init to the Set Commands - when you get the vertex normal to pass to the setCmd?
Thanks.
EDIT:
nevermind, I haven’t had enough coffee, i see where it is coming from now!!
[QUOTE=Butters;18560]Hey Alessandro,
I love artUserPaintCtx, here is some code from a tool I wrote way back, so it’s in mel.
I also have a video of it in use: Normals ToolBox & reference link to Autodesk Help: Painting with MEL scripts and the Paint Scripts Tool
So the artUserPaintCtx is split up into a couple of sections:
Calling the Paint to Start and creating a context:
ScriptPaintTool; artUserPaintCtx -e -tsc "BTB_NormalsPaint" `currentCtx`;
Setup of the Context:
global proc BTB_NormalsPaint( string $context )
{
artUserPaintCtx -e
-ic "BTB_InitNormalsPaint"
-fc "BTB_FinishNormalsPaint"
-svc "BTB_SetNormalsPaintValue"
$context;
}
Setup, Complete and Compute Functions:
global proc string BTB_InitNormalsPaint(string $name)
{
return ("-dt worldV -n local");
}
global proc BTB_FinishNormalsPaint( int $slot ){}
global proc BTB_SetNormalsPaintValue(int $slot, int $index, float $val, float $Dx, float $Dy, float $Dz, float $Nx, float $Ny, float $Nz)
{
global string $BTB_NormalsPaintCurrentObject;
global string $BTB_NormalsToolBoxErase;
vector $finalNormal;
// Get the Effect Value and Process the Normal
vector $vTo;
vector $vFrom;
float $currentvertexNormals[] = `polyNormalPerVertex -q -xyz ($BTB_NormalsPaintCurrentObject + ".pnts[" + $index + "]")`;
$vFrom = <<$currentvertexNormals[0],$currentvertexNormals[1],$currentvertexNormals[2]>>;
if(`checkBox -q -v $BTB_NormalsToolBoxErase` == 1)
{
//Erase
$vTo = unit(<<$Dx,$Dy,$Dz>>);
}else
{
//Normal Paint
$vTo = unit(<<$Nx,$Ny,$Nz>>);
}
$finalNormal = `BTB_Slerp $vFrom $vTo $val`;
polyNormalPerVertex -xyz ($finalNormal.x) ($finalNormal.y) ($finalNormal.z) ($BTB_NormalsPaintCurrentObject + ".pnts[" + $index + "]");
}
“BTB_SetNormalsPaintValue” is computed for each vert that is effected by the paint stroke.
The parameters that I am using in the Function map to:
int $index = Vertex Index
float $val = Alpha Value
float $Dx, $Dy, $Dz = Vertex Surface Normal
float $Nx, $Ny, $Nz = Brush Stroke Normal
I hope this helped, at some stage I’ll be popping up an in-depth tutorial about this on my site.
-Butters[/QUOTE]