//morphSequencer.ls //february 26 2010 //clinton reese //www.clintons3d.com // //take a series of morphs and create a sequencial morph sequence by creating intermediate morphs and //adding them at different morph values to the last morph in the sequence // // type number of morphs to use - the first morphs listed will be used // type a prefix name for the new intermediate morphs // choose morph order from the drop down lists // choose whether interpolation is linear or not(no effect on the last morph) // press ok to generate the intermediate morphs and the expressions to drive them // copy the expressions to a temp location // in layout: copy the expressions to the corresponding morphs // final result: intermediate morphs driven by the final/last morph values to create sequential morph action // // note: non-linear interp not so good, default linear // //Preprocessor Compiler Directives. // sample expression for 2 morph sequence, add together and apply to intermediate morph //range([rectangle.MorphGroup.second],0.000,0.500) * mapRange([rectangle.MorphGroup.second],0.000,0.500,0.000,1.000) //range([rectangle.MorphGroup.second],0.501,1.00) * mapRange([rectangle.MorphGroup.second],0.500,1.000,1.000,0.000) // @script modeler @name "morphSequencer" @version 2.3 main { //Create a VMap Object Agent. from all the morph maps allvmapObj = VMap(VMMORPH); //If there are no maps, notify the user. if(allvmapObj == nil) error("No morph maps in the mesh!"); /* using a while statement, if there s a VMap value, and its type is VMMORPH add the names to the variable. This handles multiple VMaps in the object. */ nummorphs = 0; while(allvmapObj && allvmapObj.type == VMMORPH) { vmapnames += allvmapObj.name; nummorphs = nummorphs + 1; //Use the .next() method to go to the next VMap. allvmapObj = allvmapObj.next(); } if(nummorphs < 2) error("Not enough morphs to sequence."); /* Interface to get morph order.*/ reqbegin("Sequence Morph"); morphcount = ctlinteger("Number of morphs to use",nummorphs); ctlposition(morphcount,12,10); morphprefixctl = ctlstring("Morph Prefix", "seqmorph"); ctlposition(morphprefixctl,12,40); for(y=1;y<=nummorphs;y++) { mtext = "morph " + y; mypopup[y] = ctlpopup(mtext, y, vmapnames);//also add checkboxes for non-linear interpolation default vpos = (y + 1) * 30 + 10; ctlposition(mypopup[y],12,vpos); mycheckctl[y] = ctlcheckbox("non-linear",false); ctlposition(mycheckctl[y],220,vpos); } return if !reqpost(); //save inputs nummorphs = getvalue(morphcount); morphprefix = getvalue(morphprefixctl); for(y=1;y<=nummorphs;y++) { theval = getvalue(mypopup[y]); newvmapnames[y] = vmapnames[theval]; mycheck[y] = getvalue(mycheckctl[y]); } reqend(); // do sequence here //check that user requested enough morphs if(nummorphs < 2) error("Not enough morphs to sequence"); //save the mesh name for the script text output obj = Mesh(0); objname = obj.name; lastvmapObj = VMap(newvmapnames[nummorphs]);//last morph - driver of the script text lastmorphname = lastvmapObj.name; selmode(USER); morphstep = 1/nummorphs; editbegin(); for(i=1;i