[Closed] Normal Brush Tool
I am trying to create a new modifier, that extends the existing Edit Normals modifier, with the ability to comb the surface nomals using the painter interface. Please see code below.
plugin modifier NBrusher
name:"Normal Brusher"
classID:#(0x624ed143, 0xc7db9b7)
extends:Edit_Normals
replaceUI:false version:1
(
Local nodeList = undefined
Local CurrNode = undefined
Local localHit = [0,0,0]
Local localNormal = [0,0,0]
Local worldHit = [0,0,0]
Local worldNormal = [0,0,0]
Local radius = 0.0
Local str = 0.5
Local shift = false
Local ctrl = false
Local alt = false
Local pressure = 0.0
Fn BrushNormals dir =
(
-- Selects the normals under the brush
if classof currnode == Editable_mesh then
(
Face_Selection = (meshop.getFacesUsingVert currnode(thePainterInterface.getPointGatherHits currnode))
)
else
(
Face_Selection = (polyop.getFacesUsingVert currnode(thePainterInterface.getPointGatherHits currnode))
)
Normal_Selection = #{}
this.Edit_Normals.ConvertFaceSelection &Face_Selection &Normal_Selection
this.Edit_Normals.SetSelection Normal_Selection
For i in this.Edit_Normals.getselection() do
(
this.Edit_Normals.SetNormal i ((this.Edit_Normals.GetNormal i)+(Dir*(thePainterInterface.maxstr)))
)
)
Fn Paintstroke =
(
CurrNode = (thePainterInterface.getHitNode 0)
thePainterInterface.getHitPointData &localHit &localNormal &worldHit &worldNormal &radius &str 0
thePainterInterface.getHitPressureData &shift &ctrl &alt &pressure 0
BrushNormals (thePainterInterface.getHitVec 0)
thePainterInterface.updateMeshes true
)
Fn PainterIni =
(
thePainterInterface.initializeNodes 0 nodelist
thePainterInterface.ScriptFunctions startStroke paintStroke endStroke cancelStroke systemEnd
thePainterInterface.pointGatherEnable = True
thePainterInterface.startPaintSession()
)
parameters main rollout:params
(
)
rollout params "Parameters"
(
groupBox grp_Brushes "Brushes" pos:[2,5] width:157 height:60
Checkbutton Btn_Comb "Comb" pos: [6,(grp_Brushes.pos.y)+25] width:69 height: 17 checked:false
button btn_PainterOpt "Brush Options" pos:[4,(grp_Brushes.pos.y)+70] width:153 height:20
On Btn_Comb changed state do
(
case state of
(
true:
(
nodelist = undefined
thePainterInterface.endPaintSession()
nodelist = $
delegate.SelLevel = 1
PainterIni()
)
false:
(
delegate.SelLevel = 0
nodelist = undefined
thePainterInterface.endPaintSession()
)
)
)
on btn_PainterOpt pressed do thePainterInterface.paintOptions()
)
)
Although the basic functionality is working I have run into an issue when assigning the modifier to multiple objects. It will only allow me to paint on the first object in the “nodelist”, although the painter interface has initialized all objects ok, painting on other objects the changes only occur on the initial object in the nodelist. The Painter interface seems to be collecting the face selections ok, but using this selection to update the normals on the intial node.
Is there anything obvious I have over looked here, or anybody suggest any improvement to the script ?
Cheers,