strarup
10-24-2007, 10:45 AM
hi everyone,
well I was working making some brick's into smaller pieces with the dynamic surface shatter function thingie...
where the shatter produced an new internal shader for the shards...
but that looked crap... and I wanted to get the bricktexture on the "new" shaded faces...
well... eventhou I'm in jail at the moment and have a lot of "spare time"...
selecting each face one by one... was quite boring... and not even sure if I got all the right faces...
so eh... after doing 3 shards this way... I thought there must be an easier way to do this... and I also needed to refresh my mel skills
so I came to this solution... :)
well I can't remember my password for my homepage... and I'm not allowed to connect to the internet with my own PC so I can't use my FTP program
where I have my password on... only on the PC's that are on the school in here... so I have attached it to this post instead... :)
well hope it's useful for some... e.g. if you end up in a situation as I was in... (not the jail situation) ;D
basicly what this script does... is showing which shaders are connect/associated with your poly object...
and then you can select which shader you want to get the faces from...
sometimes lazyness can be useful... :D
regards
Strarup
proc doDaMakeSelectFacesFromShaderOnObjWindow()
{
if ((`window -exists doDaMakeSelectFacesFromShaderOnObjHelperWindowUI`) == true)
deleteUI doDaMakeSelectFacesFromShaderOnObjHelperWindowUI;
window -title "da Face from shader selector Window..." -wh 440 330 doDaMakeSelectFacesFromShaderOnObjHelperWindowUI;
formLayout doDaMakeSelectFacesFromShaderOnObjHelperWindowUIFormLayout;
button -label "Da Selected Obj = " -en true -w 100 -annotation "get the selected Obj to the textfield..." -c "doDaGetSelectedFaceShaderObj;" daMSFSO1CmdBtn;
textField -w 300 -ed false -annotation "this field is used to hold the name of the first selected Vertex..." daMSFSOselObjTxtFld;
separator -w 400 -h 3 "daMSFSOSep01" ;
textScrollList -en 0 -width 400 -numberOfRows 10 -vis 1 -dcc "doDaEnableSelFacesCmdButton;" -allowMultiSelection false daMSFSOshaderTSL;
separator -w 400 -h 3 daMSFSOSep02;
button -label "get da faces..." -en 0 -annotation "get faces which are assigned to selected shader from the list" -width 150 -c "doDaSelectFaceToSpecifiedShaderOnObject;" daMSFSO2CmdBtn ;
separator -w 400 -h 3 daMSFSOSep03;
button -label "Close da UI" -annotation "HUH!!! just closing da UI... :-D" -w 150 -c "deleteUI doDaMakeSelectFacesFromShaderOnObjHelperWindowUI;" daMSFSOCloseUIBtn;
formLayout -e
-af "daMSFSO1CmdBtn" "left" 15
-af "daMSFSO1CmdBtn" "top" 20
-af "daMSFSOselObjTxtFld" "left" 120
-af "daMSFSOselObjTxtFld" "top" 20
-af "daMSFSOSep01" "left" 15
-af "daMSFSOSep01" "top" 50
-af "daMSFSOshaderTSL" "left" 15
-af "daMSFSOshaderTSL" "top" 70
-af "daMSFSOSep02" "left" 15
-af "daMSFSOSep02" "top" 215
-af "daMSFSO2CmdBtn" "left" 150
-af "daMSFSO2CmdBtn" "top" 225
-af "daMSFSOSep03" "left" 15
-af "daMSFSOSep03" "top" 250
-af "daMSFSOCloseUIBtn" "left" 150
-af "daMSFSOCloseUIBtn" "top" 260
doDaMakeSelectFacesFromShaderOnObjHelperWindowUIFormLayout;
doDaGetSelectedFaceShaderObj;
showWindow doDaMakeSelectFacesFromShaderOnObjHelperWindowUI;
}
proc doDaGetSelectedFaceShaderObj()
{
string $daSel[]=`ls -sl -l`;
button -e -en 0 daMSFSO2CmdBtn;
if(`size $daSel` != 0)
{
string $daObj[] = `listRelatives -s -typ mesh $daSel[0]`;
if(`objectType -isType mesh $daObj[0]` == 1)
{
textField -e -tx $daSel[0] daMSFSOselObjTxtFld;
makeDaShaderList;
}
else
{
textField -e -tx "No accepted Obj selected..." daMSFSOselObjTxtFld;
textScrollList -e -ra daMSFSOshaderTSL;
textScrollList -e -en 0 -a "No accepted Obj selected..." daMSFSOshaderTSL;
}
}
else
{
textField -e -tx "No Objs selected..." daMSFSOselObjTxtFld;
textScrollList -e -ra daMSFSOshaderTSL;
textScrollList -e -en 0 -a "Nothing selected..." daMSFSOshaderTSL;
}
}
proc makeDaShaderList()
{
string $daSel = `textField -q -tx daMSFSOselObjTxtFld`;
textScrollList -e -ra daMSFSOshaderTSL;
string $daObj[] = `listRelatives -s -typ mesh $daSel`;
if(`size $daObj` != 0)
{
string $daShadersOnObj[] = `listConnections -type "shadingEngine" -et 1 -s 0 -d 1 $daObj[0]`;
int $i;
string $daShaderList[];
clear $daShaderList;
$daShaderList = $daShadersOnObj;
if(`objectType -isType mesh $daObj[0]` == 1)
{
for($i=0; $i < size($daShaderList); $i++)
{
if(`objectType -isType shadingEngine $daShaderList[$i]` == 1)
{
textScrollList -e -a $daShaderList[$i] daMSFSOshaderTSL;
textScrollList -e -en 1 daMSFSOshaderTSL;
}
}
}
else if (`objectType -isType mesh $daObj[0]` != 1)
{
textScrollList -e -a "No accepted Obj selected..." daMSFSOshaderTSL;
textScrollList -e -en 0 daMSFSOshaderTSL;
}
}
else
{
textScrollList -e -a "No accepted Obj selected..." daMSFSOshaderTSL;
textScrollList -e -en 0 daMSFSOshaderTSL;
}
}
proc doDaSelectFaceToSpecifiedShaderOnObject()
{
string $curShader[] = `textScrollList -q -si daMSFSOshaderTSL`;
catch(`hyperShade -objects $curShader[0]`);
string $daShaObjList[] = `ls -sl -l`;
string $daMomObj = `textField -q -tx daMSFSOselObjTxtFld`;
string $daSelFaceList[];
clear $daSelFaceList;
int $j =0;
for($i=0; $i < size($daShaObjList); $i++)
{
string $daDadObj[] = eval("listRelatives -f -p `listRelatives -p "+$daShaObjList[$i]+"`");
if($daDadObj[0] == $daMomObj)
{
$daSelFaceList[$j] = $daShaObjList[$i];
$j++;
}
}
button -e -en 0 daMSFSO2CmdBtn;
textField -e -tx "Faces Selected... press button for new selection..." daMSFSOselObjTxtFld;
string $selTxt = "Faces selected for "+$curShader[0]+" on "+$daMomObj+"...";
textScrollList -e -ra daMSFSOshaderTSL;
textScrollList -e -en 0 -a $selTxt daMSFSOshaderTSL;
select -cl;
doMenuComponentSelection($daMomObj, "facet");
select -r $daSelFaceList;
}
proc doDaEnableSelFacesCmdButton()
{
button -e -en 1 daMSFSO2CmdBtn;
}
doDaMakeSelectFacesFromShaderOnObjWindow;
well I was working making some brick's into smaller pieces with the dynamic surface shatter function thingie...
where the shatter produced an new internal shader for the shards...
but that looked crap... and I wanted to get the bricktexture on the "new" shaded faces...
well... eventhou I'm in jail at the moment and have a lot of "spare time"...
selecting each face one by one... was quite boring... and not even sure if I got all the right faces...
so eh... after doing 3 shards this way... I thought there must be an easier way to do this... and I also needed to refresh my mel skills
so I came to this solution... :)
well I can't remember my password for my homepage... and I'm not allowed to connect to the internet with my own PC so I can't use my FTP program
where I have my password on... only on the PC's that are on the school in here... so I have attached it to this post instead... :)
well hope it's useful for some... e.g. if you end up in a situation as I was in... (not the jail situation) ;D
basicly what this script does... is showing which shaders are connect/associated with your poly object...
and then you can select which shader you want to get the faces from...
sometimes lazyness can be useful... :D
regards
Strarup
proc doDaMakeSelectFacesFromShaderOnObjWindow()
{
if ((`window -exists doDaMakeSelectFacesFromShaderOnObjHelperWindowUI`) == true)
deleteUI doDaMakeSelectFacesFromShaderOnObjHelperWindowUI;
window -title "da Face from shader selector Window..." -wh 440 330 doDaMakeSelectFacesFromShaderOnObjHelperWindowUI;
formLayout doDaMakeSelectFacesFromShaderOnObjHelperWindowUIFormLayout;
button -label "Da Selected Obj = " -en true -w 100 -annotation "get the selected Obj to the textfield..." -c "doDaGetSelectedFaceShaderObj;" daMSFSO1CmdBtn;
textField -w 300 -ed false -annotation "this field is used to hold the name of the first selected Vertex..." daMSFSOselObjTxtFld;
separator -w 400 -h 3 "daMSFSOSep01" ;
textScrollList -en 0 -width 400 -numberOfRows 10 -vis 1 -dcc "doDaEnableSelFacesCmdButton;" -allowMultiSelection false daMSFSOshaderTSL;
separator -w 400 -h 3 daMSFSOSep02;
button -label "get da faces..." -en 0 -annotation "get faces which are assigned to selected shader from the list" -width 150 -c "doDaSelectFaceToSpecifiedShaderOnObject;" daMSFSO2CmdBtn ;
separator -w 400 -h 3 daMSFSOSep03;
button -label "Close da UI" -annotation "HUH!!! just closing da UI... :-D" -w 150 -c "deleteUI doDaMakeSelectFacesFromShaderOnObjHelperWindowUI;" daMSFSOCloseUIBtn;
formLayout -e
-af "daMSFSO1CmdBtn" "left" 15
-af "daMSFSO1CmdBtn" "top" 20
-af "daMSFSOselObjTxtFld" "left" 120
-af "daMSFSOselObjTxtFld" "top" 20
-af "daMSFSOSep01" "left" 15
-af "daMSFSOSep01" "top" 50
-af "daMSFSOshaderTSL" "left" 15
-af "daMSFSOshaderTSL" "top" 70
-af "daMSFSOSep02" "left" 15
-af "daMSFSOSep02" "top" 215
-af "daMSFSO2CmdBtn" "left" 150
-af "daMSFSO2CmdBtn" "top" 225
-af "daMSFSOSep03" "left" 15
-af "daMSFSOSep03" "top" 250
-af "daMSFSOCloseUIBtn" "left" 150
-af "daMSFSOCloseUIBtn" "top" 260
doDaMakeSelectFacesFromShaderOnObjHelperWindowUIFormLayout;
doDaGetSelectedFaceShaderObj;
showWindow doDaMakeSelectFacesFromShaderOnObjHelperWindowUI;
}
proc doDaGetSelectedFaceShaderObj()
{
string $daSel[]=`ls -sl -l`;
button -e -en 0 daMSFSO2CmdBtn;
if(`size $daSel` != 0)
{
string $daObj[] = `listRelatives -s -typ mesh $daSel[0]`;
if(`objectType -isType mesh $daObj[0]` == 1)
{
textField -e -tx $daSel[0] daMSFSOselObjTxtFld;
makeDaShaderList;
}
else
{
textField -e -tx "No accepted Obj selected..." daMSFSOselObjTxtFld;
textScrollList -e -ra daMSFSOshaderTSL;
textScrollList -e -en 0 -a "No accepted Obj selected..." daMSFSOshaderTSL;
}
}
else
{
textField -e -tx "No Objs selected..." daMSFSOselObjTxtFld;
textScrollList -e -ra daMSFSOshaderTSL;
textScrollList -e -en 0 -a "Nothing selected..." daMSFSOshaderTSL;
}
}
proc makeDaShaderList()
{
string $daSel = `textField -q -tx daMSFSOselObjTxtFld`;
textScrollList -e -ra daMSFSOshaderTSL;
string $daObj[] = `listRelatives -s -typ mesh $daSel`;
if(`size $daObj` != 0)
{
string $daShadersOnObj[] = `listConnections -type "shadingEngine" -et 1 -s 0 -d 1 $daObj[0]`;
int $i;
string $daShaderList[];
clear $daShaderList;
$daShaderList = $daShadersOnObj;
if(`objectType -isType mesh $daObj[0]` == 1)
{
for($i=0; $i < size($daShaderList); $i++)
{
if(`objectType -isType shadingEngine $daShaderList[$i]` == 1)
{
textScrollList -e -a $daShaderList[$i] daMSFSOshaderTSL;
textScrollList -e -en 1 daMSFSOshaderTSL;
}
}
}
else if (`objectType -isType mesh $daObj[0]` != 1)
{
textScrollList -e -a "No accepted Obj selected..." daMSFSOshaderTSL;
textScrollList -e -en 0 daMSFSOshaderTSL;
}
}
else
{
textScrollList -e -a "No accepted Obj selected..." daMSFSOshaderTSL;
textScrollList -e -en 0 daMSFSOshaderTSL;
}
}
proc doDaSelectFaceToSpecifiedShaderOnObject()
{
string $curShader[] = `textScrollList -q -si daMSFSOshaderTSL`;
catch(`hyperShade -objects $curShader[0]`);
string $daShaObjList[] = `ls -sl -l`;
string $daMomObj = `textField -q -tx daMSFSOselObjTxtFld`;
string $daSelFaceList[];
clear $daSelFaceList;
int $j =0;
for($i=0; $i < size($daShaObjList); $i++)
{
string $daDadObj[] = eval("listRelatives -f -p `listRelatives -p "+$daShaObjList[$i]+"`");
if($daDadObj[0] == $daMomObj)
{
$daSelFaceList[$j] = $daShaObjList[$i];
$j++;
}
}
button -e -en 0 daMSFSO2CmdBtn;
textField -e -tx "Faces Selected... press button for new selection..." daMSFSOselObjTxtFld;
string $selTxt = "Faces selected for "+$curShader[0]+" on "+$daMomObj+"...";
textScrollList -e -ra daMSFSOshaderTSL;
textScrollList -e -en 0 -a $selTxt daMSFSOshaderTSL;
select -cl;
doMenuComponentSelection($daMomObj, "facet");
select -r $daSelFaceList;
}
proc doDaEnableSelFacesCmdButton()
{
button -e -en 1 daMSFSO2CmdBtn;
}
doDaMakeSelectFacesFromShaderOnObjWindow;
