stuh505
01-23-2005, 07:59 PM
This tool is designed to make the process of dividing a model into different material ID sections much easier. I made this for myself because I was finding it literally impossible to select the proper areas due to the number of inside faces of my model.
It works on editable meshes or editable polys.
In short, what you can do is select edges to form a closed Gaussian loop and then select a face inside this encirclement and have it select all the faces that are enclosed. ITs not very picky and doesnt matter if you have lots of extra edges defined inside or outside the loop. It can also use the transition to other matIDs as bounding edges thus making dividing a model into sections really quick. And ive put in tools at the bottom to make it so you can assign the matIDs really quickly, things like Flash etc are really helpful for checking matID locations without losing selection set.
its also recommended for best use that you assign a multi subo object material with different colors for each matID onto the object so you can see the matID sections as you work
http://img168.exs.cx/img168/9850/guiview8pq.jpg
Define Edges Group
EdgeMode - Puts the currently selected editable mesh or editable poly into edge sub-object mode
Define - Defines the currently selected edges as bounding edges
Fill Faces Group
FaceMode - Puts the currently selected editable mesh into face sub-object mode, or the currently selected editable poly into polygon sub-object mode
FillRegion - Expands the currently selected face(s) to fill the region bounded by the defined edges
Max Iterations - Use this spinner to control the number of iterations that fillRegion will run each click. Use a high value to fill the entire region in 1 click (this may take a second). Use lower values to fill the selection size slowly out from the originally selected face(s), allowing you to visualize any leaks in the bounding edges.
Bound by MatID - Check this button to consider the edges between faces of other matID's to be bounding edges for the fill operation.
Set Material ID Group
Flash - Use this button to toggle the highlighting of the material ID in the associated spinner. Use this when you want to visualize faces of a matID without losing the current selection.
Select - Use this button to select the matID in the associated spinner.
Set - Use this button to set the currently selected faces to the matID of the associated spinner.
popup button:
macroscript MatIDFill category:"Heinrich"
tooltip:"MatID Fill"
(
createDialog heinrichMatFiller
)
actual code:
rollout heinrichMatFiller "MatID Fill" width:160 height:376
(
checkButton edgeMode "EdgeMode" pos:[16,112] width:60 height:20
checkButton faceMode "FaceMode" pos:[16,176] width:60 height:20
button defineEdges "Define" pos:[80,112] width:60 height:20
button fillRegion "Fill Region" pos:[80,176] width:60 height:20
checkbox boundByMatID "Bound by MatID" pos:[16,232] width:128 height:16 checked:true
button setID "Set" pos:[24,336] width:60 height:20
checkButton flashID "Flash" pos:[24,288] width:60 height:20
groupBox grp4 "Set Material ID" pos:[8,264] width:144 height:104
bitmap bmp1 "Bitmap" pos:[8,8] width:140 height:74 enabled:true fileName:"C:\Documents and Settings\Stuart Heinrich\Desktop\HeinrichLoop\heinrichfill.jpg"
button selectID "Select" pos:[24,312] width:60 height:20
spinner spn_maxIter "" pos:[88,208] width:44 height:16 enabled:true range:[1,200,10] type:#integer
label lbl5 "Max Iterations:" pos:[16,208] width:72 height:19
groupBox grp18 "Define Edges" pos:[8,88] width:144 height:56
groupBox grp19 "Fill Faces" pos:[8,152] width:144 height:104
spinner spn_Flash "" pos:[88,288] width:48 height:16 range:[1,100,1] type:#integer
spinner spn_Select "" pos:[88,312] width:48 height:16 range:[1,100,1] type:#integer
spinner spn_Set "" pos:[88,336] width:48 height:16 range:[1,100,1] type:#integer
global storeFaceSel=#()
on edgeMode changed state do
(
if state==on and selection.count==1 then
(
subObjectLevel = 2
max modify mode
faceMode.state = false --pop button up
)
)
on faceMode changed state do
(
if state==on then
(
if classOf(selection[1]) as string=="Editable_mesh" then
(
subObjectLevel = 3;
max modify mode
edgeMode.state = false --pop button up
) else if classOf(selection[1]) as string=="Editable_Poly" then
(
subObjectLevel = 4;
max modify mode
edgeMode.state = false --pop button up
)
)
)
on defineEdges pressed do
(
obj = selection[1]
global wallEdges = getEdgeSelection obj
messageBox ((wallEdges as array).count as string + " border edges defined.") title:"MatID Fill"
)
on fillRegion pressed do
(
finished=false;
i=0;
while finished==false and i<spn_maxIter.value do
(
obj = selection[1] --get selected object
faceSel = getFaceSelection obj --get selected faces
if classOf(obj) as string=="Editable_mesh" then
(
originalMatID = getFaceMatID obj (faceSel as array)[1] --store original matID of first face selected
edgeSel = meshop.getEdgesUsingFace obj faceSel -- get edges using face
edgeSel = meshop.getEdgesReverseEdge obj edgeSel + edgeSel -- addend reverse edges
wallEdges = wallEdges + meshop.getEdgesReverseEdge obj wallEdges
edgeSel = edgeSel - wallEdges --stop growing selection at wall
newFaceSel = meshop.getFacesUsingEdge obj edgeSel -- get all new faces
if boundByMatID.state==true do --ignore unoriginal matID's
(
for f = 1 to obj.numfaces do
(
if getFaceMatID obj f!=originalMatID do
(
deleteItem newFaceSel f --dont add faces of new matID to selection
)
)
)--end if bound by mat id
) else if classOf(obj) as string=="Editable_Poly" then
(
originalMatID = polyop.getFaceMatID obj (faceSel as array)[1] --store original matID of first face selected
edgeSel = polyop.getEdgesUsingFace obj faceSel -- get edges using face
edgeSel = edgeSel - wallEdges --stop growing selection at wall
newFaceSel = polyop.getFacesUsingEdge obj edgeSel -- get all new faces
if boundByMatID.state==true do --ignore unoriginal matID's
(
for f = 1 to obj.numfaces do
(
if polyop.getFaceMatID obj f!=originalMatID do
(
deleteItem newFaceSel f --dont add faces of new matID to selection
)
)
)--end if bound by mat id
)--end editable poly conditional
if oldFaceSel==newFaceSel do
finished=true;
i = i+1;
setFaceSelection obj newFaceSel -- select polys
update obj
max modify mode
subObjectLevel = 4
)
) -- end fillRegion pressed
on flashID changed state do
(
obj = selection[1]
if state==on do
(
if classOf(obj) as string=="Editable_mesh" then
(
obj = selection[1] --get selected object
storeFaceSel = getFaceSelection obj --store selected faces
flashFaceSel = #() --empty bitarray
for f = 1 to obj.numfaces do
(
if getFaceMatID obj f==spn_Flash.value do
(
append flashFaceSel f
)
)--end for loop
setFaceSelection obj flashFaceSel
)--end editable mesh conditional
else if classOf(obj) as string=="Editable_Poly" then
(
obj = selection[1] --get selected object
storeFaceSel = getFaceSelection obj --store selected faces
flashFaceSel = #() --empty bitarray
for f = 1 to obj.numfaces do
(
if polyop.getFaceMatID obj f==spn_Flash.value do
(
append flashFaceSel f
)
)
setFaceSelection obj flashFaceSel
)--end editable poly conditional
)--end state on conditional
if state==off do
(
setFaceSelection obj storeFaceSel
)
)-- end flashID changed state
on setID pressed do
(
obj = selection[1]
if classOf(obj) as string=="Editable_mesh" then
(
obj = selection[1]
faceSel = getFaceSelection obj
selList = faceSel as array -- store bitarray as array
for count = 1 to selList.count do
(
setFaceMatID obj selList[count] spn_Set.value
)
)--end editable mesh section
else if classOf(obj) as string=="Editable_Poly" then
(
obj = selection[1]
faceSel = getFaceSelection obj
selList = faceSel as array -- store bitarray as array
for count = 1 to selList.count do
(
polyop.setFaceMatID obj selList[count] spn_Set.value
)
)--end editable poly section
)--end setID pressed
on selectID pressed do
(
obj = selection[1]
if classOf(obj) as string=="Editable_mesh" then
(
obj = selection[1] --get selected object
newFaceSel = #() --empty bitarray
for f = 1 to obj.numfaces do
(
if getFaceMatID obj f==spn_Select.value do
(
append newFaceSel f
)
)
setFaceSelection obj newFaceSel
)--end mesh section
else if classOf(obj) as string=="Editable_Poly" then
(
obj = selection[1] --get selected object
newFaceSel = #() --empty bitarray
for f = 1 to obj.numfaces do
(
if polyop.getFaceMatID obj f==spn_Select.value do
(
append newFaceSel f
)
)
setFaceSelection obj newFaceSel
)--end poly section
)--end selectID pressed
)--end rollout
It works on editable meshes or editable polys.
In short, what you can do is select edges to form a closed Gaussian loop and then select a face inside this encirclement and have it select all the faces that are enclosed. ITs not very picky and doesnt matter if you have lots of extra edges defined inside or outside the loop. It can also use the transition to other matIDs as bounding edges thus making dividing a model into sections really quick. And ive put in tools at the bottom to make it so you can assign the matIDs really quickly, things like Flash etc are really helpful for checking matID locations without losing selection set.
its also recommended for best use that you assign a multi subo object material with different colors for each matID onto the object so you can see the matID sections as you work
http://img168.exs.cx/img168/9850/guiview8pq.jpg
Define Edges Group
EdgeMode - Puts the currently selected editable mesh or editable poly into edge sub-object mode
Define - Defines the currently selected edges as bounding edges
Fill Faces Group
FaceMode - Puts the currently selected editable mesh into face sub-object mode, or the currently selected editable poly into polygon sub-object mode
FillRegion - Expands the currently selected face(s) to fill the region bounded by the defined edges
Max Iterations - Use this spinner to control the number of iterations that fillRegion will run each click. Use a high value to fill the entire region in 1 click (this may take a second). Use lower values to fill the selection size slowly out from the originally selected face(s), allowing you to visualize any leaks in the bounding edges.
Bound by MatID - Check this button to consider the edges between faces of other matID's to be bounding edges for the fill operation.
Set Material ID Group
Flash - Use this button to toggle the highlighting of the material ID in the associated spinner. Use this when you want to visualize faces of a matID without losing the current selection.
Select - Use this button to select the matID in the associated spinner.
Set - Use this button to set the currently selected faces to the matID of the associated spinner.
popup button:
macroscript MatIDFill category:"Heinrich"
tooltip:"MatID Fill"
(
createDialog heinrichMatFiller
)
actual code:
rollout heinrichMatFiller "MatID Fill" width:160 height:376
(
checkButton edgeMode "EdgeMode" pos:[16,112] width:60 height:20
checkButton faceMode "FaceMode" pos:[16,176] width:60 height:20
button defineEdges "Define" pos:[80,112] width:60 height:20
button fillRegion "Fill Region" pos:[80,176] width:60 height:20
checkbox boundByMatID "Bound by MatID" pos:[16,232] width:128 height:16 checked:true
button setID "Set" pos:[24,336] width:60 height:20
checkButton flashID "Flash" pos:[24,288] width:60 height:20
groupBox grp4 "Set Material ID" pos:[8,264] width:144 height:104
bitmap bmp1 "Bitmap" pos:[8,8] width:140 height:74 enabled:true fileName:"C:\Documents and Settings\Stuart Heinrich\Desktop\HeinrichLoop\heinrichfill.jpg"
button selectID "Select" pos:[24,312] width:60 height:20
spinner spn_maxIter "" pos:[88,208] width:44 height:16 enabled:true range:[1,200,10] type:#integer
label lbl5 "Max Iterations:" pos:[16,208] width:72 height:19
groupBox grp18 "Define Edges" pos:[8,88] width:144 height:56
groupBox grp19 "Fill Faces" pos:[8,152] width:144 height:104
spinner spn_Flash "" pos:[88,288] width:48 height:16 range:[1,100,1] type:#integer
spinner spn_Select "" pos:[88,312] width:48 height:16 range:[1,100,1] type:#integer
spinner spn_Set "" pos:[88,336] width:48 height:16 range:[1,100,1] type:#integer
global storeFaceSel=#()
on edgeMode changed state do
(
if state==on and selection.count==1 then
(
subObjectLevel = 2
max modify mode
faceMode.state = false --pop button up
)
)
on faceMode changed state do
(
if state==on then
(
if classOf(selection[1]) as string=="Editable_mesh" then
(
subObjectLevel = 3;
max modify mode
edgeMode.state = false --pop button up
) else if classOf(selection[1]) as string=="Editable_Poly" then
(
subObjectLevel = 4;
max modify mode
edgeMode.state = false --pop button up
)
)
)
on defineEdges pressed do
(
obj = selection[1]
global wallEdges = getEdgeSelection obj
messageBox ((wallEdges as array).count as string + " border edges defined.") title:"MatID Fill"
)
on fillRegion pressed do
(
finished=false;
i=0;
while finished==false and i<spn_maxIter.value do
(
obj = selection[1] --get selected object
faceSel = getFaceSelection obj --get selected faces
if classOf(obj) as string=="Editable_mesh" then
(
originalMatID = getFaceMatID obj (faceSel as array)[1] --store original matID of first face selected
edgeSel = meshop.getEdgesUsingFace obj faceSel -- get edges using face
edgeSel = meshop.getEdgesReverseEdge obj edgeSel + edgeSel -- addend reverse edges
wallEdges = wallEdges + meshop.getEdgesReverseEdge obj wallEdges
edgeSel = edgeSel - wallEdges --stop growing selection at wall
newFaceSel = meshop.getFacesUsingEdge obj edgeSel -- get all new faces
if boundByMatID.state==true do --ignore unoriginal matID's
(
for f = 1 to obj.numfaces do
(
if getFaceMatID obj f!=originalMatID do
(
deleteItem newFaceSel f --dont add faces of new matID to selection
)
)
)--end if bound by mat id
) else if classOf(obj) as string=="Editable_Poly" then
(
originalMatID = polyop.getFaceMatID obj (faceSel as array)[1] --store original matID of first face selected
edgeSel = polyop.getEdgesUsingFace obj faceSel -- get edges using face
edgeSel = edgeSel - wallEdges --stop growing selection at wall
newFaceSel = polyop.getFacesUsingEdge obj edgeSel -- get all new faces
if boundByMatID.state==true do --ignore unoriginal matID's
(
for f = 1 to obj.numfaces do
(
if polyop.getFaceMatID obj f!=originalMatID do
(
deleteItem newFaceSel f --dont add faces of new matID to selection
)
)
)--end if bound by mat id
)--end editable poly conditional
if oldFaceSel==newFaceSel do
finished=true;
i = i+1;
setFaceSelection obj newFaceSel -- select polys
update obj
max modify mode
subObjectLevel = 4
)
) -- end fillRegion pressed
on flashID changed state do
(
obj = selection[1]
if state==on do
(
if classOf(obj) as string=="Editable_mesh" then
(
obj = selection[1] --get selected object
storeFaceSel = getFaceSelection obj --store selected faces
flashFaceSel = #() --empty bitarray
for f = 1 to obj.numfaces do
(
if getFaceMatID obj f==spn_Flash.value do
(
append flashFaceSel f
)
)--end for loop
setFaceSelection obj flashFaceSel
)--end editable mesh conditional
else if classOf(obj) as string=="Editable_Poly" then
(
obj = selection[1] --get selected object
storeFaceSel = getFaceSelection obj --store selected faces
flashFaceSel = #() --empty bitarray
for f = 1 to obj.numfaces do
(
if polyop.getFaceMatID obj f==spn_Flash.value do
(
append flashFaceSel f
)
)
setFaceSelection obj flashFaceSel
)--end editable poly conditional
)--end state on conditional
if state==off do
(
setFaceSelection obj storeFaceSel
)
)-- end flashID changed state
on setID pressed do
(
obj = selection[1]
if classOf(obj) as string=="Editable_mesh" then
(
obj = selection[1]
faceSel = getFaceSelection obj
selList = faceSel as array -- store bitarray as array
for count = 1 to selList.count do
(
setFaceMatID obj selList[count] spn_Set.value
)
)--end editable mesh section
else if classOf(obj) as string=="Editable_Poly" then
(
obj = selection[1]
faceSel = getFaceSelection obj
selList = faceSel as array -- store bitarray as array
for count = 1 to selList.count do
(
polyop.setFaceMatID obj selList[count] spn_Set.value
)
)--end editable poly section
)--end setID pressed
on selectID pressed do
(
obj = selection[1]
if classOf(obj) as string=="Editable_mesh" then
(
obj = selection[1] --get selected object
newFaceSel = #() --empty bitarray
for f = 1 to obj.numfaces do
(
if getFaceMatID obj f==spn_Select.value do
(
append newFaceSel f
)
)
setFaceSelection obj newFaceSel
)--end mesh section
else if classOf(obj) as string=="Editable_Poly" then
(
obj = selection[1] --get selected object
newFaceSel = #() --empty bitarray
for f = 1 to obj.numfaces do
(
if polyop.getFaceMatID obj f==spn_Select.value do
(
append newFaceSel f
)
)
setFaceSelection obj newFaceSel
)--end poly section
)--end selectID pressed
)--end rollout
