[Closed] Param Collector and Morpher Ques?
Hello
I am a little stuck with a simple script. The script scans an object for morph targets then creates a set of parameters in the parameter collector. So far it works well enough but collects everything into one rollout. Now I need this to colect things into different rollouts based upon the names of the morphs i.e. Eyes , Mouth Etc. My Plan was to scan the names of the morphs and only read in the ones containing the words eye etc. But it doesnt appear to be respecting the wildcard I am using. Here is the script so far. I have commented ou the section I can remove for it to work at a basic level. Anyone have any ideas why the wild card is not working?
Thanks
Harry
MyMod = $Gangster_Head.morpher
MyObj = $Gangster_Head
morphCount = 0
morphname =#()
for i = 1 to 100 do
(
TempName = WM3_MC_Getname MyMod i
if WM3_MC_HasData MyMod i == true and TempName == “eye” — If I remove the section of this line ==true and tempname == “eye” then it works, but doesnt filter.
(morphCount += 1
TempName = WM3_MC_Getname MyMod i
Append morphname tempname
print Morphname
)
)
print morphcount
ParamCollectorOps.addNewRollout myObj.Name false
for i = 1 to morphcount do
(
MyParamName =
ParamCollectorOps.addParameter $.morpher[i] 1 1 morphname[i]
)
ParamCollectorOps.visible = true
Hi Harry,
The if statement should be a combo of
if <condition> then <do something here>
Change the if statement to this:
if WM3_MC_HasData MyMod i == true and (findstring TempName "eye") != undefined then
(
morphCount += 1
TempName = WM3_MC_Getname MyMod i
Append morphname tempname
print Morphname
)
You can also download a similar tool I had written for the morpher from here:
http://www.aaachooo.com/Maxscript_Details/maxscripts_FacialMorphControls.html
cheers
shibu
Hi Sibu
Thanks for that. Sometimes the most obvious answers appear to get more hidden the harder you look. I will also check your script out tomorrow as it looks similar to what I want. Shame its encrypted, but understandable, as it would have been interesting to learn from.
Thanks for your quick response.
Harry
Hi
Ok I now have the script working, up to a point. It now creates a series of rollouts and puts the appropriate morphs into each one. However there was a problem. When you changed the value of the first spinner in rollout one the first spinner of each of the other rolllouts changed. I think this is down to the fact that although I am looping through the Morph targets and getting the right name but I am not getting the correct morph target index.
This is what I think I should do but would like some other thoughts before I go down the wrong path
I will need to make an array of all the morph targets and save the morphtargets name at the same point in the array as its Subanim index. Then when I read in the name I can use its index to set the rollout parameter.
Here is the script as it stands so far. It still in development so I have not optimised it yet.
MyMod = $Gangster_Head.morpher
MyObj = $Gangster_Head
ParamCollectorOps.numcollections()
ParamCollectorOps.getactivecollection()
ParamCollectorOps.SetCollectionName 1 (MyObj.name as string)
ParamCollectorOps.linktoObject MyObj
—- Scan for Eye Left—-
TempName = “”
morphCount = 0
morphname =#()
for i = 1 to 100 do
(
TempName = WM3_MC_GetName MyMod i
if WM3_MC_HasData MyMod i == true and (findstring TempName “eye”) != undefined and (findstring TempName “L”) != undefined do
(morphCount += 1
TempName = WM3_MC_Getname MyMod i
Append morphname tempname
print Morphname
)
)
print morphcount
ParamCollectorOps.addNewRollout “Eyes Left” false
for i = 1 to morphcount do
(
MyParamName =
AName = (MyObj.morpher[i] as string)
ParamCollectorOps.addParameter MyObj.morpher[i] 1 1 AName
)
ParamCollectorOps.visible = true
—- Scan for Eye Right —-
TempName = “”
morphCount = 0
morphname =#()
for i = 1 to 100 do
(
TempName = WM3_MC_Getname MyMod i
if WM3_MC_HasData MyMod i == tru and (findstring TempName “eye”) != undefined and (findstring TempName “R”) != undefined do
(morphCount += 1
TempName = WM3_MC_Getname MyMod i
Append morphname tempname
print Morphname
)
)
print morphcount
ParamCollectorOps.addNewRollout “Eyes Right” false
for i = 1 to morphcount do
(
AName = (MyObj.morpher[i] as string)
MyParamName =
ParamCollectorOps.addParameter MyObj.morpher[i] 1 2 AName
)
ParamCollectorOps.visible = true
Ok I got that working now but have a slightly different problem.
The Script only works the second time you execute it? If you run it once you get rmpty rollouts. Run it again and its fine!?!
Here is the new script.
MyMod = $Gangster_Head.morpher
MyObj = $Gangster_Head
ParamCollectorOps.visible = true
—- Creates and Array containing all the valid moprh targets —
myArray =#()
mymod = $Gangster_Head.morpher
for i = 1 to 100 where (WM3_MC_HasData MyMod i) == true do
(
MyName = (WM3_MC_Getname MyMod i)
append myArray MyName
)
print myarray
—- Scans that Array for Targets with the word eye and L in them —
ParamCollectorOps.addNewRollout “Eyes Left” false
for m = 1 to MyArray.count do
(
if (matchpattern myarray[m] pattern:“eye”) == true and (matchpattern myarray[m] pattern:“L”) == true do
(
–print myarray[m]
–print m
–Print mymod[m]
ParamCollectorOps.addParameter Mymod[m] 1 1 myarray[m]
)
)
—- Scans that Array for Targets with the word eye and L in them —
ParamCollectorOps.addNewRollout “Eyes Right” false
for m = 1 to MyArray.count do
(
if (matchpattern myarray[m] pattern:“eye”) == true and (matchpattern myarray[m] pattern:“R”) == true do
(
–print myarray[m]
–print m
–Print mymod[m]
ParamCollectorOps.addParameter Mymod[m] 1 2 myarray[m]
)
)
—- Scans that Array for Targets with the word Nose and L in them —
ParamCollectorOps.addNewRollout “Nose Left” false
for m = 1 to MyArray.count do
(
if (matchpattern myarray[m] pattern:“Nose”) == true and (matchpattern myarray[m] pattern:“L”) == true do
(
ParamCollectorOps.addParameter Mymod[m] 1 3 myarray[m]
)
)
—- Scans that Array for Targets with the word Nose and R in them —
ParamCollectorOps.addNewRollout “Nose Right” false
for m = 1 to MyArray.count do
(
if (matchpattern myarray[m] pattern:“Nose”) == true and (matchpattern myarray[m] pattern:“R”) == true do
(
ParamCollectorOps.addParameter Mymod[m] 1 4 myarray[m]
)
)
—- Scans that Array for Targets with the word Mouth and L in them —
ParamCollectorOps.addNewRollout “Mouth Left” false
for m = 1 to MyArray.count do
(
if (matchpattern myarray[m] pattern:“Mouth”) == true and (matchpattern myarray[m] pattern:“L”) == true do
(
ParamCollectorOps.addParameter Mymod[m] 1 5 myarray[m]
)
)
—- Scans that Array for Targets with the word Mouth and R in them —
ParamCollectorOps.addNewRollout “Mouth Right” false
for m = 1 to MyArray.count do
(
if (matchpattern myarray[m] pattern:“Mouth”) == true and (matchpattern myarray[m] pattern:“R”) == true do
(
ParamCollectorOps.addParameter Mymod[m] 1 6 myarray[m]
)
)
—- Scans that Array for Targets with the word Mouth and R in them —
ParamCollectorOps.addNewRollout “Mouth Right” false
for m = 1 to MyArray.count do
(
if (matchpattern myarray[m] pattern:“Mouth”) == true and (matchpattern myarray[m] pattern:“R”) == true do
(
ParamCollectorOps.addParameter Mymod[m] 1 7 myarray[m]
)
)
—- Scans that Array for Targets with the word Mouth and R in them —
ParamCollectorOps.addNewRollout “Other” false
for m = 1 to MyArray.count do
(
if (matchpattern myarray[m] pattern:“Mouth”) != true and (matchpattern myarray[m] pattern:“eye”) != true and (matchpattern myarray[m] pattern:“nose”) != true do
(
ParamCollectorOps.addParameter Mymod[m] 1 8 myarray[m]
)
)